差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

dokuwiki:syntax:code [2019/10/24 02:24] (目前版本)
ghsrobert 建立
行 1: 行 1:
 +====== 插入程式碼 ======
  
 +===== 內建 =====
 +    行首空兩格就會變成一個 code block
 +    保留一切空格及斷行
 +    其實這方法很簡單但常被忽略
 +
 +其次,也可以使用:
 +  <code>
 +  程式碼……
 +  </code>
 +
 +或是
 +  <file>
 +  程式碼……
 +  </file>
 +
 +----
 +如果要依程式碼的類型,來為程式碼語法著色,內建就有這功能了!!!☟
 +  <code php>
 +  <?php
 +  echo "Hello World!";
 +  ?> 
 +  </code>
 +可以變成
 +<code php>
 +<?php
 +echo "Hello World!";
 +?> 
 +</code>
 +
 +此外也有進階選項,可加上行號、螢光標示指定行數:
 +^  碼  ^  效果  ^
 +| <div>
 +  <code C [enable_line_numbers="true", start_line_numbers_at="42",highlight_lines_extra="2,4"]>
 +  void main () {
 +      printf ("Hello World!");
 +      exit 0;
 +  }
 +  </code>
 +</div> | <code C [enable_line_numbers="true", start_line_numbers_at="42",highlight_lines_extra="2,4"]>
 +void main () {
 +    printf ("Hello World!");
 +    exit 0;
 +}
 +</code> |
 +
 +----
 +參考:
 +  * [[wiki:syntax#code_blocks]]、[[wiki:syntax#syntax_highlighting]]
 +  * ++syntax_highlighting 進階選項|[[https://www.dokuwiki.org/syntax_highlighting|syntax_highlighting [DokuWiki]]] {{url>https://www.dokuwiki.org/syntax_highlighting ,700px}}++
  • 上一次變更: 2019/10/24 02:24
  • ghsrobert