[R-pkg-devel] HTML validation error in roxygen2 generated documentation

Ivan Krylov |kry|ov @end|ng |rom d|@root@org
Thu Oct 31 19:06:08 CET 2024


В Thu, 31 Oct 2024 18:04:47 +0100
Nikos Bosse <nikosbosse using gmail.com> пишет:

>  Found the following HTML validation problems:
>  ae_median_quantile.html:79:1 (ae_median_quantile.Rd:41): Warning:
> inserting implicit <p>
> ae_median_quantile.html:79:1 (ae_median_quantile.Rd:41): Warning:
> trimming empty <p>

Thank you for providing the links to the source code!

This can be diagnosed using R CMD Rdconv:

R CMD Rdconv -o ae_median_quantile.html -t html ae_median_quantile.Rd
tidy ae_median_quantile.html >/dev/null

Here are the lines around the problematic part of the HTML document:

-----------------------------------8<-----------------------------------
<h3>Input format</h3>


<div style="text-align: left">
<p><img src="../help/figures/metrics-quantile.png"
style="width:750px;max-width:100%;" alt="metrics-quantile.png" /> </div>


</p> <!-- here: inserting implicit <p>, trimming empty <p> -->
-----------------------------------8<-----------------------------------

This </p> is inserted here by Rd2HTML to terminate the paragraph
started above (I think by \figure if not by \section). Rd2HTML doesn't
know that you started and ended a <div> before this line, which
implicitly ended the previous <p>, which makes the present </p> an
error.

The only way I was able to silence the warning while preserving the
existing tag structure was to make it \out{</div><p>} to start the new
paragraph and provide some text for the auto-inserted </p> to finish
it. Maybe you'll come up with a better fix that doesn't rely on Rd2HTML
auto-inserting the terminating </p>. I'm not sure, but could it help to
set style="text-align: left;..." on \figure itself, without the <div>?

-- 
Best regards,
Ivan



More information about the R-package-devel mailing list