HtmlFormatterのlineseparatorオプションの例
初回公開:2018/10/14
最終更新:未
サンプルコード
from pygments import highlight from pygments.lexers import get_lexer_by_name from pygments.formatters import HtmlFormatter code = 'print("Hello World")' lexer = get_lexer_by_name("python") with open("lineseparator.html", 'w') as outfile: highlight(code, lexer, HtmlFormatter(lineseparator="###"),outfile)
実行結果
lineseparator.html
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #008000; font-weight: bold">print</span>(<span style="color: #BA2121">"Hello World"</span>)###</pre></div>
html表示イメージ
print("Hello World")###