2021年2月4日 星期四

code prettify 在blogger中加入code block

code prettify test
ref: https://github.com/googlearchive/code-prettify
the service side has been updated, need to change some code in 






sample coode:
<pre class="prettyprint linenums lang-sh">$ sudo apt install smbclient
$ sudo smbclient -L $IP -W $domainName -U $userName
</pre>
  • use <xmp> </xmp> to escape html code
  • lang-* is optional, may auto detect
  • linenums:x shows the line numbers, x is the starting line
class Voila {
public:
  // Voila
  static const string VOILA = "Voila";

  // will not interfere with embedded tags.
}
by <pre> ...</pre>
int main()
{
    int a = 0;
    return 0;
} 
by <code> .... </code>
int main()
{
    int a = 0;
    return 0;
}

用法
<pre class="prettyprint lang-cpp linenums">...</pre>
<code class="prettyprint">...</code>
用 <pre> 在html中直接換行輸出的結果就會有換行的效果,在<code>中則需要用<br />之類的方式換行
如果再compose mode中打好了code, 可以切到HTMLmode後直接加上 <code></code>較容易

支援的語言
lang-*: "bsh", "c", "cc", "cpp", "cs", "csh", "cyc", "cv", "htm", "html", "java","js", "m", "mxml", "perl", "pl", "pm", "py", "rb", "sh", "xhtml", "xml","xsl".

1 則留言: