Stirling-Tools/Stirling-PDF

[Feature Request]: Markdown to PDf for code blocks

Open

#4,022 opened on 2025年7月22日

GitHub で見る
 (1 comment) (2 reactions) (1 assignee)TypeScript (6,899 forks)batch import
enhancementhacktoberfest

Repository metrics

Stars
 (78,754 stars)
PR merge metrics
 (平均マージ 3d 21h) (30d で 209 merged PRs)

説明

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.

コントリビューターガイド