mirror of https://github.com/laurent22/joplin.git
Desktop, Cli: enex_to_md: Support italic in span tags (#1966)
* Desktop, Cli: enex_to_md: support italic in span tags * Desktop, Cli: enex_to_md: readd debug message to resolve CI conflict * Desktop, Cli: enex_to_md: fix CI errors add spaces to commented out debug messages * Desktop, Cli: enex_to_md: remove redundant commented out debug message * Desktop, Cli: enex_to_md: readd redundant commented out debug message CI wants it in there - maybe remove in another PRpull/1986/head
parent
d3e9ffcaea
commit
f90cc8d67d
|
@ -0,0 +1,8 @@
|
|||
<div><span style="font-style: italic;">singleline italic text with span style font-style: italic;.</span></div><div><br/></div>
|
||||
<div><span style="font-style: italic;">multiline italic
|
||||
text with span style font-style: italic;.</span></div><div><br/></div>
|
||||
|
||||
<div><span style="font-style: italic;">singleline italic text with span style font-style: italic;</span> next to normal text with leading space.</div><div><br/></div>
|
||||
<div><span style="font-style: italic;">singleline italic text with span style font-style: italic; and with trailing space </span>next to normal text.</div><div><br/></div>
|
||||
<div><span style="font-style: italic;">singleline italic text with span style font-style: italic;</span><span style="font-style: italic;"> next to more italic text with span style font-style: italic; and with leading space.</span></div><div><br/></div>
|
||||
<div><span style="font-style: italic;">singleline italic text with span style font-style: italic; and with trailing space </span><span style="font-style: italic;">next to more italic text with span style font-style: italic;.</span></div>
|
|
@ -0,0 +1,11 @@
|
|||
*singleline italic text with span style font-style: italic;.*
|
||||
|
||||
*multiline italic text with span style font-style: italic;.*
|
||||
|
||||
*singleline italic text with span style font-style: italic;* next to normal text with leading space.
|
||||
|
||||
*singleline italic text with span style font-style: italic; and with trailing space *next to normal text.
|
||||
|
||||
*singleline italic text with span style font-style: italic;** next to more italic text with span style font-style: italic; and with leading space.*
|
||||
|
||||
*singleline italic text with span style font-style: italic; and with trailing space **next to more italic text with span style font-style: italic;.*
|
|
@ -400,6 +400,12 @@ function isSpanStyleBold(attributes) {
|
|||
}
|
||||
}
|
||||
|
||||
function isSpanStyleItalic(attributes) {
|
||||
let style = attributes.style;
|
||||
style = style.replace(/\s+/g, '');
|
||||
return (style.toLowerCase().includes('font-style:italic;'));
|
||||
}
|
||||
|
||||
function enexXmlToMdArray(stream, resources) {
|
||||
let remainingResources = resources.slice();
|
||||
|
||||
|
@ -694,11 +700,16 @@ function enexXmlToMdArray(stream, resources) {
|
|||
}
|
||||
} else if (n == 'span') {
|
||||
if (isSpanWithStyle(nodeAttributes)) {
|
||||
// console.debug('Found style(s) in span tag: %s', nodeAttributes.style);
|
||||
state.spanAttributes.push(nodeAttributes);
|
||||
if (isSpanStyleBold(nodeAttributes)) {
|
||||
// console.debug('Applying style found in span tag: bold')
|
||||
section.lines.push('**');
|
||||
}
|
||||
if (isSpanStyleItalic(nodeAttributes)) {
|
||||
// console.debug('Applying style found in span tag: italic')
|
||||
section.lines.push('*');
|
||||
}
|
||||
}
|
||||
} else if (['font', 'sup', 'cite', 'abbr', 'small', 'tt', 'sub', 'colgroup', 'col', 'ins', 'caption', 'var', 'map', 'area'].indexOf(n) >= 0) {
|
||||
// Inline tags that can be ignored in Markdown
|
||||
|
@ -887,6 +898,10 @@ function enexXmlToMdArray(stream, resources) {
|
|||
// console.debug('Applying style found in span tag (closing): bold')
|
||||
section.lines.push('**');
|
||||
}
|
||||
if (isSpanStyleItalic(attributes)) {
|
||||
// console.debug('Applying style found in span tag (closing): italic')
|
||||
section.lines.push('*');
|
||||
}
|
||||
}
|
||||
} else if (isIgnoredEndTag(n)) {
|
||||
// Skip
|
||||
|
|
Loading…
Reference in New Issue