[Feature Request]: Markdown to PDf for code blocks
#4,022 创建于 2025年7月22日
仓库指标
- Star
- (78,754 star)
- PR 合并指标
- (平均合并 3天 21小时) (30 天内合并 209 个 PR)
描述
Feature Description
First of all, thank you for the amazing projects and loads of features for PDFs. Its amazing how these features are all open sourced and works llke a charm.
I would like to request a feature to format the code blocks properly. Also, aplogoies if this issue already exists or in the roadmap but I cannot find it anywhere mentioned.
Basically, when I have a code block in my MD file added into three backticks, I can read the MD file in my editors and preview is fine but when I use Markdown to PDF, everything works as expected but the code bloks new lines are removed and becomes a paragraph.
Here is the MD sample:
Test 1
This is a paragraph
Test 2
This is a second paragraph under two hash
Test 3
This is last paragraph to test code block
<script>
console.log("Page is loaded");
alert("Welcome to my world!");
<script>
And please find the PDF attachment from the program. test.pdf
Why is this feature valuable?
To be able to format the code block with new lines properly to read the codeblocks in PDF.
Suggested Implementation
Not too sure about this and how complicated it might be under the hood, basic requirement will be parsing the "\n" or converting it into <br> html tag if what its used.
It might be too much but if possible, may be colorized the code block too like JS library Highlight.js does.
Additional Information
No response
No Duplicate of the Feature
- I have verified that there are no existing features requests similar to my request.