Colors of C++ code blocks all turn into grey when exported to PDF 导出为PDF时C++代码块全部变成灰色

In English:
The C++ code has proper colors viewed in Obsidian, yet when I export it to PDF all colors turned grey. I’ve tried some plugins like pandoc when exporting yet they all lead to the same result. Plus, the colors also turn grey when exported to HTML or .doc through pandoc.
Screenshot in Obsidian:


And what it looks like in exported PDF:

In Chinese if there’s someone to help me:
C++代码块在Obsidian中是彩色的,但是导出为PDF后全部变成了灰色。试着使用了诸如Pandoc的第三方插件也没有用,并且Pandoc导出的HTML和.doc中代码都是灰色的。上面分别是在Obsidian和导出的PDF中的截图。
本人初学C++,代码写得很烂,勿cue。

What viewing mode are you in where you see the colors? Live Preview? If so, switch to Reading view. That will most closely match the PDF export.

You could try

```cpp

```

for your code block language instead of c++.

https://help.obsidian.md/Editing+and+formatting/Basic+formatting+syntax#Code+blocks

https://prismjs.com/#supported-languages

Problem’s been solved. Thank you!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.