mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-24 20:42:43 +00:00
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:
3337
package-lock.json
generated
3337
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -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",
|
||||
|
||||
@@ -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;
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user