-
Notifications
You must be signed in to change notification settings - Fork 208
NEW: Add sidenote and marginnote syntax #546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
choldgraf
merged 48 commits into
executablebooks:master
from
AakashGfude:footnote-sidenote
May 19, 2022
Merged
Changes from 9 commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
692f2f7
simple sidenote in footnote example
AakashGfude 652f0c9
adding footnote in get started
AakashGfude ec9f164
replacing footnote and footnote reference with sidenote Node
AakashGfude 4c51efc
added use_sidenotes config
AakashGfude 3a955f1
adding comments and checks
AakashGfude 9b128a3
undoing docs changes here
AakashGfude 6c06065
removed use_sidenotes: True
AakashGfude eaad995
added marginnotes as well
AakashGfude 41b52b2
Updating documentation about marginnotes
choldgraf 426d77a
marginnote unique label
AakashGfude bcd7d29
color for clickable buttons
AakashGfude 8743e2f
Merge branch 'master' into footnote-sidenote
AakashGfude 9b2ddca
checking for latexbuilder
AakashGfude b783e9e
checking for html builder
AakashGfude a2ab275
removed latex handling in node
AakashGfude 6b5d97b
formats = html
AakashGfude 73a1da4
testing sidenotes and marginnotes
AakashGfude 8cc71d9
adding pandoc-sidenote in docs
AakashGfude 3195e22
Update docs/content-blocks.md
choldgraf 7db02f1
Merge branch 'master' into footnote-sidenote
choldgraf e1800a6
Merge branch 'master' into footnote-sidenote
choldgraf 83a5bc7
Update docs/content-blocks.md
AakashGfude 75d40af
user-select
AakashGfude fa96ad5
Merge branch 'master' into footnote-sidenote
choldgraf dcfc91d
Merge branch 'footnote-sidenote' of https://github.com/AakashGfude/sp…
AakashGfude ac9dcab
nested footnotes/sidenotes
AakashGfude 593c0a1
Update docs/reference/special-theme-elements.md
AakashGfude bb485b6
reducing indentation
AakashGfude 77e2cdb
Update src/sphinx_book_theme/_transforms.py
AakashGfude 037e36b
Update src/sphinx_book_theme/_transforms.py
AakashGfude ac408dd
merging
AakashGfude 1a4a531
mobile for inside admonition
AakashGfude ff53668
Update src/sphinx_book_theme/_transforms.py
AakashGfude d7d1a0d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 8098e03
Update src/sphinx_book_theme/_transforms.py
AakashGfude 3319a18
Update src/sphinx_book_theme/_transforms.py
AakashGfude a3bfaa8
Update src/sphinx_book_theme/_transforms.py
AakashGfude b11129a
Update src/sphinx_book_theme/assets/styles/content/_margin.scss
AakashGfude a87245f
sidenoteNode docstring, renaming variables in transform, d-none
AakashGfude ceae725
resolving conflicts
AakashGfude f5efddf
added comments for foot_node
AakashGfude cb2da87
Update src/sphinx_book_theme/assets/styles/base/_base.scss
AakashGfude b6a9585
Merge branch 'master' into footnote-sidenote
choldgraf 4282271
d-none
AakashGfude 76aa1d8
keeping d-n for now
AakashGfude d2ea70a
Clean up docs and add examples
choldgraf 9522bce
Popout -> margin
choldgraf 293c8aa
Update src/sphinx_book_theme/assets/styles/base/_base.scss
choldgraf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| from sphinx.transforms.post_transforms import SphinxPostTransform | ||
| from typing import Any | ||
| from docutils import nodes as docutil_nodes | ||
| from .nodes import SideNoteNode | ||
|
|
||
|
|
||
| class HandleFootnoteTransform(SphinxPostTransform): | ||
|
|
||
| default_priority = 1 | ||
|
|
||
| def apply(self, **kwargs: Any) -> None: | ||
| theme_options = self.env.config.html_theme_options | ||
| if theme_options.get("use_sidenotes", False) is True: | ||
AakashGfude marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| for node in self.document.traverse(docutil_nodes.footnote_reference): | ||
| parent = None | ||
| for ftnode in self.document.traverse(docutil_nodes.footnote): | ||
| # matching the footnote reference with footnote | ||
| if ( | ||
| len(ftnode.attributes["backrefs"]) | ||
| and ftnode.attributes["backrefs"][0] | ||
| == node.attributes["ids"][0] | ||
| ): | ||
| parent = ftnode.parent | ||
| text = ftnode.children[1].astext() | ||
|
|
||
| sidenote = SideNoteNode() | ||
| para = docutil_nodes.inline() | ||
| if text.startswith("{-}"): | ||
| # marginnotes | ||
AakashGfude marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| para.attributes["classes"].append("marginnote") | ||
| para.append(docutil_nodes.Text(text.replace("{-}", ""))) | ||
|
|
||
| sidenote.attributes["names"].append("marginnote-role") | ||
| else: | ||
| # sidenotes | ||
AakashGfude marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| label = ftnode.children[0].astext() | ||
|
|
||
| superscript = docutil_nodes.superscript("", label) | ||
| para.attributes["classes"].append("sidenote") | ||
| para.extend([superscript, docutil_nodes.Text(text)]) | ||
|
|
||
| sidenote.attributes["names"].append( | ||
| f"sidenote-role-{label}" | ||
| ) | ||
| sidenote.append(superscript) | ||
| node.replace_self([sidenote, para]) | ||
|
||
| break | ||
| if parent: | ||
| parent.remove(ftnode) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.