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

Function S_render_node

src/commonmark.c:154–464  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152}
153
154static int S_render_node(cmark_renderer *renderer, cmark_node *node,
155 cmark_event_type ev_type, int options) {
156 cmark_node *tmp;
157 int list_number;
158 cmark_delim_type list_delim;
159 size_t numticks;
160 bool extra_spaces;
161 size_t i;
162 bool entering = (ev_type == CMARK_EVENT_ENTER);
163 const char *info, *code, *title;
164 char fencechar[2] = {'\0', '\0'};
165 size_t code_len;
166 char listmarker[LISTMARKER_SIZE];
167 const char *emph_delim;
168 bool first_in_list_item;
169 bufsize_t marker_width;
170 bool has_nonspace;
171 bool allow_wrap = renderer->width > 0 && !(CMARK_OPT_NOBREAKS & options) &&
172 !(CMARK_OPT_HARDBREAKS & options);
173
174 // Don't adjust tight list status til we've started the list.
175 // Otherwise we lose the blank line between a paragraph and
176 // a following list.
177 if (entering) {
178 if (node->parent && node->parent->type == CMARK_NODE_ITEM) {
179 renderer->in_tight_list_item = node->parent->parent->as.list.tight;
180 }
181 } else {
182 if (node->type == CMARK_NODE_LIST) {
183 renderer->in_tight_list_item =
184 node->parent &&
185 node->parent->type == CMARK_NODE_ITEM &&
186 node->parent->parent->as.list.tight;
187 }
188 }
189
190 switch (node->type) {
191 case CMARK_NODE_DOCUMENT:
192 break;
193
194 case CMARK_NODE_BLOCK_QUOTE:
195 if (entering) {
196 LIT("> ");
197 renderer->begin_content = true;
198 cmark_strbuf_puts(renderer->prefix, "> ");
199 } else {
200 cmark_strbuf_truncate(renderer->prefix, renderer->prefix->size - 2);
201 BLANKLINE();
202 }
203 break;
204
205 case CMARK_NODE_LIST:
206 if (!entering && node->next && (node->next->type == CMARK_NODE_LIST)) {
207 // this ensures that a following indented code block or list will be
208 // inteprereted correctly.
209 CR();
210 LIT("<!-- end list -->");
211 BLANKLINE();

Callers

nothing calls this directly

Calls 15

cmark_strbuf_putsFunction · 0.85
cmark_strbuf_truncateFunction · 0.85
cmark_node_get_list_typeFunction · 0.85
cmark_strbuf_putcFunction · 0.85
cmark_node_get_literalFunction · 0.85
cmark_node_get_on_enterFunction · 0.85
cmark_node_get_on_exitFunction · 0.85

Tested by

no test coverage detected