Skip to content
Source
Sign inSign up
TanStack/highlight

Add ABAP highlighting #37

OpenDreierF(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/37/headopened

Changes

ABAP fences currently fall back to plaintext. This adds an isolated abap definition (no aliases), registers it in the default entry, and exposes it as a selective import (@tanstack/highlight/languages/abap). It uses the existing collectPatternRanges helpers with a small linear scanner for comments and literals: no new token classes, no new dependencies, no cross-language imports, and no changes to core or to existing language modules.

Context-aware behaviour:

  • * comments in the first column versus multiplication, and " line comments
  • '…' and `…` literals with doubled delimiters
  • string templates |…{ expr }…|, where the { } holes are tokenized as code
  • case-insensitive and hyphenated keywords (CLASS-METHODS, START-OF-SELECTION)
  • field symbols <fs>, pragmas ##NEEDED, and class names before =>
  • component selectors (-, ->, =>, ~), which keep keyword-like names plain, for example ls_entry-type
  • ABAP requires spaces inside expression parentheses and around operators, so a word touching a parenthesis is a call or a declared name (update( … ), DATA(message)), and - or / inside names never become operators

The template scanner is iterative, so deeply nested templates cannot overflow the stack. A regression test tokenizes 50,000 nested holes in well under a second.

The branch is one commit for the module and tests, then one registration commit (default entry, barrel, size and bench profiles, fixture, docs tables, changeset).

Proposal: #35

Deliberate limits

  • A variable named like a keyword (value, length, key) is highlighted as a keyword outside the positions above. highlight.js behaves the same way.
  • Templates end at a line break, as in ABAP.

Validation

pnpm run verify passes, including the new test/abap.test.ts and a representative fixture in test/fixtures.ts. I also checked the output against a few hundred lines of real ABAP from static-analysis rule descriptions.

Core + ABAP, local Node 24: 7.93 KB minified / 3.64 KB gzip / 3.27 KB Brotli, with a 3.8 KB gzip budget. Most of it is the keyword list, which ABAP needs because it has no small reserved-word core. Core and every existing selective profile are unchanged. The all-language convenience entry grows from 52.74 KB minified / 17.68 KB gzip to 56.13 KB / 18.94 KB gzip, and its budget rises from 18.0 KB to 19.2 KB gzip.

#36 (C) touches the same registration lines and size budget. Whichever merges second needs a small rebase.

🤖 Generated with Claude Code

    1. 🦋 Changeset detected

      Latest commit: 86c77555e56d086ce384b15f4fa60670c468f8fb

      The changes in this PR will be included in the next version bump.

      This PR includes changesets to release 1 package
      NameType
      @tanstack/highlightMinor

      Not sure what this means? Click here to learn what changesets are.

      Click here if you're a maintainer who wants to add another changeset to this PR

    2. Warning

      Review limit reached

      You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

      Next included review available in 59 minutes.

      Check out review usage here.

      View limit details

      Limit details: You’ve used the included review currently available.

      Learn how review limits work.

      Review configuration:

      ⚙️ Run configuration
      • Configuration used: defaults
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: dfcde623-5c3d-4a91-9b32-da8611fe979b
      📥 Commits

      Reviewing files that changed from the base of the PR and between 0541f2fdc7f96fb6245c82c739f0d816afdb670a and 86c77555e56d086ce384b15f4fa60670c468f8fb.

      📒 Files selected for processing: 18
      • .changeset/abap.md
      • README.md
      • docs/guides/performance.md
      • docs/installation.md
      • docs/language-support.md
      • docs/reference/default-entry.md
      • docs/reference/languages.md
      • docs/test-strategy.md
      • scripts/bench.mjs
      • scripts/language-utils.mjs
      • scripts/measure-size.mjs
      • skills/configure-selective-highlighting/references/languages.md
      • src/index.ts
      • src/languages/abap.ts
      • src/languages/index.ts
      • test/abap.test.ts
      • test/fixtures.ts
      • test/real-doc-fixtures.test.ts
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands.

Sign in to join this conversation.