Skip to content

Add support for Markdown rendering for YAML front matter#434

Open
stupar73 wants to merge 3 commits into
commonmark:mainfrom
stupar73:yaml-front-matter-markdown-render
Open

Add support for Markdown rendering for YAML front matter#434
stupar73 wants to merge 3 commits into
commonmark:mainfrom
stupar73:yaml-front-matter-markdown-render

Conversation

@stupar73
Copy link
Copy Markdown

commonmark-ext-yaml-front-matter does not currently support rendering to Markdown, this PR adds that functionality.

The below block will be rendered at the top of the markdown file (containing the actual key-value pairs):

---
# key: value pairs here
---

# Markdown content starts here

Copy link
Copy Markdown
Collaborator

@robinst robinst left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!


private boolean isFlowCollection(String value) {
return (value.startsWith("[") && value.endsWith("]"))
|| (value.startsWith("{") && value.endsWith("}"));
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.

All this special handling is a bit unfortunate, we should probably never have started trying to parse the YAML ourselves (but treat it as an opaque blob instead). See also this issue:

Having said that, it is what we currently do so what you have here LGTM.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yeah agreed, it feels a bit like it shouldn't be this libraries responsibility to handle the content of the YAML front matter.

But as you say, that's what we currently do, and I think this is an net positive from the current state.

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