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:
@@ -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
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user