diff --git a/DESCRIPTION b/DESCRIPTION index 86680171..9915c4ac 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: distill Title: 'R Markdown' Format for Scientific and Technical Writing -Version: 1.3.7 +Version: 1.3.8 Authors@R: c( person("JJ", "Allaire", , "jj@rstudio.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-0174-9868")), diff --git a/NEWS.md b/NEWS.md index 5dcee78f..bd793c2d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,6 @@ # distill (development version) +- Footnotes inserted in tables have now their tooltip correctly place (thanks, \\\@RMRubert, #411). - Fix an issue with Leaflet Markers not showing when using non default layout (thanks, \\\@AndersFenger, #106). - `code_folding = FALSE` set on a chunk is now correctly taken into account and does not enforce `echo = TRUE`. As a reminder, setting `code_folding: true` in YAML header will enforce `echo = TRUE` on chunk, unless `code_folding` is unset on a per-chunk basis (thanks, \\\@werkstattcodes, #297). - `create_website()` now works when no `dir` is provided and prompted to user. diff --git a/inst/rmarkdown/templates/distill_article/resources/distill.html b/inst/rmarkdown/templates/distill_article/resources/distill.html index 259cc4a2..4f89bb0c 100644 --- a/inst/rmarkdown/templates/distill_article/resources/distill.html +++ b/inst/rmarkdown/templates/distill_article/resources/distill.html @@ -1161,6 +1161,31 @@ }); }); + // fix footnotes in tables (#411) + // replacing broken distill.pub feature + $('table d-footnote').each(function() { + // we replace internal showAtNode methode which is triggered when hovering a footnote + this.hoverBox.showAtNode = function(node) { + // ported from https://github.com/distillpub/template/pull/105/files + calcOffset = function(elem) { + let x = elem.offsetLeft; + let y = elem.offsetTop; + // Traverse upwards until an `absolute` element is found or `elem` + // becomes null. + while (elem = elem.offsetParent && elem.style.position != 'absolute') { + x += elem.offsetLeft; + y += elem.offsetTop; + } + + return { left: x, top: y }; + } + // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetTop + const bbox = node.getBoundingClientRect(); + const offset = calcOffset(node); + this.show([offset.left + bbox.width, offset.top + bbox.height]); + } + }) + // clear polling timer clearInterval(tid); diff --git a/tests/manual/footnotes-in-tables.Rmd b/tests/manual/footnotes-in-tables.Rmd new file mode 100644 index 00000000..69dd7603 --- /dev/null +++ b/tests/manual/footnotes-in-tables.Rmd @@ -0,0 +1,22 @@ +--- +title: "Footnotes inside tables" +date: 04-05-2022 +output: distill::distill_article +--- + +Example of using footnotes inside tables. The tooltip should be correctly placed below the hovered text. Like footnotes in paragraph[^1] + +[^1]: like this + +| Genre | Songs | Form Song | +|:----------------:|:-----:|:-----------------------------------:| +| alternative rock | 393 | Muse - Resistance | +| ambient[^2] | 19 | Mauro Picotto - Adiemus | +| blues | 11 | Leonard Cohen - Suzanne | +| classic rock | 710 | Dire Straits - Sultans of Swing[^3] | + +[^2]: Test 2 + +[^3]: Some other content + +> From issue diff --git a/tests/manual/footnotes-in-tables.html b/tests/manual/footnotes-in-tables.html new file mode 100644 index 00000000..1259e16e --- /dev/null +++ b/tests/manual/footnotes-in-tables.html @@ -0,0 +1,2588 @@ + + + + + + + + + + + + + + + + + + + + + Footnotes inside tables + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Footnotes inside tables

+ + + +
+ + +
+

Example of using footnotes inside tables. The tooltip should be +correctly placed below the hovered text. Like footnotes in paragraph1

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
GenreSongsForm Song
alternative rock393Muse - Resistance
ambient219Mauro Picotto - Adiemus
blues11Leonard Cohen - Suzanne
classic rock710Dire Straits - Sultans of Swing3
+
+

From issue https://github.com/rstudio/distill/issues/411

+
+
+
+
+
    +
  1. like this↩︎

  2. +
  3. Test 2↩︎

  4. +
  5. Some other content↩︎

  6. +
+
+ + +
+ +
+
+ + + + + +
+ + + + + + +