-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Docbook writer: add XML namespaces to top-level elements #6923
Conversation
Previously, we only added xmlns attributes to chapter elements, even when running with --top-level-division=section. Let’s add the namespaces to part and section elements too, when they are the selected top-level divisions. We do not need to add namespaces to documents produced with --standalone flag, since those will already have xmlns attribute on the root element in the template.
1ce1e61
to
7fe692c
Compare
I'm not sure why this is needed. Fragment mode (not |
Hmm, we use this in Nixpkgs for generating sections and chapters that we then include using I guess it might make some sense to use I guess we could create a custom template like the one bellow but we would need to pass the ---
title: Sect
id: sect
block: section
---
foo. instead of # Sect {#sect}
foo. <?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE $block$>
<$block$
$if(lang)$
xml:lang="$lang$"
$endif$
xmlns="http://docbook.org/ns/docbook" version="5.0"
$if(mathml)$
xmlns:mml="http://www.w3.org/1998/Math/MathML"
$endif$
$if(id)$
xml:id="$id$"
$endif$
xmlns:xlink="http://www.w3.org/1999/xlink" >
<info>
<title>$title$</title>
$if(subtitle)$
<subtitle>$subtitle$</subtitle>
$endif$
$if(author)$
<authorgroup>
$for(author)$
<author>
$author$
</author>
$endfor$
</authorgroup>
$endif$
$if(date)$
<date>$date$</date>
$endif$
</info>
$for(include-before)$
$include-before$
$endfor$
$body$
$for(include-after)$
$include-after$
$endfor$
</$block$> But this template could be added to pandoc and the writer updated so that it gets |
Then again, it is completely fine to declare XML namespaces on non-root elements and |
On the custom template solution: you might find it handy to use |
Hm, yes, we do have code (l. 173) that says: nsAttr = if version == DocBook5 && lvl == 0 then [("xmlns", "http://docbook.org/ns/docbook"),("xmlns:xlink", "http://www.w3.org/1999/xlink")] I'm not sure what motivated this. But maybe it was exactly the thing you're talking about -- included chapters in separate files. |
OK, now that I've actually looked at your code, I see that you knew all that! I'm persuaded. I'll merge this. |
Previously, we only added xmlns attributes to chapter elements, even when running with
--top-level-division=section
. Let’s add the namespaces to part and section elements too, when they are the selected top-level divisions.We do not need to add namespaces to documents produced with
--standalone
flag, since those will already have xmlns attribute on the root element in the template.