-
Notifications
You must be signed in to change notification settings - Fork 72
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
🧮 Frontmatter in include
files removed, math/abbreviations maintained
#1156
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8582a69
🧹 Fix incorrect docstring
fwkoch de6dfac
🔧 Split source file loaders into separate functions
fwkoch 519a51f
🧮 Included files remove frontmatter and update math/abbr
fwkoch 249b104
🔧 Keep title node on include files
fwkoch 81d7490
Docs
rowanc1 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'myst-transforms': patch | ||
'myst-cli': patch | ||
--- | ||
|
||
Included files remove frontmatter and update math/abbr |
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 |
---|---|---|
|
@@ -20,6 +20,13 @@ type Options = { | |
* is defined. | ||
*/ | ||
preFrontmatter?: Record<string, any>; | ||
/** | ||
* By default, if the page starts with an H1 heading and has no title in the | ||
* frontmatter, the heading will become the title and be removed. | ||
* If `keepTitleNode` is true, the heading will still become the title | ||
* but the node will not be removed. | ||
*/ | ||
keepTitleNode?: boolean; | ||
}; | ||
|
||
export function getFrontmatter( | ||
|
@@ -70,7 +77,7 @@ export function getFrontmatter( | |
if (nextNodeIsH1 && !titleNull) { | ||
const title = toText(nextNode.children); | ||
// Only remove the title if it is the same | ||
if (frontmatter.title && frontmatter.title === title) { | ||
if (frontmatter.title && frontmatter.title === title && !opts.keepTitleNode) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think an option like this existed before, and I got rid of it a little hastily... Now, we can once again leave the title node in the tree. Useful for |
||
(nextNode as any).type = '__delete__'; | ||
frontmatter.content_includes_title = false; | ||
// If this has a label add it to the page identifiers for reference resolution | ||
|
Oops, something went wrong.
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.
Error early on
file does not exist
.