Skip to content

Mid-document --- … --- is parsed as front matter and silently dropped (herdr last loses the middle of replies) #162

Closed

Description

@chieping

A --- line in the middle of a document is read as YAML front matter when the next line is not blank and another --- line comes later. Everything between the two lines is dropped from the document view. Agent replies often use --- as a section break, so herdr last loses the middle of the reply without any sign that something is missing.

Claude Code and other Markdown previews show the full text.

Repro

plannotator-tui midrule-repro.md with:

# Title

Intro paragraph.

---
**Draft**

This paragraph is not shown.

- neither is this list

---

Closing paragraph.

The view shows "Title", "Intro paragraph." and "Closing paragraph.". Everything from **Draft** to the second --- is missing. If you add a blank line after the first ---, the full document is shown.

Cause

parse_options() in crates/plannotator-tui/src/doc.rs enables Options::ENABLE_YAML_STYLE_METADATA_BLOCKS, and split_blocks drops BlockKind::Metadata. pulldown-cmark 0.13 does not check that a metadata block is at the start of the document. It accepts one at any unindented line where:

  • the line is ---,
  • the next line is not blank,
  • a closing --- (or ...) line comes later.

See scan_metadata_block in scanners.rs and its call site in firstpass.rs.

Possible fix

Treat a metadata block as front matter only when it starts at byte 0 (or after leading blank lines). Two ways to do that:

  • Enable the option only when the source starts with ---.
  • Keep a Metadata block only when its range starts at 0, and otherwise re-parse that range as ordinary Markdown with the option off.

parse_options() is also used in cjk_emphasis.rs and decorate/syntax.rs, so it is probably simplest to make the change where the options are built.

Env

  • plannotator-tui: 0.10.0 (via herdr-annotate, annotate.last)
  • Agent: Claude Code
  • OS: macOS

Activity

  1. added a commit that references this issue on Nov 20, 2026
    9270322
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions