Skip to content

feat(frontmatter): support |/> block scalars#5

Merged
frederikbeimgraben merged 1 commit into
mainfrom
feat/frontmatter-block-scalars
Jun 3, 2026
Merged

feat(frontmatter): support |/> block scalars#5
frederikbeimgraben merged 1 commit into
mainfrom
feat/frontmatter-block-scalars

Conversation

@frederikbeimgraben
Copy link
Copy Markdown
Owner

Why

The frontmatter parser turned key: | into the literal string "|" and dropped the indented continuation lines. That blocked multi-line values — notably an inline bibliography.

Change

Add YAML block-scalar support to pytex_protocol/frontmatter.py:

  • | literal (newlines preserved) and > folded (single breaks → space, blank lines → newlines).
  • Chomping: - strip, + keep, default clip (one trailing newline).
  • Common leading indentation stripped; a value that merely starts with |/> (e.g. |pipe) stays an ordinary scalar.

Existing scalar / flow-list / block-list parsing unchanged.

bibliography: |
  @book{knuth,
    author = {Knuth},
  }

"@book{knuth,\n author = {Knuth},\n}\n"

Verification

New tests for literal/folded blocks, all three chomping modes, the non-block guard, and a body-separation regression. Full suite 701 passed; ruff + mypy --strict clean.

Foundation for the upcoming inline-bibliography frontmatter feature.

🤖 Generated with Claude Code

The hand-rolled frontmatter parser only understood scalars, flow lists
and block lists; a `key: |` value became the literal string "|" and the
indented continuation lines were silently dropped. This blocked
multi-line values such as an inline bibliography.

Add YAML block-scalar support:
- `|` literal (newlines preserved) and `>` folded (single breaks -> space,
  blank lines -> newlines).
- Chomping indicators: `-` strip, `+` keep, default clip (one trailing
  newline).
- Common leading indentation is stripped; a value that merely starts with
  `|`/`>` (e.g. `|pipe`) stays an ordinary scalar.

Existing scalar/flow-list/block-list parsing is unchanged. Tests cover
literal/folded blocks, all three chomping modes, and the non-block guard.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@frederikbeimgraben frederikbeimgraben merged commit ad26dd6 into main Jun 3, 2026
1 check 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.

1 participant