标记不显示使用棱镜JS [英] Markup Not Showing Up Using Prism JS

查看:104
本文介绍了标记不显示使用棱镜JS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用PrismJS作为我的blogspot博客的语法突出显示器。



我的代码如下所示:

 < pre class =line-numbers language-markup> 
< code>
< style type =text / css>
font-size:22px;
< / style>
< / b:if>
< / code>
< / pre>

我已将prismjs文件包含在< / head> 标签。



这些CSS可以正常工作,我的Chrome控制台中没有任何错误,但该脚本没有显示标记。

我在我的网站上有一个完全相同的代码jsFiddle,它也不显示行号,即使我的网站。 http://jsfiddle.net/fyqnz/



网站示例:< a href =http://www.xarpixels.com/2013/05/bloggers-conditional-statements-legacy.html> http://www.xarpixels.com/2013/05/bloggers-conditional-statements-legacy .html



任何想法为什么这不起作用?

解决方案 class =language - *需要放在< code> 元素上,不是< pre> 元素。我最初也犯了这个错误。



更新了正确的信息



JS小提琴似乎不喜欢棱镜。在CodePen上正常工作,并在本地机器上工作: http://codepen.io/anon/pen/xmwji。棱镜使用正则表达式来确定要突出显示的部分。确保您正确地转义您的代码。开放标签(< 符号)应该写为& lt; ,并且结束标签(> 符号)作为& gt;


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?

解决方案

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;.

这篇关于标记不显示使用棱镜JS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆