Add metadata & frontmatter #15
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #14
CC @zbraniecki and @flodolo, if you've any comments
This adds syntax for
@
prefixed key-value metadata, and for---
as a separator between resource-level comments & metadata (aka the "frontmatter") and the resource body. Together, they look like this (usingini
highlighting, which mostly works):Like comments, metadata attaches to the "next thing" in the syntax. To allow for resource-level attachment, a
---
frontmatter separator is included in the syntax. This allows using the same syntax and concepts for resources as for sections and entries. As detailed in #14, it's also a common pattern used in other formats. While many other formats with frontmatter do not themselves have something like@metadata
and so need to pick a separately defined format for their frontmatter content (often YAML), e.g. YAML itself uses%directives
in its frontmatter.Metadata values use the same
value
construct as message entries, which means that they may be multiline if indented, and their inner syntax (beyond the keyword) will need to be defined separately. The@
prefix is rather intentionally chosen to allow matching Javadoc/JSDoc/TSDoc syntax, which is relatively well known.It's likely that not all consumers of a resource will care about all or any of the metadata. For example, while something like
@version
could be important to a system tracking which messages need re-translation, it probably would not have any effect during the message's formatting. On the other hand, a resource-level@locale
could end up significant for all consumers.At this level, the syntax does not differentiate between metadata fields depending on e.g. their relevance to formatting; that should be done separately. One purely mechanical way to allow for some formatting-relevant metadata would be to only support that for the frontmatter. Another alternative would be to introduce another sigil beyond the
@
to differentiate such. Or we could define an explicit list of keywords with a formatting impact.Comments or empty lines are not allowed between metadata lines and the line they're attaching to. This is intentional, and meant to ensure that they stay together.
The
id
rule needs to get narrowed a bit as a part of this change, as it can't start with---
.