1

这一定是最令人沮丧的事情了,哈哈。

我正在使用 prettify.js 给代码语法颜色,但是使用 prettify.js 或 prism.js 当我对 html 进行编码时,我必须像下面这样在前面加上一个句点来编写它.&lt,否则我的语法会被 # 标签弄乱。

<pre class="prettyprint">.&lt;div class=&quot;modal modal--medium modal--middle&quot;&gt;
    &lt;div class=&quot;center-module&quot;&gt;
        &lt;input type=&quot;text&quot; placeholder=&quot;email&quot;&gt;
        &lt;button class=&quot;button button--primary&quot;&gt;send&lt;/button&gt;
    &lt;/div&gt;
&lt;/div&gt;</pre>

上面显示了一段时间

.<div class="modal modal--medium modal--middle">
    <div class="center-module">
        <input type="text" placeholder="email">
        <button class="button button--primary">send</button>
    </div>
</div>

之前没有句号&lt

#<DIV class="modal modal--medium modal--middle"#>
    #<DIV class="center-module"#>
        #<INPUT type="text" placeholder="email"#>
        #<BUTTON class="button button--primary"#>send#</BUTTON>
    #</DIV#>
#</DIV#>

我的问题是prettify.js如何/为什么&lt;div被包装?.tag <span class="tag">&lt;div</span>为什么我需要在&lt;div它之前添加一些字符才能工作?有什么想法为什么要这样做?

仅供参考,之前的任何字符&lt;div都会很好地显示该块,但是当它&lr;div<pre></pre>标签包裹时没有字符,它会显示一个带有#标签的块。

4

1 回答 1

0

您可能想查看HTML5 代码标签

<code>
  <DIV class="modal modal--medium modal--middle">
    <DIV class="center-module">
      <INPUT type="text" placeholder="email">
      <BUTTON class="button button--primary">send</BUTTON>
    </DIV>
  </DIV>
</code>
于 2016-11-05T23:34:16.867 回答