次のorg-modeを例とし、このファイルをHTMLに変換する。
test.org
#+TITLE : テスト用ページ
#+DATE : 2022-01-21T11:11:06+0900
#+TAGS[]: comment
* one
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
- ul item
- ul item
- ul item
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
1. ol item
FFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFF
GGGGGGGGGGGGGGGGGGGGGGGGGGGG
GGGGGGGGGGGGGGGGGGGGGGGGGGGG
2. ol item
3. ol item
4. ol item
** two
BBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBB
*** three
**** four
***** five
****** six
******* seven
******** eight
********* nine
********** ten
*** three
**** four
***** five
****** six
******* seven
******** eight
********* nine
********** ten
HTMLを出力するには go-org render
を使う。
第一引数には render
を指定する。
第二引数にはorg-modeのファイルパスを指定する。
第三引数には出力フォーマットを指定する。
出力フォーマットにはorg, html, html-chromaのいずれかを指定する。
go-org render test.org html
<h1 class="title"><p>テスト用ページ</p>
</h1>
<nav>
<ul>
<li><a href="#headline-1">one</a>
<ul>
<li><a href="#headline-2">two</a>
<ul>
<li><a href="#headline-3">three</a>
<ul>
<li><a href="#headline-4">four</a>
<ul>
<li><a href="#headline-5">five</a>
<ul>
<li><a href="#headline-6">six</a>
<ul>
<li><a href="#headline-7">seven</a>
<ul>
<li><a href="#headline-8">eight</a>
<ul>
<li><a href="#headline-9">nine</a>
<ul>
<li><a href="#headline-10">ten</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li><a href="#headline-11">three</a>
<ul>
<li><a href="#headline-12">four</a>
<ul>
<li><a href="#headline-13">five</a>
<ul>
<li><a href="#headline-14">six</a>
<ul>
<li><a href="#headline-15">seven</a>
<ul>
<li><a href="#headline-16">eight</a>
<ul>
<li><a href="#headline-17">nine</a>
<ul>
<li><a href="#headline-18">ten</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</nav>
<div id="outline-container-headline-1" class="outline-2">
<h2 id="headline-1">
one
</h2>
<div id="outline-text-headline-1" class="outline-text-2">
<p>
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA</p>
<p>
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB</p>
<p>
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCC</p>
<ul>
<li>
<p>ul item</p>
</li>
<li>
<p>ul item</p>
</li>
<li>
<p>ul item</p>
</li>
</ul>
<p>DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD</p>
<ol>
<li>
<p>ol item</p>
<p>
FFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFF</p>
<p>
GGGGGGGGGGGGGGGGGGGGGGGGGGGG
GGGGGGGGGGGGGGGGGGGGGGGGGGGG</p>
</li>
<li>
<p>ol item</p>
</li>
<li>
<p>ol item</p>
</li>
<li>
<p>ol item</p>
</li>
</ol>
<div id="outline-container-headline-2" class="outline-3">
<h3 id="headline-2">
two
</h3>
<div id="outline-text-headline-2" class="outline-text-3">
<p>
BBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBB</p>
<div id="outline-container-headline-3" class="outline-4">
<h4 id="headline-3">
three
</h4>
<div id="outline-text-headline-3" class="outline-text-4">
<div id="outline-container-headline-4" class="outline-5">
<h5 id="headline-4">
four
</h5>
<div id="outline-text-headline-4" class="outline-text-5">
<div id="outline-container-headline-5" class="outline-6">
<h6 id="headline-5">
five
</h6>
<div id="outline-text-headline-5" class="outline-text-6">
<div id="outline-container-headline-6" class="outline-7">
<h7 id="headline-6">
six
</h7>
<div id="outline-text-headline-6" class="outline-text-7">
<div id="outline-container-headline-7" class="outline-8">
<h8 id="headline-7">
seven
</h8>
<div id="outline-text-headline-7" class="outline-text-8">
<div id="outline-container-headline-8" class="outline-9">
<h9 id="headline-8">
eight
</h9>
<div id="outline-text-headline-8" class="outline-text-9">
<div id="outline-container-headline-9" class="outline-10">
<h10 id="headline-9">
nine
</h10>
<div id="outline-text-headline-9" class="outline-text-10">
<div id="outline-container-headline-10" class="outline-11">
<h11 id="headline-10">
ten
</h11>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="outline-container-headline-11" class="outline-4">
<h4 id="headline-11">
three
</h4>
<div id="outline-text-headline-11" class="outline-text-4">
<div id="outline-container-headline-12" class="outline-5">
<h5 id="headline-12">
four
</h5>
<div id="outline-text-headline-12" class="outline-text-5">
<div id="outline-container-headline-13" class="outline-6">
<h6 id="headline-13">
five
</h6>
<div id="outline-text-headline-13" class="outline-text-6">
<div id="outline-container-headline-14" class="outline-7">
<h7 id="headline-14">
six
</h7>
<div id="outline-text-headline-14" class="outline-text-7">
<div id="outline-container-headline-15" class="outline-8">
<h8 id="headline-15">
seven
</h8>
<div id="outline-text-headline-15" class="outline-text-8">
<div id="outline-container-headline-16" class="outline-9">
<h9 id="headline-16">
eight
</h9>
<div id="outline-text-headline-16" class="outline-text-9">
<div id="outline-container-headline-17" class="outline-10">
<h10 id="headline-17">
nine
</h10>
<div id="outline-text-headline-17" class="outline-text-10">
<div id="outline-container-headline-18" class="outline-11">
<h11 id="headline-18">
ten
</h11>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
go-orgを用いてHTMLを出力する例