Composer: Correct conversion of TABLE into Plain Text
The <TR> is similar to <BR> for the Plain text, thus when reading it add the new line, if needed. The WebKit returns correct `\n` in the node's innerText, but using it as a plain text hides it for the user, thus split the lines and add them as separate paragraphs.
This commit is contained in:
@ -982,7 +982,7 @@ EvoConvert.processNode = function(node, normalDivWidth, quoteLevel)
|
||||
}
|
||||
|
||||
if ((!isBlockquote || !str.endsWith("\n")) &&
|
||||
str != "\n" && ((style && style.display == "block") || node.tagName == "ADDRESS")) {
|
||||
str != "\n" && ((style && style.display == "block") || node.tagName == "ADDRESS" || node.tagName == "TR")) {
|
||||
str += "\n";
|
||||
}
|
||||
}
|
||||
|
@ -2286,10 +2286,25 @@ EvoEditor.convertTags = function()
|
||||
list = document.getElementsByTagName("TABLE");
|
||||
|
||||
for (ii = list.length - 1; ii >= 0; ii--) {
|
||||
var table = list[ii], textNode;
|
||||
var table = list[ii], lines, jj;
|
||||
|
||||
lines = table.innerText.split("\n");
|
||||
|
||||
for (jj = 0; jj < lines.length; jj++) {
|
||||
var line, divNode;
|
||||
|
||||
line = lines[jj];
|
||||
divNode = document.createElement("DIV");
|
||||
|
||||
table.parentElement.insertBefore(divNode, table);
|
||||
|
||||
if (!line.length) {
|
||||
divNode.appendChild(document.createElement("BR"));
|
||||
} else {
|
||||
divNode.innerText = line;
|
||||
}
|
||||
}
|
||||
|
||||
textNode = document.createTextNode(table.innerText);
|
||||
table.parentElement.insertBefore(textNode, table);
|
||||
table.remove();
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,10 @@ markdown_utils_sax_start_element_cb (gpointer ctx,
|
||||
if (data->quote_prefix->len)
|
||||
g_string_append (data->buffer, data->quote_prefix->str);
|
||||
} else if (!data->composer_quirks.enabled || !was_in_div_begin) {
|
||||
g_string_append (data->buffer, "<br>");
|
||||
if (data->in_pre)
|
||||
g_string_append_c (data->buffer, '\n');
|
||||
else
|
||||
g_string_append (data->buffer, "<br>");
|
||||
}
|
||||
|
||||
return;
|
||||
@ -426,9 +429,9 @@ markdown_utils_sax_end_element_cb (gpointer ctx,
|
||||
|
||||
if (data->in_pre > 0) {
|
||||
data->in_pre--;
|
||||
if (data->in_pre == 0 && !data->plain_text)
|
||||
g_string_append (data->buffer, "```");
|
||||
g_string_append_c (data->buffer, '\n');
|
||||
if (data->in_pre == 0 && !data->plain_text)
|
||||
g_string_append (data->buffer, "```\n");
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -444,6 +447,7 @@ markdown_utils_sax_end_element_cb (gpointer ctx,
|
||||
|
||||
if (g_ascii_strcasecmp (name, "p") == 0 ||
|
||||
g_ascii_strcasecmp (name, "div") == 0 ||
|
||||
g_ascii_strcasecmp (name, "tr") == 0 ||
|
||||
g_ascii_strcasecmp (name, "h1") == 0 ||
|
||||
g_ascii_strcasecmp (name, "h2") == 0 ||
|
||||
g_ascii_strcasecmp (name, "h3") == 0 ||
|
||||
@ -460,10 +464,13 @@ markdown_utils_sax_end_element_cb (gpointer ctx,
|
||||
g_string_append (data->buffer, "<br>");
|
||||
}
|
||||
|
||||
data->in_paragraph_end = TRUE;
|
||||
if (g_ascii_strcasecmp (name, "tr") != 0) {
|
||||
data->in_paragraph_end = TRUE;
|
||||
|
||||
if (data->in_paragraph > 0)
|
||||
data->in_paragraph--;
|
||||
}
|
||||
|
||||
if (data->in_paragraph > 0)
|
||||
data->in_paragraph--;
|
||||
return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user