Markdownãã¡ã¤ã«ãPandocã§HTMLåããéãã©ã®ãããªæå®ãè¯ãããè¿·ã£ã¦ããã®ã§ããããã¾ã®ã¨ãã以ä¸ã®ãããªãªãã·ã§ã³ã§è½ã¡çãã¾ããã
$ pandoc \ --standalone \ --self-contained \ --resource-path=/path/to \ --toc \ --toc-depth 2 \ --shift-heading-level-by=-1 \ --metadata title='ã¿ã¤ãã«' \ --template=html_templates/bootstrap_menu.html \ --fail-if-warnings \ --output=${destdir}/guide.html \ /path/to/target.md
HTMLãã³ãã¬ã¼ã
Pandocã§ã¯ãåºåãã©ã¼ãããã«å¿ãããã³ãã¬ã¼ããå
å
ãã¦ãã¾ãã
ããã©ã«ãã®ãã³ãã¬ã¼ãã¯pandoc -D 'html'
ã§ç¢ºèªã§ãã¾ãã
$ pandoc -D 'html' | head -5 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" lang="$lang$" xml:lang="$lang$"$if(dir)$ dir="$dir$"$endif$> <head> <meta charset="utf-8" /> <meta name="generator" content="pandoc" />
ãã³ãã¬ã¼ãã¯èªèº«ã§ãè¨è¿°å¯è½ãªã®ã§ããããªã·ã£ã¬ãªãã³ãã¬ã¼ããGitHubçã§å ¬éããã¦ãã¾ãã ä¾ãã°åã使ã£ãã®ã¯ãã¡ãã®ãã³ãã¬ã¼ãã§ãã
screenshotãã©ã«ããè¦ãã°ãåºåãããHTMLãç解ã§ããã§ãããã
ã¼ãã¯ãã³ãã¬ã¼ãã¨ãã¦bootstrap_menu.html
ãå©ç¨ãã¾ããã
以ä¸ã®ããã«ããã¼ã«ã«ã«ãã³ãã¬ã¼ãããã¦ã³ãã¼ããã¦ãpandocã®`--template=ã§æå®ããã°è¯ãã§ãã
$ curl 'https://raw.githubusercontent.com/ryangrose/easy-pandoc-templates/master/html/bootstrap_menu.html' > html_templates/bootstrap_menu.html
Table of Contents(TOC)ã®ä½æ
ä¸è¨ã®ãã³ãã¬ã¼ãã¯ãµã¤ããã¼ã«ç´¢å¼ã表示ãã¦ããã¾ããããã®ç´¢å¼ãçæããã®ã--toc
ãªãã·ã§ã³ã§ãã
ä¸æ¹ã§ãMarkdownã§ã¯ãããã¬ãã«ã®#
ããã¼ã¸ã®ã¿ã¤ãã«ãæ§æãããã¨ãå¤ãããããç´¢å¼ã«è¡¨ç¤ºããããªãã±ã¼ã¹ãããã¾ãã
ãã®ãããªã±ã¼ã¹ã§ã¯--shift-heading-level-by
ãªãã·ã§ã³ãå©ç¨ãã¾ããããããã¯ç´¢å¼ã«è¡¨ç¤ºããã¬ãã«ãããããããã¨ãã§ãããªãã·ã§ã³ã§ããä¾ãã°-1
ãæå®ããã¨ã#
ã¯ç´¢å¼ã«è¡¨ç¤ºãããªããªãã¾ãã
ã©ãã¾ã§ãç´¢å¼ã«è¡¨ç¤ºãããã¯ã--toc-depth
ã§æå®ãã¾ãã
ä¾ãã°pandoc --toc --toc-depth=2 --shift-heading-level-by=-1
ã¨æå®ããå ´åãèãã¾ãã
ãã®å ´åãMarkdownä¸ã®# header
ã¯ç´¢å¼ãé¤å»ããã## header
ã¨### header
ã¯ç´¢å¼ã«è¡¨ç¤ºããã¾ãã
ç»åãã¡ã¤ã«ã®å梱
HTMLãã¡ã¤ã«ãçæãã¦ããç»åãã¡ã¤ã«ãå梱ããªããã°HTMLããåç §ã§ãã¾ãããä¸è¬çã«ã¯ã
Pandocã®ãããã¨ããã¯ããã§ã--self-contained
ãªãã·ã§ã³ã使ç¨ããã¨ãç»åãåç»ã«é¢ãã¦ã¯data:
ã¹ãã¼ã ã«ç½®ãæãã¦ããã¾ããã¤ã¾ããç»åãåç»ããã¡ã¤ã«ã¨ãã¦ä¸ç·ã«é
å¸ãããã¨ãªããHTMLãã¡ã¤ã«1æãé
å¸ããã ãã§ãã¿ã¾ãã便å©ã
ãã¡ãããã©ãã«ç»åãåç»ãé
ç½®ããã¦ããããæå®ãã--resource-path
ãå¿ããã«ã