Skip to content

fix(converters): stop blog footer turning the last body line into a heading#75

Merged
thepushkaraj merged 1 commit into
dodopayments:mainfrom
abhay-codes07:fix/blog-converter-setext-heading
Jul 19, 2026
Merged

fix(converters): stop blog footer turning the last body line into a heading#75
thepushkaraj merged 1 commit into
dodopayments:mainfrom
abhay-codes07:fix/blog-converter-setext-heading

Conversation

@abhay-codes07

Copy link
Copy Markdown
Contributor

Summary

The blog converter joined its footer onto the body with no blank line, so the output ended with last body line\n---. CommonMark reads that as a setext H2, so the final line of every blog post body was rendered as a heading and the horizontal rule before the footer links vanished. This adds the missing blank line.

Closes #74.

Changes

  • packages/converters/src/blog.ts: separate the body from the footer with a blank line so the trailing --- is a thematic break, not a setext underline.
  • Added a regression test asserting the last body line is followed by a blank line and ---, and is not glued directly to ---.

Type

  • Bug fix (non-breaking)
  • New feature (non-breaking)
  • Breaking change
  • Spec change (requires bump in AEO_SPEC_VERSION)
  • Docs / examples / tooling only

Verification

  • bun run build passes
  • bun run test passes (converters: 39 tests)
  • bun run typecheck passes
  • If touching examples: ran dualmark verify (no examples touched)
  • If touching /spec/: ran sync-spec (no spec files touched)

Changeset

  • Added a changeset (patch for @dualmark/converters)

cc @thepushkaraj @aagarwal1012. Small one, but it affects the rendered markdown of every blog post that has a body.

…eading

The footer was concatenated onto the body with no blank line, so output
ended with 'last body line\n---'. CommonMark parses text immediately
followed by '---' as a setext H2, so the final line of every blog post
body became a heading and the intended horizontal rule was dropped. Add a
blank line between the body and the footer so '---' is a thematic break.
Copilot AI review requested due to automatic review settings July 1, 2026 02:15
@vercel

vercel Bot commented Jul 1, 2026

Copy link
Copy Markdown

@abhay-codes07 is attempting to deploy a commit to the Dodo Payments Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a CommonMark rendering bug in the blog markdown converter where the footer’s --- could be parsed as a setext heading underline for the final body line, causing the rule to disappear and the last line to render as an H2.

Changes:

  • Insert an extra newline between the blog post body and the footer so the footer’s --- is parsed as a thematic break, not a setext underline.
  • Add a regression test to ensure the output contains last body line\n\n--- (and not last body line\n---).
  • Add a changeset for a patch release of @dualmark/converters.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/converters/src/blog.ts Adds a separating newline between body and footer to prevent setext heading parsing.
packages/converters/test/converters.test.ts Adds a regression test asserting the body/footer separation behavior.
.changeset/blog-converter-setext-heading.md Records the bug fix as a patch changeset for release notes/versioning.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +55 to +57
// Separate the body from the footer with a blank line. `base` ends with the
// body's last line (no trailing newline) and `footer` starts with "---";
// without the blank line CommonMark parses "lastline\n---" as a setext H2,

@dodo-squirrels dodo-squirrels Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: fix(converters): stop blog footer turning the last body line into a heading

Verdict: LGTM — approving.

Reviewed end-to-end and verified with a real CommonMark parser.

Root cause (confirmed on main)

The blog converter concatenated the footer directly onto the body:

return normalizeUnicode(base + footer.join("\n"));

base ends with the body's last line (cleanBody trims trailing whitespace) and footer starts with "\n---", so the output contained last body line\n---. Per CommonMark, a line of text immediately followed by --- is a setext H2, not a paragraph + thematic break.

User-facing impact (verified with marked)

I rendered both variants through a real CommonMark parser:

main  →  "Final body line.\n---"     ⇒  <h2>Final body line.</h2>   (rule swallowed!)
fix   →  "Final body line.\n\n---"    ⇒  <p>Final body line.</p><hr>

So on main, every blog post's final body line was silently promoted to a heading and the intended --- divider before the footer links vanished. This directly corrupts the markdown twin that AI clients read. The fix (inserting a blank line) resolves both symptoms.

Fix verification

Exercised blogConverter on the branch — output tail is now ... "Final body line.", "", "---", "- [More … articles]" ..., i.e. Final body line.\n\n---. The added test asserts both the presence of \n\n--- and the absence of the bad \n---\n sequence.

Tests

  • @dualmark/converters: 39/39 pass locally.

Minimal, correct, well-commented, changeset present. No concerns.

@thepushkaraj thepushkaraj left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @abhay-codes07!

@thepushkaraj
thepushkaraj merged commit 8611bed into dodopayments:main Jul 19, 2026
20 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

blog converter turns the last body line into a heading (setext H2)

3 participants