jbt / docker

Documentation generator
http://jbt.github.com/docker
MIT License
234 stars 56 forks source link

Unexpected Pygments Output in <v1.0.0 results in visible '----DIVIDER----' comments #107

Open iabw opened 7 years ago

iabw commented 7 years ago

First, thanks for the library, been using it for a while. I just wanted to document this problem I ran into, even though it's for the last version and from what I can tell completely inapplicable to v1.

I was looking to add the Velocity templating language to the available languages in version 0.2.x

I figured I'd be able to easily add it, but it was breaking rather bizarrely due to the highlighted HTML that Pygments outputs not matching the regex used to split its output. As a result, the code was being output in a giant clump in the first section, with all the '----DIVIDER----' comments intact, and all the rest of the sections had 'undefined' for their code.

The html the regex expected (and was being generated for other languages) looked like <span class="err">##</span><span class="x">----DIVIDER----</span>

and what I was getting was <span class="cp">##</span><span class="c">----DIVIDER----</span><span class="x"></span>

I fixed this by changing that regex line at docker.js#L1061 to var bits = out.split(/^<span[^>]*>[^<]+(?:<\/span><span[^>]*>)?----DIVIDER----[^<]*(?:<\/span><span[^>]*>)?<\/span>$/gm);

This just copies the same optional span detecting block after the DIVIDER block, and now it works.