Syntax highlight feature for Grunt-ngdocs


I don’t know whether something is going wrong or it’s not supported yet, but I expect to see code blocks like:

var example = 3;

in documentations to be highlighted.
How can I fix/add this feature?



marked module is used in grunt-ngdocs (grunt-ngdocs\node_modules\marked\lib).
Since grunt-ngdocs uses angular-bootstrap-prettify (which BTW uses google-code-prettify), it’s enough to tweak marked a little in order to produce <pre class="prettyprint linenums">...</pre> instead of <pre>...</pre>.
So at Renderer.prototype.code function (line 757 at my version), return statements can change like this:

  • return '<pre class="prettyprint linenums"><code>' ...
  • return '<pre class="prettyprint linenums"><code class="' ...

Cleaner solution:

ngDocs seems to replace all <pre>..</pre> blocks with <pre class="prettyprint linenums">...</pre> (line 266 at v0.2.6). So instead of using markdown ``` code ``` blocks, we can use <pre>...</pre> blocks directly at documentations.

Answered By – Alireza Mirian

Answer Checked By – Cary Denson (AngularFixing Admin)

Leave a Reply

Your email address will not be published.