Comments (12)
@yihui Is there a straightforward way for us to add this capability to Radix?
from distill.
Those xxx2 formats in bookdown are extensible: https://bookdown.org/yihui/bookdown/a-single-document.html You may try a different base_format
:
output:
bookdown::html_document2:
base_format: ANOTHER_HTML_FORMAT
from distill.
Is there a way we could pull the code out of html_document2? (so that these dependencies and format specification conventions aren't required?)
from distill.
The relevant had been factored out to bookdown:::resolve_refs_html
: https://github.com/rstudio/bookdown/blob/dda5f5a220058271a43ba8b81c6e6859ae3b9815/R/html.R#L136
Instead of letting other package authors use this function in their output formats (in the post-processors), I think it may be easier for users to specify a base_format
in bookdown::html_document2
.
from distill.
It's just not super-intuitive to explain to users that in order to add this feature they should not use the format you've documented extensively elsewhere but instead "switch to bookdown" and specify a base format.
Would it be enough to just export the resolve_refs_html()
function? Alternatively, I wonder if radix_article could just do the base_format
composition itself under the hood?
from distill.
Yes, I can export the function. Then you will have to call it in your post-processor.
from distill.
Okay, that would be great!
from distill.
@yihui A reminder to export the resolve_refs_html()
function from bookdown.
from distill.
Done.
from distill.
I am trying to use this and am not getting the results I expect. Specifically, when I run the radix generated HTML through the function it fails to find the figure labels. I've attempted to simplify this to a minimal reproducible case as follows:
html <- '
<div class="figure">
<img src="plot.png" alt="Cars analysis" width="672" />
<p class="caption">
Cars analysis
</p>
</div>
<p>See Figure @ref(fig:plot1).</p>
'
cat(bookdown:::resolve_refs_html(html, global = TRUE))
## Warning: The label(s) fig:plot1 not found
##
## <div class="figure">
## <img src="plot.png" alt="Cars analysis" width="672" />
## <p class="caption">
## Cars analysis
## </p>
## </div>
##
## <p>See Figure <a href="#fig:plot1"><strong>??</strong></a>.</p>
This appears to be correctly handled with html_document2 (i.e. the span with id
is inserted within the figure div) but the same HTML appears to not work here.
I am speculating that there might be some additional side effects of rendering that resolve_refs_html()
is relying upon? (e.g. a lookup table of chunk labels).
from distill.
After this line: https://github.com/rstudio/radix/blob/27b482a21b6cba1c21752abdcd6b55ff5e083218/R/radix_article.R#L69
Try to add:
knitr_options$opts_knit$bookdown.internal.label <- TRUE
I guess that should work.
from distill.
Yes, that does indeed work!
This has now been implemented here: rstudio/radix@1179466
Docs are here: https://rstudio.github.io/radix/figures.html#cross-references
from distill.
Related Issues (20)
- Upkeep for distill
- Check and add alt-text to pictures, plots, ... in website
- invalid byte sequence when deploying to github HOT 3
- RSS category-based feeds HOT 1
- Creative Commons Markdown Table Not Rendering Properly
- Warning due to deprecation of 'format' argument to 'as.character.POSIXlt()' HOT 2
- Description in _site.yaml causing Error "STRING_ELT() can only be applied to a 'character vector', not a 'list'" HOT 1
- How to add email and multiple affiliations to a single author? HOT 2
- Article description does not show up when adding posts HOT 1
- Improve alt-text for ORCiD icon HOT 3
- Add <hr> for screen reader accessibility HOT 1
- Space between lines in bulleted lists HOT 1
- Various minor accessibility issues
- Release distill 1.6
- Gallery outdated, remove Quarto pages HOT 1
- Javascript & D3 page error HOT 1
- Journal (site) title is incorrectly prepended to the article title in cititations.
- Has anyone used any alternative to Google analytics? HOT 4
- italicized species names in a Rmarkdown distill package
- Using a `distill` vignette on CRAN HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from distill.