やってみる

アウトプットすべく己を導くためのブログ。その試行錯誤すらたれ流す。

pulldown-cmarkをビルドした(rust製markdownパーサ)

 rust製なので高速。

手順

wget https://github.com/raphlinus/pulldown-cmark/archive/v0.8.0.zip
unzip v0.8.0.zip
cd pulldown-cmark-0.8.0
cargo build --release

cd target/release
./pulldown-cmark --help
echo '# タイトル' | ./pulldown-cmark
echo -e '- [ ] 未完了\n- [x] 完了した' | ./pulldown-cmark -L
echo -e '名前|性別\n----|----\n山田|男\n鈴木|女\n' | ./pulldown-cmark -T
echo '~~これは間違ったテキストでした~~' | ./pulldown-cmark -S
echo '[^privacy]: There are some privacy concerns.' | ./pulldown-cmark -F

ヘルプ

Usage: pulldown-cmark [options]

Reads markdown from standard input and emits HTML.

Options:
    -h, --help          this help message
    -d, --dry-run       dry run, produce no output
    -e, --events        print event sequence instead of rendering
    -T, --enable-tables 
                        enable GitHub-style tables
    -F, --enable-footnotes 
                        enable Hoedown-style footnotes
    -S, --enable-strikethrough 
                        enable GitHub-style strikethrough
    -L, --enable-tasklists 
                        enable GitHub-style task lists

使ってみた

echo '# タイトル' | ./pulldown-cmark
<h1>タイトル</h1>

github tasklist

echo -e '- [ ] 未完了\n- [x] 完了した' | ./pulldown-cmark -L
<ul>
<li><input disabled="" type="checkbox"/>
未完了</li>
<li><input disabled="" type="checkbox" checked=""/>
完了した</li>
</ul>

github table

echo -e '名前|性別\n----|----\n山田|男\n鈴木|女\n' | ./pulldown-cmark -T
<table><thead><tr><th>名前</th><th>性別</th></tr></thead><tbody>
<tr><td>山田</td><td></td></tr>
<tr><td>鈴木</td><td></td></tr>
</tbody></table>

github strikethrough

echo '~~これは間違ったテキストでした~~' | ./pulldown-cmark -S
<p><del>これは間違ったテキストでした</del></p>

Hoedown footnotes

echo '[^privacy]: There are some privacy concerns.' | ./pulldown-cmark -F
<div class="footnote-definition" id="privacy"><sup class="footnote-definition-label">1</sup>
<p>There are some privacy concerns.</p>
</div>