44 lines
1.6 KiB
C
44 lines
1.6 KiB
C
/*
|
|
* TinyBlocks - tb_syntax.h
|
|
* Library tinyblocks-syntax: realce de sintaxe (syntax highlight) de um texto
|
|
* em varias linguagens, devolvendo o texto colorido em XML.
|
|
* Independente do editor.
|
|
*
|
|
* O XML gerado tem a forma:
|
|
* <code lang="c">
|
|
* <line><t type="kw" color="#c678dd">int</t> <t type="id" color="#9cdcfe">x</t>...</line>
|
|
* ...
|
|
* </code>
|
|
* Cada linha do texto vira um elemento <line>; os trechos viram <t> com o tipo
|
|
* do token e a cor (#rrggbb). Texto fora de tokens vira <t type="plain">.
|
|
*/
|
|
#ifndef TINYBLOCKS_SYNTAX_H
|
|
#define TINYBLOCKS_SYNTAX_H
|
|
|
|
#include <tinyblocks/tinyblocks.h>
|
|
|
|
TB_API const TinyBlocks_LibraryDescriptor* tb_syntax_get_library(void);
|
|
|
|
/* -- API C --------------------------------------------------------------- */
|
|
|
|
/* Realca `text` como `lang` e devolve XML (malloc; libere com free). */
|
|
TB_API char* tb_syntax_highlight(const char* text, const char* lang);
|
|
|
|
/* Realca `text` como um trecho de codigo C numa unica linha (sem <line>),
|
|
* util para assinaturas/hover. Devolve XML (malloc). */
|
|
TB_API char* tb_syntax_highlight_inline(const char* text, const char* lang);
|
|
|
|
/* Numero de linguagens conhecidas e o nome normalizado da i-esima. */
|
|
TB_API int tb_syntax_language_count(void);
|
|
TB_API const char* tb_syntax_language_name(int i);
|
|
|
|
/* Cor (#rrggbb) associada a um tipo de token ("kw", "str", "cmt", ...). */
|
|
TB_API const char* tb_syntax_type_color(const char* type);
|
|
|
|
/* Normaliza um nome/extensao de linguagem ("py" -> "python"); nunca NULL. */
|
|
TB_API const char* tb_syntax_normalize_lang(const char* lang);
|
|
|
|
TB_API const char* tb_syntax_last_error(void);
|
|
|
|
#endif /* TINYBLOCKS_SYNTAX_H */
|