Solved issue #2192 (Respect blank lines in capture templates)#2203
Merged
jethrokuan merged 5 commits intoorg-roam:mainfrom May 25, 2022
Merged
Solved issue #2192 (Respect blank lines in capture templates)#2203jethrokuan merged 5 commits intoorg-roam:mainfrom
jethrokuan merged 5 commits intoorg-roam:mainfrom
Conversation
Member
|
if you don't mind could you add a test case for your template so it doesn't regress |
Contributor
Author
|
Just added the test case. Changed the CI workflow so it'll run on pushes to "main", as that's the default branch in my fork. Edit: seems to be working fine! :) |
Contributor
Author
|
Just reverted the CI trigger change (so runs are again triggered by pushes to "master") |
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Issue: #2192
Motivation for this change
Unwanted removal of
\ncharacters in Org Roam template strings.org-capture-fill-templatefills the template string, but it removes whitespace and newlines at the beginning and end of the template.*org-roam-capture--fill-templateremoves all blank lines and restores them after callingorg-capture-fill-template.The regex formula used for this however (
\n$) eliminates all blank lines in the template, whether or not they are at the beginning and end of the template.By replacing it with
[\n]*\\'only the blank lines at the end of the template will be removed -only the ones which will be later restored.Example
With a default template as follows:
org-roam-capture--fill-templatewould previously outputwhile with the new formula it outputs (the user's input as would be expected)
*: paraphrased from the comment in
org-roam-capture--fill-template