-
Notifications
You must be signed in to change notification settings - Fork 163
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 yaml metadata parsing #91
Conversation
ff094ce
to
55ef0f1
Compare
(defun markdown-match-generic-metadata (regexp last) | ||
(defun markdown-get-match-boundaries (start-header end-header last &optional pos) | ||
(save-excursion | ||
(goto-char (if pos pos (point-min))) |
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.
How about (or pos (point-min))
like other parts ?
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.
Fixed, not sure what I was thinking.
Thanks for great work. I put some comments, please check them. |
Looks good. Could you squash commits ? |
99a4207
to
ac0f734
Compare
Done. |
And please remove following lines from commit messages, they makes no sense.
|
Also allow multiple pandoc metadata, with tests. Fix jrblevin#66.
ac0f734
to
722ef85
Compare
Fixed. |
Thanks 👍 |
Thanks for this patch. I only noticed one potential issue: YAML blocks inside fenced code blocks should be ignored:
You can use |
Regarding my comment above about YAML in code blocks, I appended the test case and marked it with |
I'll take a look at these tomorrow. I think I can speed up the metadata block matching by propertizing metadata block start and end boundaries (the With respect to the if statements, I wanted to allow for local binding of the pandoc style; if you want to remove the if statements, I can factor that out into a separate function. |
Thank you @cosmicexplorer for this! 👍 |
Thinking about it a bit more, metadata would be invalid inside any other "block"-level construct, such as gfm code blocks or tilde blocks; I think that's it? All the other block constructs have some required characters at the beginning of each line. I think what would probably work would be to propertize all three "border" types (gfm blocks, pandoc tilde blocks, yaml metadata blocks) at once in a single pass, then figure out the appropriate context for any text enclosed within them by finding which if any characters with the syntax property for start/end blocks of those three block types are closest to the characters to propertize. So basically, if our text is like:
I'll try to do this, it seems not too hard. |
Improve on jrblevin#91 by increasing speed of matching block constructs, and allow them to be nested within each other, by matching all of them in a single pass. - Ensure font locking of block constructs is predicated solely on text properties. - Add "language" field to tilde fence opening regexp. - Make `test-markdown-font-lock/pandoc-yaml-metadata` pass.
Improve on jrblevin#91 by increasing speed of matching block constructs, and allow them to be nested within each other, by matching all of them in a single pass. - Ensure font locking of block constructs is predicated solely on text properties. - Add "language" field to tilde fence opening regexp. - Make `test-markdown-font-lock/pandoc-yaml-metadata` pass. - Add `markdown-font-lock-extend-region-function` and rework `markdown-syntax-propertize-extend-region` to stretch repropertization/refontification to all of a code block. - Add test cases for fenced block conditions.
Improve on jrblevin#91 by increasing speed of matching block constructs, and allow them to be nested within each other, by matching all of them in a single pass. - Ensure font locking of block constructs is predicated solely on text properties. - Add "language" field to tilde fence opening regexp. - Make `test-markdown-font-lock/pandoc-yaml-metadata` pass. - Add `markdown-font-lock-extend-region-function` and rework `markdown-syntax-propertize-extend-region` to stretch repropertization/refontification to all of a code block. - Add test cases for fenced block conditions.
Also add testing and allow multiple pandoc metadata blocks. Fix #66.