| 799 | } |
| 800 | |
| 801 | int cmark_node_append_child(cmark_node *node, cmark_node *child) { |
| 802 | if (!S_can_contain(node, child)) { |
| 803 | return 0; |
| 804 | } |
| 805 | |
| 806 | S_node_unlink(child); |
| 807 | |
| 808 | cmark_node *old_last_child = node->last_child; |
| 809 | |
| 810 | child->next = NULL; |
| 811 | child->prev = old_last_child; |
| 812 | child->parent = node; |
| 813 | node->last_child = child; |
| 814 | |
| 815 | if (old_last_child) { |
| 816 | old_last_child->next = child; |
| 817 | } else { |
| 818 | // Also set first_child if node previously had no children. |
| 819 | node->first_child = child; |
| 820 | } |
| 821 | |
| 822 | return 1; |
| 823 | } |
| 824 | |
| 825 | static void S_print_error(FILE *out, cmark_node *node, const char *elem) { |
| 826 | if (out == NULL) { |