Skip to content

feat: support ==text== highlighting in the GFM flavour - #230

Merged
Peter Gromov (donnerpeter) merged 1 commit into
masterfrom
gfm-highlight-support
Sep 25, 2026
Merged

Peter Gromov (donnerpeter) merged 1 commit into
masterfrom
gfm-highlight-support

Conversation

@jetbrains-air

@jetbrains-air jetbrains-air Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Fixes IJPL-175082: ==...== syntax is not rendered as highlighted, while being an official extended-syntax alternative to the HTML <mark> tag.

What

Adds ==text== highlighting to GFMFlavourDescriptor, following the same pattern previously used for strikethrough and math:

  • Lexer: = is now lexed as a separate token (GFMTokenTypes.EQUALS) instead of being merged into TEXT, and \= was added to the backslash-escape rule (CommonMark treats every ASCII punctuation character as escapable). _GFMLexer.kt is regenerated from gfm.flex with the IntelliJ JFlex 1.9.2 fork and idea-flex.skeleton; the regeneration toolchain was validated by first reproducing the committed lexer byte-for-byte from the unmodified gfm.flex.
  • Parser: a new HighlightDelimiterParser (mirroring StrikeThroughDelimiterParser) participates in EmphasisLikeParser and produces a GFMElementTypes.HIGHLIGHT node. Only runs of exactly two = count, so =text= and ===text=== stay plain text, matching markdown-it-mark/Obsidian behavior.
  • HTML: HIGHLIGHT renders as <mark> via the existing EqualDelimiterTrimmingInlineTagProvider.

Like the earlier math support, the token is added to the GFM lexer only; SFMFlavourDescriptor inherits the parser but its lexer emits no EQUALS tokens, so its behavior is unchanged.

AST note

= characters in inline text are now separate = tokens instead of being merged into adjacent TEXT tokens (the same kind of change ~ and $ introduced). Two existing parser goldens (math.txt, gfmTableWithBlockQuote.txt) were regenerated accordingly; rendered HTML is unaffected.

Testing

  • New parser AST test (testHighlight in MarkdownParsingTest) and HTML test (testHighlight in HtmlGeneratorCommonTest) covering: basic and multi-word highlights, single/triple/quadruple =, intraword, adjacent pairs, backslash escapes, unclosed delimiters, = in plain text and URLs, nesting with strong/strikethrough/links/code spans, and a setext heading regression case.
  • Full JVM suite: 1551 tests pass (includes CommonMark and GFM spec suites). JS suite passes; JS/Native/WASM targets compile.

Produced by Air Automations. Name: Markdown library: fix the bug / Run: https://air.jetbrains.cloud/org/05cf1a7f-6ab5-713b-abd3-29d0c8a05e2d/automations/cb6a17f6-e7a9-41a8-9611-7c95c4eb0141?run=faef9ac2-8bf0-4db1-8e17-4dce310f599f

Add a GFM extension that parses `==highlighted text==` into a
HIGHLIGHT element rendered as the HTML `<mark>` tag, an official
alternative to `<mark>` in extended Markdown syntax.

- Lex `=` as a separate token (GFMTokenTypes.EQUALS) and allow
  escaping it with a backslash; the GFM lexer is regenerated from
  gfm.flex with JFlex 1.9.2 and the IntelliJ skeleton
- Parse runs of exactly two `=` with HighlightDelimiterParser,
  mirroring StrikeThroughDelimiterParser: `=text=` and
  `===text===` stay plain text
- Render HIGHLIGHT as `<mark>` in GFMFlavourDescriptor

Fixes IJPL-175082

Produced by Air Automations. Name: Markdown library: fix the bug / Run: https://air.jetbrains.cloud/org/05cf1a7f-6ab5-713b-abd3-29d0c8a05e2d/automations/cb6a17f6-e7a9-41a8-9611-7c95c4eb0141?run=faef9ac2-8bf0-4db1-8e17-4dce310f599f
@donnerpeter
Peter Gromov (donnerpeter) merged commit b3b13b9 into master Sep 25, 2026
6 checks passed
@donnerpeter
Peter Gromov (donnerpeter) deleted the gfm-highlight-support branch September 25, 2026 09:06
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.

1 participant