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 all commits
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
14 changes: 6 additions & 8 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 @@ -54,7 +54,7 @@ YUI.add('doc-builder', function (Y) {
if (options.themedir) {
themeDir = options.themedir;
}

this.md = new MarkdownIt(options.markdown);
this.data = data;
Y.log('Building..', 'info', 'builder');
this.files = 0;
Expand Down Expand Up @@ -138,16 +138,15 @@ 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 html = this.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 +155,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