rstudio / pagedown

Paginate the HTML Output of R Markdown with CSS for Print
https://pagedown.rbind.io
Other
892 stars 128 forks source link

Fix LOT / LOF with Pandoc 2.17+ #281

Closed cderv closed 2 years ago

cderv commented 2 years ago

This close #280

For context, Release note is telling us the issue (https://pandoc.org/releases.html#pandoc-2.17-2022-01-12)

Functions of name Doc are no longer accepted as alternatives for Pandoc filter functions. This functionality was undocumented.

It seems just renaming is ok.

I'll wait for the test to run, and try to add some test to check LOT / LOF are correctly present in our resulting documents.

I'll merge once done.

cderv commented 2 years ago

@yihui is this ok to you to add xml2 as Suggest so that we can use it in tests ? It is helpful for testing HTML content without regex

Otherwise it is good to merge.

cderv commented 2 years ago

BTW the two failures in CI are from #270 and yet to be fixed sometime

adamvi commented 2 years ago

Thank you all for working on this so quickly!

I tested this morning on my example report scripts and it worked for my use case 👏 I think for the vast majority of others' use cases it will work too, however, I had first tried it using my example with the skeleton.Rmd and saw a potentially lingering issue.

Running the (YAML modified) skeleton produced the ToC entry and LoF page correctly, but there were no items under the "Figures" (with 3 images placed in the text). The LoT was created perfectly. It appears as though there are some differences in how the LoT and LoF items are identified in the LUA filter, which may be the issue. Lot has this additional piece:

-- test the presence of a bookdown table id
  found = string.find(caption, "%(#tab:.*%)")

whereas the LoF does not search for #fig:. I think this may work in my example because I'm using knit::include_graphics while the skeleton uses a simple addition of markdown script ![(#fig:ABCXYZ)The R logo.](...). This works in my example even with unnamed chunks that don't have an id or @Ref, so I'm assuming there's something in the include_graphics pixie dust that is supplied/required and not present in the simple markdown figure code...

Not sure if this is a bug or a feature, but wanted to point it out for fixing/documentation and to THANK YOU again!

cderv commented 2 years ago

Good catch ! We should probably fix support for figure - that seems like a bug ! 😅

cderv commented 2 years ago

In fact it seems like something not supported at all considering how the Lua filter works. I opened another issue to track.