fix: ignore bash [[ ]] conditionals and disable single-dollar math#1203
Merged
Conversation
Wiki-link regex now requires a non-whitespace first character after [[, which prevents bash-style conditionals (e.g. [[ -n "$var" ]]) from being matched as wiki-links in both the Go backend and the TS preprocessor. Disables singleDollarTextMath in remarkMath to avoid conflicts between $var in bash prose and math delimiters; use $$...$$ for math blocks.
Copilot stopped reviewing on behalf of
perber due to an error
June 25, 2026 14:37
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates wikilink parsing and Markdown preview math handling to avoid false-positive link parsing in bash-style [[ ... ]] conditionals, and documents the resulting math delimiter expectations.
Changes:
- Tighten wikilink regex (UI + server) to require a non-whitespace first character in the wikilink target.
- Add regression tests to ensure bash
[[ ... ]]conditionals are ignored as wikilinks (UI + server). - Disable single-dollar inline math parsing in the Markdown preview and update README to reflect
$$...$$math blocks.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| ui/leafwiki-ui/src/lib/preprocessWikilinks.ts | Tightens wikilink target regex to avoid matching bash conditionals. |
| ui/leafwiki-ui/src/lib/preprocessWikilinks.test.ts | Adjusts whitespace test and adds regression coverage for bash [[ ... ]]. |
| ui/leafwiki-ui/src/features/preview/MarkdownPreview.tsx | Disables single-dollar inline math parsing to reduce conflicts with $var patterns. |
| internal/links/link_service_test.go | Adds server-side regression test ensuring bash conditionals don’t produce wikilinks. |
| internal/links/helpers.go | Aligns server wikilink regex with UI behavior to reject targets starting with whitespace. |
| README.md | Documents KaTeX math blocks using $$...$$. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Adds explicit regression test for leading-whitespace syntax to lock in the intended behavior introduced in the #1200 fix. Also clarifies in the README that inline $...$ math is not supported; use $$...$$ instead.
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.
Wiki-link regex now requires a non-whitespace first character after [[, which prevents bash-style conditionals (e.g. [[ -n "$var" ]]) from being matched as wiki-links in both the Go backend and the TS preprocessor.
Disables singleDollarTextMath in remarkMath to avoid conflicts between$var in bash prose and math delimiters; use $ $...$$ for math blocks.