Skip to content

Commit

Permalink
fix: add whitespace handling for line breaks within paragraphs
Browse files Browse the repository at this point in the history
This change ensures words separated by line breaks inside a markdown paragraph retain spacing in the generated PDF output. This prevents unintended word joining.
  • Loading branch information
leonardstruck committed Oct 31, 2024
1 parent 7295674 commit a433b99
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/QuestPDF.Markdown/MarkdownRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,8 @@ private void ProcessLeafInline(LeafInline inline, TextDescriptor text)
break;
case LineBreakInline lineBreak:
// Only add a line break within a paragraph if trailing spaces or a backslash are used.
if(lineBreak.IsBackslash || lineBreak.IsHard) text.Span("\n");
if (lineBreak.IsBackslash || lineBreak.IsHard) text.Span("\n");
else text.Span(" ");
break;
case TaskList task:
text.Span(task.Checked ? _options.TaskListCheckedGlyph : _options.TaskListUncheckedGlyph)
Expand Down
Binary file modified tests/QuestPDF.Markdown.Tests/test.pdf
Binary file not shown.

0 comments on commit a433b99

Please sign in to comment.