Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRAN checks produce HTML validation errors #30

Closed
mihaiconstantin opened this issue Sep 9, 2022 · 1 comment
Closed

CRAN checks produce HTML validation errors #30

mihaiconstantin opened this issue Sep 9, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@mihaiconstantin
Copy link
Owner

mihaiconstantin commented Sep 9, 2022

Upon submitting to CRAN, the following NOTE was produced:

- checking HTML version of manual ... [0s/1s] NOTE
    Found the following HTML validation problems:
    plot.Method.html:107:1: Warning: inserting implicit <p>
    plot.Method.html:112:1: Warning: inserting implicit <p>
    plot.Method.html:118:1: Warning: inserting implicit <p>
    plot.StepOne.html:86:1: Warning: inserting implicit <p>
    plot.StepThree.html:86:1: Warning: inserting implicit <p>
    plot.StepTwo.html:86:1: Warning: inserting implicit <p>
    plot.Validation.html:92:1: Warning: inserting implicit <p>

The issue seems to be with the \if{html}{...} parts in the documentation.

Take, for example, the following code (i.e., at 7e068a9) in file plot-Validation.R:

#' \if{html}{
#' Example of a validation plot:
#'
#' \out{<div style="text-align: center">}
#' \figure{example-validation.png}{options: style="width: 640px; max-width: 90\%;" alt="Example Validation"}
#' \out{</div>}
#' }

First, regenerate the ./man/plot.Validation.Rd file via, e.g., devtools::document(). Then, parse the .Rd file to HTML via tools::Rd2HTML("./man/plot.Validation.Rd"). The HTML output looks like this (i.e., indentation preserved):

<!-- ... -->

<p>Example of a validation plot:
</p>
<div style="text-align: center">
<p><img src="../help/figures/example-validation.png" style="width: 640px; max-width: 90%;" alt="Example Validation" />
</div>

</p>

<!-- ... -->

Note that the empty line below the #' Example of a validation plot: line confuses the parser, which closes the <p> tag. Also, according to HTML semantics it is not valid to have block-level content between <p>...</p>.

The problem seems to go away by removing the empty line mentioned above, which will result in the following HTML:

<!-- ... -->

<p>Example of a validation plot:
<div style="text-align: center">
<img src="../help/figures/example-validation.png" style="width: 640px; max-width: 90%;" alt="Example Validation" />
</div>

</p>

<!-- ... -->
@mihaiconstantin mihaiconstantin self-assigned this Sep 9, 2022
@mihaiconstantin mihaiconstantin added the bug Something isn't working label Sep 9, 2022
@mihaiconstantin mihaiconstantin moved this to Backlog in powerly Sep 9, 2022
Repository owner moved this from Backlog to Done in powerly Sep 9, 2022
Repository owner moved this from Done to Todo in powerly Sep 9, 2022
@mihaiconstantin
Copy link
Owner Author

This does not solve the issue. The tidy utility (i.e., html-tidy.org) still produces a warning when ran against the following HTML:

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Test</title>
</head>
<body>
    <p>
        Example of a validation plot:
        <div style="text-align: center">
            <img src="../help/figures/example-validation.png" style="width: 640px; max-width: 90%;" alt="Example Validation" />
        </div>
    </p>
</body>
</html>

Namely:

line 12 column 5 - Warning: inserting implicit <p>

The same can be observed from the online HTML validator at validator.w3.org, which produces:

CleanShot 2022-09-09 at 14 55 34@2x

The issue seems due to placing a div element inside the p element. This is not allowed since it is not semantically correct.

One way around this is to replace:

<p>
    Example of a validation plot:
    <div style="text-align: center">
        <img src="../help/figures/example-validation.png" style="width: 640px; max-width: 90%;" alt="Example Validation" />
    </div>
</p>

with:

<p>
    Example of a validation plot:
    <span style="display: block; text-align: center;">
        <img src="../help/figures/example-validation.png" style="width: 640px; max-width: 90%;" alt="Example Validation" />
    </span>
</p>

Repository owner moved this from Todo to Done in powerly Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

1 participant