GeoBosh / Rdpack

R package Rdpack provides functions and macros facilitating writing and management of R documentation.
https://geobosh.github.io/Rdpack/
28 stars 6 forks source link

Spaces after rendered citations #33

Open ms609 opened 6 months ago

ms609 commented 6 months ago

\insertCite{Smith2019;textual}{Quartet}. renders a breaking whitespace between the citation and the ensuing full stop. (This can be particularly ugly where the full stop wraps onto the following line.) image

Potentially related, if less obviously an error, is the addition of a space after DOIs in rendered citations (but not after URLs, or other endings of a citation): image

Not sure whether this is an Rdpack issue, or something further downstream?

GeoBosh commented 6 months ago

Thanks for the report. It doesn't matter if it is in Rdpack or downstream, I will chase it down.

GeoBosh commented 1 day ago

This seems to happen in html but not in pdf, am I right?

ms609 commented 1 day ago

Yes, this is an HTML issue; I can't build the PDF right now to see whether the issue arises there too.

GeoBosh commented 1 day ago

For the previous comment, I was looking at the pages created by pkgdown, where I observed the redundant spaces before the final full stop.

On the other hand, the rendered R documentation doesn't have these. For example,

?QuartetStatus
help(QuartetStatus, help_type = "html")

We can see also that there are no redundant spaces before the full stop by printing the object in "html" format:

library("rbibutils")
Quartet_bibpath <- system.file("REFERENCES.bib", package = "Quartet")
Quartet_bib <- readBib(Quartet_bibpath, direct = TRUE)
> names(Quartet_bib)
## [1] "Bluis2003"       "Bocker2013"      "Bogdanowicz2012" "Bogdanowicz2013" "Bogdanowicz2017"
## [6] "Brodal2013"      "Day1986"         "Estabrook1985"   "Holt2014"        "Kullback1951"   
## [11] "Marczewski1958"  "Nye2006"         "Penny1985"       "Robinson1981"    "Sand2014"       
## [16] "Smith2019"       "Smith2020"       "Smith2022"       "Steel1993"       "Ternary"        
## [21] "TreeSearch"     

Quartet_bib[["Smith2019"]]
## Smith MR (2019). "Bayesian and parsimony approaches reconstruct informative trees from
## simulated morphological datasets." _Biology Letters_, *15*(2), 20180632.
## doi:10.1098/rsbl.2018.0632 <https://doi.org/10.1098/rsbl.2018.0632>,
## <https://doi.org/10.1098/rsbl.2018.0632>.

print(Quartet_bib[["Smith2019"]], style = "html")
## <p>Smith MR (2019).
## &ldquo;Bayesian and parsimony approaches reconstruct informative trees from simulated morphological datasets.&rdquo;
## <em>Biology Letters</em>, <b>15</b>(2), 20180632.
## <a href="https://doi.org/10.1098/rsbl.2018.0632">doi:10.1098/rsbl.2018.0632</a>, <a  href="https://doi.org/10.1098/rsbl.2018.0632">https://doi.org/10.1098/rsbl.2018.0632</a>. 
## </p>

print(Quartet_bib[["Holt2014"]], style = "html")
## <p>Holt MK, Johansen J, Brodal GS (2014).
## &ldquo;On the scalability of computing triplet and quartet distances.&rdquo;
## In <em>Proceedings of 16th Workshop on Algorithm Engineering and Experiments (ALENEX) Portland, Oregon, USA</em>. 
## </p>

Here is a snipped from the reference page for QuartetStatus generated by pkgdown:

<html>
<body>
<!--StartFragment-->
<p>Brodal GS, Fagerberg R, Mailund T, Pedersen CNS, Sand A (2013).
--
  | ...
  | <a href="https://doi.org/10.1137/1.9781611973105.130" class="external-link">doi:10.1137/1.9781611973105.130</a>
  | .<br><br> Estabrook GF, McMorris FR, Meacham CA (1985).
  | “Comparison of undirected phylogenetic trees based on subtrees of four evolutionary units.”
  | <em>Systematic Zoology</em>, <b>34</b>(2), 193–200.
  | <a href="https://doi.org/10.2307/2413326" class="external-link">doi:10.2307/2413326</a>
  | .<br><br> Holt MK, Johansen J, Brodal GS (2014).
  | “On the scalability of computing triplet and quartet distances.”
  | In <em>Proceedings of 16th Workshop on Algorithm Engineering and Experiments (ALENEX) Portland, Oregon, USA</em>.<br><br> Sand A, Holt MK, Johansen J, Brodal GS, Mailund T, Pedersen CNS (2014).
  | “tqDist: a library for computing the quartet and triplet distances between binary or general trees.”
  | <em>Bioinformatics</em>, <b>30</b>(14), 2079–2080.
  | ISSN 1460-2059, <a href="https://doi.org/10.1093/bioinformatics/btu157" class="external-link">doi:10.1093/bioinformatics/btu157</a>
  | .</p>

<!--EndFragment-->
</body>
</html>

We see that the DOI links are on lines of their own, enclosed in <a>. The dots following them are on new lines. I think that the new lines count as white space, which is then put between before the dot in the rendered page.

Does this analysis seem correct?

ms609 commented 1 day ago

Yes, the new line before the . would render as a space – I think that explains the behaviour.