c-md/srcs/transpile/fence.c.md
lohhiiccc 80f7a1b9b6 feat(build): add build instructions in README and convert sources to .c.md format
- 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.
2026-01-12 14:54:49 +01:00

886 B

#include <stdlib.h>
#include <string.h>
#include <stdio.h>

#include "internal/transpile_internal.h"
#include "utils.h"

int8_t
handle_fence_open(t_state *s, char *line)
{
	char	*block_ext;

	block_ext = extract_fence_ext(line);
	if (NULL == block_ext)
		return (0);
	if (0 != strcmp(block_ext, s->ext))
	{
		free(block_ext);
		return (0);
	}
	free(block_ext);
	if (0 == s->first_block)
	{
		if (0 > fprintf(s->out, "\n"))
			return (1);
		s->dst_line++;
	}
	s->first_block = 0;
	s->in_block = 1;
	s->block_src_start = s->src_line + 1;
	s->block_dst_start = s->dst_line + 1;
	return (0);
}

int8_t
handle_fence_close(t_state *s)
{
	uint32_t	src_end;
	uint32_t	dst_end;

	s->in_block = 0;
	src_end = s->src_line - 1;
	dst_end = s->dst_line;
	if (s->block_src_start <= src_end)
	{
		map_add(s->map, s->block_src_start, src_end,
			s->block_dst_start, dst_end);
	}
	return (0);
}