docpad / docpad-plugin-highlightjs

Adds support for Highlight.js syntax highlighting to DocPad
Other
20 stars 18 forks source link

Plugin overrides own classes for pre #7

Open philippwiddra opened 10 years ago

philippwiddra commented 10 years ago

It appears to me that the plugin overrides other classes of the pre tag when generating.

Especially when using the bootstrap class .pre-scrollable it is a little annoying that all original classes are stripped off the <pre> tag. Im not sure if this also applies to classes of the original <code> tag.

Example:

<pre class="pre-scrollable">
    <code class="lang-json">
{
    "foo": 1
}
    </code>
</pre>

Should generate into:

<pre class="pre-scrollable highlight">
    <code class="json">
{
    "<span class="attribute">foo</span>": <span class="value"><span class="number">1</span></span>
}
    </code>
</pre>

But instead generates into:

<pre class="highlight">
    <code class="json">
{
    "<span class="attribute">foo</span>": <span class="value"><span class="number">1</span></span>
}
    </code>
</pre>

If this is the intended behavior i apologize for bothering you, but if not it may be important for more people than me.

jacoscaz commented 10 years ago

Same here. This also breaks support for some of the .css themes as they look for '.hljs'-classed <pre> tags.

EDIT: I'll elaborate a bit more. I have just updated all the plugins for a docpad-generated website and docpad-plugin-highlightjs' update broke support for Highlight.js' solarized_dark (but also solarized_light) themes, even for their latest versions. This seems to be due to the <pre> tag missing the .hljs (which, I presume, used to be there in previous versions).

Adding the aforementioned class via dev console gets things back to normal.

balupton commented 10 years ago

If someone can submit a pull request for this, that would be amazing.

jacoscaz commented 10 years ago

I'll have a look into it over the weekend. There seem to be two different issues at play: one is the default class being set to 'highlightjs' instead of 'hljs', which seems to be easily fixable, and the other is classes being overridden instead of appended to. I'll let you know asap. On Feb 7, 2014 12:29 AM, "Benjamin Arthur Lupton" notifications@github.com wrote:

If someone can submit a pull request for this, that would be amazing.

— Reply to this email directly or view it on GitHubhttps://github.com/docpad/docpad-plugin-highlightjs/issues/7#issuecomment-34387163 .