highlighting html with prism.js

前端 未结 2 405
悲&欢浪女
悲&欢浪女 2021-01-12 17:03

I cant seem to highlight html with prism.js because it removes the markup just printing the text. the following code inside the \"pre\" tag shows as just the text. I have th

相关标签:
2条回答
  • 2021-01-12 17:19

    You need to escape the beginning of the tags with &lt;. The easiest way is to paste your html code into the pre tag, then perform a find and replace for all < characters.

    This should work:

    &lt;table class="data-table">
        &lt;tr>
            &lt;td>Title&lt;/td>
            &lt;td>Amount&lt;/td>
        &lt;/tr>
        &lt;tr>
            &lt;td>Shorts&lt;/td>
            &lt;td>£1.00&lt;/td>
        &lt;/tr>   
        &lt;tr>
            &lt;td>Shorts&lt;/td>
            &lt;td>£1.00&lt;/td>
        &lt;/tr>           
    &lt;/table>
    
    0 讨论(0)
  • 2021-01-12 17:34

    In alternative you can wrap your code with <script type="prism-html-markup"> your code </script>

    0 讨论(0)
提交回复
热议问题