You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-15 23:00:36 +02:00
Desktop: WYSIWYG: Fixed inserting date time and other content inside header
This commit is contained in:
@ -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>`;
|
||||
|
Reference in New Issue
Block a user