Skip to content

Highlight C Library Code Examples #2811

Closed Answered by wervin
wervin asked this question in Q&A
Discussion options

You must be logged in to vote

Okay, I should have verified whether ts_highlighter_add_language returned an error, that should provide the answer. And now, it works! 😄

extern const TSLanguage *tree_sitter_json(void);

void _test(void)
{
    const char source_code[] = "[1, null]";
    
    const char highlight_query[] = "(number) @number";

    const char *highlight_names[] = {"number"};
    const char *attribute_strings[] = {"red"};

    TSHighlighter *highlighter = ts_highlighter_new(highlight_names, attribute_strings, 1);

    ts_highlighter_add_language(highlighter, "source.json", NULL, tree_sitter_json(), highlight_query, NULL, NULL, sizeof(highlight_query) - 1, 0, 0);

    TSHighlightBuffer *buffer = ts_highlight_…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by wervin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant