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

`sidenotes` don't appear to work #40

Closed
lrdegeest opened this issue Apr 8, 2020 · 20 comments
Closed

`sidenotes` don't appear to work #40

lrdegeest opened this issue Apr 8, 2020 · 20 comments

Comments

@lrdegeest
Copy link

@lrdegeest lrdegeest commented Apr 8, 2020

Love the theme. But it looks like sidenotes:

Any use of a footnote will automatically be converted to a sidenote. ^[This is a sidenote that was entered using a footnote.]

don't seem to work. The sidenote number is printed -- but the note itself isn't.

In your demo, none of the sidenotes are printed: https://eddelbuettel.github.io/tint/tintHTML.html#fn1

@eddelbuettel
Copy link
Owner

@eddelbuettel eddelbuettel commented Apr 8, 2020

That is a left-over of the original Tufte style we started from. In the beginning I wanted to keep the text unchanged.

Of course I changed some style preference along the way.

But maybe it is time to review that. Would you be able to take a second look and maybe make a short list of things that need cleanup. I may have tunnel vision :)

@lrdegeest
Copy link
Author

@lrdegeest lrdegeest commented Apr 8, 2020

The sidenotes issue could be related to a pandoc issue: rstudio/tufte#76

@eddelbuettel
Copy link
Owner

@eddelbuettel eddelbuettel commented Apr 8, 2020

I mostly use pdf mode; the regexp fix is in the html helper function which could explain why I haven't come across this.

@sjoleary
Copy link

@sjoleary sjoleary commented Jul 13, 2020

apparently the fix for this is to line 201 in the html.R file from '<li id="fn([0-9]+)"><p>(.+)<a href="#fnref\\1">.</a></p></li>' to '<li id="%s([0-9]+)"><p>(.+)<a href="#%sref\\1"([^>]*)>.{1,2}</a></p></li>', (https://github.com/rstudio/tufte/pull/76/files/a2dff8970ee54d397af8e8741c470583c1c01f25) .

The issue has to do with the change to pandoc 2.7.3 being the standard pandoc version now distributed with Rstudio.

This is also have the side effect (no pun intended) of the references no longer being transformed into a margin note either when knitting to html. I assume line 221 ids = sprintf('<a href="#%s">([^<]+)</a>', ids) is the culprit but I don't understand how pandoc works sufficiently to be able to figure out how to make the change... ideas?

I almost exclusively use the html version so I don't know if this is an issue with the conversion to pdf as well, now that the pandoc version has changed.

@eddelbuettel
Copy link
Owner

@eddelbuettel eddelbuettel commented Jul 13, 2020

Nice find! Your comment was really hard to read, though. GitHub supports triple-backtick 'diff' notation though and the link helped. I just commited that to tint now and rolled the minor version. Can you try that version and report back?

@sjoleary
Copy link

@sjoleary sjoleary commented Jul 13, 2020

I updated tint using install_github() and now have version 1.2.1; I tried knitting a document with both a sidenote and references; it doesn't appear to have worked.
Yesterday when I was troubleshooting I did try to knit the same document using the developmental version of tufte, there the sidenotes worked now that the minor fix was implemented though the references aren't properly converted to the margin.

@eddelbuettel
Copy link
Owner

@eddelbuettel eddelbuettel commented Jul 13, 2020

That would be 0.1.2.1, but yes. Sorry, but that was all I time for. Maybe you can fetch the html.R pages of both tufte and tint and look a little more closer. There was more delta than just that one regexp line...

@eddelbuettel
Copy link
Owner

@eddelbuettel eddelbuettel commented Jul 14, 2020

Ok, I gave it another spin which seems to work for me here on a sample document processed as tufte::tufte_html and tint::tintHtml. The code is currently in branch feature/html_update and I rolled the minor version once more. Can you possibly try 0.1.2.2 from there?

@eddelbuettel
Copy link
Owner

@eddelbuettel eddelbuettel commented Jul 15, 2020

Now also in master.

@sjoleary
Copy link

@sjoleary sjoleary commented Jul 15, 2020

I gave it a whirl last night - the footnotes now convert to sidenotes, thanks!

The references still don't convert to sidenotes though when converting to html. Using

output: tint::tintHtml
bibliography: SOC.bib
link-citations: yes

in my YAML header I get a similar effect as previously with the footnotes where you still get the inline citation as a "link" (i.e. it's underlined) but when you click on it it doesn't take you to the references.

I have found a work around where adding -

# References
<div id="refs"></div>

At the end of my document adds the references I've used throughout the document and then the citations are hyperlinks that take you to the reference.

@eddelbuettel
Copy link
Owner

@eddelbuettel eddelbuettel commented Jul 15, 2020

Is there are a particular reason you didn't report that back?

Anyway -- fixed in a new branch.

@sjoleary
Copy link

@sjoleary sjoleary commented Jul 15, 2020

yeah - "last night" would probably be more accurately described as "wee hours of the morning" ... so reporting back in the comment above was one of the first things I did this morning.
I realized that I still had the section adding the references at the end of the document, I wasn't sure if that could cause the references not being converted to side notes (like I mentioned the part where/how pandoc does the converting from Rmd to html/other formats is still a bit of a mystery to me). So, I sent rstudio a-knitting and myself to bed ...

@eddelbuettel
Copy link
Owner

@eddelbuettel eddelbuettel commented Jul 15, 2020

I understand how it goes. But thanks for continuing to probe. It seems that subtle changes in pandoc required subtle changes in the R code preparing it -- and package tufte has them so I could just carry them over. Should work now. Give it a spin when you can, and I can update the package in a few days.

@sjoleary
Copy link

@sjoleary sjoleary commented Jul 15, 2020

Yes, the footnotes in the developmental version convert as they should; though references do not.

Using the tufte package to create an html as such

tufte::tufte_html: default

the references do convert into sidenotes as expected.

I dug through the issues/change log to track down the updates that were made; there seems to be two relevant changes, first here and then here; both update the margin_references function (not surprisingly).

I forked a copy of the repository and replaced the margin_references function in the html.R file from the tint package with the most recent code from the tufte package and that did the trick.

@eddelbuettel
Copy link
Owner

@eddelbuettel eddelbuettel commented Jul 15, 2020

Did you look at the most recent version that I was refering to?

image

based on eg this updated input (partial source snippet)

# An Introduction to `tint`

[tint](http://github.com/eddelbuettel/tint) [@cran:tint] updates the look and feel of
'Tufte' documents for R. It combines the (html and pdf parts of the) excellent
[tufte](https://github.com/rstudio/tufte) package [@cran:tufte] with the [Roboto
Condensed](https://fonts.google.com/specimen/Roboto+Condensed) font use and color scheme

Also, I think you continue to underestimate how a collection of code refers to more than commit. Your original #40 (comment) already made that sin, it may make sense for you to realise that there is more involved. I would recommend you stop looking at isolated commits, and, if you can, actually compare (and run code).

@eddelbuettel
Copy link
Owner

@eddelbuettel eddelbuettel commented Jul 15, 2020

Did you look at the most recent version that I was refering to?

Turns out you couldn't as I hadn't pushed that. Ah well. My bad. I gotta concentrate on some other, so if you want to help help beyond the useful nudges you have given consider writing a pull request.

@eddelbuettel
Copy link
Owner

@eddelbuettel eddelbuettel commented Jul 17, 2020

@sjoleary Thanks for all the nudges. The version in the main branch should now be ready. If you have time to give it another go, great -- if not just let me know. It is probably ready for a quick new release.

@sjoleary
Copy link

@sjoleary sjoleary commented Jul 17, 2020

I installed the developmental version (1.2.2) and used it to knit a more complicated document that has references from a *.bib file, footnotes etc. and everything comes out as advertised!
Thanks for taking the time to update everything - I do really enjoy using the tint package; I've always liked the tufte style but since I generally use html files I like the font & design as it works better for screens than a serif font.
While I've become are heavy (and I like to think increasingly sophisiticated) user and big fan of Rmarkdown, I think when it comes to the pandoc converting *.Rmd files to *.html I'm barely at a novice level in understanding the mechanics, so I'm still at a level where I can pinpoint-ish where the issues is but am not quite at the level of being able to figure out the solutions ... I did read up on the mechanics of forking repositories and writing pull requests so maybe next time, I'll push a little farther out of my comfort zone!

@eddelbuettel
Copy link
Owner

@eddelbuettel eddelbuettel commented Jul 17, 2020

Excellent, thanks again for testing, and of course the confirmation!

Will roll this up for CRAN tomorrow or Saturday (as maybe a new RcppArmadillo comes first).

I am still tied to pdf as the final product as ~30 years of latex are hard to undo :) Even if the last five or so were driven from RMarkdown. So I use html less, and this mode fell behind. Because of LaTeX I use \citet{} and friends all the times and [@foo] much less. Another strike against this. But maybe it will grow on me for some things.

As for the mechanics, part of the fun of doing what became the quarted of tint ("Tufte"), binb (Beamer-alike but nicer), pinp (nice pdf vignettes a la PNAS) and linl (letters) was to actually grok what the packages do. This one may be the most complicated. But by working a small framework package -- maybe an rticles extention or new style? -- you can force yourself to walk through.

There are only two or three key gotchas:

  • the style you put in the yaml header is a function in the package: tint::tintHTML
  • you can take that function and "shred it" down to minimal content til it breaks, then see what is left
  • in essence the function "just" prepares the pandoc call (that you also see on the command-line)
  • some of it is hardwired (via rmarkdown and friends)
  • one other piece of magic is how yaml metadata "variables" get picked up in the include template file

It's doable, and if you have a fun project to try, not too bad. Then again, we all have actual real work to do so ... ;-)

@sjoleary
Copy link

@sjoleary sjoleary commented Jul 17, 2020

Thanks for the pointers ... I'll definitely file this away for when I'm ready to go down that rabbit hole!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.