Adiciona tinyblocks-syntax, tinyblocks-regex e tinyblocks-markdown (com testes)
This commit is contained in:
1 parent
c75d4be1c2
commit
a921f6574d
16 files changed
+1846
-4
No files matched your search
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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 */
|
||||
Reference in new issue
Block a user