0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-01 02:02:43 +00:00

Adding my own markdown-html validator, still needs line numbers though

This commit is contained in:
Scott Tolksdorf
2016-09-09 09:36:45 -04:00
parent 54542a8ec1
commit 9a96eebdb1
2 changed files with 34 additions and 1 deletions

View File

@@ -17,5 +17,27 @@ module.exports = {
render : (rawText)=>{
return Markdown(rawText, {renderer : renderer})
},
validate : (rawText)=>{
var errors = [];
var tokens = Markdown.lexer(rawText);
_.each(tokens, (token)=>{
if(token.type === 'paragraph'){
if(_.startsWith(token.text, '<div')){
errors.push({
err : ' No closing tag',
token : token
});
}else if(_.startsWith(token.text, '</div>')){
errors.push({
err : ' No opening tag',
token : token
})
}
}
});
return errors;
},
marked : Markdown
};