You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TanStack Highlight should ship an isolated language definition for C, with the fence names c and h.
We render documentation that contains C code blocks, and these currently fall back to plaintext. Registering c as an alias of cpp would be the cheapest option, but it is inaccurate: C code can use new, class, this, template, and namespace as ordinary identifiers, and the C++ definition highlights them as keywords. C also has keywords that C++ lacks, such as restrict, _Generic, _Static_assert, and _Atomic.
I have an implementation ready that follows the shape of the C++ module:
src/languages/c.ts on the existing patternTokenizer, with no cross-language imports
prefixed strings, character literals, include paths, preprocessor directives, C11 and C23 keywords and types, digit separators, and wb suffixes
C++-only words stay plain
tests, a size profile, a benchmark profile, a fixture, docs, and a changeset
Size: Core + C is 2.84 KB gzip. The all-language entry grows from 17.68 KB to 17.88 KB gzip. Core and the existing selective profiles are unchanged. pnpm run verify passes.
If you prefer the alias on cpp instead, I can reduce the PR to that.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
TanStack Highlight should ship an isolated language definition for C, with the fence names
candh.We render documentation that contains C code blocks, and these currently fall back to plaintext. Registering
cas an alias ofcppwould be the cheapest option, but it is inaccurate: C code can usenew,class,this,template, andnamespaceas ordinary identifiers, and the C++ definition highlights them as keywords. C also has keywords that C++ lacks, such asrestrict,_Generic,_Static_assert, and_Atomic.I have an implementation ready that follows the shape of the C++ module:
src/languages/c.tson the existingpatternTokenizer, with no cross-language importswbsuffixesSize: Core + C is 2.84 KB gzip. The all-language entry grows from 17.68 KB to 17.88 KB gzip. Core and the existing selective profiles are unchanged.
pnpm run verifypasses.If you prefer the alias on
cppinstead, I can reduce the PR to that.All reactions