Fixed need for spaces to render html in a DIV

Marked update does not naturally detect the end of blocked elements like DIVs. The fix is to handle cases where only one half of the Div is detected separately.
This commit is contained in:
Trevor Buckner committed 2020-02-04 14:10:36 -05:00
1 parent 3259836964
commit b9cfc2e6af
3 files changed
+1696 -1655

No files matched your search

+1688 -1649
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -46,7 +46,7 @@
"express": "^4.17.1",
"jwt-simple": "^0.5.6",
"lodash": "^4.17.15",
"marked": "^0.3.19",
"marked": "^0.8.0",
"moment": "^2.24.0",
"mongoose": "^5.7.5",
"nconf": "^0.10.0",
+7 -5
View File
@@ -4,11 +4,14 @@ const renderer = new Markdown.Renderer();
//Processes the markdown within an HTML block if it's just a class-wrapper
renderer.html = function (html) {
if(_.startsWith(_.trim(html), '<div') && _.endsWith(_.trim(html), '</div>')){
const openTag = html.substring(0, html.indexOf('>')+1);
if(_.startsWith(_.trim(html), '<div')){
let openTag = html.substring(0, html.indexOf('>')+1);
let closeTag = '';
html = html.substring(html.indexOf('>')+1);
html = html.substring(0, html.lastIndexOf('</div>'));
return `${openTag} ${Markdown(html)} </div>`;
if(_.endsWith(_.trim(html), '</div>')){
closeTag = '</div>'
}
return `${openTag} ${Markdown(html)} ${closeTag}`;
}
return html;
};
@@ -87,4 +90,3 @@ module.exports = {
return errors;
},
};