From ff567f0132cc1513736edd96c30c4c91d93327f5 Mon Sep 17 00:00:00 2001 From: AakashGC Date: Tue, 8 Nov 2022 17:42:03 +1100 Subject: [PATCH 1/3] changes in _transforms to accomodate other nodes --- src/sphinx_book_theme/_transforms.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/sphinx_book_theme/_transforms.py b/src/sphinx_book_theme/_transforms.py index 1b5dc2d1..f97aee6f 100644 --- a/src/sphinx_book_theme/_transforms.py +++ b/src/sphinx_book_theme/_transforms.py @@ -31,18 +31,21 @@ def run(self, **kwargs: Any) -> None: ): parent = foot_node.parent # second children of footnote node is the content text - text = foot_node.children[1].astext() + foot_node_content = foot_node.children[1].children sidenote = SideNoteNode() para = docutil_nodes.inline() # first children of footnote node is the label label = foot_node.children[0].astext() - if text.startswith("{-}"): + if foot_node_content[0].astext().startswith("{-}"): # marginnotes will have content starting with {-} # remove the number so it doesn't show para.attributes["classes"].append("marginnote") - para.append(docutil_nodes.Text(text.replace("{-}", ""))) + foot_node_content[0] = docutil_nodes.Text( + foot_node_content[0].replace("{-}", "") + ) + para.children = foot_node_content sidenote.attributes["names"].append(f"marginnote-role-{label}") else: @@ -50,7 +53,8 @@ def run(self, **kwargs: Any) -> None: # in this case we keep the number superscript = docutil_nodes.superscript("", label) para.attributes["classes"].append("sidenote") - para.extend([superscript, docutil_nodes.Text(text)]) + parachildren = [superscript] + foot_node_content + para.children = parachildren sidenote.attributes["names"].append(f"sidenote-role-{label}") sidenote.append(superscript) From 70b34bbee70290a09287e0f10b6478567781c73e Mon Sep 17 00:00:00 2001 From: AakashGC Date: Wed, 9 Nov 2022 00:17:37 +1100 Subject: [PATCH 2/3] modifying test --- tests/sites/base/page2.md | 4 ++-- tests/test_build/test_marginnote.html | 9 ++++++++- tests/test_build/test_sidenote.html | 9 ++++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/tests/sites/base/page2.md b/tests/sites/base/page2.md index 42909a9f..afbaa6b3 100644 --- a/tests/sites/base/page2.md +++ b/tests/sites/base/page2.md @@ -7,13 +7,13 @@ Some text to test out one sidenote[^myref] and another sidenote[^3] [^myref]: This is a sidenote. -[^3]: This is another sidenote. +[^3]: This is *another* **sidenote**. ## Marginnotes Some text to test out one marginnote[^somemargin] and another marginnote[^6] [^somemargin]: {>} This is a marginnote. -[^6]: {>} This is another marginnote. +[^6]: {>} This is *another* **marginnote**. This is the end of Page 2. diff --git a/tests/test_build/test_marginnote.html b/tests/test_build/test_marginnote.html index c2f395c1..9e938124 100644 --- a/tests/test_build/test_marginnote.html +++ b/tests/test_build/test_marginnote.html @@ -37,7 +37,14 @@

6 - {>} This is another marginnote. + {>} This is + + another + + + marginnote + + .

diff --git a/tests/test_build/test_sidenote.html b/tests/test_build/test_sidenote.html index ffaf22b7..6e6ada4f 100644 --- a/tests/test_build/test_sidenote.html +++ b/tests/test_build/test_sidenote.html @@ -37,7 +37,14 @@

3 - This is another sidenote. + This is + + another + + + sidenote + + .

From 2f78b155b1f458636bdd48bfd994cd06322f2cc8 Mon Sep 17 00:00:00 2001 From: AakashGC Date: Wed, 9 Nov 2022 00:26:57 +1100 Subject: [PATCH 3/3] correcting marginnote test --- tests/sites/base/page2.md | 4 ++-- tests/test_build/test_marginnote.html | 32 +++++++-------------------- 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/tests/sites/base/page2.md b/tests/sites/base/page2.md index afbaa6b3..ab500a8b 100644 --- a/tests/sites/base/page2.md +++ b/tests/sites/base/page2.md @@ -13,7 +13,7 @@ Some text to test out one sidenote[^myref] and another sidenote[^3] Some text to test out one marginnote[^somemargin] and another marginnote[^6] -[^somemargin]: {>} This is a marginnote. -[^6]: {>} This is *another* **marginnote**. +[^somemargin]: {-} This is a marginnote. +[^6]: {-} This is *another* **marginnote**. This is the end of Page 2. diff --git a/tests/test_build/test_marginnote.html b/tests/test_build/test_marginnote.html index 9e938124..729b996e 100644 --- a/tests/test_build/test_marginnote.html +++ b/tests/test_build/test_marginnote.html @@ -10,34 +10,18 @@

Some text to test out one marginnote -