8000 feat: hide double square brackets in internal links by Linrui-Li · Pull Request #5791 · Zettlr/Zettlr · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: hide double square brackets in internal links #5791

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

Linrui-Li
Copy link

This pull request hides the double square brackets ([[ and ]]) used in internal links in the editor view, improving visual clarity.
If ZknLink AST nodes are available, the plugin hides the pipe (|) and internal target.
As a fallback, it uses a RegExp to hide brackets manually when no AST is available.
This resolves #5783.
I'm happy to receive feedback and make any changes as needed.

@Linrui-Li Linrui-Li force-pushed the hide-double-brackets branch from 61759d0 to 319d613 Compare June 14, 2025 08:06
Copy link
Member
@nathanlesage nathanlesage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, I appreciate this PR. However, there is a reason I did not implement double bracket hiding, to make it easier for users to distinguish between regular links and internal links. I would suggest a separate renderer setting for that so that users can decide for themselves if they want both formatting character types hidden, or only one. You should be able to copy and reuse most of the code, and simply transfer the changes you have made to said new renderer.

@@ -68,6 +68,18 @@ function hideLinkMarkers (view: EditorView): RangeSet<Decoration> {
})
}

// Fallback: Manually hide [[ and ]] using RegExp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why "Fallback"?

@@ -68,6 +68,18 @@ function hideLinkMarkers (view: EditorView): RangeSet<Decoration> {
})
}

// Fallback: Manually hide [[ and ]] using RegExp
const docText = view.state.doc.toString()
const bracketPattern = /\[\[(.*?)\]\]/g
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I advise against regular expressions where not necessary. There are syntax nodes within the syntax tree for double brackets that you can target instead. The reason the links above are handled a bit awkwardly is simply due to the complex nature of Markdown inline and reference links.

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.

Hide double square brackets in internal links
2 participants
0