Skip to content

Markdown Front Matter - #10

Merged
kampute merged 6 commits into
mainfrom
md_front_matter
Mar 21, 2026
Merged

kampute merged 6 commits into
mainfrom
md_front_matter

Conversation

@kampute

@kampute kampute commented Mar 21, 2026

Copy link
Copy Markdown
Owner

This pull request introduces support for parsing and handling YAML front matter in Markdown files, enhances Markdown heading extraction utilities, and updates the MarkdownFileTopic class to leverage these features for improved topic metadata handling.

Markdown front matter and heading extraction:

  • Added methods to Markdown (src/Support/Markdown.cs) for enumerating ATX-style headings, extracting the first heading, and parsing YAML front matter blocks from Markdown content.
  • Updated MarkdownFileTopic (src/Topics/MarkdownFileTopic.cs) to lazily parse Markdown files, extracting front matter and content separately, and expose front matter metadata via a new property. Topic title generation now prefers the "title" from front matter, falling back to the first Markdown heading, then the base logic. [1] [2] [3] [4]

Project and test updates:

  • Updated project metadata: changed the package title to Kampute.DocToolkit and bumped the version to 2.3.0 in Kampute.DocToolkit.csproj.
  • Removed the obsolete MarkdownHelperTests test class, which is now outdated due to the refactorings and new Markdown logic.

Introduced a new YAML parser in Yaml.cs supporting string keys, scalars, sequences, nested mappings, and block scalars, with robust error handling for malformed input. Added YamlTests.cs with extensive NUnit tests covering empty cases, key-value pairs, null/boolean/numeric values, quoted strings, comments, nested structures, sequences, block scalars, structural errors, and edge cases.
Implemented a simple YAML parser in Yaml.cs supporting string keys, scalars, sequences, nested mappings, and block scalars for basic metadata scenarios. Added YamlTests.cs with extensive NUnit tests covering parsing, edge cases, and error handling. Both files include MIT license headers. Advanced YAML features are not supported.
Added methods to enumerate ATX headings, extract the first heading, and parse YAML front matter blocks in the Markdown class. Replaced MarkdownHelperTests with a new MarkdownTests suite covering encoding/decoding, heading detection, and front matter extraction, including edge cases and error handling.
Add parsing and exposure of YAML front matter metadata in MarkdownFileTopic. Title extraction now prioritizes the "title" field in front matter before falling back to Markdown headings or default logic. Content readers now exclude front matter. Includes new tests for front matter title handling.
Correct project title in .csproj from "Kampute.DocDotLib" to "Kampute.DocToolkit" to reflect the actual project name. Increment version from 2.2.1 to 2.3.0 for the new release.
@kampute
kampute merged commit efa299b into main Mar 21, 2026
1 check passed
@kampute
kampute deleted the md_front_matter branch March 21, 2026 13:19
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.

2 participants