2017-03-14 21:07:33 +03:00
|
|
|
var SimpleDom = require('simple-dom'),
|
|
|
|
Renderer = require('mobiledoc-dom-renderer').default,
|
|
|
|
config = require('../config'),
|
2017-03-24 13:03:33 +03:00
|
|
|
logging = require('../logging'),
|
|
|
|
errors = require('../errors'),
|
2017-03-14 21:07:33 +03:00
|
|
|
defaults = require(config.get('paths').internalAppPath + 'default-cards'),
|
|
|
|
options = {
|
|
|
|
dom: new SimpleDom.Document(),
|
|
|
|
cards: defaults.cards,
|
2017-03-24 13:03:33 +03:00
|
|
|
atoms: defaults.atoms,
|
|
|
|
unknownCardHandler: function (args) {
|
|
|
|
var error = new errors.InternalServerError({message: 'Mobiledoc card \'' + args.env.name + '\' not found.'});
|
|
|
|
logging.error(error);
|
|
|
|
}
|
2017-03-14 21:07:33 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
// function getCards() {
|
2017-05-29 22:48:42 +03:00
|
|
|
// return config.get('apps:internal').reduce(
|
2017-03-14 21:07:33 +03:00
|
|
|
// function (cards, appName) {
|
|
|
|
// var app = require(path.join(config.get('paths').internalAppPath, appName));
|
|
|
|
// if (app.hasOwnProperty('cards')) {
|
|
|
|
// cards = cards.concat(app.cards);
|
|
|
|
// }
|
|
|
|
// return cards;
|
|
|
|
// }, [ ]);
|
|
|
|
// }
|
|
|
|
// function getAtoms() {
|
2017-05-29 22:48:42 +03:00
|
|
|
// return config.get('apps:internal').reduce(
|
2017-03-14 21:07:33 +03:00
|
|
|
// function (atoms, appName) {
|
|
|
|
// var app = require(path.join(config.get('paths').internalAppPath, appName));
|
|
|
|
// if (app.hasOwnProperty('atoms')) {
|
|
|
|
// atoms = atoms.concat(app.atoms);
|
|
|
|
// }
|
|
|
|
// return atoms;
|
|
|
|
// }, [ ]);
|
|
|
|
// }
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
render: function (mobiledoc) {
|
|
|
|
var renderer = new Renderer(options),
|
|
|
|
rendered = renderer.render(mobiledoc),
|
🐛 fix incorrect rendering of non-closing tags (eg. <br></br>) (#8749)
closes https://github.com/TryGhost/Ghost/issues/8743
- the serializer in our mobiledoc renderer didn't have the list of non-closing HTML tags passed in which meant that tags such as `<br>` in the markdown HTML output were being re-serialized to `<br></br>` which is invalid HTML which (at least Chrome) then attempts to fix by rendering it as `<br><br>` instead
- the elements with incorrect rendering that may result in unwanted "fixing" by browsers are `AREA`, `BASE`, `BR`, `COL`, `COMMAND`, `EMBED`, `HR`, `IMG`, `INPUT`, `KEYGEN`, `LINK`, `META`, `PARAM`, `SOURCE`, `TRACK`, and `WBR`
2017-07-25 14:50:33 +03:00
|
|
|
serializer = new SimpleDom.HTMLSerializer(SimpleDom.voidMap),
|
2017-03-14 21:07:33 +03:00
|
|
|
html = serializer.serializeChildren(rendered.result);
|
|
|
|
return html;
|
|
|
|
}
|
|
|
|
};
|