Skip to content

Commit

Permalink
Patch cmark to allow nested documents
Browse files Browse the repository at this point in the history
Patch taken from commonmark/cmark#522
  • Loading branch information
Ericson2314 committed Jan 17, 2024
1 parent 967d866 commit c41eddc
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
27 changes: 27 additions & 0 deletions dep-patches/cmark-allow-nested-documents.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
diff --git a/api_test/main.c b/api_test/main.c
index c2db737..9bc5748 100644
--- a/api_test/main.c
+++ b/api_test/main.c
@@ -456,6 +456,7 @@ void hierarchy(test_batch_runner *runner) {

int list_item_flag = 1 << CMARK_NODE_ITEM;
int top_level_blocks =
+ (1 << CMARK_NODE_DOCUMENT) |
(1 << CMARK_NODE_BLOCK_QUOTE) | (1 << CMARK_NODE_LIST) |
(1 << CMARK_NODE_CODE_BLOCK) | (1 << CMARK_NODE_HTML_BLOCK) |
(1 << CMARK_NODE_PARAGRAPH) | (1 << CMARK_NODE_HEADING) |
diff --git a/src/node.c b/src/node.c
index c90b0d4..64a4ed7 100644
--- a/src/node.c
+++ b/src/node.c
@@ -39,10 +39,6 @@ static bool S_can_contain(cmark_node *node, cmark_node *child) {
}
}

- if (child->type == CMARK_NODE_DOCUMENT) {
- return false;
- }
-
switch (node->type) {
case CMARK_NODE_DOCUMENT:
case CMARK_NODE_BLOCK_QUOTE:
8 changes: 8 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,13 @@
];
});

cmark-nix = final.cmark.overrideAttrs (o: {
patches = (o.patches or []) ++ [
# https://github.com/commonmark/cmark/pull/522
./dep-patches/cmark-allow-nested-documents.diff
];
});

changelog-d-nix = final.buildPackages.callPackage ./misc/changelog-d.nix { };

nix =
Expand All @@ -188,6 +195,7 @@
;
officialRelease = false;
boehmgc = final.boehmgc-nix;
cmark = final.cmark-nix;
libgit2 = final.libgit2-nix;
busybox-sandbox-shell = final.busybox-sandbox-shell or final.default-busybox-sandbox-shell;
changelog-d = final.changelog-d-nix;
Expand Down

0 comments on commit c41eddc

Please sign in to comment.