Unicode 带有表情符号和象形文字的Pandoc
有没有办法从包含unicode、表情符号和象形文字的标记文件中获取PDF 我正在运行此测试:Unicode 带有表情符号和象形文字的Pandoc,unicode,fonts,emoji,pandoc,xelatex,Unicode,Fonts,Emoji,Pandoc,Xelatex,有没有办法从包含unicode、表情符号和象形文字的标记文件中获取PDF 我正在运行此测试: echo ':smile: → ★ A few days ago I was looking for a solution for this exact problem, but couldn't find any... so I developed my own solution: a Pandoc filter to include emojis in the generated PDF. The
echo ':smile: → ★ A few days ago I was looking for a solution for this exact problem,
but couldn't find any... so I developed my own solution:
a Pandoc filter to include emojis in the generated PDF.
There are some compromises and limitations though:
- I had to use a
template.tex
file, so if you already use a template, you'll have to merge pieces from my template with yours. That could be a real pain... but I flagged the changes that I made to the original template.tex
generated by Pandoc. At least this can help a little.
- I have no experience with
Lua
language to make a filter. So I tried Python
, and it didn't work as I expected, because I couldn't find a library to translate the unicode emoji code-points to something I could work with. Finally, I made it using Javascript
, so NodeJS
is required. Also, some NPM packages must be installed.
- I used
InkScape
to convert SVG from online sources, to PDF, so that they could be inserted into the PDF. This is necessary because LaTeX was not recognizing the SVG image format.
- At this moment, I didn't have time yet to implement an automatic install of the filter.
Checkout the Git repository, and use it from there... it's the best advice I can give. There is a an example script to convert the
readme.md
to pdf. I also committed the resulting PDF.
- I don't know if it will work with
xelatex
or lualatex
or anything othar than pdflatex
, because I only had time to test it using the default engine for Pandoc, that is pdflatex
.
Using the Emoji filter
Prerequisites: Pandoc
and NodeJS
- Checkout the repository
- Install NPM packages that are needed:
npm install
echo':微笑:→ ★ 几天前,我在为这个问题寻找解决方案,
但是找不到任何。。。因此,我开发了自己的解决方案:
a
但也存在一些折衷和限制:
- 我必须使用
template.tex
文件,因此如果您已经使用了模板,则必须将我的模板中的片段与您的合并。那可能真的很痛苦。。。但是我标记了我对Pandoc生成的原始template.tex
所做的更改。至少这有点帮助
- 我没有使用
Lua
语言制作过滤器的经验。所以我尝试了Python
,但它没有像我预期的那样工作,因为我找不到一个库来将unicode表情符号代码点翻译成我可以使用的东西。最后,我使用Javascript
,所以需要NodeJS
。此外,必须安装一些NPM软件包
- 我使用
InkScape
将SVG从在线源代码转换为PDF,这样就可以将它们插入到PDF中。这是必要的,因为LaTeX无法识别SVG图像格式
- 此时,我还没有时间实现过滤器的自动安装。
签出Git存储库,然后从那里使用它。。。这是我能给你的最好的建议。这里有一个示例脚本,用于将文件转换为pdf。我也犯了同样的错误
- 我不知道它是否能与
xelatex
或lualatex
或任何其他pdflatex
一起工作,因为我只有时间使用Pandoc的默认引擎进行测试,即pdflatex
使用表情过滤器
先决条件:Pandoc
和NodeJS
- 签出存储库
- 安装所需的NPM软件包:
pandoc --template="template.tex" -o example.pdf readme.md \
--filter=emoji_filter.js -M emoji=noto-emoji --from gfm \
-V links-as-notes=true -V colorlinks -V urlcolor=NavyBlue
- 运行Pandoc,传递过滤器、模板、正确的输入格式、表情符号源等等。以下是用于从readme.md编译example.pdf的命令:
--template=“template.tex”
指示存储库中存在的template.tex文件
-o example.pdf
表示输出文件名
readme.md
是输入文件名
--filter=emoji\u filter.js
指示表情过滤器脚本文件名
-M emoji=noto emoji
是一个元数据参数,emoji过滤器会读取该参数,以了解您需要哪种表情。目前有两个选项:noto表情符号
和twemoji
。你可以看到一个。
noto表情符号
:指
twemoji
:指
--from gfm
是输入格式,gfm表示GitHub风格的降价。我之所以使用它,是因为它可以将:\uuuu name:
格式的表情符号转换为我的过滤器可以识别的unicode代码点
- 其他参数对此答案没有意义。。。它们用于调整链接在最终PDF中的显示方式
我希望这个答案和表情过滤器会有所帮助!
任何进一步的问题,请在评论中询问。。。
也许你认为我应该发布并解释代码的某些部分。
我真的不知道哪一部分对简洁的回答有帮助
因为代码很复杂
不管怎样,请随时询问=)