mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-24 20:42:43 +00:00
Updating project version
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
# changelog
|
||||
|
||||
### Friday, 09/09/2016 - v2.4.0
|
||||
- Adding in a HTML validator that will display warnings whenever you save. This should stop a lot of the issues generated with pages not showing up.
|
||||
|
||||
### Saturday, 20/08/2016 - v2.3.0
|
||||
- Added in a license file
|
||||
- Updated the welcome text
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
var _ = require('lodash');
|
||||
var Markdown = require('marked');
|
||||
var 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>')){
|
||||
var openTag = html.substring(0, html.indexOf('>')+1);
|
||||
html = html.substring(html.indexOf('>')+1);
|
||||
html = html.substring(0, html.lastIndexOf('</div>'));
|
||||
return `${openTag} ${Markdown(html)} </div>`;
|
||||
}
|
||||
return html;
|
||||
};
|
||||
|
||||
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