
All the docs related files (docs-app, doc-gen, content, etc) are now to be found inside the `/aio` folder. The related gulp tasks have been moved from the top level gulp file to a new one inside the `/aio` folder. The structure of the `/aio` folder now looks like: ``` /aio/ build/ # gulp tasks content/ #MARKDOWN FILES for devguides, cheatsheet, etc devguides/ cheatsheets/ transforms/ #dgeni packages, templates, etc src/ app/ assets/ content/ #HTML + JSON build artifacts produced by dgeni from /aio/content. #This dir is .gitignored-ed e2e/ #protractor tests for the doc viewer app node_modules/ #dependencies for both the doc viewer builds and the dgeni stuff #This dir is .gitignored-ed gulpfile.js #Tasks for generating docs and building & deploying the doc viewer ``` Closes #14361
55 lines
1.7 KiB
JavaScript
55 lines
1.7 KiB
JavaScript
var rho = require('rho');
|
|
|
|
/**
|
|
* @dgService renderMarkdown
|
|
* @description
|
|
* Render the markdown in the given string as HTML.
|
|
*/
|
|
module.exports = function renderMarkdown() {
|
|
|
|
|
|
// TODO(petebd): We might want to remove the leading whitespace from the code
|
|
// block before it gets to the markdown code render function
|
|
|
|
// We need to teach Rho about inline tags so that it doesn't try to process
|
|
// the inside of the tag
|
|
const emitNormal = rho.InlineCompiler.prototype.emitNormal;
|
|
rho.InlineCompiler.prototype.emitNormal = function(walk) {
|
|
if (this.emitText(walk)) return;
|
|
if (tryDgeniInlineTag(this, walk)) return;
|
|
emitNormal.call(this, walk);
|
|
};
|
|
|
|
rho.BlockCompiler.prototype.emitBlock = function(walk) {
|
|
walk.skipBlankLines();
|
|
this.countBlockIndent(walk);
|
|
if (this.tryUnorderedList(walk)) return;
|
|
if (this.tryOrderedList(walk)) return;
|
|
if (this.tryDefinitionList(walk)) return;
|
|
if (this.tryHeading(walk)) return;
|
|
if (this.tryCodeBlock(walk)) return;
|
|
if (this.tryDiv(walk)) return;
|
|
if (this.tryHtml(walk)) return;
|
|
if (tryDgeniInlineTag(this, walk, true)) return;
|
|
if (this.tryHrTable(walk)) return;
|
|
this.emitParagraph(walk);
|
|
};
|
|
|
|
function tryDgeniInlineTag(compiler, walk, isBlock) {
|
|
if (!walk.at('{@')) return false;
|
|
|
|
const startIdx = walk.position;
|
|
var endIdx = walk.indexOf('}');
|
|
|
|
if (endIdx === null) return false;
|
|
|
|
if (isBlock) compiler.out.push('<div>');
|
|
compiler.out.push(walk.substring(startIdx, endIdx + 1));
|
|
if (isBlock) compiler.out.push('</div>');
|
|
|
|
walk.startFrom(endIdx + 2);
|
|
return true;
|
|
};
|
|
|
|
return function renderMarkdownImpl(content) { return rho.toHtml(content, true); };
|
|
}; |