Using lyxhtml_validity.py

Thibaut Cuvelier dourouc05 at gmail.com
Sat Jan 7 02:59:54 UTC 2023


On Sat, 31 Dec 2022 at 10:37, Kornel Benko <kornel at lyx.org> wrote:

> Hi Thibaut,
> I started to integrate (a modified) version of lyxhtml_validity.py.
> But I am getting errors like in the attached.
>

Hi Kornel,

It may very well be the latest patches I got for XHTML that trigger
different code paths for the validator (I haven't run it yet since the
switch to XHTML 5): some errors and warnings are related to the conversion
to XHTML5, others just didn't trigger before.

Error: Bad value "en_US" for attribute "lang" on element "html": The
language subtag "en_us" is not a valid language subtag.
This problem should be fixed by switching lib/languages' LangCode to BCP47,
as suggested as a TODO in the comments. I implemented a quick fix in
26e6b1c2. As these are the only two places in LyX where the conversion is
needed, I believe it is sufficient for now.

Error: Bad value "Content-type" for attribute "http-equiv" on element
"meta".
The value must be in lower case, i.e. "content-type" (
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta). This is
fixed at cabb12ba.

Error: A document must not include both a "meta" element with an
"http-equiv" attribute whose value is "content-type", and a "meta" element
with a "charset" attribute.
I removed one occurrence (the charset, because it is the newest and has the
worst support among ancient browsers, pre-2010 roughly, and I had to pick
one).

Error: CSS: "font-weight": "medium" is not a "font-weight" value.
That one is more tricky, it's a problem when defining a style. That's fixed
as of 4c1f9d11.

Warning:  The "type" attribute for the "style" element is not needed and
should be omitted.
Not an error per se, but removing the deprecated argument shouldn't be a
problem even for ancient browsers (only CSS was ever implemented, after
all). https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style Fixed
at fb4a2657.

Warning: Section lacks heading. Consider using "h2"-"h6" elements to add
identifying headings to all sections.
Not a serious error, but semantically the XHTML code could be much better
(that could help with accessibility, for instance). Here is an excerpt for
the Tufte example you are using:
    <section>
      <div class='chapter' id='magicparlabel-21'>The Features of the
Tufte-book Class</div>
This <div> really should be a <hSOMETHING>. I'm implementing a change in
the layouts themselves for this (051c5f27). The other possibility would be
to change Layout::htmltag() to return hX instead of div for sectioning
elements, based on toclevel; the problem is that we would need to convert
toclevel to an integer between 1 and 6. I remember seeing horrible values
(including -1000, but also -1 for Beamer parts and other layouts), making
me wary: is it possible to write simple code that works automagically for
every interesting case?

In any case, the script works as expected :)!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20230107/536a6df2/attachment-0001.html>


More information about the lyx-devel mailing list