-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replace custom showdown fork with markdown-it (#8451)
refs TryGhost/Admin#690, closes #1501, closes #2093, closes #4592, closes #4627, closes #4659, closes #5039, closes #5237, closes #5587, closes #5625, closes #5632, closes #5822, closes #5939, closes #6840, closes #7183, closes #7536 - replace custom showdown fork with markdown-it - swaps showdown for markdown-it when rendering markdown - match existing header ID behaviour - allow headers without a space after the #s - add duplicate header ID handling - remove legacy markdown spec - move markdown-it setup into markdown-converter util - update mobiledoc specs to match markdown-it newline behaviour - update data-generator HTML to match markdown-it newline behaviour - fix Post "converts html to plaintext" test - update rss spec to match markdown-it newline behaviour - close almost all related showdown bugs
- Loading branch information
1 parent
3bae41c
commit 5d868d1
Showing
11 changed files
with
94 additions
and
648 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,14 +1,17 @@ | ||
var SimpleDom = require('simple-dom'), | ||
tokenizer = require('simple-html-tokenizer').tokenize, | ||
Showdown = require('showdown-ghost'), | ||
converter = new Showdown.converter({extensions: ['ghostgfm', 'footnotes', 'highlight']}), | ||
markdownConverter = require('../../../utils/markdown-converter'), | ||
parser; | ||
|
||
module.exports = { | ||
name: 'card-markdown', | ||
type: 'dom', | ||
render(opts) { | ||
parser = new SimpleDom.HTMLParser(tokenizer, opts.env.dom, SimpleDom.voidMap); | ||
return parser.parse('<div class="kg-card-markdown">' + converter.makeHtml(opts.payload.markdown || '') + '</div>'); | ||
return parser.parse('' | ||
+ '<div class="kg-card-markdown">' | ||
+ markdownConverter.render(opts.payload.markdown || '') | ||
+ '</div>' | ||
); | ||
} | ||
}; |
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
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
var MarkdownIt = require('markdown-it'), | ||
converter = new MarkdownIt({ | ||
html: true, | ||
breaks: true, | ||
linkify: true | ||
}) | ||
.use(require('markdown-it-footnote')) | ||
.use(require('markdown-it-lazy-headers')) | ||
.use(require('markdown-it-mark')) | ||
.use(require('markdown-it-named-headers'), { | ||
// match legacy Showdown IDs otherwise default is github style dasherized | ||
slugify: function (inputString, usedHeaders) { | ||
var slug = inputString.replace(/[^\w]/g, '').toLowerCase(); | ||
if (usedHeaders[slug]) { | ||
usedHeaders[slug] += 1; | ||
slug += usedHeaders[slug]; | ||
} | ||
return slug; | ||
} | ||
}); | ||
|
||
module.exports = { | ||
render: function (markdown) { | ||
return converter.render(markdown); | ||
} | ||
}; |
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.