-
Notifications
You must be signed in to change notification settings - Fork 579
Add frontmatter #2197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
traviscross
wants to merge
12
commits into
master
Choose a base branch
from
TC/frontmatter
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+110
−2
Open
Add frontmatter #2197
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
fafe84b
docs(ref): Specify frontmatter
epage 5f5eff9
Revise frontmatter grammar; add ⊥ rule
traviscross a60ca22
Clarify the fence description
traviscross 0840484
Revise the infostring description
traviscross 69f90af
Clarify the body restrictions
traviscross 87d5914
Link horizontal whitespace to the grammar rule
traviscross d978d31
Flesh out the frontmatter removal section
traviscross 432b613
Clarify frontmatter position rule
traviscross 5d79ac6
Revise frontmatter intro example
traviscross 39faf0a
Rewrite frontmatter intro sentence
traviscross a0727c5
Note the UAX 31 provenance of `HORIZONTAL_WHITESPACE`
traviscross 526c143
Move frontmatter intro and example ahead of grammar
traviscross File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| r[frontmatter] | ||
| # Frontmatter | ||
|
|
||
| r[frontmatter.intro] | ||
| Frontmatter is an optional section of metadata whose syntax allows external tools to read it without parsing Rust. | ||
|
|
||
| > [!EXAMPLE] | ||
| > <!-- ignore: test runner doesn't support frontmatter --> | ||
| > ```rust,ignore | ||
| > #!/bin/env cargo | ||
| > --- cargo | ||
| > package.edition = "2024" | ||
| > --- | ||
| > | ||
| > fn main() {} | ||
| > ``` | ||
| r[frontmatter.syntax] | ||
| ```grammar,lexer | ||
| @root FRONTMATTER -> | ||
| WHITESPACE_ONLY_LINE* | ||
| !FRONTMATTER_INVALID | ||
| FRONTMATTER_MAIN | ||
| WHITESPACE_ONLY_LINE -> (!LF WHITESPACE)* LF | ||
| FRONTMATTER_INVALID -> (!LF WHITESPACE)+ `---` ^ ⊥ | ||
| FRONTMATTER_MAIN -> | ||
| `-`{n:3..=255} ^ FRONTMATTER_REST | ||
| FRONTMATTER_REST -> | ||
| FRONTMATTER_FENCE_START | ||
| FRONTMATTER_LINE* | ||
| FRONTMATTER_FENCE_END | ||
| FRONTMATTER_FENCE_START -> | ||
| MAYBE_INFOSTRING_OR_WS LF | ||
| FRONTMATTER_FENCE_END -> | ||
| `-`{n} HORIZONTAL_WHITESPACE* ( LF | EOF ) | ||
| FRONTMATTER_LINE -> !`-`{n} ~[LF CR]* LF | ||
| MAYBE_INFOSTRING_OR_WS -> | ||
| HORIZONTAL_WHITESPACE* INFOSTRING? HORIZONTAL_WHITESPACE* | ||
| INFOSTRING -> (XID_Start | `_`) ( XID_Continue | `-` | `.` )* | ||
| ``` | ||
| r[frontmatter.position] | ||
| Frontmatter may appear at the start of the file (after the optional [byte order mark]) or after a [shebang]. In either case, it may be preceded by [whitespace]. | ||
|
|
||
| r[frontmatter.fence] | ||
| Frontmatter must start and end with a *fence*. Each fence must start at the beginning of a line. The opening fence must consist of at least 3 and no more than 255 hyphens (`-`). The closing fence must have exactly the same number of hyphens as the opening fence. The hyphens of either fence may be followed by [horizontal whitespace]. | ||
|
|
||
| r[frontmatter.infostring] | ||
| The opening fence, after optional [horizontal whitespace], may be followed by an infostring that identifies the format or purpose of the body. An infostring may be followed by horizontal whitespace. | ||
|
|
||
| r[frontmatter.body] | ||
| No line in the body may start with a sequence of hyphens (`-`) equal to or longer than the opening fence. The body may not contain any carriage returns (that survive [CRLF normalization]). | ||
|
|
||
| [byte order mark]: https://en.wikipedia.org/wiki/Byte_order_mark#UTF-8 | ||
| [CRLF normalization]: input.crlf | ||
| [horizontal whitespace]: grammar-HORIZONTAL_WHITESPACE | ||
| [shebang]: input-format.md#shebang-removal | ||
| [whitespace]: whitespace.md | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Uh oh!
There was an error while loading. Please reload this page.