Bugfix #177 Match list item block IDs in $cleantext according to Obsidian spec#178
Merged
GamerGirlandCo merged 1 commit intoJun 22, 2026
Conversation
Block IDs at the end of lines need leading whitespace, no trailing whitespace, and contain only Latin letters, numbers, or hyphens. I also split the cleaning operation between removing the block ID and removing everything after and including the first inline field.
$cleantext according to Obsidian spec
GamerGirlandCo
approved these changes
Jun 22, 2026
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix to #177. Fixed how list item
$cleantextmatches block IDs, as block links within a list item text were erroneously culled.Block IDs at the end of lines need leading whitespace, no trailing whitespace, and contain only Latin letters, numbers, or hyphens 1. I also split the cleaning operation between removing the block ID and removing everything after and including the first inline field.
I also changed the flags used in the regex patterns. Previous pattern used
/gm, which I removed:/m, especially since$textis only one line, but if multiline list items were to be supported by Datacore in the future, we would only want to match block IDs at the end of the block, not at the end of a line./g, since the block ID can only match once anyways and using/ginsidesplit()is redundant.I added the
/uflag for Unicode support, since we can expect Unicode input. Ideally we could use the/vflag but we have to target ES2024 or higher for that. The/vflag supersedes/uand makes some breaking changes to how special characters in character classes are handled 2. Basically, they have to be escaped whereas this ambiguity was allowed before. I made these patterns future compatible if we do upgrade and adopt the/vflag in the future.The pattern for inline fields is flawed, but that will be a lot of work beyond this bug fix. I am keeping this PR small for now.
Footnotes
https://obsidian.md/help/links#Link+to+a+block+in+a+note ↩
https://github.com/tc39/proposal-regexp-v-flag#how-is-the-v-flag-different-from-the-u-flag ↩