Invalid XHTML: type="text/css" missing
stroobandt opened this issue · 23 comments
When converting to XHTML, pandoc-eqnos
adds the following code to the <head>
of the document:
<!-- pandoc-eqnos: equation style -->
<style>
.eqnos { display: inline-block; position: relative; width: 100%; }
.eqnos br { display: none; }
.eqnos-number { position: absolute; right: 0em; top: 50%; line-height: 0; }
</style>
The W3C XHTML validator evaluates the second line as erroneous: required attribute "type" not specified
. For the XHTML document to be valid, the second line should read:
<style type="text/css">
For HTML5, it is the other way around. <style>
is preferred, whereas <style type="text/css">
results in a warning, but not an error.
Error-free conversion to valid XHTML remains important for unattended typesetting of paged media with, for example, PrinceXML.
In the default pandoc
(X)HTML template, the above problem is circumvented as follows:
<style$if(html5)$$else$ type="text/css"$endif$>
I have put a single, relatively simple page on my website into production with the pandoc-xnos
suite. It serves as a demonstrator until the most pressing (X)HTML bugs get sorted.
Here is the XHTML validation error caused by pandoc-eqnos
.
Above pull request resolves this issue, and the additional fact that format html4
was not taken into account in at least pandoc_eqnos.py
.
Nonetheless, pandoc-xnos
may also not be recognising format html4
.
This is great, thank you. I have merged your changes into the nextrelease
branch. I further added in the special processing for html4 versus html/html5. I also added an html4 target to pandoc-fignos
and pandoc-tablenos
.
Should there be a problem following the next release, please feel welcome to re-open.
Cheers,
Tom
pandoc-eqnos 2.2.0 is now released. --Tom
I am afraid this issue requires reopening. I tested this with:
$ pip3 show pandoc-eqnos
Name: pandoc-eqnos
Version: 2.2.1
$ pandoc --version
pandoc 1.19.2.4
My makefile
contains as target --to='html4'
.
Nonetheless, the XHTML validation error persists.
Here is the single XHTML test page on my web site which now employs pandoc-xnos
.
Oof, sorry, I didn't look at the output carefully enough. I just released pandoc-eqnos 2.2.2 which should resolve the problem. Fingers crossed. :o) Cheers, Tom.
I am sorry, Tom; It is still not OK. Same validation error.
$ pip3 show pandoc-eqnos
Name: pandoc-eqnos
Version: 2.2.2
The output only contains <style>
. I am afraid the condition if fmt == 'html4'
does not get properly detected. Perhaps it should read just html
, as this was the original term used by pandoc
.
I am afraid the condition if fmt == 'html4' does not get properly detected. Perhaps it should read just html, as this was the original term used by pandoc.
I tested it again with as condition if fmt == 'html'
. Now it works and the XHTML output passes the validation test!
Weird. This should work with --to=html4
. Can we both try the following test? Here is test.md
:
---
title: Test
eqnos-cleveref: True
xnos-capitalise: True
...
$$ y = mx + b $${#eq:1}
Ref to @eq:1.
I process it using:
pandoc demo.md --to=html4 --filter=pandoc-eqnos --standalone -o demo.html
The output in demo.html
is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="generator" content="pandoc" />
<title>Test</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
</style>
<!-- pandoc-eqnos: equation style -->
<style type="text/css">
.eqnos { display: inline-block; position: relative; width: 100%; }
.eqnos br { display: none; }
.eqnos-number { position: absolute; right: 0em; top: 50%; line-height: 0; }
</style>
</head>
<body>
<div id="header">
<h1 class="title">Test</h1>
</div>
<p><span id="eq:1" class="eqnos"><span class="math display"><em>y</em> = <em>m</em><em>x</em> + <em>b</em></span><span class="eqnos-number">(1)</span></span></p>
<p>Ref to Eq. <a href="#eq:1">1</a>.</p>
</body>
</html>
This html successfully passes validation. Do you get something different?
Just in case:
$ pandoc --version
pandoc 2.10.1
Compiled with pandoc-types 1.21, texmath 0.12.0.2, skylighting 0.8.5
Default user data directory: /Users/tomduck/.local/share/pandoc or /Users/tomduck/.pandoc
Copyright (C) 2006-2020 John MacFarlane
Web: https://pandoc.org
This is free software; see the source for copying conditions.
There is no warranty, not even for merchantability or fitness
for a particular purpose.
Also:
$ pandoc-eqnos --version
pandoc-eqnos 2.2.2
Cheers,
Tom
Dear Tom, html4
and html
are --to
synonyms for pandoc
. I am still using Pandoc with target --to='html4'
.
However, it appears that within your Python API library, only fmt == 'html'
can be used for it to work. I tested it over here by editing /usr/local/lib/python3.6/dist-packages/pandoc_eqnos.py
on my computer.
In the early days, pandoc
only knew about html
and not html4
, whereas html5
was not adopted as a standard yet. That is probably why.
I created pull request #54, which resolves this issue.
Hi, Serge. As far as I can tell from the pandoc documentation, html
is a synonym for html5
. The output also looks that way, and validates. Can you check the test I have outlined above? I think that will reveal where we are differing. I want to make sure that I understand what the problem is before making further changes. Cheers, Tom.
Note: There was a problem with the setup.py
script where it would crash during an install with pip install -e . --user
. This is fixed and pushed to both the nextrelease
and master
branches. I doubt that that Issue here is related, but thought I would advise you of this change just in case. Cheers, Tom.
OK, first I reverted /usr/local/lib/python3.6/dist-packages/pandoc_eqnos.py
to version 2.2.2
.
Here is my output:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="generator" content="pandoc" />
<title>Test</title>
<style type="text/css">code{white-space: pre;}</style>
<!-- pandoc-eqnos: equation style -->
<style>
.eqnos { display: inline-block; position: relative; width: 100%; }
.eqnos br { display: none; }
.eqnos-number { position: absolute; right: 0em; top: 50%; line-height: 0; }
</style>
</head>
<body>
<div id="header">
<h1 class="title">Test</h1>
</div>
<p><span id="eq:1" class="eqnos"><br /><span class="math display"><em>y</em> = <em>m</em><em>x</em> + <em>b</em></span><br /><span class="eqnos-number">(1)</span></span></p>
<p>Ref to Eq. <a href="#eq:1">1</a>.</p>
</body>
</html>
My best guess is that what html
actually stands for, recently changed in pandoc
. I am going to check pandoc
release notes.
Aha! My tests show that the behaviour changed with pandoc 2.0. I will work on a pre-2.0 fix.
Can you first confirm that you are using a 1.x-series pandoc?
I am running pandoc 1.19.2.4
from the Ubuntu 18.04 LTS repository. Yes, the meaning of html
changed with the release of pandoc 2.0
.
Excellent. I will work up a fix. :o)
You are kind of "lucky" 😄 that I bumped into this issue because Xubuntu 20.4.1 is any day due now. Xubuntu LTS releases always upgrade at the .1 release in August. It seems that I will have some catching up to do with pandoc
. The polyglot HTML5 which is supposed to be also XHTML valid seems interesting. I need XHTML as an input for PDF production with Prince. Many thanks for your efforts!
Lucky indeed! If one person is reporting this problem, it is a fair bet that many others have had the same problem and given up. So, I appreciate all such feedback. :o)
I just posted pandoc-eqnos 2.2.3. Please let me know if this solves the problem. Fingers crossed.
[Edit: pandoc-eqnos has been updated, not pandoc-xnos]
Cheers,
Tom
I tested pandoc-eqnos 2.2.3
with another XHTML document that now validates without a glitch.
Thanks!
Wonderful! Thanks for your help with this, Serge. Cheers, Tom.