mirror of https://github.com/laurent22/joplin.git
Desktop: WYSIWYG: Fixed inserting date time and other content inside header
parent
9c057071b5
commit
77a03599de
|
@ -140,7 +140,7 @@ describe('MdToHtml', function() {
|
|||
// The style is instead in the cssStrings property.
|
||||
const result = await mdToHtml.render('just **testing**', null, { bodyOnly: true });
|
||||
expect(result.cssStrings.length).toBe(1);
|
||||
expect(result.html.trim()).toBe('<p>just <strong>testing</strong></p>');
|
||||
expect(result.html.trim()).toBe('just <strong>testing</strong>');
|
||||
}));
|
||||
|
||||
it('should split HTML and CSS', asyncTest(async () => {
|
||||
|
|
|
@ -1 +1 @@
|
|||
<p><a href="#" class="jop-noMdConv">Testing <strong>inline</strong> text</a></p>
|
||||
<a href="#" class="jop-noMdConv">Testing <strong>inline</strong> text</a>
|
|
@ -1 +1 @@
|
|||
<p>Should be <span style="color: red;" class="jop-noMdConv">red</span>.</p>
|
||||
Should be <span style="color: red;" class="jop-noMdConv">red</span>.
|
|
@ -1 +1 @@
|
|||
<p><mark class="jop-noMdConv">bla</mark></p>
|
||||
<mark class="jop-noMdConv">bla</mark>
|
|
@ -166,6 +166,14 @@ class MdToHtml {
|
|||
return output;
|
||||
}
|
||||
|
||||
removeMarkdownItWrappingParagraph_(html) {
|
||||
// <p></p>\n
|
||||
if (html.length < 8) return html;
|
||||
if (html.substr(0, 3) !== '<p>') return html;
|
||||
if (html.slice(-5) !== '</p>\n') return html;
|
||||
return html.substring(3, html.length - 5);
|
||||
}
|
||||
|
||||
// "style" here is really the theme, as returned by themeStyle()
|
||||
async render(body, theme = null, options = null) {
|
||||
options = Object.assign({}, {
|
||||
|
@ -305,7 +313,12 @@ class MdToHtml {
|
|||
if (options.userCss) cssStrings.push(options.userCss);
|
||||
|
||||
if (options.bodyOnly) {
|
||||
output.html = renderedBody;
|
||||
// Markdown-it wraps any content in <p></p> by default. There's a function to parse without
|
||||
// adding these tags (https://github.com/markdown-it/markdown-it/issues/540#issuecomment-471123983)
|
||||
// however when using it, it seems the loaded plugins are not used. In my tests, just changing
|
||||
// render() to renderInline() means the checkboxes would not longer be rendered. So instead
|
||||
// of using this function, we manually remove the <p></p> tags.
|
||||
output.html = this.removeMarkdownItWrappingParagraph_(renderedBody);
|
||||
output.cssStrings = cssStrings;
|
||||
} else {
|
||||
const styleHtml = `<style>${cssStrings.join('\n')}</style>`;
|
||||
|
|
Loading…
Reference in New Issue