Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the Markdown parser #321

Merged
merged 2 commits into from
Mar 5, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/args/index.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ See below for <a href="#ex-yui3">more</a> <a href="#ex-yuidoc">examples</a>.
<tr>
<td>`markdown`</td>
<td>
Options to pass to Marked, the Markdown compiler used to compile API descriptions.
See the <a href="https://github.com/chjj/marked#options">Marked readme</a> for details.
Options to pass to markdown-it, the Markdown compiler used to compile API descriptions.
See the <a href="https://markdown-it.github.io/markdown-it/#MarkdownIt.new">markdown-it API</a> for details.
</td>
</tr>
</table>
Expand Down
13 changes: 6 additions & 7 deletions lib/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Code licensed under the BSD License:
* https://github.com/yui/yuidoc/blob/master/LICENSE
*/
var marked = require('marked'),
var MarkdownIt = require('markdown-it'),
fs = require('graceful-fs'),
noop = function () {},
path = require('path'),
Expand Down Expand Up @@ -138,16 +138,16 @@ YUI.add('doc-builder', function (Y) {
* Wrapper around the Markdown parser so it can be normalized or even side stepped
* @method markdown
* @private
* @param {String} md The Markdown string to parse
* @param {String} data The Markdown string to parse
* @return {HTML} The rendered HTML
*/
markdown: function (md) {
var html = marked(md, this.options.markdown);
markdown: function (data) {
var md = new MarkdownIt(this.options.markdown);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we create the instance only once? Also, what are the defaults for this.options.markdown?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, I'll take a look!

var html = md.render(data);
//Only reprocess if helpers were asked for
if (this.options.helpers || (html.indexOf('{{#crossLink') > -1)) {
//console.log('MD: ', html);
try {
// marked auto-escapes quotation marks (and unfortunately
// markdown-it auto-escapes quotation marks (and unfortunately
// does not expose the escaping function)
html = html.replace(/&quot;/g, "\"");
html = (Y.Handlebars.compile(html))({});
Expand All @@ -156,7 +156,6 @@ YUI.add('doc-builder', function (Y) {
html = html.replace(/\\{/g, '{').replace(/\\}/g, '}');
Y.log('Failed to parse Handlebars, probably an unknown helper, skipping..', 'warn', 'builder');
}
//console.log('HB: ', html);
}
return html;
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"dependencies": {
"express": "^4.10.1",
"graceful-fs": "2.x",
"marked": "^0.3.3",
"markdown-it": "^3.0.7",
"minimatch": "^2.0.1",
"rimraf": "2.x",
"yui": "^3.18.1"
Expand Down