- Add detailed build and bootstrap instructions to README.md. - Convert all source and header files from .c/.h to .c.md/.h.md. - Add bootstrap.sh script for automated building across version history. - Update Makefile and sources.mk to reflect new markdown-based source organization.
40 lines
745 B
Markdown
40 lines
745 B
Markdown
```c
|
|
#include <stdlib.h>
|
|
|
|
#include "transpile.h"
|
|
#include "internal/transpile_internal.h"
|
|
#include "utils.h"
|
|
|
|
int8_t
|
|
process_line(t_state *s, char *line)
|
|
{
|
|
s->src_line++;
|
|
if (0 == s->in_block && starts_with(line, "```"))
|
|
return (handle_fence_open(s, line));
|
|
if (1 == s->in_block && starts_with(line, "```"))
|
|
return (handle_fence_close(s));
|
|
if (1 == s->in_block)
|
|
return (handle_code_line(s, line));
|
|
return (0);
|
|
}
|
|
|
|
int8_t
|
|
transpile(FILE *in, FILE *out, const char *ext, t_map *map)
|
|
{
|
|
t_state s;
|
|
char *line;
|
|
int8_t ret;
|
|
|
|
state_init(&s, in, out, ext, map);
|
|
ret = 0;
|
|
line = read_line(in);
|
|
while (NULL != line && 0 == ret)
|
|
{
|
|
ret = process_line(&s, line);
|
|
free(line);
|
|
line = read_line(in);
|
|
}
|
|
free(line);
|
|
return (ret);
|
|
}
|
|
```
|