Repository navigation
Obsidian highlights (==text==, color emoji) and footnotes - #63
Open
experintellia wants to merge 10 commits into
Open
experintellia wants to merge 10 commits into
experintellia wants to merge 10 commits into
Conversation
Notes written in Obsidian can use ==highlight==. It is parsed like GFM strikethrough (same flanking rules, exactly two = as the delimiter, so a lone = or a === run is text), nests with emphasis both ways, and honours backslash escapes and inline code. A color emoji right after the opening == picks the color: 🔴 red, 🟠 orange, 🟡 yellow, 🟢 green, 🔵 blue, 🟣 purple. Without one the default (yellow) is used. In the live preview the == and the emoji are hidden off the cursor line, as the other markup is. - live-preview/highlight.ts: the MarkdownConfig extension (Highlight, HighlightMark nodes), registered in the editor and the history view. - decorations.ts: md-highlight class, the color class, hidden marks. - CSS: --hl-* tokens for light and dark themes, translucent so a selection still shows through. - Help syntax table row, CHANGELOG entry. - Unit tests for the parser and the decorations, and one e2e test. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
A reference reads as a superscript label with its brackets hidden off the cursor's line. A definition keeps its [^1]: marker visible and muted, takes lines indented two columns as its continuation, and may start right under a paragraph line. ^[note] is an inline footnote, set small and muted. Parser in live-preview/footnote.ts, registered in the editor and the history view; parser, decoration and e2e tests; help rows; CHANGELOG. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
📦
|
| bundle | |
|---|---|
| this PR | 721.0 KB |
main at the merge base |
714.1 KB |
| change | +6.8 KB (+1.0%) |
This comment updates on every push.
Notes written in Obsidian can use ==highlight==. It is parsed like GFM strikethrough (same flanking rules, exactly two = as the delimiter, so a lone = or a === run is text), nests with emphasis both ways, and honours backslash escapes and inline code. A color emoji right after the opening == picks the color: 🔴 red, 🟠 orange, 🟡 yellow, 🟢 green, 🔵 blue, 🟣 purple. Without one the default (yellow) is used. In the live preview the == and the emoji are hidden off the cursor line, as the other markup is. - live-preview/highlight.ts: the MarkdownConfig extension (Highlight, HighlightMark nodes), registered in the editor and the history view. - decorations.ts: md-highlight class, the color class, hidden marks. - CSS: --hl-* tokens for light and dark themes, translucent so a selection still shows through. - Help syntax table row, CHANGELOG entry. - Unit tests for the parser and the decorations, and one e2e test. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
A reference reads as a superscript label with its brackets hidden off the cursor's line. A definition keeps its [^1]: marker visible and muted, takes lines indented two columns as its continuation, and may start right under a paragraph line. ^[note] is an inline footnote, set small and muted. Parser in live-preview/footnote.ts, registered in the editor and the history view; parser, decoration and e2e tests; help rows; CHANGELOG. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…menu Footnotes: - Read mode numbers references as Obsidian's reading view does (by first reference, named and inline ones too), hides the definitions, and lists the notes at the end of the document, each with a ↩ back to the text. - A tap on a reference goes to its note: to the definition while editing (caret at the start of its text), to its list entry in read mode. - References in table cells take part: superscript, numbered in read mode, and followable. Highlights: - A Highlight button in the toolbar (wraps the selection in ==). - Right after an opening == with no color yet, a menu at the caret offers the six color emoji, as Obsidian suggests them after ==. - Table cells draw colored highlights without the emoji. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ArrowDown steps from the text into the menu, ArrowLeft / ArrowRight move between the colors (wrapping), Enter or Space puts the chosen one in, and ArrowUp goes back to the text. Escape closes the menu until the caret or the text moves on. Until ArrowDown, every key goes to the text as before, so Enter after `==` still starts a new line. The menu is a listbox now, and the editor points a screen reader at the chosen color with aria-activedescendant. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main (#65) rewrote bold, italic and strikethrough to follow the styled text. Highlight is now a fourth style of that toggle instead of a plain wrapper, so a selection inside a highlight is cut out of it and one across its edge extends it. A color emoji belongs to its highlight: a highlight cut in two keeps its color on both sides, and removing one removes its emoji too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The whole toolbar was the sideways scroller, with the read toggle and ⋮ held at its edge by position: sticky, so on iOS they bounced along with the commands. The commands now scroll in a container of their own; the buttons after it are a plain flex item and stay put. The container also takes the old spacer's job of pushing them to the right. From the over-engineering review of this PR: - The read-mode footnote widget drops its unused label. - One followFootnote() for the click in the text and in a table cell. - One SyntaxNodeLike type, exported from decorations.ts, for the three files that spelled it out. - The footnote index drops its unread `numbers` map. - .md-highlight-yellow repeated the .md-highlight default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Where the commands' cut edge falls between two buttons, nothing showed that there are more. The side with more to scroll to now fades out, as a mask on the buttons themselves (no overlay color to match per theme), and only while there is more: scrolled to the end, the last button is not faded as if disabled. A scroll listener and a ResizeObserver set the more-before / more-after classes; when everything fits, nothing fades. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
With this PR, notes written in Obsidian look the same in MD-Docs.
Highlights
==text==is drawn highlighted. It parses like GFM~~strikethrough~~: the same flanking rules, and only a run of exactly two=, soa == b,=x=and===stay plain text. Highlights nest with emphasis both ways, and escapes and inline code work.==picks the color: 🔴 🟠 🟡 🟢 🔵 🟣. When the cursor is on another line, the==and the emoji are hidden.==and no emoji follows, a menu at the caret offers the six colors, as Obsidian suggests them after==.==, in a===run, after an escaped\==, in code or math, or in read mode.==still starts a new line.aria-activedescendant.====with the caret in the middle, so the color menu opens.==🔴ein «langer» text==→==🔴ein== langer ==🔴text==. Removing a highlight removes its emoji too.Footnotes
text[^1]shows the label as a superscript.[^1]: noteis a block whose following lines, indented by two spaces, continue the note, and it may start right under a paragraph line.^[inline note]is shown small and muted.[^note]) and inline ones get numbers too.Toolbar
position: sticky, so on iOS they bounced along with the commands. The commands now scroll in their own.md-tool-cmdscontainer, which also replaces the old spacer, and the buttons at the end stay in place.Notes for review
highlight.tsandfootnote.ts, and are registered in both the editor and the history view.footnoteField, infootnote.ts.buildFootnoteListindecorations.ts.highlight-menu.ts.eqnow also compares the footnote numbers its cells show, because adding a reference above a table renumbers them while the table's own source stays the same.mainis merged in, including Bold, italic and strikethrough follow the text that is already styled #65. The resolution makes Highlight a style of the new toggle incommands.ts, and keeps Strikethrough's wide-screen button next to the Highlight button.Tests
npm testpasses: 307 unit tests.highlight.test.tsandfootnote.test.tscover the parsers.footnote-view.test.tscovers numbering, the read-mode list, table cells, and when the color menu opens or stays closed.commands.test.tscovers the highlight toggle, including the color cases.decorations.test.tsandtoolbar.test.tshave additions.🤖 Generated with Claude Code