Skip to content

Obsidian highlights (==text==, color emoji) and footnotes - #63

Open
experintellia wants to merge 10 commits into
mainfrom
claude/charming-einstein-l3umw2
Open

experintellia wants to merge 10 commits into
mainfrom
claude/charming-einstein-l3umw2

Conversation

@experintellia

@experintellia experintellia commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

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 =, so a == b, =x= and === stay plain text. Highlights nest with emphasis both ways, and escapes and inline code work.
  • A color emoji right after the opening == picks the color: 🔴 🟠 🟡 🟢 🔵 🟣. When the cursor is on another line, the == and the emoji are hidden.
  • Color menu: when the caret sits right after an opening == and no emoji follows, a menu at the caret offers the six colors, as Obsidian suggests them after ==.
    • The menu does not open after a closing ==, in a === run, after an escaped \==, in code or math, or in read mode.
    • Keyboard: ↓ moves into the menu, ← → choose a color (wrapping at the ends), Enter or Space inserts it, ↑ goes back to the text, and Esc closes the menu. Until ↓ is pressed, every key goes to the text as usual, so Enter after == still starts a new line.
    • The menu is a listbox, and the editor points screen readers at the chosen color with aria-activedescendant.
  • Toolbar button: a new Highlight button sits next to Italic and is shown on all screen sizes. With nothing selected it inserts ==== with the caret in the middle, so the color menu opens.
  • Toggle: Highlight is a fourth style of the toggle from Bold, italic and strikethrough follow the text that is already styled #65, so it behaves like bold, italic and strikethrough. A selection inside a highlight is cut out of it, and one across its edge extends it.
    • The color emoji belongs to its highlight. A colored highlight cut in two keeps its color on both sides: ==🔴ein «langer» text== → ==🔴ein== langer ==🔴text==. Removing a highlight removes its emoji too.
  • Table cells draw colored highlights too, without the emoji.

Footnotes

  • text[^1] shows the label as a superscript. [^1]: note is 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.
  • Tapping a reference goes to its note. While editing, the caret moves to the start of the definition's text. In read mode, the view scrolls to the note's entry in the list and flashes it. As with links, this works only when the cursor is on another line.
  • Read mode works like Obsidian's reading view:
    • References are numbered by first reference. Named ones ([^note]) and inline ones get numbers too.
    • Definitions are hidden where they were written.
    • All notes that are referred to are listed at the end of the document, each with a ↩ back to the text.
  • References in table cells are superscripts, are numbered in read mode, and can be tapped to follow them.

Toolbar

  • Only the editing commands scroll sideways now. Before, the whole toolbar was the scroller, and the read toggle and ⋮ were held at its edge by position: sticky, so on iOS they bounced along with the commands. The commands now scroll in their own .md-tool-cmds container, which also replaces the old spacer, and the buttons at the end stay in place.

Notes for review

  • The two parsers are in highlight.ts and footnote.ts, and are registered in both the editor and the history view.
  • The footnote numbering is computed in footnoteField, in footnote.ts.
  • The read-mode list is a block widget, built in buildFootnoteList in decorations.ts.
  • The color menu is a CodeMirror tooltip with its own key bindings, in highlight-menu.ts.
  • The table widget's eq now 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.
  • main is 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 in commands.ts, and keeps Strikethrough's wide-screen button next to the Highlight button.
  • The PR has had a review for over-engineering. The worthwhile cuts are applied: an unused field and map are gone, one click helper serves both footnote paths, one node type replaces three copies, and a duplicate CSS rule is removed.

Tests

  • npm test passes: 307 unit tests.
    • highlight.test.ts and footnote.test.ts cover the parsers.
    • footnote-view.test.ts covers numbering, the read-mode list, table cells, and when the color menu opens or stays closed.
    • commands.test.ts covers the highlight toggle, including the color cases.
    • decorations.test.ts and toolbar.test.ts have additions.
  • The e2e suite passes on chromium and mobile-chrome: 110 passed. It covers footnote taps, the read-mode list, table cells, the toolbar button, choosing a color by mouse and by keyboard, and only the commands scrolling on a narrow phone.
  • WebKit is not installed in the dev container, so the Safari projects run only in CI.

🤖 Generated with Claude Code

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>
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

📦 .xdc preview

Download md-docs.xdc — send the file into a Delta Chat conversation to run it. Built from 77d71ca.

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>
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.

2 participants