-
Notifications
You must be signed in to change notification settings - Fork 66
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
Conversation
This begins to address the "latex subfile" task here: econ-ark/REMARK#152 |
Also, as a side effect, this addresses the first half of #1152 - now, when providing a non-existent file at the CLI, you are told it does not exist. (Complaints about the extension will only surface if the file exists but has a bad extension. Anyway - still more to do on that one...) |
@@ -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 comment
The 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 include
files where we almost certainly do not want to remove headings.
|
||
try { | ||
const content = fs.readFileSync(file).toString(); |
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
.
Tested locally, works well! |
Files loaded in the
include
directive previously retained their frontmatter in themdast
tree, resulting in an unwantedyaml
code block. Additionally, everything in theinclude
frontmatter was ignored (mostly we do want to ignore it, but for.tex
source files,include
s may have math macros, etc, that we need to inherit).Now, we reuse the file loading functions from
loadFile
in theinclude
directive. These functions remove and give access to file frontmatter. That means no more yaml blocks and we can inheritmath
andabbreviations
into the parent file's frontmatter.