NEW: Add sidenote and marginnote syntax#546
NEW: Add sidenote and marginnote syntax#546choldgraf merged 48 commits intoexecutablebooks:masterfrom
Conversation
|
@AakashGfude I have been taking a look at this PR in addition to #523 and from a
To me this flow seems more logical rater than overloading the |
|
Thanks, @mmcky, that sounds like a reasonable way to go. I will approach it that way and see how it feels. |
|
made changes, and updated the top description. |
choldgraf
left a comment
There was a problem hiding this comment.
This is looking nice! Much cleaner than having lots of new roles/directives, I think. A few quick thoughts:
- I pushed a commit that added the extra docs from your other PR, and updated them a bit for this new syntax.
- I updated the "marginnote" prefix to
{-}instead of{>}to be in-line with what the pandoc-sidenotes extension uses. - I've added some example usage in our reference docs as well so we can show off the behavior there.
- I noticed that having multiple marginnotes in the same sentence does not work on mobile screens, I think it's because the
foris pointing to the same thing in both cases, can you fix that? - I think that it'd be good to have some visual cue that the numbers/symbols are "clickable" on mobile - maybe they can still be blue? Or some other way to suggest they can be clicked?
|
Thank you so much @choldgraf, for the additions, very helpful.
Have pushed the fix now.
Yes, I think the original color (blue) seems like a good option. As the user is already used to assuming that it is a clickable reference? Have pushed the change. Let's see how it feels. |
|
I think the current implementation is pretty good to me. The behavior is nearly identical to how pandoc-sidenotes works, so we're not reinventing the wheel from a UX perspective or anything. One thing I noticed: If you have a marginnote in between two sidenotes, it still takes up a "number" even though it is not actually numbered (so the sidenotes will jump from 1 to 3 even though there is no 2). Is that easy to fix? If not it's not a blocker on this PR in my opinion. Actually while we're at it, we might as well note in the docs that the UX of this is inspired by pandoc-sidenote (https://github.com/jez/pandoc-sidenote) |
ooh yeah, it's because we are converting footnotes to sidenotes/margin notes and using the numbering of footnotes. margin notes were also footnotes and had a number. |
Co-authored-by: Chris Holdgraf <choldgraf@gmail.com>
for more information, see https://pre-commit.ci
Co-authored-by: Chris Holdgraf <choldgraf@gmail.com>
Co-authored-by: Chris Holdgraf <choldgraf@gmail.com>
Co-authored-by: Chris Holdgraf <choldgraf@gmail.com>
Co-authored-by: Chris Holdgraf <choldgraf@gmail.com>
Co-authored-by: Chris Holdgraf <choldgraf@gmail.com>
|
@choldgraf I think you will be the best person to resolve the conflict, as you had written the doc file. :) |
|
OK I think I fixed up the docs conflict, wanna take a look and let me know if it reads OK to you? Other than that, anything else you'd like to tackle here? |
|
@choldgraf the doc looks good to me. Thank you! Else I think rest is good. |
choldgraf
left a comment
There was a problem hiding this comment.
OK this looks good to me - let's merge it in and see how folks like using it, and we can iterate from there!
|
Thanks very much @AakashGfude for this addition! |
|
Thank you, @choldgraf. |
Taking @mmcky and @choldgraf's comments into account. Implemented the sidenote and marginnote using footnote syntax as the first step. Changing footnote nodes to sidenote and inline element nodes in a post-transform. This does not create any new syntax to write sidenotes and uses the already available footnote syntax. To convert all footnotes to sidenotes, the config variable is -
use_sidenotes: Trueunderhtml_theme_options. To convert a sidenote to marginnote (i.e. not haveing superscripted numbers), use{>}at the start of the footnote source text (similar syntax was first proposed in #523 (comment)).Example:
Source Code:
Footnote:
Sidenote:
When modifying the above source code with:
The output is:
Note that sidenotes do not support any directives inside it as it is an inline element. Tufte also uses inline span elements. The reason span makes more sense than aside in my opinion is mentioned in the 31st March description below.
NOTE: The functionality of clickable text/icon on smaller screens as was implemented in #523, is also present in this PR.
31st march
Was trying to implement sidenote leveraging the footnote code and syntax as discussed in #523 . I tried going through the docutils code, where the footnote is implemented.
I have a few concerns which I wanted to discuss:
the insertion of
footnotenode in the document happens during the parsing phase I think. And possibly the only place to rearrange the document to make thefootnotenode move near thefootnote-referenceis during a post-transform.It was much easier to deal with
spanelements we generated here A simple sidenote, marginnote functionality #523 for sidenotes, and which Tufte CSS uses as well, to position the sidenote. Asspancan go inside aptag, and other similar tags, which will have the sidenote reference inside it. And so relative positioning is pretty straightforward. Theasidetag on the other hand, when trying to insert inside a 'p' tag in post-transform, does not work, and it is always inserted after theptag, which makes it hard to position.cc: @choldgraf @chrisjsewell @mmcky @rowanc1