Skip to content

Commit

Permalink
Feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Aug 29, 2024
1 parent 9b5d8d1 commit 15a7db2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
16 changes: 0 additions & 16 deletions src/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,6 @@ struct cmark_node {

CMARK_EXPORT int cmark_node_check(cmark_node *node, FILE *out);

static inline bool CMARK_NODE_TYPE_BLOCK_P(cmark_node_type node_type) {
return node_type < CMARK_NODE_TEXT;
}

static inline bool CMARK_NODE_BLOCK_P(cmark_node *node) {
return node != NULL && CMARK_NODE_TYPE_BLOCK_P((cmark_node_type) node->type);
}

static inline bool CMARK_NODE_TYPE_INLINE_P(cmark_node_type node_type) {
return node_type >= CMARK_NODE_TEXT;
}

static inline bool CMARK_NODE_INLINE_P(cmark_node *node) {
return node != NULL && CMARK_NODE_TYPE_INLINE_P((cmark_node_type) node->type);
}

#ifdef __cplusplus
}
#endif
Expand Down
6 changes: 5 additions & 1 deletion src/render.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ void cmark_render_code_point(cmark_renderer *renderer, uint32_t c) {
renderer->column += 1;
}

static inline int cmark_is_block(cmark_node *node) {
return node->type >= CMARK_NODE_FIRST_BLOCK && node->type <= CMARK_NODE_LAST_BLOCK;
}

char *cmark_render(cmark_node *root, int options, int width,
void (*outc)(cmark_renderer *, cmark_escaping, int32_t,
unsigned char),
Expand Down Expand Up @@ -179,7 +183,7 @@ char *cmark_render(cmark_node *root, int options, int width,
}

// If the root node is a block type (i.e. not inline), ensure there's a final newline:
if (CMARK_NODE_TYPE_BLOCK_P(root->type)) {
if (cmark_is_block(root)) {
if (renderer.buffer->size == 0 || renderer.buffer->ptr[renderer.buffer->size - 1] != '\n') {
cmark_strbuf_putc(renderer.buffer, '\n');
}
Expand Down

0 comments on commit 15a7db2

Please sign in to comment.