문제

I'm using the SyntaxHighlighter plugin for CKEditor to insert code into my pages. The plugin uses <pre> tags to contain the code whilst making use of "brush" classes to define the programming language. My problem is that upon submission of the page HTML Purifier is stripping the class attribute from the pre tags, which effectively prevents the syntax highlighting from occurring.

The source code goes from:

<pre class="brush:php;">
   <?php echo '<p>Hello World</p>'; ?>
</pre>

to:

<pre>
   <?php echo '<p>Hello World</p>'; ?>
</pre>

I'm hoping there is some magical setting to stop HTML Purifier from doing this.

도움이 되었습니까?

해결책

The reason is brush:php is not a valid class name per the HTML4 specification. I guess you could write your own class name validator and override the builtin using http://htmlpurifier.org/docs/enduser-customize.html

But a better solution might be to run the syntax highlighting before you run HTML Purifier!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top