Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
68
rated 0 times [  71] [ 3]  / answers: 1 / hits: 23105  / 11 Years ago, thu, august 22, 2013, 12:00:00

I'm trying to use PrismJS as my syntax highlighter for my blogspot blog. After having troubles with Syntax Highlighter, I thought I would give prism a try.



My code look like this:



<pre class=line-numbers language-markup>
<code>
<b:if cond='data:blog.url == http://domain.com/p/about.html'>
<style type=text/css>
font-size: 22px;
</style>
</b:if>
</code>
</pre>


I have included the prismjs file before the </head> tag.



The CSS works, there are no errors in my Chrome console, yet the script shows no markup.



I have a jsFiddle with the exact same code on my site, and it also doesn't show the line numbers, even though my site does. http://jsfiddle.net/fyqnz/



Site example: http://www.xarpixels.com/2013/05/bloggers-conditional-statements-legacy.html



Any idea why this isn't working?


More From » html

 Answers
11

The class=language-* needs to go on the <code> element, not the <pre> element. I was making this mistake at first, too.



Updated with correct info



It appears the JS Fiddle doesn't like Prism. Working fine on CodePen and locally on my machine: http://codepen.io/anon/pen/xmwji. Prism uses Regex to identify the sections to highlight. Make sure you escape your code properly. Opening tags (the < symbol) should be written as &lt;, and closing tags (the > symbol) as &gt;.


[#76202] Thursday, August 22, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
meadowe

Total Points: 0
Total Questions: 97
Total Answers: 97

Location: Laos
Member since Fri, Sep 11, 2020
4 Years ago
meadowe questions
Thu, Aug 5, 21, 00:00, 3 Years ago
Thu, Jul 9, 20, 00:00, 4 Years ago
Mon, Jun 8, 20, 00:00, 4 Years ago
Sun, Feb 9, 20, 00:00, 4 Years ago
;