最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Code highlighting with semantic-ui - Stack Overflow

programmeradmin0浏览0评论

I'm using semantic-ui for a website and I want to know if code highlighting is an actual feature it supports.

There are code blocks shown throughout the library's docs pages with highlighted code but I can't find any details about how to use it in my project.

After looking at their page's source code I tried creating the following divs which did not highlight the code:

<div class="ui segment">
  <div class="ui ignored code" data-type="bash" data-title="mands">
    #!/bin/bash

    # test
    echo 'hello there'
  </div>
</div>

Also tried including this script: .min.js

Am I coding it wrong or is code highlighting not even part of the library?

I'm using semantic-ui for a website and I want to know if code highlighting is an actual feature it supports.

There are code blocks shown throughout the library's docs pages with highlighted code but I can't find any details about how to use it in my project.

After looking at their page's source code I tried creating the following divs which did not highlight the code:

<div class="ui segment">
  <div class="ui ignored code" data-type="bash" data-title="mands">
    #!/bin/bash

    # test
    echo 'hello there'
  </div>
</div>

Also tried including this script: http://semantic-ui./javascript/library/highlight.min.js

Am I coding it wrong or is code highlighting not even part of the library?

Share Improve this question edited Apr 16, 2016 at 4:21 aish asked Apr 14, 2016 at 16:13 aishaish 1832 silver badges12 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

As jlukic said in this post they use highlight.js library to insert code.Then you need to initialize initHighlightingOnLoad() function to use their code syntax:

hljs.initHighlightingOnLoad();
<link rel="stylesheet" href="//cdnjs.cloudflare./ajax/libs/highlight.js/9.12.0/styles/default.min.css">
<script src="https://semantic-ui./javascript/library/highlight.min.js"></script>

<div class="ui segment">

  <pre><code class="bash">

      #!/bin/bash

      # test
      echo 'hello there'
    </code></pre>
</div>

发布评论

评论列表(0)

  1. 暂无评论