Skip to content

TitlePromoter transformer #10

Description

@roxspring

Implement a transformer that promotes the title: front matter field to an H1 heading.

Scope

  • If the document has front matter with a title: field, and the document body does not already begin with an H1 heading, prepend # <title> as the first node in the document body
  • If an H1 already exists, do nothing
  • If there is no title: in front matter, do nothing

Use case

Source Markdown files often omit the H1 because a CMS or site generator renders it from front matter. Downstream tools (e.g. Pandoc for PDF generation) need an explicit heading in the document body.

Acceptance criteria

  • Document with title: Foo and no H1 → H1 "Foo" prepended
  • Document with title: Foo and existing H1 → unchanged
  • Document with no front matter → unchanged
  • Document with front matter but no title: → unchanged

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions