[Tex/LaTex] pandoc does not recognize Chinese characters

bashcjkpandocxetex

I want to compile, with pandoc, a Markdown document containing CJK elements (Chinese, actually).
It was stated there that --latex-engine=xelatex option allows pandoc to compile Unicode characters.

However, I tried
cjk.md:

Hello
你好

compiled with (in bash)

pandoc -s -o cjk.pdf --latex-engine=xelatex cjk.md

But the resulting .pdf has Hello shown only, while 你好 is not shown.
Have I missed something?

(Yesterday I asked this in Stack overflow, but no one paid attention to me…. and people there are scary to me ><" )

background: I plan to ask quite many question in Math SE, and want to minimize the trouble converting them to another file convenient to compile on local.
Mandarin is my native, I sometimes desire to add comments in Chinese (for my own reference only).
If I cannot find a easy way to compile, on local, markdown documents embedded with LaTeX and strewn with few Chinese words, my motivation to do all these would be discouraged.

Best Answer

The conversion to PDF uses LaTex as the backend. You will need to specify a suitable mainfont with chinese glyphs. You can do this by putting the following section at the top of your .md document, e.g.

---
mainfont: Noto Sans Mono CJK TC
---

Then compile with the --latex-engine=xelatex switch and you should have your desired output. Note: run fc-list from a terminal to see which CJK fonts are installed.