From 1afe595890b709d39a6fa23074756916b2604f57 Mon Sep 17 00:00:00 2001 From: Adam Israel Date: Tue, 24 Mar 2026 16:01:21 -0400 Subject: [PATCH 1/2] feat: Add support for blockquotes Fixes issue #16 - adds support for blockquotes formatted per Shunn's recommendation. --- src/markdown.rs | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/markdown.rs b/src/markdown.rs index 22fc929..5bae17e 100644 --- a/src/markdown.rs +++ b/src/markdown.rs @@ -45,6 +45,8 @@ fn content_to_paragraphs(mut content: String) -> Vec { .line_spacing(LineSpacing::new().after_lines(100)); if content.lines().count() > 0 { + let mut blockquote = false; + content.lines().for_each(|line| { // If the line is empty, skip it. We'll handle line spacing elsewhere. if !line.trim().is_empty() { @@ -53,7 +55,48 @@ fn content_to_paragraphs(mut content: String) -> Vec { // This will add the separator for single Markdown documents that explicitly // include the separator, like the `standalone.md` example. paragraphs.push(sep.clone()); + } else if line.starts_with(">") { + // This is a blockquote, so it needs to be handled correctly: + // a centered # before and after the text, and the blockquote should + // be indented "one half-inch from the left margin" + // https://www.shunn.net/format/2010/09/long_quotations_within_your_te.html + + // The first time we encounter a blockquote, inject a centered # before it + if !blockquote { + let sep = Paragraph::new() + .add_run(Run::new().add_text("#")) + .align(AlignmentType::Center) + .size(constants::FONT_SIZE) + .line_spacing(LineSpacing::new().after_lines(100)); + paragraphs.push(sep); + } + blockquote = true; + + let runs = parse_paragraph(line); + + let mut p = Paragraph::new() + .align(AlignmentType::Center) + .line_spacing( + LineSpacing::new() + .line_rule(LineSpacingType::Auto) + .line(480), // double spaced + ) + .indent(Some(357), Some(SpecialIndentType::FirstLine(357)), None, None); + for run in runs { + p = p.add_run(run).align(AlignmentType::Left); + } + paragraphs.push(p); } else { + // Inject a closing centered # after the blockquote + if blockquote { + let sep = Paragraph::new() + .add_run(Run::new().add_text("#")) + .align(AlignmentType::Center) + .size(constants::FONT_SIZE) + .line_spacing(LineSpacing::new().after_lines(100)); + paragraphs.push(sep); + blockquote = false; + } // Parse the paragraph into runs, which will handle simple formatting. let runs = parse_paragraph(line); From 1172633bab4f3e62ecae501691a2585bf85b8baf Mon Sep 17 00:00:00 2001 From: Adam Israel Date: Tue, 24 Mar 2026 16:04:23 -0400 Subject: [PATCH 2/2] rustfmt --- src/markdown.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/markdown.rs b/src/markdown.rs index 5bae17e..2871922 100644 --- a/src/markdown.rs +++ b/src/markdown.rs @@ -81,7 +81,12 @@ fn content_to_paragraphs(mut content: String) -> Vec { .line_rule(LineSpacingType::Auto) .line(480), // double spaced ) - .indent(Some(357), Some(SpecialIndentType::FirstLine(357)), None, None); + .indent( + Some(357), + Some(SpecialIndentType::FirstLine(357)), + None, + None, + ); for run in runs { p = p.add_run(run).align(AlignmentType::Left); }