-
Notifications
You must be signed in to change notification settings - Fork 96
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
Add a frontmatter to mld pages #1187
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
79b39ac
Parse and add frontmatter to page model
panglesd 1daf933
Add frontmatter to page's root
panglesd c6d98f1
Add a test for frontmatters
panglesd af49b1f
Frontmatter: extract all frontmatters in a single page
panglesd 5ed045c
rename "frontmatter" to "meta"
panglesd 9e8604e
Add changelog entry for #1187
panglesd d5f5da6
open Odoc_utils on top of file
panglesd 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 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 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 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 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 @@ | ||
type t = (string * string) list |
This file contains 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 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 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 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 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 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 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,6 @@ | ||
{0 One frontmatter} | ||
|
||
{@meta[ | ||
bli1: bloblobloblo1 | ||
bli2: bloblobloblo2 | ||
]} |
This file contains 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,101 @@ | ||
When there is no frontmatter, everything is normal | ||
|
||
$ odoc compile zero_frontmatter.mld | ||
$ odoc_print page-zero_frontmatter.odoc | jq '.frontmatter' | ||
[] | ||
|
||
When there is one frontmatter, it is extracted from the content: | ||
|
||
$ odoc compile one_frontmatter.mld | ||
$ odoc_print page-one_frontmatter.odoc | jq '.frontmatter' | ||
[ | ||
[ | ||
"bli1", | ||
" bloblobloblo1" | ||
], | ||
[ | ||
"bli2", | ||
" bloblobloblo2" | ||
] | ||
] | ||
$ odoc_print page-one_frontmatter.odoc | jq '.content' | ||
[ | ||
{ | ||
"`Heading": [ | ||
{ | ||
"heading_level": "`Title", | ||
"heading_label_explicit": "false" | ||
}, | ||
{ | ||
"`Label": [ | ||
{ | ||
"`LeafPage": [ | ||
"None", | ||
"one_frontmatter" | ||
] | ||
}, | ||
"one-frontmatter" | ||
] | ||
}, | ||
[ | ||
{ | ||
"`Word": "One" | ||
}, | ||
"`Space", | ||
{ | ||
"`Word": "frontmatter" | ||
} | ||
] | ||
] | ||
} | ||
] | ||
|
||
When there is more than one frontmatter, they are all extracted from the content: | ||
|
||
$ odoc compile two_frontmatters.mld | ||
$ odoc_print page-two_frontmatters.odoc | jq '.frontmatter' | ||
[ | ||
[ | ||
"bli3", | ||
" bloblobloblo1" | ||
], | ||
[ | ||
"bli1", | ||
" bloblobloblo1" | ||
], | ||
[ | ||
"bli2", | ||
" bloblobloblo2" | ||
] | ||
] | ||
$ odoc_print page-two_frontmatters.odoc | jq '.content' | ||
[ | ||
{ | ||
"`Heading": [ | ||
{ | ||
"heading_level": "`Title", | ||
"heading_label_explicit": "false" | ||
}, | ||
{ | ||
"`Label": [ | ||
{ | ||
"`LeafPage": [ | ||
"None", | ||
"two_frontmatters" | ||
] | ||
}, | ||
"two-frontmatters" | ||
] | ||
}, | ||
[ | ||
{ | ||
"`Word": "Two" | ||
}, | ||
"`Space", | ||
{ | ||
"`Word": "frontmatters" | ||
} | ||
] | ||
] | ||
} | ||
] |
This file contains 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,10 @@ | ||
{0 Two frontmatters} | ||
|
||
{@meta[ | ||
bli1: bloblobloblo1 | ||
bli2: bloblobloblo2 | ||
]} | ||
|
||
{@meta[ | ||
bli3: bloblobloblo1 | ||
]} |
This file contains 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 @@ | ||
{0 No frontmatter} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One advantage of the frontmatter is that it's immediately recognizable. With this syntax, it can be confused for a code block and present several times all over the document.
This doesn't sound much better than
@
tags, which would be shorter to type and more easily recognized.I think a proper frontmatter should be a new syntax and expected at the beginning of the page only. For example using the markdown syntax (but without the yaml):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've agreed to consider this, but not to hold up the PR until it's decided, as several things depend upon this. We'll revisit the question before releasing 3.0.