Repository navigation
Conversation
Bootstrap CSS shipped by `rmarkdown::html_document()` styles the blockquote footer (em-dash prefix, grey small text) but does not right-align it. Add an inline `text-align: right` so the visual intent of `quote_footer()` carries to non-tufte HTML formats. Bootstrap 4 and 5 (via `bslib::bs_theme()`) replaced the `blockquote footer` element selector with a class-based `.blockquote-footer` selector. Tag the emitted `<footer>` with that class so BS4/5 themes apply the same styling as BS3. Also silence the "only works for HTML and LaTeX" warning when `knitr::pandoc_to()` is NULL, so callers can use `quote_footer()` unconditionally in inline R expressions evaluated outside a pandoc context.
Lock file pins installed agent skills (posit-dev/skills) so the set is reproducible across clones. The .claude/ and .agents/ directories hold copies of those skills and are personal/transient — gitignored, and R-build-ignored to keep R CMD build output clean.
…tputs
`quote_footer()` previously emitted whatever `text` the caller supplied
verbatim, leaving the em-dash story to each format's CSS or to pandoc's
smart-punct extension. This produced different visual output for the same
R call across tufte HTML, non-tufte HTML, and LaTeX outputs. In
particular, the pattern shown in the R Markdown documentation,
`quote_footer('--- Joe Martin')`, rendered as a doubled em-dash
(`-- --- Joe Martin`) in `html_document()` because Bootstrap's
`blockquote footer::before` rule already injects an em-dash.
Detect a leading `"---"` (or em-dash) in `text` and branch on whether
the active output is a tufte format. The tufte output formats now
register a `tufte.format` entry in `knitr::opts_knit` so
`quote_footer()` can read it without heuristics, mirroring the pattern
used by `rmarkdown` for its own `rmarkdown.*` opts_knit entries.
- non-tufte HTML: strip the leading `"---"` so Bootstrap CSS does not
double the em-dash;
- tufte HTML: insert an em-dash + non-breaking space in the markup,
since `tufte.css` has no `::before` rule;
- LaTeX (tufte or non-tufte): preserve the leading `"---"` so pandoc's
smart-punct extension converts it to an em-dash glyph.
Add a `local_knit_opts()` test helper that temporarily sets
`knitr::opts_knit` entries via `withr::defer`, and use it to exercise
the new tufte-vs-non-tufte branch in `quote_footer()`. Switch the
remaining `expect_false(grepl(...))` calls to `expect_no_match()`.
- DESCRIPTION: add missing trailing comma after `xml2` in `Suggests`.
Without it `read.dcf()` parses `xml2` and `bookdown` as a single
malformed dependency, breaking R CMD check (review job 1206).
- `quote_footer()`: detect an active `bslib::bs_theme()` via
`bslib::bs_current_theme()` instead of unconditionally stripping a
leading `"---"` for all non-tufte HTML outputs. The unconditional
strip silently dropped the em-dash for `html_document(theme = NULL)`
and other non-Bootstrap HTML formats (ioslides, slidy, custom
frameworks, ...), since no CSS rule replaced the stripped marker.
Three HTML branches now:
- Tufte HTML: emit `<footer>` with an em-dash glyph injected in markup
(unchanged).
- Non-tufte HTML with bslib (Bootstrap 4/5) active: strip the `"---"`
and emit `<footer class="blockquote-footer">` so the
`.blockquote-footer::before` rule supplies the em-dash exactly once.
- All other HTML (Bootstrap 3 default `html_document`, `theme: null`,
ioslides, slidy, ...): emit `<p>` with the em-dash glyph injected in
markup. `<p>` is chosen rather than `<footer>` to avoid Bootstrap 3's
`blockquote footer::before` rule doubling the em-dash for callers
following the documented `quote_footer('--- Author')` pattern.
Add `bslib` to `Suggests` so `R CMD check` recognises the namespace
reference; the call to `bslib::bs_current_theme()` is wrapped in
`tryCatch()` for robustness when the package is absent.
Add integration tests rendering `quote_footer('--- Author')` in
`html_document` with default theme, `theme = NULL`, and bslib BS4,
asserting that the rendered footer contains an em-dash but not a
literal `"---"` in each case (review job 1209).
The bslib-based detection introduced in 9a811ec covered Bootstrap 4/5 via `bslib::bs_current_theme()` but had no signal for the legacy Bootstrap 3 default theme (which doesn't go through bslib). The fallback `<p>` branch silently dropped Bootstrap's CSS-supplied em-dash for the `quote_footer('Author')` (no leading dash) case in `html_document(theme = "default")` — a regression for the rmarkdown default. Revert to the simpler unconditional strip from cf58d41: non-tufte HTML emits `<footer class="blockquote-footer">` with the leading `"---"` stripped, relying on Bootstrap CSS (`::before` on either the `blockquote footer` element selector in BS3 or the `.blockquote-footer` class selector in BS4/5) to supply the em-dash. Known limitation (review job 1209): when the active HTML output ships no Bootstrap CSS (e.g. `html_document(theme = NULL)`, ioslides, slidy, custom HTML frameworks), the em-dash is silently dropped. Detecting this reliably requires distinguishing legacy BS3 default from non-Bootstrap formats at knit time, which has no clean signal — bslib returns NULL for both. The trade-off favours not regressing the common BS3-default case. Keep the DESCRIPTION trailing-comma fix from 9a811ec (review job 1206); drop `bslib` from `Suggests` since it is no longer referenced.
R CMD check warns on non-ASCII characters in R source. Replace the literal em-dash in the dash_pattern regex and the em-dash + nbsp prefix literal with — / escapes, and rewrite the comment glyph in plain English. No behaviour change.
The original issue reported that a markdown citation passed to
quote_footer() rendered literally (un-converted) in beamer with
citation_package: natbib. The behaviour passes on current pandoc; lock
it with three tests:
- Unit-level: assert pandoc emits \citep when given quote_footer()'s
LaTeX output (--natbib path, no TinyTeX required).
- Integration: render tufte_handout and beamer_presentation with
natbib + a citation inside quote_footer(), assert the kept .tex
contains both \hfill and \citep[3]{dorian10}.
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
quote_footer()produced inconsistent output across formats:rmarkdown::html_document()andbslib::bs_theme()themes(Bootstrap 3/4/5), the footer was not right-aligned because
Bootstrap's CSS styles
blockquote footerwithouttext-align: right.blockquote footerto the.blockquote-footerclass, so the bare<footer>emitted byquote_footer()received no Bootstrap stylingat all (no em-dash, no grey small text).
quote_footer('--- Author')pattern shown in the R Markdown bookrendered as a doubled em-dash (
— --- Author) in non-tufte HTML,because Bootstrap's
::beforerule injects an em-dash on top of thecaller's literal
---.Fix
quote_footer()now emits<footer class="blockquote-footer" style="text-align: right;">for non-tufte HTML. The class matches Bootstrap 4 and 5; Bootstrap 3 still styles the same element via itsblockquote footerselector; tufte's own CSS is unaffected because it also targetsblockquote footer.To render an em-dash consistently across all outputs, the helper now strips a leading
"---"(or em-dash) fromtextand branches per destination:::beforeem-dash is not doubled;tufte.csshas no::beforerule;"---"so pandoc's smart-punctuation extension converts it to an em-dash glyph.tufte_html()andtufte_pdf()now register atufte.formatentry inknitr::opts_knitsoquote_footer()can detect whether it is being called from a tufte format without resorting to heuristics. This mirrors thermarkdown.*entries thatrmarkdown::render()already sets inopts_knit.The "only works for HTML and LaTeX output" warning is silenced when
knitr::pandoc_to()returnsNULL, soquote_footer()can be used unconditionally in inline R expressions evaluated outside a pandoc context.Test Plan
Most output is asserted in
tests/testthat/test-utils.R(structural checks via xml2). Reviewer eyeball items:`r tufte::quote_footer('--- Joe Martin')`in a renderedhtml_document()(default Bootstrap 3) and in abslib::bs_theme()Bootstrap 5 theme (only BS4 is exercised in tests).--- Joe Martinrenders as— Joe Martininpdf_document()andtufte_handoutoutputs (relies on pandoc's smart-punct conversion, which is not asserted in tests).Fixes #73