Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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: <a href=" http:="">#339933;">=</span> <span style="color: <a href=" http:="">#003399;">Document</span>.<span style="color: <a href=" http:="">#006633;">get</span><span style="color: <a href=" http:="">#009900;">(</span><span style="color: <a href=" http:="">#009900;">)</span>.<span style="color: <a href=" http:="">#006633;">createIFrameElement</span><span style="color: <a href=" http:="">#009900;">(</span><span style="color: <a href=" http:="">#009900;">)</span><span style="color: <a href=" http:="">#339933;">;</span>
iframe.<span style="color: <a href=" http:="">#006633;">setInnerHTML</span><span style="color: <a href=" http:="">#009900;">(</span>htmlContent<span style="color: <a href=" http:="">#009900;">)</span><span style="color: <a href=" http:="">#339933;">;</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
Comment #1
soxofaan CreditAttribution: soxofaan commentedI 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.
Comment #2
organicveggie CreditAttribution: organicveggie commentedPipeline for Full HTML looks like:
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.
Comment #3
organicveggie CreditAttribution: organicveggie commentedInterestingly enough, it seems to be working for Ruby syntax highlighting... Strange.
Comment #4
soxofaan CreditAttribution: soxofaan commentedI 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"?
Comment #5
organicveggie CreditAttribution: organicveggie commentedAwesome! That was it.
Thank you!