Skip to content
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

References updates #12

Merged
merged 13 commits into from
Apr 4, 2022
Merged

References updates #12

merged 13 commits into from
Apr 4, 2022

Conversation

katamartin
Copy link
Member

@katamartin katamartin commented Mar 24, 2022

This PR makes a few updates to the way references are tracked in order to support some additional features:

  • Automatically number references based on the order in which the inline Cite/Sidenotes are rendered
    • Previously, references.js numbered the references based on the order in which they were threaded through to ReferencesProvider. This (1) relied on object ordering and (2) required consumers to manually sort the references object.
  • Add a PrintedFootnotes section to the bottom of Article which displays a list of references using the Endnote layout (isolated to printing using '@media print')
    • Previously, citation contents were hidden on print because of the mobile styles that are applied.
    • Addresses references point in Improved printing to PDF research#206.
    • See example PDF (also generated using scrambled references and two inline Sidenotes).
  • Support additional, notes added inline via the Sidenote component
    • Allows non-citation notes to be easily added in text. For example, adding:
      ...or macronutrient fertilizers.<Sidenote>Sample custom note defined inline.</Sidenote>
      
      to this line in the seaweed farming article would render:
      Screen Shot 2022-03-24 at 10 16 59 AM

closes carbonplan/research#205

@freeman-lab
Copy link
Member

This looks really clean to me! And super excited for this functionality. Only one question: what happens when a reference is repeated twice? I'm not sure we'll have this often (or ever), but I seem to recall we've avoided it because we were worried it would screw things up.

From a rendering standpoint, I think what we want is if <Cite id='example'/> appears, say, second, it has the superscript number 2 and we have the full citation to the right, and then if <Cite id='example'/> appears again later on in the article, the superscript number 2 appears but we don't repeat the full citation again (because we have it above), and the numbering continues as though there was no repeat. Is that easy to support given this implementation?

Also rename CiteInner sx props for consistency
Also use single hide prop to handle hiding inline reference
@katamartin
Copy link
Member Author

Ah good question! I added in a hide prop, which will allow a repeated citation to be omitted from the inline references. This will have to be added manually for repeated references, which I think is desirable because we currently don't handle scrolling to references.

Also while I was touching the logic that handles groups of IDs, I tweaked the mobile rendering so that all references can be opened inline:
Screen Shot 2022-03-30 at 10 53 00 AM

Previously, this was rendered using 3-6 which we can still use for desktop + printing (see updated example):
Screen Shot 2022-03-30 at 10 58 22 AM

@freeman-lab
Copy link
Member

lgtm! and very nice tweak for mobile, that's smart

@katamartin katamartin merged commit ffb11e8 into main Apr 4, 2022
@katamartin katamartin deleted the katamartin/references-updates branch April 4, 2022 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

improved reference handling
2 participants