Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[doc] book: override xhtml11 backend to change html output structure

  • Loading branch information...
commit ec02551759c971eb4a536c8bec5bcd7232dfa74e 1 parent e69eeee
Anthonin Bonnefoy authored Mathieu Baudet committed
Showing with 310 additions and 0 deletions.
  1. +182 −0 doc/book/asciidoc.conf
  2. +128 −0 doc/book/javascripts/asciidoc-xhtml11.js
View
182 doc/book/asciidoc.conf
@@ -132,3 +132,185 @@ filter=source-highlight -f {backend-xhtml11?xhtml}{backend-html4?html}{backend-d
# Opa
OPA=Opa
+
+
+# xhtml11 backend override
+ifdef::backend-xhtml11[]
+[header]
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{lang=en}">
+<head>
+<meta http-equiv="Content-Type" content="{quirks=application/xhtml+xml}{quirks?text/html}; charset={encoding}" />
+<meta name="generator" content="AsciiDoc {asciidoc-version}" />
+<title>{doctitle=}</title>
+ifdef::linkcss[]
+<link rel="stylesheet" href="{stylesdir=.}/{theme={backend}}.css" type="text/css" />
+{doctype-manpage}<link rel="stylesheet" href="{stylesdir=.}/{theme={backend}}-manpage.css" type="text/css" />
+ifdef::quirks[]
+<link rel="stylesheet" href="{stylesdir=.}/{theme={backend}}-quirks.css" type="text/css" />
+endif::quirks[]
+<link rel="stylesheet" href="{stylesdir=.}/{stylesheet}" type="text/css" />
+endif::linkcss[]
+ifndef::linkcss[]
+<style type="text/css">
+include1::{stylesdir=./stylesheets}/{theme={backend}}.css[]
+ifdef::doctype-manpage[]
+include1::{stylesdir=./stylesheets}/{theme={backend}}-manpage.css[]
+endif::doctype-manpage[]
+ifdef::quirks[]
+include1::{stylesdir=./stylesheets}/{theme={backend}}-quirks.css[]
+endif::quirks[]
+include1::{stylesheet}[]
+</style>
+endif::linkcss[]
+ifndef::disable-javascript[]
+ifdef::linkcss[]
+<script type="text/javascript">
+# Escape as CDATA to pass validators.
+/*<![CDATA[*/
+window.onload = function()\{asciidoc.footnotes();{toc? asciidoc.toc({toclevels});}\}
+/*]]>*/
+</script>
+<script type="text/javascript" src="{scriptsdir=.}/asciidoc-xhtml11.js"></script>
+endif::linkcss[]
+ifndef::linkcss[]
+<script type="text/javascript">
+# Escape as CDATA to pass validators.
+/*<![CDATA[*/
+window.onload = function()\{asciidoc.footnotes();{toc? asciidoc.toc({toclevels});}\}
+include1::{scriptsdir=./javascripts}/asciidoc-xhtml11.js[]
+/*]]>*/
+</script>
+endif::linkcss[]
+endif::disable-javascript[]
+ifdef::asciimath[]
+ifdef::linkcss[]
+<script type="text/javascript" src="{scriptsdir=.}/ASCIIMathML.js"></script>
+endif::linkcss[]
+ifndef::linkcss[]
+<script type="text/javascript">
+# Escape as CDATA to pass validators.
+/*<![CDATA[*/
+include1::{scriptsdir=./javascripts}/ASCIIMathML.js[]
+/*]]>*/
+</script>
+endif::linkcss[]
+endif::asciimath[]
+ifdef::latexmath[]
+ifdef::linkcss[]
+<script type="text/javascript" src="{scriptsdir=.}/LaTeXMathML.js"></script>
+endif::linkcss[]
+ifndef::linkcss[]
+<script type="text/javascript">
+# Escape as CDATA to pass validators.
+/*<![CDATA[*/
+include1::{scriptsdir=./javascripts}/LaTeXMathML.js[]
+/*]]>*/
+</script>
+endif::linkcss[]
+endif::latexmath[]
+</head>
+<body{max-width? style="max-width:{max-width}"}>
+<div class="wrapper">
+# Article, book header.
+ifndef::doctype-manpage[]
+<div id="header">
+<div class="container">
+<h1>{doctitle}</h1>
+</div>
+{doctitle#}<span id="author">{author}</span><br />
+{doctitle#}<span id="email"><tt>&lt;<a href="mailto:{email}">{email}</a>&gt;</tt></span><br />
+{doctitle#}<span id="revnumber">version {revnumber}{revdate?,}</span>
+{doctitle#}<span id="revdate">{revdate}</span>
+{doctitle#}<br /><span id="revremark">{revremark}</span>
+{docinfo#}{include:{docdir}/{docname}-docinfo.html}
+</div>
+ifdef::toc[]
+<div class="sidebar">
+<div class="inset">
+<div id="toc">
+ <div id="toctitle">{toc-title}</div>
+ <noscript><p><b>JavaScript must be enabled in your browser to display the table of contents.</b></p></noscript>
+</div>
+</div>
+endif::toc[]
+</div>
+endif::doctype-manpage[]
+# Man page header.
+ifdef::doctype-manpage[]
+<div id="header">
+<div class="container">
+<h1>
+{doctitle} Manual Page
+</h1>
+</div>
+</div>
+ifdef::toc[]
+<div class="sidebar">
+<div class="inset">
+<div id="toc">
+ <div id="toctitle">{toc-title}</div>
+ <noscript><p><b>JavaScript must be enabled in your browser to display the table of contents.</b></p></noscript>
+</div>
+</div>
+endif::toc[]
+<h2>{manname-title}</h2>
+<div class="sectionbody">
+<p>{manname} -
+ {manpurpose}
+</p>
+</div>
+</div>
+endif::doctype-manpage[]
+<div class="content">
+<div class="inset">
+<div id="content">
+
+[footer]
+</div>
+</div>
+</div>
+
+<div class="footer">
+<div class="container">
+<div class="footnote">
+{disable-javascript%<div id="footnotes"><hr /></div>}
+<div id="footer">
+<div id="footer-text">
+Version {revnumber}<br />
+Last updated {docdate} {doctime}
+</div>
+ifdef::badges[]
+<div id="footer-badges">
+ifndef::icons[]
+Valid <a href="http://validator.w3.org/check?uri=referer">XHTML</a>
+and <a href="http://jigsaw.w3.org/css-validator/check/referer">CSS</a>.
+endif::icons[]
+ifdef::icons[]
+<a href="http://validator.w3.org/check?uri=referer">
+ <img style="border:0;width:88px;height:31px"
+ src="http://www.w3.org/Icons/valid-xhtml11-blue"
+ alt="Valid XHTML 1.1" height="31" width="88" />
+</a>
+<a href="http://jigsaw.w3.org/css-validator/">
+ <img style="border:0;width:88px;height:31px"
+ src="http://jigsaw.w3.org/css-validator/images/vcss-blue"
+ alt="Valid CSS!" />
+</a>
+<a href="http://www.mozilla.org/products/firefox/">
+ <img style="border:none; width:110px; height:32px;"
+ src="http://www.spreadfirefox.com/community/images/affiliates/Buttons/110x32/safer.gif"
+ alt="Get Firefox!" />
+</a>
+endif::icons[]
+</div>
+endif::badges[]
+</div>
+</div>
+</div>
+</div>
+</div>
+</body>
+</html>
+endif::backend-xhtml11[]
View
128 doc/book/javascripts/asciidoc-xhtml11.js
@@ -0,0 +1,128 @@
+var asciidoc = { // Namespace.
+
+/////////////////////////////////////////////////////////////////////
+// Table Of Contents generator
+/////////////////////////////////////////////////////////////////////
+
+/* Author: Mihai Bazon, September 2002
+ * http://students.infoiasi.ro/~mishoo
+ *
+ * Table Of Content generator
+ * Version: 0.4
+ *
+ * Feel free to use this script under the terms of the GNU General Public
+ * License, as long as you do not remove or alter this notice.
+ */
+
+ /* modified by Troy D. Hanson, September 2006. License: GPL */
+ /* modified by Stuart Rackham, 2006, 2009. License: GPL */
+
+// toclevels = 1..4.
+toc: function (toclevels) {
+
+ function getText(el) {
+ var text = "";
+ for (var i = el.firstChild; i != null; i = i.nextSibling) {
+ if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
+ text += i.data;
+ else if (i.firstChild != null)
+ text += getText(i);
+ }
+ return text;
+ }
+
+ function TocEntry(el, text, toclevel) {
+ this.element = el;
+ this.text = text;
+ this.toclevel = toclevel;
+ }
+
+ function tocEntries(el, toclevels) {
+ var result = new Array;
+ var re = new RegExp('[hH]([2-'+(toclevels+1)+'])');
+ // Function that scans the DOM tree for header elements (the DOM2
+ // nodeIterator API would be a better technique but not supported by all
+ // browsers).
+ var iterate = function (el) {
+ for (var i = el.firstChild; i != null; i = i.nextSibling) {
+ if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
+ var mo = re.exec(i.tagName);
+ if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
+ result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
+ }
+ iterate(i);
+ }
+ }
+ }
+ iterate(el);
+ return result;
+ }
+
+ var toc = document.getElementById("toc");
+ var entries = tocEntries(document.getElementById("content"), toclevels);
+ for (var i = 0; i < entries.length; ++i) {
+ var entry = entries[i];
+ if (entry.element.id == "")
+ entry.element.id = "_toc_" + i;
+ var a = document.createElement("a");
+ a.href = "#" + entry.element.id;
+ a.appendChild(document.createTextNode(entry.text));
+ var div = document.createElement("div");
+ div.appendChild(a);
+ div.className = "toclevel" + entry.toclevel;
+ toc.appendChild(div);
+ }
+ if (entries.length == 0)
+ toc.parentNode.removeChild(toc);
+},
+
+
+/////////////////////////////////////////////////////////////////////
+// Footnotes generator
+/////////////////////////////////////////////////////////////////////
+
+/* Based on footnote generation code from:
+ * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
+ */
+
+footnotes: function () {
+ var cont = document.getElementById("content");
+ var noteholder = document.getElementById("footnotes");
+ var spans = cont.getElementsByTagName("span");
+ var refs = {};
+ var n = 0;
+ for (i=0; i<spans.length; i++) {
+ if (spans[i].className == "footnote") {
+ n++;
+ // Use [\s\S] in place of . so multi-line matches work.
+ // Because JavaScript has no s (dotall) regex flag.
+ note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
+ noteholder.innerHTML +=
+ "<div class='footnote' id='_footnote_" + n + "'>" +
+ "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
+ n + "</a>. " + note + "</div>";
+ spans[i].innerHTML =
+ "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
+ "' title='View footnote' class='footnote'>" + n + "</a>]";
+ var id =spans[i].getAttribute("id");
+ if (id != null) refs["#"+id] = n;
+ }
+ }
+ if (n == 0)
+ noteholder.parentNode.removeChild(noteholder);
+ else {
+ // Process footnoterefs.
+ for (i=0; i<spans.length; i++) {
+ if (spans[i].className == "footnoteref") {
+ var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
+ href = href.match(/#.*/)[0]; // Because IE return full URL.
+ n = refs[href];
+ spans[i].innerHTML =
+ "[<a href='#_footnote_" + n +
+ "' title='View footnote' class='footnote'>" + n + "</a>]";
+ }
+ }
+ }
+}
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.