Initial CST-Agent: portable Linux/Termux/Windows coding agent.
Vendored sashidown, OpenAI-compatible env (OPENAI_*), and bootstrap scripts. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Vendored
+90
@@ -0,0 +1,90 @@
|
||||
#ifndef MD_RENDER_H
|
||||
#define MD_RENDER_H
|
||||
|
||||
#include "sashidown.h"
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef enum {
|
||||
LK_EMPTY,
|
||||
LK_FENCE,
|
||||
LK_HEADING,
|
||||
LK_HR,
|
||||
LK_BQ,
|
||||
LK_UL,
|
||||
LK_OL,
|
||||
LK_LATEX_LINE,
|
||||
LK_LATEX_BLOCK,
|
||||
LK_PARA,
|
||||
} line_kind_t;
|
||||
|
||||
typedef struct {
|
||||
line_kind_t kind;
|
||||
size_t content_start;
|
||||
size_t content_end;
|
||||
int heading_level;
|
||||
int fence_len;
|
||||
char fence_char; /* '`' or '~' */
|
||||
size_t info_start; /* fence info string */
|
||||
size_t info_end;
|
||||
int task; /* 0=none, 1=unchecked, 2=checked */
|
||||
} line_info_t;
|
||||
|
||||
/*
|
||||
* [CST State Q] — open-block environment registers (finite CST state).
|
||||
* Tracks which block containers are currently open so the transducer can
|
||||
* emit close tags without an AST. Constant size; independent of |B|.
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t ul;
|
||||
uint8_t ol;
|
||||
uint8_t bq;
|
||||
uint8_t para;
|
||||
} block_env_t;
|
||||
|
||||
/*
|
||||
* [CST State Q] — full confirmation-state transducer state.
|
||||
* Holds block_env plus soft-window / delayed-commit registers (fence,
|
||||
* LaTeX, pending line, table gate). Maps to CST state Q in the paper:
|
||||
* Scan(B[0..stop)) advances Q and emits only confirmed Y.
|
||||
*/
|
||||
typedef struct {
|
||||
block_env_t block; /* [CST State Q] nested open-block bits */
|
||||
int pending_valid;
|
||||
size_t pending_pos;
|
||||
size_t pending_le;
|
||||
line_info_t pending_li;
|
||||
int in_fence;
|
||||
int fence_len;
|
||||
char fence_char;
|
||||
size_t fence_info_start;
|
||||
size_t fence_info_end;
|
||||
int in_latex_block;
|
||||
size_t latex_start;
|
||||
uint8_t para_hard_break;
|
||||
/* Streaming table (scheme C): after header+sep committed, body rows
|
||||
* emit immediately; close on empty / non-pipe / final. */
|
||||
int in_table;
|
||||
int table_cols;
|
||||
/* Inline emphasis/code spans an open <p> across soft line breaks. */
|
||||
uint8_t inline_bold;
|
||||
uint8_t inline_italic;
|
||||
uint8_t inline_code;
|
||||
uint8_t inline_latex;
|
||||
uint8_t inline_strike;
|
||||
} sashidown_render_state_t;
|
||||
|
||||
void sashidown_render_state_init(sashidown_render_state_t *state);
|
||||
|
||||
/* Render input[start..stop) or full len when is_final. Updates *pos_io. */
|
||||
int sashidown_render_incremental(
|
||||
sashidown_ctx_t *restrict ctx,
|
||||
sashidown_render_state_t *restrict state,
|
||||
const char *restrict input, size_t len,
|
||||
size_t *pos_io,
|
||||
size_t stop,
|
||||
int is_final);
|
||||
|
||||
int sashidown_render(sashidown_ctx_t *ctx, const char *input, size_t len);
|
||||
|
||||
#endif /* MD_RENDER_H */
|
||||
Reference in New Issue
Block a user