日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

pandoc讲html转换为pdf,mac下利用Pandoc、LaTeX 转换markdown成html,pdf

發布時間:2023/12/3 编程问答 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 pandoc讲html转换为pdf,mac下利用Pandoc、LaTeX 转换markdown成html,pdf 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

環境所使用的插件有pandoc,tlmgr,fc-listcss

brew?install?pandoc

由于mac ox 系統生成pdf 須要找到對應的編碼集 全部還須要去下載LaTeX,進行安裝html5

使用tlmgr工具安裝全部要的包先進行更新,若是提示所須要的字體沒有找到安裝git

sudo?tlmgr?update?--self

tlmgr?install?collection-fontsrecommended

安裝fontconfig使用fc-list查看mac中可用的中文集,由于os x 10.8之后已經不安裝x11

github

brew?install?fontconfig

fc-list?:lang=zh-cn

字符集放在/Library/Fonts 下面已宋體為例?web

/Library/Fonts/Songti.ttc: 宋體\-簡,宋體\-簡,Songti SC:style=粗體,粗體,Boldshell

pandoc?--latex-engine=xelatex?-V?mainfont='

Songti?SC

'?--template=./pandoc.template?xxx.md?-o?xxx.pdf

下面是markdown轉換的工具

ruby

安裝makemarkdown

建立shell文件名為md2pdf,能夠指定使用字體集app

#!/bin/sh

#?Wrapper?script?around?pandoc?/?markdown2pdf

#?Provides?templates?to?apply?with?pdf?processing

#?Copyright?Claes?Holmerson?2010,?GPL?licensed?(see?COPYING?for?details)

#Find?this?directory

#?template_home=$(dirname?$(readlink?-f?$0))

template_home=$(cd?`dirname?$0`;?pwd)

paper=a4paper

hmargin=3cm

vmargin=3.5cm

fontsize=12pt

#fontsize=11pt

#fontsize=12pt

#?mainfont=SimSun

#?sansfont=Corbel

#?monofont=Consolas

#?mainfont="WenQuanYi?Zen?Hei?Sharp"

#?sansfont="WenQuanYi?Zen?Hei?Sharp"

#?monofont="WenQuanYi?Zen?Hei?Mono"

language=english

#language=swedish

nohyphenation=false

columns=onecolumn

#columns=twocolumn

geometry=portrait

#geometry=landscape

alignment=flushleft

#alignment=flushright

#alignment=center

toc=3

pandoc?--latex-engine=xelatex?--template=$template_home/pandoc.template?\

-V?language=$language?-V?paper=$paper?-V?hmargin=$hmargin?-V?vmargin=$vmargin?\

-V?mainfont="$mainfont"?-V?sansfont="$sansfont"?-V?monofont="$monofont"?\

-V?geometry=$geometry?-V?alignment=$alignment?-V?columns=$columns?\

-V?fontsize=$fontsize?-V?nohyphenation=$nohyphenation?\

-V?toc=$toc?\

$@

建立markdown.css

@font-face?{

font-family:?"AR?PL?New?Sung";

src:?url("/usr/share/fonts/TTF/odosung.ttc");

}

body?{

background-color:?#fcfcfc;

color:?#3c3c3c;

}

a?{

color:?#308bd8;

text-decoration:none;

}

a:hover?{

text-decoration:?underline;

}

p?{

margin:0?0?24px?0;

}

p:last-child?{

margin:0;

}

hr?{

width:?100%;

margin:?1em?auto;

border:?0;

color:?#eee;

background-color:?#ccc;

height:?1px;

-webkit-box-shadow:0px?1px?0px?rgba(255,?255,?255,?0.75);

}

blockquote?{

margin-left:?0;

margin-right:?auto;

width:?96%;

padding:?10px?10px;

border-left:?3px?solid?#ddd;

color:?#777;

background-color:?#f2f2f2;

}

table?{

margin-left:?0;

margin-right:?auto;

margin-bottom:?24px;

border-bottom:?1px?solid?#ddd;

border-right:?1px?solid?#ddd;

border-spacing:?0;

}

table?th?{

padding:?3px?10px;

background-color:?#eee;

border-top:?1px?solid?#ddd;

border-left:?1px?solid?#ddd;

}

table?tr?{

}

table?td?{

padding:?3px?10px;

border-top:?1px?solid?#ddd;

border-left:?1px?solid?#ddd;

}

caption?{

font-size:?1.2em;

font-weight:?bold;

margin-bottom:?5px;

}

@page?{

size:?A4;

margin:?1cm?auto;

}

@media?print?{

body?{

font-family:?"Arial?Black",?Arial,?sans-serif;

-webkit-print-color-adjust:?exact;

}

img,?pre,?blockquote,?table,?figure?{

page-break-inside:?avoid;

}

.footnotes?{

page-break-before:?always;

}

header.onlyprint,?footer.onlyprint{

display:?none;

}

}

/*?fix?pandoc?default?style?*/

code?{

}

code?>?span.dt?{

text-decoration:?none;

}

建立Makefile文件內容以下,若是你markdown 是分文件模塊進行編譯的能夠使用cat進行合并 分別生成html,pdf

main?:

#?cat?00*.md?>?xxx.md

pandoc?-f?markdown_github-autolink_bare_uris?-s?--highlight-style?espresso?-t?html5?-c?"./markdown.css"?-o?xxx.html?xxx.md

#?cat?00*.md?>?xxx.md

./md2pdf?xxx.md?-o?xxx.pdf

生成pdf

./md2pdf?xxx.md?-o?xxx.pdf

生成html 和pdf

make

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的pandoc讲html转换为pdf,mac下利用Pandoc、LaTeX 转换markdown成html,pdf的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。