-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refs #9505 - updates mobiledoc converter's `render` method to accept a `version` argument - `1` === Ghost 1.0's markdown-only renderer output - `2` === Koenig's full mobiledoc renderer output - switch between mobiledoc renderer versions in Post model's `onSaving` hook - version 1 by default - version 2 if Koenig is enabled (currently behind dev experiments config + labs flag) - version 2 if the post's mobiledoc is not compatible with the markdown-only renderer - "version 2" full-Koenig mobiledoc renderer output - wraps content in a `.kg-post` div - removes wrapper around markdown and html card output - adds classes to image card output including selected image size/style - standardises es6 usage across mobiledoc related files
- Loading branch information
1 parent
58aa531
commit e953a1c
Showing
16 changed files
with
427 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
var softReturn = require('./soft-return'); | ||
'use strict'; | ||
|
||
const softReturn = require('./soft-return'); | ||
|
||
module.exports = [softReturn]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
name: 'soft-return', | ||
type: 'dom', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
name: 'hr', | ||
type: 'dom', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
var hr = require('./hr'), | ||
html = require('./html'), | ||
image = require('./image'), | ||
markdown = require('./markdown'), | ||
cardMarkdown = require('./card-markdown'); | ||
'use strict'; | ||
|
||
const hr = require('./hr'); | ||
const html = require('./html'); | ||
const image = require('./image'); | ||
const markdown = require('./markdown'); | ||
const cardMarkdown = require('./card-markdown'); | ||
|
||
module.exports = [hr, html, image, markdown, cardMarkdown]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
name: 'markdown', | ||
type: 'dom', | ||
render: function (opts) { | ||
var converters = require('../converters'), | ||
html, element; | ||
|
||
let converters = require('../converters'); | ||
let payload = opts.payload; | ||
let version = opts.options.version; | ||
// convert markdown to HTML ready for insertion into dom | ||
html = '<div class="kg-card-markdown">' | ||
+ converters.markdownConverter.render(opts.payload.markdown || '') | ||
+ '</div>'; | ||
let html = converters.markdownConverter.render(payload.markdown || ''); | ||
|
||
// Ghost 1.0's markdown-only renderer wrapped cards | ||
if (version === 1) { | ||
html = `<div class="kg-card-markdown">${html}</div>`; | ||
} | ||
|
||
// use the SimpleDOM document to create a raw HTML section. | ||
// avoids parsing/rendering of potentially broken or unsupported HTML | ||
element = opts.env.dom.createRawHTMLSection(html); | ||
|
||
return element; | ||
return opts.env.dom.createRawHTMLSection(html); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
var should = require('should'), // jshint ignore:line | ||
card = require('../../../../../server/lib/mobiledoc/atoms/soft-return'), | ||
SimpleDom = require('simple-dom'), | ||
opts; | ||
'use strict'; | ||
|
||
describe('Soft return card', function () { | ||
const should = require('should'); // jshint ignore:line | ||
const atom = require('../../../../../server/lib/mobiledoc/atoms/soft-return'); | ||
const SimpleDom = require('simple-dom'); | ||
const serializer = new SimpleDom.HTMLSerializer(SimpleDom.voidMap); | ||
|
||
describe('Soft return atom', function () { | ||
it('generates a `br` tag', function () { | ||
opts = { | ||
let opts = { | ||
env: { | ||
dom: new SimpleDom.Document() | ||
} | ||
}; | ||
|
||
var serializer = new SimpleDom.HTMLSerializer([]); | ||
serializer.serialize(card.render(opts)).should.match('<br></br>'); | ||
serializer.serialize(atom.render(opts)).should.match('<br>'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
var should = require('should'), // jshint ignore:line | ||
card = require('../../../../../server/lib/mobiledoc/cards/hr'), | ||
SimpleDom = require('simple-dom'), | ||
opts; | ||
'use strict'; | ||
|
||
const should = require('should'); // jshint ignore:line | ||
const card = require('../../../../../server/lib/mobiledoc/cards/hr'); | ||
const SimpleDom = require('simple-dom'); | ||
const serializer = new SimpleDom.HTMLSerializer(SimpleDom.voidMap); | ||
|
||
describe('HR card', function () { | ||
it('generates a horizontal rule', function () { | ||
opts = { | ||
let opts = { | ||
env: { | ||
dom: new SimpleDom.Document() | ||
} | ||
}; | ||
|
||
var serializer = new SimpleDom.HTMLSerializer([]); | ||
serializer.serialize(card.render(opts)).should.match('<hr></hr>'); | ||
serializer.serialize(card.render(opts)).should.match('<hr>'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.