Skip to content

Fix emacs one-liner file vars having surrounding whitespace stripped#460

Merged
nicholasserra merged 2 commits intotrentm:masterfrom
Crozzers:fix-emacs-oneliners
Jul 21, 2022
Merged

Fix emacs one-liner file vars having surrounding whitespace stripped#460
nicholasserra merged 2 commits intotrentm:masterfrom
Crozzers:fix-emacs-oneliners

Conversation

@Crozzers
Copy link
Copy Markdown
Contributor

@Crozzers Crozzers commented Jul 20, 2022

In #454, I introduced a bug with emacs one-liner file variables that caused surrounding whitespace to be removed from them.
This issue is demonstrated by the following markdown:

---
key: value
---

-*- markdown-extras: metadata -*-

The emacs one-liner would be matched and substituted by _emacs_vars_oneliner_sub, which would not replace the \n\n between the markdown metadata closing fence and the one-liner, resulting in the following text:

---
key: value
---<!-- -*- markdown-extras: metadata -*- -->

Which would later go on to cause an IndexError in _extract_metadata.
This PR fixes this issue by extracting the leading and tailing whitespace from the matched emacs one-liner and making sure they are added back to the one-liner after it has been wrapped in HTML comment tags

@nicholasserra nicholasserra merged commit 6032f8b into trentm:master Jul 21, 2022
@nicholasserra
Copy link
Copy Markdown
Collaborator

Thanks!

@Crozzers Crozzers deleted the fix-emacs-oneliners branch August 9, 2022 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants