Matthias Bünger created DOXIASITETOOLS-358:
----------------------------------------------
Summary: Doxia duplicates meta-tags if defined by page (Markdown)
Key: DOXIASITETOOLS-358
URL: https://issues.apache.org/jira/browse/DOXIASITETOOLS-358
Project: Maven Doxia Sitetools
Issue Type: Bug
Components: Site renderer
Affects Versions: 2.0.0-M19
Reporter: Matthias Bünger
In my MavenSite's PR to fix rendering warnings the question if html headers can
be added when writing Markdown files. [~kwindszus] answered that it it's
possible in general, but unclear how doxia-sitetolls handles them:
{quote}In general every valid HTML is also valid in MD
([https://daringfireball.net/projects/markdown/syntax#html]). This is more a
question on how the resulting HTML is being partitioned by the doxia-sitetools
(to inject things like navigation).
{quote}
Because there's interest to transform the xml-docs into Markdown I made some
tests about this.
h2. First test
{code:java}
<head>
<meta charset="UTF-8">
<meta name="description" content="Free Web tutorials">
<meta name="keywords" content="HTML, CSS, JavaScript">
<meta name="author" content="John Doe">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
{code}
This failes in exceptions
{code:java}
URI: /developers/mdwithhtmltest2.html
STATUS: 500
MESSAGE: javax.servlet.ServletException:
org.apache.maven.doxia.siterenderer.RendererException: Error parsing
'D:\Github\Maven\maven-site\content\markdown\developers\mdwithhtmltest2.md',
line 28
SERVLET: default
CAUSED BY: javax.servlet.ServletException:
org.apache.maven.doxia.siterenderer.RendererException: Error parsing
'D:\Github\Maven\maven-site\content\markdown\developers\mdwithhtmltest2.md',
line 28
CAUSED BY: org.apache.maven.doxia.siterenderer.RendererException: Error
parsing
'D:\Github\Maven\maven-site\content\markdown\developers\mdwithhtmltest2.md',
line 28
CAUSED BY: org.apache.maven.doxia.parser.ParseException: Error parsing the
model
CAUSED BY: org.codehaus.plexus.util.xml.pull.XmlPullParserException: end
tag name </head> must be the same as start tag <meta> from line 20 (position:
TEXT seen ...<title>Download Apache Maven</title>\n</head>... @28:8)
{code}
We learn
* void elements (like meta tags) are not (fully) supported by DOXIA
h2. Second test
{code:java}
<head>
<meta charset="UTF-8" />
<meta name="description" content="Free Web tutorials" />
<meta name="keywords" content="HTML, CSS, JavaScript" />
<meta name="author" content="John Doe" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
{code}
This gets transformed to
{code:java}
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="generator" content="Apache Maven Doxia Site Renderer 2.0.0" />
<meta name="author" content="John Doe" />
<title>Maven</title>
<link rel="stylesheet" href="../css/apache-maven-fluido-2.0.1.min.css" />
<link rel="stylesheet" href="../css/site.css" />
<link rel="stylesheet" href="../css/print.css" media="print" />
<script src="../js/apache-maven-fluido-2.0.1.min.js"></script>
<meta charset="UTF-8" /><meta name="description" content="Free Web tutorials"
/><meta name="keywords" content="HTML, CSS, JavaScript" /><meta name="viewport"
content="width=device-width, initial-scale=1.0" /> <!-- Matomo -->
<script>
///
</script>
<!-- End Matomo Code -->
</head>
<body>
{code}
We see
* "Maven" as a title gets added somehow (for me, but I assume it's some Doxia
or fluido skin configuration)
* The manually added HTML meta tags *{*}all excepts author{*}* got put behind
the path definition for the fluido Javascript
* This leads duplicated meta, in this test the "viewport" one.
* Void elements are renedered with a trailing slash resulting in validator
infos / warning
{quote}Info: Trailing slash on void elements has no effect and interacts badly
with unquoted attribute values.
>From line 19, column 5; to line 19, column 67
s" />↩ <link rel="stylesheet" href="../css/print.css" media="print" />↩ <
{quote}
h2. Third test
As we have xml-files with multiple authors and a title definition I tested this
too.
{code:java}
<head>
<meta charset="UTF-8" />
<meta name="description" content="Free Web tutorials" />
<meta name="keywords" content="HTML, CSS, JavaScript" />
<meta name="author" content="John Doe" />
<meta name="author" content="Maven 1" />
<meta name="author" content="Maven 2" />
<meta name="generator" content="Not Doxia">
<title>Download Apache Maven</title>
</head>
{code}
This gets transformed to
{code:java}
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="generator" content="Apache Maven Doxia Site Renderer 2.0.0" />
<meta name="author" content="John Doe" />
<meta name="author" content="Maven 1" />
<meta name="author" content="Maven 2" />
<title>Download Apache Maven – Maven</title>
<link rel="stylesheet" href="../css/apache-maven-fluido-2.0.1.min.css" />
<link rel="stylesheet" href="../css/site.css" />
<link rel="stylesheet" href="../css/print.css" media="print" />
<script src="../js/apache-maven-fluido-2.0.1.min.js"></script>
<meta charset="UTF-8" /><meta name="description" content="Free Web tutorials"
/><meta name="keywords" content="HTML, CSS, JavaScript" /><meta
name="generator" content="Not Doxia" /> <!-- Matomo -->
<script>
///
</script>
<!-- End Matomo Code -->
</head>
{code}
Additional to what we saw in the first test:
* multiple authors are picked up and rendered correctly
* the "title" attribute" is picked up and used
h2. Fourth test
Last test was about the html elements which are not headers.
{code:java}
<nav>
<a href="/html/">HTML</a> |
<a href="/css/">CSS</a> |
<a href="/js/">JavaScript</a> |
<a href="/python/">Python</a>
</nav>
# Mojo API Specification
Let's test this
{code}
{code:java}
<main id="bodyColumn" class="span10">
<nav>
<a href="/html/">HTML</a> |
<a href="/css/">CSS</a> |
<a href="/js/">JavaScript</a> |
<a href="/python/">Python</a>
</nav>
<section><a id="Mojo_API_Specification"></a>
<h1>Mojo API Specification</h1>
<p>Let's test this</p></section> </main>
{code}
As expected they just got put into the main area of the page (here resulting in
duplicate nav, but that's user's fault)
h2. Result
As a result we can see that it's possible to add meta tags, but this might
create invalid HTML, e.g. duplicate charset, but also infos/warnings, due the
trailing slash on void elements
--
This message was sent by Atlassian Jira
(v8.20.10#820010)