I'm trying to use GeSHi Filter with Drupal 7.14 to produce syntax highlighting for Java code and it's producing invalid HTML, regardless of which language I set it to. The node content looks like:

IFrameElement iframe = Document.get().createIFrameElement();
iframe.setInnerHTML(htmlContent);

I'm using normal "code" tags. And here's the HTML it produces:

<div class="geshifilter">
<div class="java geshifilter-java" style="font-family:monospace;">
<pre style="font-family: monospace; font-weight: normal; font-style: normal">IFrameElement iframe <span style="color: &lt;a href=" http:="">#339933;"&gt;=</span> <span style="color: &lt;a href=" http:="">#003399;"&gt;Document</span>.<span style="color: &lt;a href=" http:="">#006633;"&gt;get</span><span style="color: &lt;a href=" http:="">#009900;"&gt;(</span><span style="color: &lt;a href=" http:="">#009900;"&gt;)</span>.<span style="color: &lt;a href=" http:="">#006633;"&gt;createIFrameElement</span><span style="color: &lt;a href=" http:="">#009900;"&gt;(</span><span style="color: &lt;a href=" http:="">#009900;"&gt;)</span><span style="color: &lt;a href=" http:="">#339933;"&gt;;</span>
iframe.<span style="color: &lt;a href=" http:="">#006633;"&gt;setInnerHTML</span><span style="color: &lt;a href=" http:="">#009900;"&gt;(</span>htmlContent<span style="color: &lt;a href=" http:="">#009900;"&gt;)</span><span style="color: &lt;a href=" http:="">#339933;"&gt;;</span></pre></div>
</div>

When it renders, it looks like:

IFrameElement iframe #339933;">= #003399;">Document.#006633;">get#009900;">(#009900;">).#006633;">createIFrameElement#009900;">(#009900;">)#339933;">;
iframe.#006633;">setInnerHTML#009900;">(htmlContent#009900;">)#339933;">;

Any suggestions?

Comments

soxofaan’s picture

I think there is another filter in your input format that post-processes GeSHi filter's output. It looks like all color hex codes from GeSHi are wrapped with additional broken markup.
What is the complete pipeline of your input format?

Also, what setting for 'CSS mode for syntax highlighting' on the GeSHi filter admin page are you using? Have you already tried to play with this setting? Note that you have to flush the page cache to see the effect on all existing nodes.

organicveggie’s picture

Pipeline for Full HTML looks like:

  • GeSHi
  • Twitter @username converter
  • Twitter #hashtag converter
  • Convert URLs into links
  • Convert line breaks into HTML
  • Correct faulty and chopped off HTML

CSS mode for syntax highlighting is set to "Inline". I have tried playing with that setting and that didn't help. Obviously it moved the style settings out, but still left broken HTML.

Clearing the page cache didn't help.

organicveggie’s picture

Interestingly enough, it seems to be working for Ruby syntax highlighting... Strange.

soxofaan’s picture

I think the Twitter hashtag filter is the culprit here.
Can you try to put the Geshi filter after the "Convert URLS into links" and before the "Convert line breaks into HTML"?

organicveggie’s picture

Status: Active » Closed (works as designed)

Awesome! That was it.

Thank you!