MCPcopy Create free account
hub / github.com/commonmark/cmark / S_render_node

Function S_render_node

src/latex.c:220–452  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

218}
219
220static int S_render_node(cmark_renderer *renderer, cmark_node *node,
221 cmark_event_type ev_type, int options) {
222 int list_number;
223 int enumlevel;
224 char list_number_string[LIST_NUMBER_STRING_SIZE];
225 bool entering = (ev_type == CMARK_EVENT_ENTER);
226 cmark_list_type list_type;
227 bool allow_wrap = renderer->width > 0 && !(CMARK_OPT_NOBREAKS & options);
228
229 // avoid warning about unused parameter:
230 (void)(options);
231
232 switch (node->type) {
233 case CMARK_NODE_DOCUMENT:
234 break;
235
236 case CMARK_NODE_BLOCK_QUOTE:
237 if (entering) {
238 LIT("\\begin{quote}");
239 CR();
240 } else {
241 LIT("\\end{quote}");
242 BLANKLINE();
243 }
244 break;
245
246 case CMARK_NODE_LIST:
247 list_type = cmark_node_get_list_type(node);
248 if (entering) {
249 LIT("\\begin{");
250 LIT(list_type == CMARK_ORDERED_LIST ? "enumerate" : "itemize");
251 LIT("}");
252 CR();
253 list_number = cmark_node_get_list_start(node);
254 if (list_number > 1) {
255 enumlevel = S_get_enumlevel(node);
256 // latex normally supports only five levels
257 if (enumlevel >= 1 && enumlevel <= 5) {
258 snprintf(list_number_string, LIST_NUMBER_STRING_SIZE, "%d",
259 list_number - 1); // the next item will increment this
260 LIT("\\setcounter{enum");
261 switch (enumlevel) {
262 case 1: LIT("i"); break;
263 case 2: LIT("ii"); break;
264 case 3: LIT("iii"); break;
265 case 4: LIT("iv"); break;
266 case 5: LIT("v"); break;
267 default: LIT("i"); break;
268 }
269 LIT("}{");
270 OUT(list_number_string, false, NORMAL);
271 LIT("}");
272 }
273 CR();
274 }
275 } else {
276 LIT("\\end{");
277 LIT(list_type == CMARK_ORDERED_LIST ? "enumerate" : "itemize");

Callers

nothing calls this directly

Calls 9

cmark_node_get_list_typeFunction · 0.85
S_get_enumlevelFunction · 0.85
cmark_node_get_literalFunction · 0.85
cmark_node_get_on_enterFunction · 0.85
cmark_node_get_on_exitFunction · 0.85
cmark_node_get_urlFunction · 0.85
get_link_typeFunction · 0.85

Tested by

no test coverage detected