summaryrefslogtreecommitdiff
path: root/doc/asciidoc/tests
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2014-02-17 18:04:46 +1100
committerChris Johns <chrisj@rtems.org>2014-02-17 18:04:46 +1100
commitf91e023fc4c68867e8ef9476ae28226feaa9929e (patch)
treec7daa4f99352fc45e27c5f5fa53d07b51292c14f /doc/asciidoc/tests
parent11d4b8976e9c5fa13c77faecc197cc9d1bc1ddfc (diff)
Add the documentation.
Diffstat (limited to 'doc/asciidoc/tests')
-rw-r--r--doc/asciidoc/tests/asciidocapi.py257
-rw-r--r--doc/asciidoc/tests/data/deprecated-quotes.txt12
-rw-r--r--doc/asciidoc/tests/data/filters-test.txt90
-rw-r--r--doc/asciidoc/tests/data/lang-de-man-test.txt21
-rw-r--r--doc/asciidoc/tests/data/lang-de-test.txt106
-rw-r--r--doc/asciidoc/tests/data/lang-en-man-test.txt21
-rw-r--r--doc/asciidoc/tests/data/lang-en-test.txt114
-rw-r--r--doc/asciidoc/tests/data/lang-es-man-test.txt21
-rw-r--r--doc/asciidoc/tests/data/lang-es-test.txt106
-rw-r--r--doc/asciidoc/tests/data/lang-fr-man-test.txt21
-rw-r--r--doc/asciidoc/tests/data/lang-fr-test.txt106
-rw-r--r--doc/asciidoc/tests/data/lang-hu-man-test.txt21
-rw-r--r--doc/asciidoc/tests/data/lang-hu-test.txt106
-rw-r--r--doc/asciidoc/tests/data/lang-it-man-test.txt21
-rw-r--r--doc/asciidoc/tests/data/lang-it-test.txt106
-rw-r--r--doc/asciidoc/tests/data/lang-nl-man-test.txt21
-rw-r--r--doc/asciidoc/tests/data/lang-nl-test.txt94
-rw-r--r--doc/asciidoc/tests/data/lang-pt-BR-man-test.txt21
-rw-r--r--doc/asciidoc/tests/data/lang-pt-BR-test.txt106
-rw-r--r--doc/asciidoc/tests/data/lang-ru-man-test.txt21
-rw-r--r--doc/asciidoc/tests/data/lang-ru-test.txt106
-rw-r--r--doc/asciidoc/tests/data/lang-uk-man-test.txt21
-rw-r--r--doc/asciidoc/tests/data/lang-uk-test.txt106
-rw-r--r--doc/asciidoc/tests/data/oldtables.txt64
-rw-r--r--doc/asciidoc/tests/data/open-block-test.txt117
-rw-r--r--doc/asciidoc/tests/data/rcs-id-marker-test.txt6
-rw-r--r--doc/asciidoc/tests/data/testcases.conf12
-rw-r--r--doc/asciidoc/tests/data/testcases.txt786
-rw-r--r--doc/asciidoc/tests/data/utf8-bom-test.txt9
-rw-r--r--doc/asciidoc/tests/data/utf8-examples.txt217
-rw-r--r--doc/asciidoc/tests/testasciidoc.conf652
-rwxr-xr-xdoc/asciidoc/tests/testasciidoc.py420
32 files changed, 3908 insertions, 0 deletions
diff --git a/doc/asciidoc/tests/asciidocapi.py b/doc/asciidoc/tests/asciidocapi.py
new file mode 100644
index 0000000..dcdf262
--- /dev/null
+++ b/doc/asciidoc/tests/asciidocapi.py
@@ -0,0 +1,257 @@
+#!/usr/bin/env python
+"""
+asciidocapi - AsciiDoc API wrapper class.
+
+The AsciiDocAPI class provides an API for executing asciidoc. Minimal example
+compiles `mydoc.txt` to `mydoc.html`:
+
+ import asciidocapi
+ asciidoc = asciidocapi.AsciiDocAPI()
+ asciidoc.execute('mydoc.txt')
+
+- Full documentation in asciidocapi.txt.
+- See the doctests below for more examples.
+
+Doctests:
+
+1. Check execution:
+
+ >>> import StringIO
+ >>> infile = StringIO.StringIO('Hello *{author}*')
+ >>> outfile = StringIO.StringIO()
+ >>> asciidoc = AsciiDocAPI()
+ >>> asciidoc.options('--no-header-footer')
+ >>> asciidoc.attributes['author'] = 'Joe Bloggs'
+ >>> asciidoc.execute(infile, outfile, backend='html4')
+ >>> print outfile.getvalue()
+ <p>Hello <strong>Joe Bloggs</strong></p>
+
+ >>> asciidoc.attributes['author'] = 'Bill Smith'
+ >>> infile = StringIO.StringIO('Hello _{author}_')
+ >>> outfile = StringIO.StringIO()
+ >>> asciidoc.execute(infile, outfile, backend='docbook')
+ >>> print outfile.getvalue()
+ <simpara>Hello <emphasis>Bill Smith</emphasis></simpara>
+
+2. Check error handling:
+
+ >>> import StringIO
+ >>> asciidoc = AsciiDocAPI()
+ >>> infile = StringIO.StringIO('---------')
+ >>> outfile = StringIO.StringIO()
+ >>> asciidoc.execute(infile, outfile)
+ Traceback (most recent call last):
+ File "<stdin>", line 1, in <module>
+ File "asciidocapi.py", line 189, in execute
+ raise AsciiDocError(self.messages[-1])
+ AsciiDocError: ERROR: <stdin>: line 1: [blockdef-listing] missing closing delimiter
+
+
+Copyright (C) 2009 Stuart Rackham. Free use of this software is granted
+under the terms of the GNU General Public License (GPL).
+
+"""
+
+import sys,os,re,imp
+
+API_VERSION = '0.1.2'
+MIN_ASCIIDOC_VERSION = '8.4.1' # Minimum acceptable AsciiDoc version.
+
+
+def find_in_path(fname, path=None):
+ """
+ Find file fname in paths. Return None if not found.
+ """
+ if path is None:
+ path = os.environ.get('PATH', '')
+ for dir in path.split(os.pathsep):
+ fpath = os.path.join(dir, fname)
+ if os.path.isfile(fpath):
+ return fpath
+ else:
+ return None
+
+
+class AsciiDocError(Exception):
+ pass
+
+
+class Options(object):
+ """
+ Stores asciidoc(1) command options.
+ """
+ def __init__(self, values=[]):
+ self.values = values[:]
+ def __call__(self, name, value=None):
+ """Shortcut for append method."""
+ self.append(name, value)
+ def append(self, name, value=None):
+ if type(value) in (int,float):
+ value = str(value)
+ self.values.append((name,value))
+
+
+class Version(object):
+ """
+ Parse and compare AsciiDoc version numbers. Instance attributes:
+
+ string: String version number '<major>.<minor>[.<micro>][suffix]'.
+ major: Integer major version number.
+ minor: Integer minor version number.
+ micro: Integer micro version number.
+ suffix: Suffix (begins with non-numeric character) is ignored when
+ comparing.
+
+ Doctest examples:
+
+ >>> Version('8.2.5') < Version('8.3 beta 1')
+ True
+ >>> Version('8.3.0') == Version('8.3. beta 1')
+ True
+ >>> Version('8.2.0') < Version('8.20')
+ True
+ >>> Version('8.20').major
+ 8
+ >>> Version('8.20').minor
+ 20
+ >>> Version('8.20').micro
+ 0
+ >>> Version('8.20').suffix
+ ''
+ >>> Version('8.20 beta 1').suffix
+ 'beta 1'
+
+ """
+ def __init__(self, version):
+ self.string = version
+ reo = re.match(r'^(\d+)\.(\d+)(\.(\d+))?\s*(.*?)\s*$', self.string)
+ if not reo:
+ raise ValueError('invalid version number: %s' % self.string)
+ groups = reo.groups()
+ self.major = int(groups[0])
+ self.minor = int(groups[1])
+ self.micro = int(groups[3] or '0')
+ self.suffix = groups[4] or ''
+ def __cmp__(self, other):
+ result = cmp(self.major, other.major)
+ if result == 0:
+ result = cmp(self.minor, other.minor)
+ if result == 0:
+ result = cmp(self.micro, other.micro)
+ return result
+
+
+class AsciiDocAPI(object):
+ """
+ AsciiDoc API class.
+ """
+ def __init__(self, asciidoc_py=None):
+ """
+ Locate and import asciidoc.py.
+ Initialize instance attributes.
+ """
+ self.options = Options()
+ self.attributes = {}
+ self.messages = []
+ # Search for the asciidoc command file.
+ # Try ASCIIDOC_PY environment variable first.
+ cmd = os.environ.get('ASCIIDOC_PY')
+ if cmd:
+ if not os.path.isfile(cmd):
+ raise AsciiDocError('missing ASCIIDOC_PY file: %s' % cmd)
+ elif asciidoc_py:
+ # Next try path specified by caller.
+ cmd = asciidoc_py
+ if not os.path.isfile(cmd):
+ raise AsciiDocError('missing file: %s' % cmd)
+ else:
+ # Try shell search paths.
+ for fname in ['asciidoc.py','asciidoc.pyc','asciidoc']:
+ cmd = find_in_path(fname)
+ if cmd: break
+ else:
+ # Finally try current working directory.
+ for cmd in ['asciidoc.py','asciidoc.pyc','asciidoc']:
+ if os.path.isfile(cmd): break
+ else:
+ raise AsciiDocError('failed to locate asciidoc')
+ self.cmd = os.path.realpath(cmd)
+ self.__import_asciidoc()
+
+ def __import_asciidoc(self, reload=False):
+ '''
+ Import asciidoc module (script or compiled .pyc).
+ See
+ http://groups.google.com/group/asciidoc/browse_frm/thread/66e7b59d12cd2f91
+ for an explanation of why a seemingly straight-forward job turned out
+ quite complicated.
+ '''
+ if os.path.splitext(self.cmd)[1] in ['.py','.pyc']:
+ sys.path.insert(0, os.path.dirname(self.cmd))
+ try:
+ try:
+ if reload:
+ import __builtin__ # Because reload() is shadowed.
+ __builtin__.reload(self.asciidoc)
+ else:
+ import asciidoc
+ self.asciidoc = asciidoc
+ except ImportError:
+ raise AsciiDocError('failed to import ' + self.cmd)
+ finally:
+ del sys.path[0]
+ else:
+ # The import statement can only handle .py or .pyc files, have to
+ # use imp.load_source() for scripts with other names.
+ try:
+ imp.load_source('asciidoc', self.cmd)
+ import asciidoc
+ self.asciidoc = asciidoc
+ except ImportError:
+ raise AsciiDocError('failed to import ' + self.cmd)
+ if Version(self.asciidoc.VERSION) < Version(MIN_ASCIIDOC_VERSION):
+ raise AsciiDocError(
+ 'asciidocapi %s requires asciidoc %s or better'
+ % (API_VERSION, MIN_ASCIIDOC_VERSION))
+
+ def execute(self, infile, outfile=None, backend=None):
+ """
+ Compile infile to outfile using backend format.
+ infile can outfile can be file path strings or file like objects.
+ """
+ self.messages = []
+ opts = Options(self.options.values)
+ if outfile is not None:
+ opts('--out-file', outfile)
+ if backend is not None:
+ opts('--backend', backend)
+ for k,v in self.attributes.items():
+ if v == '' or k[-1] in '!@':
+ s = k
+ elif v is None: # A None value undefines the attribute.
+ s = k + '!'
+ else:
+ s = '%s=%s' % (k,v)
+ opts('--attribute', s)
+ args = [infile]
+ # The AsciiDoc command was designed to process source text then
+ # exit, there are globals and statics in asciidoc.py that have
+ # to be reinitialized before each run -- hence the reload.
+ self.__import_asciidoc(reload=True)
+ try:
+ try:
+ self.asciidoc.execute(self.cmd, opts.values, args)
+ finally:
+ self.messages = self.asciidoc.messages[:]
+ except SystemExit, e:
+ if e.code:
+ raise AsciiDocError(self.messages[-1])
+
+
+if __name__ == "__main__":
+ """
+ Run module doctests.
+ """
+ import doctest
+ options = doctest.NORMALIZE_WHITESPACE + doctest.ELLIPSIS
+ doctest.testmod(optionflags=options)
diff --git a/doc/asciidoc/tests/data/deprecated-quotes.txt b/doc/asciidoc/tests/data/deprecated-quotes.txt
new file mode 100644
index 0000000..2f44edf
--- /dev/null
+++ b/doc/asciidoc/tests/data/deprecated-quotes.txt
@@ -0,0 +1,12 @@
+// Deprecated quote attributes.
+[role="foo"]##fun with text##.
+["green","yellow",2,role="foo"]##fun with text##.
+[green,yellow,2]##fun with text##.
+More [red,black,4]*fun with text*.
+Yet more [red,,1.5]**fun with text**.
+Yet more [red,,1.5]+fun with text+.
+Yet more [red,,1.5]'fun with text'.
+
+Yet more [red,,1.5]_fun with text_.
+
+Yet more [orange]'fun with text'.
diff --git a/doc/asciidoc/tests/data/filters-test.txt b/doc/asciidoc/tests/data/filters-test.txt
new file mode 100644
index 0000000..a8b051e
--- /dev/null
+++ b/doc/asciidoc/tests/data/filters-test.txt
@@ -0,0 +1,90 @@
+Filter Tests
+============
+
+
+== Toy filter example from User Guide
+
+[code,python]
+----------------------------------------------
+''' A multi-line
+ comment.'''
+def sub_word(mo):
+ ''' Single line comment.'''
+ word = mo.group('word') # Inline comment
+ if word in keywords[language]:
+ return quote + word + quote
+ else:
+ return word
+----------------------------------------------
+
+
+== Pychart Chart generations from FAQ
+
+// Generate chart image file.
+sys2::[python "{indir}/barchart.py" --format=png --output="{outdir={indir}}/{imagesdir=}{imagesdir?/}barchart.png" --scale=2]
+
+// Display chart image file.
+image::barchart.png[]
+
+
+== Graphviz Graphs
+
+.Simple graph
+["graphviz", "graphviz1.png", alt="Graphviz->AsciiDoc->HTML"]
+---------------------------------------------------------------------
+digraph G { rankdir=LR; Graphviz->AsciiDoc->HTML}
+---------------------------------------------------------------------
+
+.Not so simple graph
+["graphviz", "graphviz2.png"]
+---------------------------------------------------------------------
+digraph automata_0 {
+ size ="8.5, 11";
+ node [shape = circle];
+ 0 [ style = filled, color=lightgrey ];
+ 2 [ shape = doublecircle ];
+ 0 -> 2 [ label = "a " ];
+ 0 -> 1 [ label = "other " ];
+ 1 -> 2 [ label = "a " ];
+ 1 -> 1 [ label = "other " ];
+ 2 -> 2 [ label = "a " ];
+ 2 -> 1 [ label = "other " ];
+ "Machine: a" [ shape = plaintext ];
+}
+---------------------------------------------------------------------
+
+
+== Music filter
+
+.A tune generated from ABC notation
+[music,music1.png]
+---------------------------------------------------------------------
+T:The Butterfly
+R:slip jig
+C:Tommy Potts
+H:Fiddle player Tommy Potts made this tune from two older slip jigs,
+H:one of which is called "Skin the Peelers" in Roche's collection.
+D:Bothy Band: 1975.
+M:9/8
+K:Em
+vB2(E G2)(E F3)|B2(E G2)(E F)ED|vB2(E G2)(E F3)|(B2d) d2(uB A)FD:|
+|:(vB2c) (e2f) g3|(uB2d) (g2e) (dBA)|(B2c) (e2f) g2(ua|b2a) (g2e) (dBA):|
+|:~B3 (B2A) G2A|~B3 BA(uB d)BA|~B3 (B2A) G2(A|B2d) (g2e) (dBA):|
+---------------------------------------------------------------------
+
+<<X1,Link to following fragment>>.
+
+[[X1]]
+.A fragment generated from LilyPond source
+["music", "music2.png", "ly", link="music2.ly"]
+---------------------------------------------------------------------
+\version "2.10.0"
+\paper {
+ ragged-right = ##t
+}
+{
+ \time 3/4
+ \clef bass
+ c2 e4 g2. f4 e d c2 r4
+}
+---------------------------------------------------------------------
diff --git a/doc/asciidoc/tests/data/lang-de-man-test.txt b/doc/asciidoc/tests/data/lang-de-man-test.txt
new file mode 100644
index 0000000..f1806d4
--- /dev/null
+++ b/doc/asciidoc/tests/data/lang-de-man-test.txt
@@ -0,0 +1,21 @@
+// Test for lang-de.conf language file.
+:lang: de
+
+ASCIIDOC(1)
+===========
+:doctype: manpage
+
+NAME
+----
+asciidoc - converts an AsciiDoc text file to HTML or DocBook
+
+ÜBERSICHT
+---------
+*asciidoc* ['OPTIONS'] 'FILE'
+
+DESCRIPTION
+-----------
+The asciidoc(1) command translates the AsciiDoc text file 'FILE' to
+DocBook or HTML. If 'FILE' is '-' then the standard input is used.
+
+...
diff --git a/doc/asciidoc/tests/data/lang-de-test.txt b/doc/asciidoc/tests/data/lang-de-test.txt
new file mode 100644
index 0000000..ebddb62
--- /dev/null
+++ b/doc/asciidoc/tests/data/lang-de-test.txt
@@ -0,0 +1,106 @@
+// Test for lang-de.conf language file.
+:lang: de
+
+Languages Test
+==============
+:revnumber: v1.0
+:revdate: 2003-12-21
+
+ifdef::doctype-article[]
+Zusammenfassung
+---------------
+Abstract special section.
+
+endif::doctype-article[]
+
+
+ifdef::doctype-book[]
+Widmung
+-------
+Dedication special section.
+
+
+Vorwort
+-------
+Preface special section.
+
+
+Kolophon
+--------
+Colophon special section.
+
+endif::doctype-book[]
+
+
+The First Section
+-----------------
+Admonishments
+~~~~~~~~~~~~~
+Do not translate in the source file -- they are translated to the
+output file
+
+NOTE: Lorum ipsum.
+
+TIP: Lorum ipsum.
+
+WARNING: Lorum ipsum.
+
+CAUTION: Lorum ipsum.
+
+IMPORTANT: Lorum ipsum.
+
+.Tiger
+image::../../images/tiger.png[Tiger image]
+
+Followed by an example table:
+
+.Table
+[width="60%",options="header"]
+|==============================================
+| Option | Description
+| -a 'USER GROUP' | Add 'USER' to 'GROUP'.
+| -R 'GROUP' | Disables access to 'GROUP'.
+|==============================================
+
+And now for something completely different: ((monkeys)), lions and
+tigers.
+
+
+Anhang A: Example Appendix
+--------------------------
+Appendix special section.
+
+
+Literaturverzeichnis
+--------------------
+Bibliography special section.
+
+[bibliography]
+- [[[taoup]]] Eric Steven Raymond. 'The Art of Unix
+ Programming'. Addison-Wesley. ISBN 0-13-142901-9.
+- [[[walsh-muellner]]] Norman Walsh & Leonard Muellner.
+ 'DocBook - The Definitive Guide'. O'Reilly & Associates. 1999.
+ ISBN 1-56592-580-7.
+
+
+Glossar
+-------
+Glossary special section.
+
+[glossary]
+A glossary term::
+ The corresponding (indented) definition.
+
+A second glossary term::
+ The corresponding (indented) definition.
+
+
+ifdef::basebackend-docbook[]
+Stichwortverzeichnis
+--------------------
+////////////////////////////////////////////////////////////////
+Index special section.
+The index is normally left completely empty, it's contents being
+generated automatically by the DocBook toolchain.
+////////////////////////////////////////////////////////////////
+endif::basebackend-docbook[]
diff --git a/doc/asciidoc/tests/data/lang-en-man-test.txt b/doc/asciidoc/tests/data/lang-en-man-test.txt
new file mode 100644
index 0000000..0dec04a
--- /dev/null
+++ b/doc/asciidoc/tests/data/lang-en-man-test.txt
@@ -0,0 +1,21 @@
+// Test for lang-en.conf language file.
+:lang: en
+
+ASCIIDOC(1)
+===========
+:doctype: manpage
+
+NAME
+----
+asciidoc - converts an AsciiDoc text file to HTML or DocBook
+
+SYNOPSIS
+--------
+*asciidoc* ['OPTIONS'] 'FILE'
+
+DESCRIPTION
+-----------
+The asciidoc(1) command translates the AsciiDoc text file 'FILE' to
+DocBook or HTML. If 'FILE' is '-' then the standard input is used.
+
+...
diff --git a/doc/asciidoc/tests/data/lang-en-test.txt b/doc/asciidoc/tests/data/lang-en-test.txt
new file mode 100644
index 0000000..a312458
--- /dev/null
+++ b/doc/asciidoc/tests/data/lang-en-test.txt
@@ -0,0 +1,114 @@
+// Test for lang-en.conf language file.
+:lang: en
+
+Languages Test
+==============
+:revnumber: v1.0
+:revdate: 2003-12-21
+
+ifdef::doctype-article[]
+// Translate title.
+Abstract
+--------
+Abstract special section.
+
+endif::doctype-article[]
+
+
+ifdef::doctype-book[]
+// Translate title.
+Dedication
+----------
+Dedication special section.
+
+
+// Translate title.
+Preface
+-------
+Preface special section.
+
+
+// Translate title.
+Colophon
+--------
+Colophon special section.
+
+endif::doctype-book[]
+
+
+The First Section
+-----------------
+Admonishments
+~~~~~~~~~~~~~
+Do not translate in the source file -- they are translated to the
+output file
+
+NOTE: Lorum ipsum.
+
+TIP: Lorum ipsum.
+
+WARNING: Lorum ipsum.
+
+CAUTION: Lorum ipsum.
+
+IMPORTANT: Lorum ipsum.
+
+.Tiger
+image::../../images/tiger.png[Tiger image]
+
+Followed by an example table:
+
+.Table
+[width="60%",options="header"]
+|==============================================
+| Option | Description
+| -a 'USER GROUP' | Add 'USER' to 'GROUP'.
+| -R 'GROUP' | Disables access to 'GROUP'.
+|==============================================
+
+And now for something completely different: ((monkeys)), lions and
+tigers.
+
+
+// Translate title.
+Appendix A: Example Appendix
+----------------------------
+Appendix special section.
+
+
+// Translate title.
+Bibliography
+------------
+Bibliography special section.
+
+[bibliography]
+- [[[taoup]]] Eric Steven Raymond. 'The Art of Unix
+ Programming'. Addison-Wesley. ISBN 0-13-142901-9.
+- [[[walsh-muellner]]] Norman Walsh & Leonard Muellner.
+ 'DocBook - The Definitive Guide'. O'Reilly & Associates. 1999.
+ ISBN 1-56592-580-7.
+
+
+// Translate title.
+Glossary
+--------
+Glossary special section.
+
+[glossary]
+A glossary term::
+ The corresponding (indented) definition.
+
+A second glossary term::
+ The corresponding (indented) definition.
+
+
+ifdef::basebackend-docbook[]
+// Translate title.
+Index
+-----
+////////////////////////////////////////////////////////////////
+Index special section.
+The index is normally left completely empty, it's contents being
+generated automatically by the DocBook toolchain.
+////////////////////////////////////////////////////////////////
+endif::basebackend-docbook[]
diff --git a/doc/asciidoc/tests/data/lang-es-man-test.txt b/doc/asciidoc/tests/data/lang-es-man-test.txt
new file mode 100644
index 0000000..cb95b70
--- /dev/null
+++ b/doc/asciidoc/tests/data/lang-es-man-test.txt
@@ -0,0 +1,21 @@
+// Test for lang-es.conf language file.
+:lang: es
+
+ASCIIDOC(1)
+===========
+:doctype: manpage
+
+NAME
+----
+asciidoc - converts an AsciiDoc text file to HTML or DocBook
+
+SINOPSIS
+--------
+*asciidoc* ['OPTIONS'] 'FILE'
+
+DESCRIPTION
+-----------
+The asciidoc(1) command translates the AsciiDoc text file 'FILE' to
+DocBook or HTML. If 'FILE' is '-' then the standard input is used.
+
+...
diff --git a/doc/asciidoc/tests/data/lang-es-test.txt b/doc/asciidoc/tests/data/lang-es-test.txt
new file mode 100644
index 0000000..97eca94
--- /dev/null
+++ b/doc/asciidoc/tests/data/lang-es-test.txt
@@ -0,0 +1,106 @@
+// Test for lang-es.conf language file.
+:lang: es
+
+Languages Test
+==============
+:revnumber: v1.0
+:revdate: 2003-12-21
+
+ifdef::doctype-article[]
+Resumen
+-------
+Abstract special section.
+
+endif::doctype-article[]
+
+
+ifdef::doctype-book[]
+Dedicación
+----------
+Dedication special section.
+
+
+Prefacio
+--------
+Preface special section.
+
+
+Colofón
+-------
+Colophon special section.
+
+endif::doctype-book[]
+
+
+The First Section
+-----------------
+Admonishments
+~~~~~~~~~~~~~
+Do not translate in the source file -- they are translated to the
+output file
+
+NOTE: Lorum ipsum.
+
+TIP: Lorum ipsum.
+
+WARNING: Lorum ipsum.
+
+CAUTION: Lorum ipsum.
+
+IMPORTANT: Lorum ipsum.
+
+.Tiger
+image::../../images/tiger.png[Tiger image]
+
+Followed by an example table:
+
+.Table
+[width="60%",options="header"]
+|==============================================
+| Option | Description
+| -a 'USER GROUP' | Add 'USER' to 'GROUP'.
+| -R 'GROUP' | Disables access to 'GROUP'.
+|==============================================
+
+And now for something completely different: ((monkeys)), lions and
+tigers.
+
+
+Apéndice A: Example Appendix
+----------------------------
+Appendix special section.
+
+
+Bibliografía
+------------
+Bibliography special section.
+
+[bibliography]
+- [[[taoup]]] Eric Steven Raymond. 'The Art of Unix
+ Programming'. Addison-Wesley. ISBN 0-13-142901-9.
+- [[[walsh-muellner]]] Norman Walsh & Leonard Muellner.
+ 'DocBook - The Definitive Guide'. O'Reilly & Associates. 1999.
+ ISBN 1-56592-580-7.
+
+
+Glosario
+--------
+Glossary special section.
+
+[glossary]
+A glossary term::
+ The corresponding (indented) definition.
+
+A second glossary term::
+ The corresponding (indented) definition.
+
+
+ifdef::basebackend-docbook[]
+Índice
+------
+////////////////////////////////////////////////////////////////
+Index special section.
+The index is normally left completely empty, it's contents being
+generated automatically by the DocBook toolchain.
+////////////////////////////////////////////////////////////////
+endif::basebackend-docbook[]
diff --git a/doc/asciidoc/tests/data/lang-fr-man-test.txt b/doc/asciidoc/tests/data/lang-fr-man-test.txt
new file mode 100644
index 0000000..edb681f
--- /dev/null
+++ b/doc/asciidoc/tests/data/lang-fr-man-test.txt
@@ -0,0 +1,21 @@
+// Test for lang-fr.conf language file.
+:lang: fr
+
+ASCIIDOC(1)
+===========
+:doctype: manpage
+
+NAME
+----
+asciidoc - converts an AsciiDoc text file to HTML or DocBook
+
+SYNOPSIS
+--------
+*asciidoc* ['OPTIONS'] 'FILE'
+
+DESCRIPTION
+-----------
+The asciidoc(1) command translates the AsciiDoc text file 'FILE' to
+DocBook or HTML. If 'FILE' is '-' then the standard input is used.
+
+...
diff --git a/doc/asciidoc/tests/data/lang-fr-test.txt b/doc/asciidoc/tests/data/lang-fr-test.txt
new file mode 100644
index 0000000..84c25fa
--- /dev/null
+++ b/doc/asciidoc/tests/data/lang-fr-test.txt
@@ -0,0 +1,106 @@
+// Test for lang-fr.conf language file.
+:lang: fr
+
+Languages Test
+==============
+:revnumber: v1.0
+:revdate: 2003-12-21
+
+ifdef::doctype-article[]
+Résumé
+------
+Abstract special section.
+
+endif::doctype-article[]
+
+
+ifdef::doctype-book[]
+Dédicace
+--------
+Dedication special section.
+
+
+Préface
+-------
+Preface special section.
+
+
+Colophon
+--------
+Colophon special section.
+
+endif::doctype-book[]
+
+
+The First Section
+-----------------
+Admonishments
+~~~~~~~~~~~~~
+Do not translate in the source file -- they are translated to the
+output file
+
+NOTE: Lorum ipsum.
+
+TIP: Lorum ipsum.
+
+WARNING: Lorum ipsum.
+
+CAUTION: Lorum ipsum.
+
+IMPORTANT: Lorum ipsum.
+
+.Tiger
+image::../../images/tiger.png[Tiger image]
+
+Followed by an example table:
+
+.Table
+[width="60%",options="header"]
+|==============================================
+| Option | Description
+| -a 'USER GROUP' | Add 'USER' to 'GROUP'.
+| -R 'GROUP' | Disables access to 'GROUP'.
+|==============================================
+
+And now for something completely different: ((monkeys)), lions and
+tigers.
+
+
+Appendice A: Example Appendix
+-----------------------------
+Appendix special section.
+
+
+Bibliographie
+-------------
+Bibliography special section.
+
+[bibliography]
+- [[[taoup]]] Eric Steven Raymond. 'The Art of Unix
+ Programming'. Addison-Wesley. ISBN 0-13-142901-9.
+- [[[walsh-muellner]]] Norman Walsh & Leonard Muellner.
+ 'DocBook - The Definitive Guide'. O'Reilly & Associates. 1999.
+ ISBN 1-56592-580-7.
+
+
+Glossaire
+---------
+Glossary special section.
+
+[glossary]
+A glossary term::
+ The corresponding (indented) definition.
+
+A second glossary term::
+ The corresponding (indented) definition.
+
+
+ifdef::basebackend-docbook[]
+Index
+-----
+////////////////////////////////////////////////////////////////
+Index special section.
+The index is normally left completely empty, it's contents being
+generated automatically by the DocBook toolchain.
+////////////////////////////////////////////////////////////////
+endif::basebackend-docbook[]
diff --git a/doc/asciidoc/tests/data/lang-hu-man-test.txt b/doc/asciidoc/tests/data/lang-hu-man-test.txt
new file mode 100644
index 0000000..7caf1ad
--- /dev/null
+++ b/doc/asciidoc/tests/data/lang-hu-man-test.txt
@@ -0,0 +1,21 @@
+// Test for lang-hu.conf language file.
+:lang: hu
+
+ASCIIDOC(1)
+===========
+:doctype: manpage
+
+NAME
+----
+asciidoc - converts an AsciiDoc text file to HTML or DocBook
+
+ÁTTEKINTÉS
+----------
+*asciidoc* ['OPTIONS'] 'FILE'
+
+DESCRIPTION
+-----------
+The asciidoc(1) command translates the AsciiDoc text file 'FILE' to
+DocBook or HTML. If 'FILE' is '-' then the standard input is used.
+
+...
diff --git a/doc/asciidoc/tests/data/lang-hu-test.txt b/doc/asciidoc/tests/data/lang-hu-test.txt
new file mode 100644
index 0000000..cf873c2
--- /dev/null
+++ b/doc/asciidoc/tests/data/lang-hu-test.txt
@@ -0,0 +1,106 @@
+// Test for lang-hu.conf language file.
+:lang: hu
+
+Languages Test
+==============
+:revnumber: v1.0
+:revdate: 2003-12-21
+
+ifdef::doctype-article[]
+Kivonat
+-------
+Abstract special section.
+
+endif::doctype-article[]
+
+
+ifdef::doctype-book[]
+Ajánlás
+--------
+Dedication special section.
+
+
+Előszó
+------
+Preface special section.
+
+
+Utószó
+------
+Colophon special section.
+
+endif::doctype-book[]
+
+
+The First Section
+-----------------
+Admonishments
+~~~~~~~~~~~~~
+Do not translate in the source file -- they are translated to the
+output file
+
+NOTE: Lorum ipsum.
+
+TIP: Lorum ipsum.
+
+WARNING: Lorum ipsum.
+
+CAUTION: Lorum ipsum.
+
+IMPORTANT: Lorum ipsum.
+
+.Tiger
+image::../../images/tiger.png[Tiger image]
+
+Followed by an example table:
+
+.Table
+[width="60%",options="header"]
+|==============================================
+| Option | Description
+| -a 'USER GROUP' | Add 'USER' to 'GROUP'.
+| -R 'GROUP' | Disables access to 'GROUP'.
+|==============================================
+
+And now for something completely different: ((monkeys)), lions and
+tigers.
+
+
+A függelék: Example Appendix
+----------------------------
+Appendix special section.
+
+
+Bibliográfia
+------------
+Bibliography special section.
+
+[bibliography]
+- [[[taoup]]] Eric Steven Raymond. 'The Art of Unix
+ Programming'. Addison-Wesley. ISBN 0-13-142901-9.
+- [[[walsh-muellner]]] Norman Walsh & Leonard Muellner.
+ 'DocBook - The Definitive Guide'. O'Reilly & Associates. 1999.
+ ISBN 1-56592-580-7.
+
+
+Szójegyzék
+----------
+Glossary special section.
+
+[glossary]
+A glossary term::
+ The corresponding (indented) definition.
+
+A second glossary term::
+ The corresponding (indented) definition.
+
+
+ifdef::basebackend-docbook[]
+Index
+-----
+////////////////////////////////////////////////////////////////
+Index special section.
+The index is normally left completely empty, it's contents being
+generated automatically by the DocBook toolchain.
+////////////////////////////////////////////////////////////////
+endif::basebackend-docbook[]
diff --git a/doc/asciidoc/tests/data/lang-it-man-test.txt b/doc/asciidoc/tests/data/lang-it-man-test.txt
new file mode 100644
index 0000000..7309a0c
--- /dev/null
+++ b/doc/asciidoc/tests/data/lang-it-man-test.txt
@@ -0,0 +1,21 @@
+// Test for lang-it.conf language file.
+:lang: it
+
+ASCIIDOC(1)
+===========
+:doctype: manpage
+
+NAME
+----
+asciidoc - converts an AsciiDoc text file to HTML or DocBook
+
+SINOSSI
+-------
+*asciidoc* ['OPTIONS'] 'FILE'
+
+DESCRIPTION
+-----------
+The asciidoc(1) command translates the AsciiDoc text file 'FILE' to
+DocBook or HTML. If 'FILE' is '-' then the standard input is used.
+
+...
diff --git a/doc/asciidoc/tests/data/lang-it-test.txt b/doc/asciidoc/tests/data/lang-it-test.txt
new file mode 100644
index 0000000..790a57e
--- /dev/null
+++ b/doc/asciidoc/tests/data/lang-it-test.txt
@@ -0,0 +1,106 @@
+// Test for lang-it.conf language file.
+:lang: it
+
+Languages Test
+==============
+:revnumber: v1.0
+:revdate: 2003-12-21
+
+ifdef::doctype-article[]
+Abstract
+--------
+Abstract special section.
+
+endif::doctype-article[]
+
+
+ifdef::doctype-book[]
+Dedica
+------
+Dedication special section.
+
+
+Prefazione
+----------
+Preface special section.
+
+
+Colofone
+--------
+Colophon special section.
+
+endif::doctype-book[]
+
+
+The First Section
+-----------------
+Admonishments
+~~~~~~~~~~~~~
+Do not translate in the source file -- they are translated to the
+output file
+
+NOTE: Lorum ipsum.
+
+TIP: Lorum ipsum.
+
+WARNING: Lorum ipsum.
+
+CAUTION: Lorum ipsum.
+
+IMPORTANT: Lorum ipsum.
+
+.Tiger
+image::../../images/tiger.png[Tiger image]
+
+Followed by an example table:
+
+.Table
+[width="60%",options="header"]
+|==============================================
+| Option | Description
+| -a 'USER GROUP' | Add 'USER' to 'GROUP'.
+| -R 'GROUP' | Disables access to 'GROUP'.
+|==============================================
+
+And now for something completely different: ((monkeys)), lions and
+tigers.
+
+
+Appendice A: Example Appendix
+-----------------------------
+Appendix special section.
+
+
+Bibliografia
+------------
+Bibliography special section.
+
+[bibliography]
+- [[[taoup]]] Eric Steven Raymond. 'The Art of Unix
+ Programming'. Addison-Wesley. ISBN 0-13-142901-9.
+- [[[walsh-muellner]]] Norman Walsh & Leonard Muellner.
+ 'DocBook - The Definitive Guide'. O'Reilly & Associates. 1999.
+ ISBN 1-56592-580-7.
+
+
+Glossario
+---------
+Glossary special section.
+
+[glossary]
+A glossary term::
+ The corresponding (indented) definition.
+
+A second glossary term::
+ The corresponding (indented) definition.
+
+
+ifdef::basebackend-docbook[]
+Index
+-----
+////////////////////////////////////////////////////////////////
+Index special section.
+The index is normally left completely empty, it's contents being
+generated automatically by the DocBook toolchain.
+////////////////////////////////////////////////////////////////
+endif::basebackend-docbook[]
diff --git a/doc/asciidoc/tests/data/lang-nl-man-test.txt b/doc/asciidoc/tests/data/lang-nl-man-test.txt
new file mode 100644
index 0000000..4844c17
--- /dev/null
+++ b/doc/asciidoc/tests/data/lang-nl-man-test.txt
@@ -0,0 +1,21 @@
+// Test for lang-nl.conf language file.
+:lang: nl
+
+ASCIIDOC(1)
+===========
+:doctype: manpage
+
+NAME
+----
+asciidoc - converts an AsciiDoc text file to HTML or DocBook
+
+SYNOPSIS
+--------
+*asciidoc* ['OPTIONS'] 'FILE'
+
+DESCRIPTION
+-----------
+The asciidoc(1) command translates the AsciiDoc text file 'FILE' to
+DocBook or HTML. If 'FILE' is '-' then the standard input is used.
+
+...
diff --git a/doc/asciidoc/tests/data/lang-nl-test.txt b/doc/asciidoc/tests/data/lang-nl-test.txt
new file mode 100644
index 0000000..7e6e823
--- /dev/null
+++ b/doc/asciidoc/tests/data/lang-nl-test.txt
@@ -0,0 +1,94 @@
+// Test for lang-nl.conf language file.
+:lang: nl
+
+= Languages Test
+:revnumber: v1.0
+:revdate: 2003-12-21
+
+ifdef::doctype-article[]
+== Samenvatting
+Bijzonder 'abstract' sectie.
+
+endif::doctype-article[]
+
+
+ifdef::doctype-book[]
+== Opdracht
+Bijzonder 'dedication' sectie.
+
+
+== Voorwoord
+Bijzonder 'preface' sectie.
+
+
+== Colofon
+Bijzonder 'colophon' sectie.
+
+endif::doctype-book[]
+
+
+== Het Eerste Hoofdstuk
+=== Vermaningen
+Vertaal ze niet in the broncode -- ze worden vanzelf vertaald in het
+output bestand
+
+NOTE: Lorum ipsum.
+
+TIP: Lorum ipsum.
+
+WARNING: Lorum ipsum.
+
+CAUTION: Lorum ipsum.
+
+IMPORTANT: Lorum ipsum.
+
+.Tiger
+image::../../images/tiger.png[Tiger image]
+
+Gevolgd door een voorbeeld tabel:
+
+.Table
+[width="60%",options="header"]
+|==============================================
+| Optie | Beschrijving
+| -a 'USER GROUP' | Voeg 'USER' toe aan 'GROUP'.
+| -R 'GROUP' | Schakel toegang uit tot 'GROUP'.
+|==============================================
+
+En nu iets totaal anders: ((apen)), leeuwen en tijgers.
+
+
+== Bijlage A: Voorbeeld Bijlage
+Bijzonder 'appendix' sectie.
+
+
+== Literatuurlijst
+Bijzonder 'bibliography' sectie.
+
+[bibliography]
+- [[[taoup]]] Eric Steven Raymond. 'The Art of Unix
+ Programming'. Addison-Wesley. ISBN 0-13-142901-9.
+- [[[walsh-muellner]]] Norman Walsh & Leonard Muellner.
+ 'DocBook - The Definitive Guide'. O'Reilly & Associates. 1999.
+ ISBN 1-56592-580-7.
+
+
+== Woordenlijst
+Bijzonder 'glossary' sectie.
+
+[glossary]
+Een woordenlijst term::
+ De bijhorende (ingesprongen) definitie.
+
+Een tweede term::
+ De bijhorende (ingesprongen) definitie.
+
+
+ifdef::basebackend-docbook[]
+== Register
+////////////////////////////////////////////////////////////////
+Bijzonder 'index' sectie.
+Het register wordt normaal leeg gehouden, de inhoud wordt
+automatisch gegenereerd door de DocBook hulpmiddelen.
+////////////////////////////////////////////////////////////////
+endif::basebackend-docbook[]
diff --git a/doc/asciidoc/tests/data/lang-pt-BR-man-test.txt b/doc/asciidoc/tests/data/lang-pt-BR-man-test.txt
new file mode 100644
index 0000000..0363ea6
--- /dev/null
+++ b/doc/asciidoc/tests/data/lang-pt-BR-man-test.txt
@@ -0,0 +1,21 @@
+// Test for lang-pt-BR.conf language file.
+:lang: pt-BR
+
+ASCIIDOC(1)
+===========
+:doctype: manpage
+
+NAME
+----
+asciidoc - converts an AsciiDoc text file to HTML or DocBook
+
+SINOPSE
+-------
+*asciidoc* ['OPTIONS'] 'FILE'
+
+DESCRIPTION
+-----------
+The asciidoc(1) command translates the AsciiDoc text file 'FILE' to
+DocBook or HTML. If 'FILE' is '-' then the standard input is used.
+
+...
diff --git a/doc/asciidoc/tests/data/lang-pt-BR-test.txt b/doc/asciidoc/tests/data/lang-pt-BR-test.txt
new file mode 100644
index 0000000..daaff18
--- /dev/null
+++ b/doc/asciidoc/tests/data/lang-pt-BR-test.txt
@@ -0,0 +1,106 @@
+// Test for lang-pt-BR.conf language file.
+:lang: pt-BR
+
+Languages Test
+==============
+:revnumber: v1.0
+:revdate: 2003-12-21
+
+ifdef::doctype-article[]
+Resumo
+------
+Abstract special section.
+
+endif::doctype-article[]
+
+
+ifdef::doctype-book[]
+Dedicação
+---------
+Dedication special section.
+
+
+Prefácio
+--------
+Preface special section.
+
+
+Cólofon
+-------
+Colophon special section.
+
+endif::doctype-book[]
+
+
+The First Section
+-----------------
+Admonishments
+~~~~~~~~~~~~~
+Do not translate in the source file -- they are translated to the
+output file
+
+NOTE: Lorum ipsum.
+
+TIP: Lorum ipsum.
+
+WARNING: Lorum ipsum.
+
+CAUTION: Lorum ipsum.
+
+IMPORTANT: Lorum ipsum.
+
+.Tiger
+image::../../images/tiger.png[Tiger image]
+
+Followed by an example table:
+
+.Table
+[width="60%",options="header"]
+|==============================================
+| Option | Description
+| -a 'USER GROUP' | Add 'USER' to 'GROUP'.
+| -R 'GROUP' | Disables access to 'GROUP'.
+|==============================================
+
+And now for something completely different: ((monkeys)), lions and
+tigers.
+
+
+Appêndice A: Example Appendix
+-----------------------------
+Appendix special section.
+
+
+Bibliografia
+------------
+Bibliography special section.
+
+[bibliography]
+- [[[taoup]]] Eric Steven Raymond. 'The Art of Unix
+ Programming'. Addison-Wesley. ISBN 0-13-142901-9.
+- [[[walsh-muellner]]] Norman Walsh & Leonard Muellner.
+ 'DocBook - The Definitive Guide'. O'Reilly & Associates. 1999.
+ ISBN 1-56592-580-7.
+
+
+Glossário
+---------
+Glossary special section.
+
+[glossary]
+A glossary term::
+ The corresponding (indented) definition.
+
+A second glossary term::
+ The corresponding (indented) definition.
+
+
+ifdef::basebackend-docbook[]
+Índice
+------
+////////////////////////////////////////////////////////////////
+Index special section.
+The index is normally left completely empty, it's contents being
+generated automatically by the DocBook toolchain.
+////////////////////////////////////////////////////////////////
+endif::basebackend-docbook[]
diff --git a/doc/asciidoc/tests/data/lang-ru-man-test.txt b/doc/asciidoc/tests/data/lang-ru-man-test.txt
new file mode 100644
index 0000000..3e50548
--- /dev/null
+++ b/doc/asciidoc/tests/data/lang-ru-man-test.txt
@@ -0,0 +1,21 @@
+// Test for lang-ru.conf language file.
+:lang: ru
+
+ASCIIDOC(1)
+===========
+:doctype: manpage
+
+NAME
+----
+asciidoc - converts an AsciiDoc text file to HTML or DocBook
+
+ОБЗОР
+-----
+*asciidoc* ['OPTIONS'] 'FILE'
+
+DESCRIPTION
+-----------
+The asciidoc(1) command translates the AsciiDoc text file 'FILE' to
+DocBook or HTML. If 'FILE' is '-' then the standard input is used.
+
+...
diff --git a/doc/asciidoc/tests/data/lang-ru-test.txt b/doc/asciidoc/tests/data/lang-ru-test.txt
new file mode 100644
index 0000000..51d9b60
--- /dev/null
+++ b/doc/asciidoc/tests/data/lang-ru-test.txt
@@ -0,0 +1,106 @@
+// Test for lang-ru.conf language file.
+:lang: ru
+
+Languages Test
+==============
+:revnumber: v1.0
+:revdate: 2003-12-21
+
+ifdef::doctype-article[]
+Аннотация
+---------
+Abstract special section.
+
+endif::doctype-article[]
+
+
+ifdef::doctype-book[]
+Посвящение
+----------
+Dedication special section.
+
+
+Введение
+--------
+Preface special section.
+
+
+Колофон
+-------
+Colophon special section.
+
+endif::doctype-book[]
+
+
+The First Section
+-----------------
+Admonishments
+~~~~~~~~~~~~~
+Do not translate in the source file -- they are translated to the
+output file
+
+NOTE: Lorum ipsum.
+
+TIP: Lorum ipsum.
+
+WARNING: Lorum ipsum.
+
+CAUTION: Lorum ipsum.
+
+IMPORTANT: Lorum ipsum.
+
+.Tiger
+image::../../images/tiger.png[Tiger image]
+
+Followed by an example table:
+
+.Table
+[width="60%",options="header"]
+|==============================================
+| Option | Description
+| -a 'USER GROUP' | Add 'USER' to 'GROUP'.
+| -R 'GROUP' | Disables access to 'GROUP'.
+|==============================================
+
+And now for something completely different: ((monkeys)), lions and
+tigers.
+
+
+Приложение A: Example Appendix
+------------------------------
+Appendix special section.
+
+
+Библиография
+------------
+Bibliography special section.
+
+[bibliography]
+- [[[taoup]]] Eric Steven Raymond. 'The Art of Unix
+ Programming'. Addison-Wesley. ISBN 0-13-142901-9.
+- [[[walsh-muellner]]] Norman Walsh & Leonard Muellner.
+ 'DocBook - The Definitive Guide'. O'Reilly & Associates. 1999.
+ ISBN 1-56592-580-7.
+
+
+Словарь терминов
+----------------
+Glossary special section.
+
+[glossary]
+A glossary term::
+ The corresponding (indented) definition.
+
+A second glossary term::
+ The corresponding (indented) definition.
+
+
+ifdef::basebackend-docbook[]
+Предметный указатель
+--------------------
+////////////////////////////////////////////////////////////////
+Index special section.
+The index is normally left completely empty, it's contents being
+generated automatically by the DocBook toolchain.
+////////////////////////////////////////////////////////////////
+endif::basebackend-docbook[]
diff --git a/doc/asciidoc/tests/data/lang-uk-man-test.txt b/doc/asciidoc/tests/data/lang-uk-man-test.txt
new file mode 100644
index 0000000..8212e4c
--- /dev/null
+++ b/doc/asciidoc/tests/data/lang-uk-man-test.txt
@@ -0,0 +1,21 @@
+// Test for lang-uk.conf language file.
+:lang: uk
+
+ASCIIDOC(1)
+===========
+:doctype: manpage
+
+NAME
+----
+asciidoc - converts an AsciiDoc text file to HTML or DocBook
+
+ОГЛЯД
+-----
+*asciidoc* ['OPTIONS'] 'FILE'
+
+DESCRIPTION
+-----------
+The asciidoc(1) command translates the AsciiDoc text file 'FILE' to
+DocBook or HTML. If 'FILE' is '-' then the standard input is used.
+
+...
diff --git a/doc/asciidoc/tests/data/lang-uk-test.txt b/doc/asciidoc/tests/data/lang-uk-test.txt
new file mode 100644
index 0000000..76c58eb
--- /dev/null
+++ b/doc/asciidoc/tests/data/lang-uk-test.txt
@@ -0,0 +1,106 @@
+// Test for lang-uk.conf language file.
+:lang: uk
+
+Languages Test
+==============
+:revnumber: v1.0
+:revdate: 2011-01-30
+
+ifdef::doctype-article[]
+Анотація
+--------
+Abstract special section.
+
+endif::doctype-article[]
+
+
+ifdef::doctype-book[]
+Присвячення
+-----------
+Dedication special section.
+
+
+Вступ
+-----
+Preface special section.
+
+
+Колофон
+-------
+Colophon special section.
+
+endif::doctype-book[]
+
+
+The First Section
+-----------------
+Admonishments
+~~~~~~~~~~~~~
+Do not translate in the source file -- they are translated to the
+output file
+
+NOTE: Lorum ipsum.
+
+TIP: Lorum ipsum.
+
+WARNING: Lorum ipsum.
+
+CAUTION: Lorum ipsum.
+
+IMPORTANT: Lorum ipsum.
+
+.Tiger
+image::../../images/tiger.png[Tiger image]
+
+Followed by an example table:
+
+.Table
+[width="60%",options="header"]
+|==============================================
+| Option | Description
+| -a 'USER GROUP' | Add 'USER' to 'GROUP'.
+| -R 'GROUP' | Disables access to 'GROUP'.
+|==============================================
+
+And now for something completely different: ((monkeys)), lions and
+tigers.
+
+
+Додаток A: Example Appendix
+---------------------------
+Appendix special section.
+
+
+Бібліографія
+------------
+Bibliography special section.
+
+[bibliography]
+- [[[taoup]]] Eric Steven Raymond. 'The Art of Unix
+ Programming'. Addison-Wesley. ISBN 0-13-142901-9.
+- [[[walsh-muellner]]] Norman Walsh & Leonard Muellner.
+ 'DocBook - The Definitive Guide'. O'Reilly & Associates. 1999.
+ ISBN 1-56592-580-7.
+
+
+Словник термінів
+----------------
+Glossary special section.
+
+[glossary]
+A glossary term::
+ The corresponding (indented) definition.
+
+A second glossary term::
+ The corresponding (indented) definition.
+
+
+ifdef::basebackend-docbook[]
+Предметний покажчик
+-------------------
+////////////////////////////////////////////////////////////////
+Index special section.
+The index is normally left completely empty, it's contents being
+generated automatically by the DocBook toolchain.
+////////////////////////////////////////////////////////////////
+endif::basebackend-docbook[]
diff --git a/doc/asciidoc/tests/data/oldtables.txt b/doc/asciidoc/tests/data/oldtables.txt
new file mode 100644
index 0000000..f6e0706
--- /dev/null
+++ b/doc/asciidoc/tests/data/oldtables.txt
@@ -0,0 +1,64 @@
+AsciiDoc Old Tables
+===================
+
+Examples of the AsciiDoc 'old tables' syntax. This syntax was used in
+AsciiDoc versions up to 8.2.7 and has since been deprecated in favor
+of the 'new tables' syntax.
+
+Simple table:
+
+`---`---
+1 2
+3 4
+5 6
+--------
+
+Table with title, header and footer:
+
+.An example table
+[grid="all"]
+`-----------.--------------
+Column 1 Column 2
+---------------------------
+1 Item 1
+2 Item 2
+3 Item 3
+---------------------------
+6 Three items
+---------------------------
+
+Four columns totaling 15% of the 'pagewidth', CSV data:
+
+[frame="all"]
+````~15
+1,2,3,4
+a,b,c,d
+A,B,C,D
+~~~~~~~~
+
+A table with a numeric ruler and externally sourced CSV data:
+
+[frame="all", grid="all"]
+`15`20`25`20`~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ID,Customer Name,Contact Name,Customer Address,Phone
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+"AROUT","Around the Horn","Thomas Hardy","120 Hanover Sq.
+London","(171) 555-7788"
+"BERGS","Berglunds snabbkop","Christina Berglund","Berguvsvagen 8
+Lulea","0921-12 34 65"
+"BLAUS","Blauer See Delikatessen","Hanna Moos","Forsterstr. 57
+Mannheim","0621-08460"
+"BLONP","Blondel pere et fils","Frederique Citeaux","24, place Kleber
+Strasbourg","88.60.15.31"
+"BOLID","Bolido Comidas preparadas","Martin Sommer","C/ Araquil, 67
+Madrid","(91) 555 22 82"
+"BONAP","Bon app'","Laurence Lebihan","12, rue des Bouchers
+Marseille","91.24.45.40"
+"BOTTM","Bottom-Dollar Markets","Elizabeth Lincoln","23 Tsawassen Blvd.
+Tsawassen","(604) 555-4729"
+"BSBEV","B's Beverages","Victoria Ashworth","Fauntleroy Circus
+London","(171) 555-1212"
+"CACTU","Cactus Comidas para llevar","Patricio Simpson","Cerrito 333
+Buenos Aires","(1) 135-5555"
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
diff --git a/doc/asciidoc/tests/data/open-block-test.txt b/doc/asciidoc/tests/data/open-block-test.txt
new file mode 100644
index 0000000..4826c3a
--- /dev/null
+++ b/doc/asciidoc/tests/data/open-block-test.txt
@@ -0,0 +1,117 @@
+= Additional Open Block and Paragraph styles
+
+
+[comment]
+Lorum ipsum...
+
+[comment]
+--
+Lorum ipsum...
+--
+
+[example]
+Lorum ipsum...
+
+[example]
+--
+Lorum ipsum...
+
+Lorum ipsum...
+--
+
+[sidebar]
+Lorum ipsum...
+
+[sidebar]
+.A title
+--
+Lorum ipsum...
+
+Lorum ipsum...
+--
+
+[NOTE]
+--
+Lorum ipsum...
+
+Lorum ipsum...
+--
+
+[CAUTION]
+--
+Lorum ipsum...
+
+Lorum ipsum...
+--
+
+[IMPORTANT]
+--
+Lorum ipsum...
+
+Lorum ipsum...
+--
+
+[WARNING]
+--
+Lorum ipsum...
+
+Lorum ipsum...
+--
+
+[TIP]
+--
+Lorum ipsum...
+
+Lorum ipsum...
+--
+
+[quote, Sir Arthur Conan Doyle, The Adventures of Sherlock Holmes]
+--
+As he spoke there was the sharp sound of horses' hoofs and
+grating wheels against the curb, followed by a sharp pull at the
+bell. Holmes whistled.
+
+"A pair, by the sound," said he. "Yes," he continued, glancing
+out of the window. "A nice little brougham and a pair of
+beauties. A hundred and fifty guineas apiece. There's money in
+this case, Watson, if there is nothing else."
+--
+
+[verse, William Blake, from Auguries of Innocence]
+--
+To see a world in a grain of sand,
+And a heaven in a wild flower,
+Hold infinity in the palm of your hand,
+And eternity in an hour.
+--
+
+[source,python]
+--
+y = 15
+
+if y == 24:
+ x = 42
+--
+
+[latex]
+--
+$y = \int_0^\infty \gamma^2 \cos(x) dx$
+--
+
+[graphviz]
+--
+digraph G { rankdir=LR; Graphviz->AsciiDoc->HTML}
+--
+
+[music]
+--
+\version "2.10.0"
+\paper {
+ ragged-right = ##t
+}
+{
+ \time 3/4
+ \clef bass
+ c2 e4 g2. f4 e d c2 r4
+}
+--
diff --git a/doc/asciidoc/tests/data/rcs-id-marker-test.txt b/doc/asciidoc/tests/data/rcs-id-marker-test.txt
new file mode 100644
index 0000000..55b0892
--- /dev/null
+++ b/doc/asciidoc/tests/data/rcs-id-marker-test.txt
@@ -0,0 +1,6 @@
+RCS $Id$ Marker Test
+====================
+$Id: mydoc.txt,v 1.5 2009/05/17 17:58:44 jbloggs Exp $
+
+
+Lorum ipsum...
diff --git a/doc/asciidoc/tests/data/testcases.conf b/doc/asciidoc/tests/data/testcases.conf
new file mode 100644
index 0000000..de605ac
--- /dev/null
+++ b/doc/asciidoc/tests/data/testcases.conf
@@ -0,0 +1,12 @@
+[replacements]
+test-replacement=TEST_REPLACEMENT
+
+[test-template]
+This template is overriden and should not be displayed.
+
+[test-template]
+Template line 1.
+
+[+test-template]
+Template line 2.
+
diff --git a/doc/asciidoc/tests/data/testcases.txt b/doc/asciidoc/tests/data/testcases.txt
new file mode 100644
index 0000000..0678d5c
--- /dev/null
+++ b/doc/asciidoc/tests/data/testcases.txt
@@ -0,0 +1,786 @@
+//
+// A collection of AsciiDoc test cases.
+//
+
+Test 'Cases'
+============
+:author: Joe Bloggs
+// Web page meta data.
+:title: Test Cases
+:keywords: AsciiDoc, DocBook, EPUB, slideshow
+:description: AsciiDoc is a text document format for writing short documents, +
+ articles, books, slideshows and UNIX man pages.
+:replacements.(\w)'(\w): \1&#8217;\2
+:test-attribute: TEST_ATTRIBUTE
+
+
+== Passthrough attributes ==
+ifdef::basebackend-docbook[]
+:passtest: pass:[<emphasis>*lorum ipsum*</emphasis>]
+endif::basebackend-docbook[]
+ifdef::basebackend-html[]
+:passtest: pass:[<b>*lorum ipsum*</b>]
+endif::basebackend-html[]
+{passtest}
+
+ifdef::basebackend-docbook[]
+:passtest: pass:specialcharacters,quotes[<emphasis>*lorum ipsum*</emphasis>]
+endif::basebackend-docbook[]
+ifdef::basebackend-html[]
+:passtest: pass:specialcharacters,quotes[<b>*lorum ipsum*</b>]
+endif::basebackend-html[]
+{passtest}
+
+
+== Author attributes ==
+\{eval:expression}, \{sys:command} and \{sys2:command}, \{counter:c1}
+
+Hello *{author}* ({firstname} {lastname}, {authorinitials}).
+
+{firstname,lastname,surname#}first name or last name or surname.
+
+{firstname+lastname+surname#}first name and last name and surname.
+
+{firstname+lastname#}first name and last name.
+
+
+== System attributes ==
+{counter:c1} {counter:c2:99} {counter:c3:A}
+
+{c1} = 1, {c2} = 99, {c3} = A
+
+{counter:c1} {counter:c2:99} {counter:c3:A}
+{c1} {c2} {c3}
+
+{c1} = 2, {c2} = 100, {c3} = B
+
+{set:y:Foobar}
+y: {y}
+
+{set:y!}
+
+y: {y}
+
+:x: 3
+:y: {eval:{x}+4}
+
+{x}, {y}
+
+{set:y:{x}}
+
+{x}, {y}
+
+
+== Quoted text attributes ==
+
+A=_X_, (_X_), _X_, [_X_] _X_
+
+A=*_X_*, (`_X_`), _`X`_, [*_X_*] +_X_+ _X_
+
+// These two illustrate that nesting doesn't always work.
+[_*X*_] _+X+_
+
+[[_intro]]
+<<_intro>> <<_intro,intro>> xref:_intro[] _intro_
+
+// Quote attributes.
+[foo]#fun with text#.
+[foo bar]*fun with text*.
+[foo]+fun with text+.
+[foo]_fun with text_.
+[foo]'fun with text'.
+[foo]``fun with text''.
+[foo]`fun with text'.
+
+[foo]$$fun with text$$.
+
+[foo]+++fun with text+++.
+
+[red]#Obvious# and [big red yellow-background]*very obvious*.
+
+[underline]#Underline text#, [overline]#overline text#
+and [line-through]#line-through text#.
+
+[firstletter]##T##esting 123 ...
+
+(``+1\n+'') if (usually ``+-1\n+'')
+
+(``++1\n++'') if (usually ``++-1\n++'')
+
+(`{author}') and `{author}'
+
+
+== Configuration attribute entries ==
+
+:listdef-labeled.style: horizontal
+term:: definition
+
+:listdef-labeled.style: vertical
+term:: definition
+
+ifdef::backend-xhtml11[]
+<<link1>>
+
+:xref2-inlinemacro.: <a href="#{1}">{2?{2}}</a>
+
+<<link1>>
+
+:xref2-inlinemacro.: <a href="#{1}">{2=[{1}]}</a>
+endif::[]
+
+
+== role attribute ==
+
+[role="test"]
+Paragraph with a role attribute.
+
+[role="test"]
+- first
+- second
+- third
+
+
+== Break list nesting ==
+1. List 1.
+2. List 1.
+
+// New list.
+a. List 2.
+b. List 2.
+
+
+== Listing Blocks ==
+[subs="quotes"]
+------------------------------------------
+$ ls *-al*
+------------------------------------------
+
+[listing]
+..........................................
+[subs="quotes"]
+------------------------------------------
+$ ls *-al*
+------------------------------------------
+..........................................
+
+.Listing
+------------------------------------------
+$ ls -al
+------------------------------------------
+
+.Listing example
+==========================================
+------------------------------------------
+$ ls -al
+------------------------------------------
+==========================================
+
+.Python paragraph
+[source,python]
+if n < 0: print 'Hello World!'
+
+.Titled Python listing
+[source,python]
+------------------------------------------
+if n < 0: print 'Hello World!'
+------------------------------------------
+
+.Python listing example
+==========================================
+[source,python]
+------------------------------------------
+if n < 0: print 'Hello World!'
+------------------------------------------
+==========================================
+
+
+[[X1,anchor reftext]]
+== Links ==
+An [[X2]] inline anchor.
+An [[X3, anchor reftext]] inline anchor with reftext.
+
+<<X1>>; captioned link to <<X1,this test case>>.
+
+<<X2>> link to inline anchor; captioned link to <<X2,inline anchor>>.
+
+Link to <<X3>> anchor.
+
+An example link to a bibliography entry <<Test::Unit>>.
+
+[horizontal]
+[[[Test::Unit]]]:: http://ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit.html
+
+
+== Titles ==
+
+[float]
+===== Level 4 =====
+[float]
+==== Level 3 ====
+[float]
+=== Level 2 ===
+[float]
+== Level 1 ==
+[float]
+Level 4
++++++++
+[float]
+Level 3
+^^^^^^^
+[float]
+Level 2
+~~~~~~~
+[float]
+Level 1
+-------
+
+.Block title
+Lorum ipsum.
+
+
+== Lists ==
+
+Bulleted:
+
+- item text
+* item text
+** item text
+*** item text
+**** item text
+***** item text
+
+Numbered:
+
+1. arabic (decimal) numbering
+a. loweralpha numbering
+A. upperalpha numbering
+i) lowerroman numbering
+I) upperroman numbering
+. arabic (decimal) numbering
+.. loweralpha numbering
+... lowerroman numbering
+.... upperalpha numbering
+..... upperroman numbering
+
+Labeled:
+
+label:: item text
+label;; item text
+label::: item text
+label:::: item text
+
+With item anchor:
+
+one:: Item one.
+[[item_two]]two:: Item two.
+three:: Item three.
+
+
+== Inline passthroughs ==
+
+- Test pass:[`ABC`].
+- Test `pass:[ABC]`.
+- The `++i` and `++j` auto-increments.
+- Paths `~/.vim` and `~/docs`.
+- The `__init__` method.
+- The `{id}` attribute.
+
+List start number test:
+
+// The ol start attribute is not valid XHTML 1.1 (but it works in all
+// browsers).
+ifndef::backend-xhtml11[]
+[start=7]
+. List item 7.
+. List item 8.
+endif::backend-xhtml11[]
+
+== Images
+
+=== Block images
+
+[[tiger_image]]
+.Tyger tyger
+image::../../images/tiger.png[Tyger tyger]
+
+:height: 250
+:width: 350
+.Tyger tyger two
+image::../../images/tiger.png[caption="Figure 2: ", alt="Tiger", align="center"]
+:height!:
+:width!:
+
+// Images and icons directories.
+:imagesdir: ../../doc
+image::music2.png[]
+
+:icons:
+:iconsdir: ../../images/icons
+NOTE: Lorum ipsum.
+
+:icons!:
+
+ifdef::backend-xhtml11[]
+:imagesdir: ../../images
+:data-uri:
+image:smallnew.png[NEW] 'testing' `123`.
+
+endif::[]
+
+:data-uri!:
+
+=== Inline images
+
+:imagesdir: ../../images
+
+Inline image image:smallnew.png[]
+
+Inline image image:smallnew.png[NEW!]
+
+Inline image image:smallnew.png["NEW!",title="Small new"]
+
+
+== Admonishments
+
+NOTE: Lorum ipsum.
+
+TIP: Lorum ipsum.
+
+WARNING: Lorum ipsum.
+
+CAUTION: Lorum ipsum.
+
+IMPORTANT: Lorum ipsum.
+
+// With icon images.
+:icons:
+:iconsdir: ../../images/icons
+
+NOTE: Lorum ipsum.
+
+TIP: Lorum ipsum.
+
+WARNING: Lorum ipsum.
+
+CAUTION: Lorum ipsum.
+
+IMPORTANT: Lorum ipsum.
+
+:icons!:
+
+== Backslash escapes
+
+.Apostrophe
+Don't vs don\'t.
+
+.Exceptions
+There are a number of exceptions to the usual single backslash rule
+-- mostly relating to URL macros that have two syntaxes or quoting
+ambiguity. Here are some non-standard escape examples:
+
+[cols="l,v",width="40%",options="header"]
+|========================================
+|AsciiDoc | Renders
+
+2*|
+\srackham@methods.co.nz
+<\srackham@methods.co.nz>
+\mailto:[\srackham@methods.co.nz]
+
+2*|
+\http://www.foo1.co.nz
+\\http://www.foobar.com[]
+\\http://www.foobar.com[Foobar Limited]
+
+2*|
+A C\++ Library for C++
+\\``double-quotes''
+\*\*F**ile Open\...
+|========================================
+
+
+== Paragraphs
+
+.Normal paragraph
+This is a *bold* a line
+This is a 'strong' line
+This is another _strong_ line
+
+.Literal paragraph
+[literal]
+This is a *bold* a line
+This is a 'strong' line
+This is another _strong_ line
+
+.Verse paragraph
+[verse]
+This is a *bold* a line
+This is a 'strong' line
+This is another _strong_ line
+
+.Indented (literal) paragraph
+ This is a *bold* a line
+ This is a 'strong' line
+ This is another _strong_ line
+
+.Indented with quotes substitution
+[subs="quotes"]
+ This is a *bold* a line
+ This is a 'strong' line
+ This is another _strong_ line
+
+.Literal paragraph with quotes substitution
+["literal",subs="quotes"]
+This is a *bold* a line
+This is a 'strong' line
+This is another _strong_ line
+
+ifndef::basebackend-docbook[]
+.Monospaced paragraph with line breaks
++This is a *bold* line+ +
++This is a 'strong' line+ +
++This is another _strong_ line+
+
+
+.Another monospaced paragraph with line breaks
++This is a *bold* a line +
+This is a 'strong' line +
+This is another _strong_ line+
+
+endif::basebackend-docbook[]
+
+.Literal block with quotes substitution
+[subs="quotes"]
+.............................
+This is a *bold* a line
+This is a 'strong' line
+This is another _strong_ line
+.............................
+
+[verse, William Blake, from Auguries of Innocence]
+To see a world in a grain of sand,
+And a heaven in a wild flower,
+Hold infinity in the palm of your hand,
+And eternity in an hour.
+
+[quote, Bertrand Russell, The World of Mathematics (1956)]
+A good notation has subtlety and suggestiveness which at times makes
+it almost seem like a live teacher.
+
+
+URLs
+----
+Mail Addresses
+~~~~~~~~~~~~~~
+joe_bloggs@mail_server.com_
+
+joe-bloggs@mail-server.com.
+
+joe-bloggs@mail-server.com,joe-bloggs@mail-server.com,
+
+mailto:joe-bloggs@mail-server.com[Mail]
+
+mailto:joe_bloggs@mail_server.com[Mail]
+
+mailto:joe.bloggs@mail.server.com[Mail]
+
+joe.bloggs@mail.server.com +
+lorum ipsum.
+
+
+Comments
+--------
+/////////////////////////////////////////////////////////////////////
+A comment
+block.
+/////////////////////////////////////////////////////////////////////
+
+// This is a comment line.
+
+Qui in magna commodo, est labitur dolorum an. Est ne magna primis.
+// Inline comment line.
+adolescens. Sit munere ponderum dignissim et. Minim luptatum et.
+
+:showcomments:
+// This comment line will be displayed in the output.
+
+Qui in magna commodo, est labitur dolorum an. Est ne magna primis.
+// Visible inline comment line.
+adolescens. Sit munere ponderum dignissim et. Minim luptatum et.
+
+/////////////////////////////////////////////////////////////////////
+Comment blocks are never displayed in the output.
+/////////////////////////////////////////////////////////////////////
+
+:showcomments!:
+
+[[comment_macro]]
+.Block title
+// Block macro comment does not consume titles or attributes.
+Lorum ipsum.
+
+[[comment_block]]
+.Block title
+/////////////////////////////////////////////////////////////////////
+Delimited comment block does not consume titles or attributes.
+/////////////////////////////////////////////////////////////////////
+Lorum ipsum.
+
+
+ifdef::basebackend-docbook[]
+[glossary]
+List of terms
+-------------
+Using positional attribute to specify section template.
+
+[glossary]
+A glossary term::
+ The corresponding (indented) definition.
+
+A second glossary term::
+ The corresponding (indented) definition.
+
+[template="glossary"]
+List of terms
+-------------
+Using named 'template' attribute to specify section template.
+
+[glossary]
+A glossary term::
+ The corresponding (indented) definition.
+
+A second glossary term::
+ The corresponding (indented) definition.
+
+endif::basebackend-docbook[]
+
+Index Terms
+-----------
+Multi-passthough substitution (see
+http://groups.google.com/group/asciidoc/browse_frm/thread/1269dc2feb1a482c)
+((`foo`))
+(((foo,`bar`)))
+(((foo,`bar`,`two`)))
+
+Table with fractional column width units
+----------------------------------------
+NOTE: 'pagewidth' and 'pageunits' only apply to DocBook outputs.
+
+:miscellaneous.pagewidth: 17.5
+:miscellaneous.pageunits: cm
+
+.Horizontal and vertical source data
+[width="50%",cols="3,^2,^2,10",options="header"]
+|=========================================================
+|Date |Duration |Avg HR |Notes
+
+|22-Aug-08 |10:24 | 157 |
+Worked out MSHR (max sustainable heart rate) by going hard
+for this interval.
+
+|22-Aug-08 |23:03 | 152 |
+Back-to-back with previous interval.
+
+|24-Aug-08 |40:00 | 145 |
+Moderately hard interspersed with 3x 3min intervals (2min
+hard + 1min really hard taking the HR up to 160).
+
+|=========================================================
+
+== Table with parent configuration file and header attribute entry
+
+[cols="asciidoc"]
+|====
+|
+- Attribute entry from header: {test-attribute}
+- Replacement from `testcases.conf` configuration file: test-replacement
+|====
+
+== Table column specifiers with merged cells
+See
+http://groups.google.com/group/asciidoc/browse_thread/thread/c9238380a1f2507a
+
+[cols="<1m,>1,^1s, ^1e"]
+|============================================
+ .2+| .2+|1- A 2+|2- B
+ |i- a |ii- b
+ |Values 1 |v1 |v2 |v3
+ |Values 2 |v4 |v5 |v6
+|============================================
+
+Floating tables and images
+--------------------------
+.Simple table
+[float="left",width="15%"]
+|=======
+|1 |2 |A
+|3 |4 |B
+|5 |6 |C
+|=======
+
+.Tiger
+[float="right"]
+image::images/tiger.png["Tiger image"]
+
+unfloat::[]
+
+Section level offsets
+---------------------
+At level 1
+
+:leveloffset: -1
+Section title
+^^^^^^^^^^^^^
+At level 2
+
+:leveloffset: 0
+Section title
+~~~~~~~~~~~~~
+At level 2
+
+:leveloffset: 2
+Section title
+-------------
+At level 3
+
+:leveloffset!:
+:numbered!:
+
+Section level offsets
+---------------------
+At level 1
+
+Single-quoted attributes
+------------------------
+[quote,'http://en.wikipedia.org/wiki/Samuel_Johnson[Samuel Johnson]']
+_____________________________________________________________________
+Sir, a woman's preaching is like a dog's walking on his hind legs. It
+is not done well; but you are surprised to find it done at all.
+_____________________________________________________________________
+
+["quote","'http://en.wikipedia.org/wiki/Samuel_Johnson[Samuel Johnson]'"]
+_____________________________________________________________________
+Sir, a woman's preaching is like a dog's walking on his hind legs. It
+is not done well; but you are surprised to find it done at all.
+_____________________________________________________________________
+
+Footnotes
+---------
+Qui in magna commodo, est labitur dolorum an. Est ne magna primis
+adolescens. Sit munere ponderum dignissim et. Minim luptatum et vel.
+footnote:[footnote one.
+Qui in magna commodo, est labitur dolorum an. Est ne magna primis
+adolescens. Sit munere ponderum dignissim et. Minim luptatum et vel.
+Qui in magna commodo, est labitur dolorum an. Est ne magna primis
+adolescens. Sit munere ponderum dignissim et. Minim luptatum et vel.]
+Qui in magna commodo, est labitur dolorum an. Est ne magna primis
+adolescens. Sit munere ponderum dignissim et. Minim luptatum et vel.
+footnoteref:["F2","footnote two.
+Qui in magna commodo, est labitur dolorum an. Est ne magna primis
+adolescens. Sit munere ponderum dignissim et. Minim luptatum et vel."]
+Qui in magna commodo, est labitur dolorum an. Est ne magna primis
+adolescens. Sit munere ponderum dignissim et. Minim luptatum et vel
+footnoteref:[F2].
+Qui in magna commodo, est labitur dolorum an. Est ne magna primis
+adolescens. Sit munere ponderum dignissim et. Minim luptatum et vel.
+footnote:[http://www.methods.co.nz/asciidoc/ Qui in magna commodo,
+est labitur dolorum an. Est ne magna primis adolescens. Sit munere
+ponderum dignissim et. Minim luptatum et vel
+image:images/smallnew.png[]]
+Qui in magna commodo, est labitur dolorum an. Est ne magna primis
+adolescens. Sit munere ponderum dignissim et. Minim luptatum et vel.
+footnote:[http://www.methods.co.nz/asciidoc/]
+Qui in magna commodo, est labitur dolorum an. Est ne magna primis
+adolescens. Sit munere ponderum dignissim et. Minim luptatum et
+vel footnote:[http://www.methods.co.nz/asciidoc/[AsciiDoc website].].
+Qui in magna commodo, est labitur dolorum an. Est ne magna primis
+adolescens. Sit munere ponderum dignissim et. Minim luptatum et
+footnoteref:[F3,A footnote&#44; &#34;with an image&#34;
+image:images/smallnew.png[]].
+footnote:[With [square brackets\]] Qui in magna commodo, est labitur
+dolorum an. Est ne magna primis.
+
+
+Rulers and page breaks
+----------------------
+
+Lorum ipsum...
+
+''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+
+Lorum ipsum...
+
+<<<
+
+Lorum ipsum...
+
+
+这是一个测试
+------------
+Double-with character titles.
+<<_这是一个测试,link to auto-generated section ID>>.
+
+
+ifdef::backend-html5[]
+HTML 5 audio and video block macros
+-----------------------------------
+audio::images/example.ogg[]
+
+.Audio tag test
+audio::images/example.ogg[]
+
+video::images/gizmo.ogv[width=200,options="nocontrols,autoplay"]
+
+.Example video
+video::images/gizmo.ogv[]
+
+video::http://www.808.dk/pics/video/gizmo.ogv[]
+
+++++
+<video poster="images/gizmo.jpg" id="video" style="cursor: pointer;" >
+ <source src="images/gizmo.webm" type="video/webm" />
+ <source src="images/gizmo.ogv" type="video/ogg" />
+ Video not playing? <a href="images/gizmo.mp4">Download file</a> instead.
+</video>
+
+<script type="text/javascript">
+ var video = document.getElementById('video');
+ video.addEventListener('click',function(){
+ video.play();
+ },false);
+</script>
+++++
+
+endif::backend-html5[]
+
+
+== Block macros
+
+:rs458: 2
+
+ifeval::[{rs458}==2]
+RS458 is 2.
+endif::[]
+ifeval::[not ({rs458}==2)]
+This will not be processed.
+endif::[]
+
+// Test eval block macro.
+eval::[Section.setlevel(1)]
+
+// Test template concatenation.
+{template:test-template}
+
+// Test ascii-ids attribute.
+:ascii-ids:
+== àn îd without accénts
+Lorum ipsum...
+
+:ascii-ids!:
+== àn îd with accénts
+Lorum ipsum...
+
+
+== Inline macros
+http://groups.google.com/group/asciidoc/[A URL with [square
+brackets\]].
diff --git a/doc/asciidoc/tests/data/utf8-bom-test.txt b/doc/asciidoc/tests/data/utf8-bom-test.txt
new file mode 100644
index 0000000..03aae22
--- /dev/null
+++ b/doc/asciidoc/tests/data/utf8-bom-test.txt
@@ -0,0 +1,9 @@
+UTF-8 BOM Test
+==============
+
+Include file with UTF-8 BOM:
+
+:leveloffset: 1
+include::{docfile}[depth=1]
+
+Lorum ipsum...
diff --git a/doc/asciidoc/tests/data/utf8-examples.txt b/doc/asciidoc/tests/data/utf8-examples.txt
new file mode 100644
index 0000000..0358f24
--- /dev/null
+++ b/doc/asciidoc/tests/data/utf8-examples.txt
@@ -0,0 +1,217 @@
+UTF-8 encoded sample plain-text file
+====================================
+
+Markus Kuhn [ˈmaʳkʊs kuːn] <http://www.cl.cam.ac.uk/~mgk25/> — 2002-07-25
+
+
+The ASCII compatible UTF-8 encoding used in this plain-text file
+is defined in Unicode, ISO 10646-1, and RFC 2279.
+
+
+Using Unicode/UTF-8, you can write in emails and source code things such as
+
+== Mathematics and sciences
+
+ ∮ E⋅da = Q, n → ∞, ∑ f(i) = ∏ g(i), ⎧⎡⎛┌─────┐⎞⎤⎫
+ ⎪⎢⎜│a²+b³ ⎟⎥⎪
+ ∀x∈ℝ: ⌈x⌉ = −⌊−x⌋, α ∧ ¬β = ¬(¬α ∨ β), ⎪⎢⎜│───── ⎟⎥⎪
+ ⎪⎢⎜⎷ c₈ ⎟⎥⎪
+ ℕ ⊆ ℕ₀ ⊂ ℤ ⊂ ℚ ⊂ ℝ ⊂ ℂ, ⎨⎢⎜ ⎟⎥⎬
+ ⎪⎢⎜ ∞ ⎟⎥⎪
+ ⊥ < a ≠ b ≡ c ≤ d ≪ ⊤ ⇒ (⟦A⟧ ⇔ ⟪B⟫), ⎪⎢⎜ ⎲ ⎟⎥⎪
+ ⎪⎢⎜ ⎳aⁱ-bⁱ⎟⎥⎪
+ 2H₂ + O₂ ⇌ 2H₂O, R = 4.7 kΩ, ⌀ 200 mm ⎩⎣⎝i=1 ⎠⎦⎭
+
+
+== Linguistics and dictionaries
+
+ði ıntəˈnæʃənəl fəˈnɛtık əsoʊsiˈeıʃn +
+Y [ˈʏpsilɔn], Yen [jɛn], Yoga [ˈjoːgɑ]
+
+
+== APL
+
+ ((V⍳V)=⍳⍴V)/V←,V ⌷←⍳→⍴∆∇⊃‾⍎⍕⌈
+
+
+== Nicer typography in plain text files
+
+- ‘single’ and “double” quotes
+- Curly apostrophes: “We’ve been here”
+- ‚deutsche‘ „Anführungszeichen“
+- †, ‡, ‰, •, 3–4, —, −5/+5, ™, …
+- ASCII safety test: 1lI|, 0OD, 8B
+- the euro symbol: 14.95 €
+
+
+== Combining characters
+
+STARGΛ̊TE SG-1, a = v̇ = r̈, a⃑ ⊥ b⃑
+
+== Greek (in Polytonic)
+
+[verse, The Greek anthem]
+________________________________
+Σὲ γνωρίζω ἀπὸ τὴν κόψη
+τοῦ σπαθιοῦ τὴν τρομερή,
+σὲ γνωρίζω ἀπὸ τὴν ὄψη
+ποὺ μὲ βία μετράει τὴ γῆ.
+
+᾿Απ᾿ τὰ κόκκαλα βγαλμένη
+τῶν ῾Ελλήνων τὰ ἱερά
+καὶ σὰν πρῶτα ἀνδρειωμένη
+χαῖρε, ὦ χαῖρε, ᾿Ελευθεριά!
+________________________________
+
+[verse,From a speech of Demosthenes in the 4th century BC]
+______________________________________________________________
+Οὐχὶ ταὐτὰ παρίσταταί μοι γιγνώσκειν, ὦ ἄνδρες ᾿Αθηναῖοι,
+ὅταν τ᾿ εἰς τὰ πράγματα ἀποβλέψω καὶ ὅταν πρὸς τοὺς
+λόγους οὓς ἀκούω· τοὺς μὲν γὰρ λόγους περὶ τοῦ
+τιμωρήσασθαι Φίλιππον ὁρῶ γιγνομένους, τὰ δὲ πράγματ᾿
+εἰς τοῦτο προήκοντα, ὥσθ᾿ ὅπως μὴ πεισόμεθ᾿ αὐτοὶ
+πρότερον κακῶς σκέψασθαι δέον. οὐδέν οὖν ἄλλο μοι δοκοῦσιν
+οἱ τὰ τοιαῦτα λέγοντες ἢ τὴν ὑπόθεσιν, περὶ ἧς βουλεύεσθαι,
+οὐχὶ τὴν οὖσαν παριστάντες ὑμῖν ἁμαρτάνειν. ἐγὼ δέ, ὅτι μέν
+ποτ᾿ ἐξῆν τῇ πόλει καὶ τὰ αὑτῆς ἔχειν ἀσφαλῶς καὶ Φίλιππον
+τιμωρήσασθαι, καὶ μάλ᾿ ἀκριβῶς οἶδα· ἐπ᾿ ἐμοῦ γάρ, οὐ πάλαι
+γέγονεν ταῦτ᾿ ἀμφότερα· νῦν μέντοι πέπεισμαι τοῦθ᾿ ἱκανὸν
+προλαβεῖν ἡμῖν εἶναι τὴν πρώτην, ὅπως τοὺς συμμάχους
+σώσομεν. ἐὰν γὰρ τοῦτο βεβαίως ὑπάρξῃ, τότε καὶ περὶ τοῦ
+τίνα τιμωρήσεταί τις καὶ ὃν τρόπον ἐξέσται σκοπεῖν· πρὶν δὲ
+τὴν ἀρχὴν ὀρθῶς ὑποθέσθαι, μάταιον ἡγοῦμαι περὶ τῆς
+τελευτῆς ὁντινοῦν ποιεῖσθαι λόγον.
+
+Δημοσθένους, Γ´ ᾿Ολυνθιακὸς
+______________________________________________________________
+
+
+== Georgian:
+
+.From a Unicode conference invitation
+გთხოვთ ახლავე გაიაროთ რეგისტრაცია Unicode-ის მეათე საერთაშორისო
+კონფერენციაზე დასასწრებად, რომელიც გაიმართება 10-12 მარტს,
+ქ. მაინცში, გერმანიაში. კონფერენცია შეჰკრებს ერთად მსოფლიოს
+ექსპერტებს ისეთ დარგებში როგორიცაა ინტერნეტი და Unicode-ი,
+ინტერნაციონალიზაცია და ლოკალიზაცია, Unicode-ის გამოყენება
+ოპერაციულ სისტემებსა, და გამოყენებით პროგრამებში, შრიფტებში,
+ტექსტების დამუშავებასა და მრავალენოვან კომპიუტერულ სისტემებში.
+
+
+== Russian
+
+.From a Unicode conference invitation
+Зарегистрируйтесь сейчас на Десятую Международную Конференцию по
+Unicode, которая состоится 10-12 марта 1997 года в Майнце в Германии.
+Конференция соберет широкий круг экспертов по вопросам глобального
+Интернета и Unicode, локализации и интернационализации, воплощению и
+применению Unicode в различных операционных системах и программных
+приложениях, шрифтах, верстке и многоязычных компьютерных системах.
+
+
+== Thai (UCS Level 2)
+
+Excerpt from a poetry on The Romance of The Three Kingdoms (a Chinese
+classic 'San Gua'):
+
+ [----------------------------|------------------------]
+ ๏ แผ่นดินฮั่นเสื่อมโทรมแสนสังเวช พระปกเกศกองบู๊กู้ขึ้นใหม่
+ สิบสองกษัตริย์ก่อนหน้าแลถัดไป สององค์ไซร้โง่เขลาเบาปัญญา
+ ทรงนับถือขันทีเป็นที่พึ่ง บ้านเมืองจึงวิปริตเป็นนักหนา
+ โฮจิ๋นเรียกทัพทั่วหัวเมืองมา หมายจะฆ่ามดชั่วตัวสำคัญ
+ เหมือนขับไสไล่เสือจากเคหา รับหมาป่าเข้ามาเลยอาสัญ
+ ฝ่ายอ้องอุ้นยุแยกให้แตกกัน ใช้สาวนั้นเป็นชนวนชื่นชวนใจ
+ พลันลิฉุยกุยกีกลับก่อเหตุ ช่างอาเพศจริงหนาฟ้าร้องไห้
+ ต้องรบราฆ่าฟันจนบรรลัย ฤๅหาใครค้ำชูกู้บรรลังก์ ฯ
+
+(The above is a two-column text. If combining characters are handled
+correctly, the lines of the second column should be aligned with the
+| character above.)
+
+
+== Ethiopian
+
+.Proverbs in the Amharic language
+[verse]
+ሰማይ አይታረስ ንጉሥ አይከሰስ።
+ብላ ካለኝ እንደአባቴ በቆመጠኝ።
+ጌጥ ያለቤቱ ቁምጥና ነው።
+ደሀ በሕልሙ ቅቤ ባይጠጣ ንጣት በገደለው።
+የአፍ ወለምታ በቅቤ አይታሽም።
+አይጥ በበላ ዳዋ ተመታ።
+ሲተረጉሙ ይደረግሙ።
+ቀስ በቀስ፥ ዕንቁላል በእግሩ ይሄዳል።
+ድር ቢያብር አንበሳ ያስር።
+ሰው እንደቤቱ እንጅ እንደ ጉረቤቱ አይተዳደርም።
+እግዜር የከፈተውን ጉሮሮ ሳይዘጋው አይድርም።
+የጎረቤት ሌባ፥ ቢያዩት ይስቅ ባያዩት ያጠልቅ።
+ሥራ ከመፍታት ልጄን ላፋታት።
+ዓባይ ማደሪያ የለው፥ ግንድ ይዞ ይዞራል።
+የእስላም አገሩ መካ የአሞራ አገሩ ዋርካ።
+ተንጋሎ ቢተፉ ተመልሶ ባፉ።
+ወዳጅህ ማር ቢሆን ጨርስህ አትላሰው።
+እግርህን በፍራሽህ ልክ ዘርጋ።
+
+
+== Runes
+
+ᚻᛖ ᚳᚹᚫᚦ ᚦᚫᛏ ᚻᛖ ᛒᚢᛞᛖ ᚩᚾ ᚦᚫᛗ ᛚᚪᚾᛞᛖ ᚾᚩᚱᚦᚹᛖᚪᚱᛞᚢᛗ ᚹᛁᚦ ᚦᚪ ᚹᛖᛥᚫ
+
+(Old English, which transcribed into Latin reads ``He cwaeth that he
+bude thaem lande northweardum with tha Westsae.'' and means ``He said
+that he lived in the northern land near the Western Sea.'')
+
+
+== Braille
+
+ ⡌⠁⠧⠑ ⠼⠁⠒ ⡍⠜⠇⠑⠹⠰⠎ ⡣⠕⠌
+
+ ⡍⠜⠇⠑⠹ ⠺⠁⠎ ⠙⠑⠁⠙⠒ ⠞⠕ ⠃⠑⠛⠔ ⠺⠊⠹⠲ ⡹⠻⠑ ⠊⠎ ⠝⠕ ⠙⠳⠃⠞
+ ⠱⠁⠞⠑⠧⠻ ⠁⠃⠳⠞ ⠹⠁⠞⠲ ⡹⠑ ⠗⠑⠛⠊⠌⠻ ⠕⠋ ⠙⠊⠎ ⠃⠥⠗⠊⠁⠇ ⠺⠁⠎
+ ⠎⠊⠛⠝⠫ ⠃⠹ ⠹⠑ ⠊⠇⠻⠛⠹⠍⠁⠝⠂ ⠹⠑ ⠊⠇⠻⠅⠂ ⠹⠑ ⠥⠝⠙⠻⠞⠁⠅⠻⠂
+ ⠁⠝⠙ ⠹⠑ ⠡⠊⠑⠋ ⠍⠳⠗⠝⠻⠲ ⡎⠊⠗⠕⠕⠛⠑ ⠎⠊⠛⠝⠫ ⠊⠞⠲ ⡁⠝⠙
+ ⡎⠊⠗⠕⠕⠛⠑⠰⠎ ⠝⠁⠍⠑ ⠺⠁⠎ ⠛⠕⠕⠙ ⠥⠏⠕⠝ ⠰⡡⠁⠝⠛⠑⠂ ⠋⠕⠗ ⠁⠝⠹⠹⠔⠛ ⠙⠑
+ ⠡⠕⠎⠑ ⠞⠕ ⠏⠥⠞ ⠙⠊⠎ ⠙⠁⠝⠙ ⠞⠕⠲
+
+ ⡕⠇⠙ ⡍⠜⠇⠑⠹ ⠺⠁⠎ ⠁⠎ ⠙⠑⠁⠙ ⠁⠎ ⠁ ⠙⠕⠕⠗⠤⠝⠁⠊⠇⠲
+
+ ⡍⠔⠙⠖ ⡊ ⠙⠕⠝⠰⠞ ⠍⠑⠁⠝ ⠞⠕ ⠎⠁⠹ ⠹⠁⠞ ⡊ ⠅⠝⠪⠂ ⠕⠋ ⠍⠹
+ ⠪⠝ ⠅⠝⠪⠇⠫⠛⠑⠂ ⠱⠁⠞ ⠹⠻⠑ ⠊⠎ ⠏⠜⠞⠊⠊⠥⠇⠜⠇⠹ ⠙⠑⠁⠙ ⠁⠃⠳⠞
+ ⠁ ⠙⠕⠕⠗⠤⠝⠁⠊⠇⠲ ⡊ ⠍⠊⠣⠞ ⠙⠁⠧⠑ ⠃⠑⠲ ⠔⠊⠇⠔⠫⠂ ⠍⠹⠎⠑⠇⠋⠂ ⠞⠕
+ ⠗⠑⠛⠜⠙ ⠁ ⠊⠕⠋⠋⠔⠤⠝⠁⠊⠇ ⠁⠎ ⠹⠑ ⠙⠑⠁⠙⠑⠌ ⠏⠊⠑⠊⠑ ⠕⠋ ⠊⠗⠕⠝⠍⠕⠝⠛⠻⠹
+ ⠔ ⠹⠑ ⠞⠗⠁⠙⠑⠲ ⡃⠥⠞ ⠹⠑ ⠺⠊⠎⠙⠕⠍ ⠕⠋ ⠳⠗ ⠁⠝⠊⠑⠌⠕⠗⠎
+ ⠊⠎ ⠔ ⠹⠑ ⠎⠊⠍⠊⠇⠑⠆ ⠁⠝⠙ ⠍⠹ ⠥⠝⠙⠁⠇⠇⠪⠫ ⠙⠁⠝⠙⠎
+ ⠩⠁⠇⠇ ⠝⠕⠞ ⠙⠊⠌⠥⠗⠃ ⠊⠞⠂ ⠕⠗ ⠹⠑ ⡊⠳⠝⠞⠗⠹⠰⠎ ⠙⠕⠝⠑ ⠋⠕⠗⠲ ⡹⠳
+ ⠺⠊⠇⠇ ⠹⠻⠑⠋⠕⠗⠑ ⠏⠻⠍⠊⠞ ⠍⠑ ⠞⠕ ⠗⠑⠏⠑⠁⠞⠂ ⠑⠍⠏⠙⠁⠞⠊⠊⠁⠇⠇⠹⠂ ⠹⠁⠞
+ ⡍⠜⠇⠑⠹ ⠺⠁⠎ ⠁⠎ ⠙⠑⠁⠙ ⠁⠎ ⠁ ⠙⠕⠕⠗⠤⠝⠁⠊⠇⠲
+
+(The first couple of paragraphs of "A Christmas Carol" by Dickens)
+
+
+== Compact font selection example text
+
+ ABCDEFGHIJKLMNOPQRSTUVWXYZ /0123456789
+ abcdefghijklmnopqrstuvwxyz £©µÀÆÖÞßéöÿ
+ –—‘“”„†•…‰™œŠŸž€ ΑΒΓΔΩαβγδω АБВГДабвгд
+ ∀∂∈ℝ∧∪≡∞ ↑↗↨↻⇣ ┐┼╔╘░►☺♀ fi�⑀₂ἠḂӥẄɐː⍎אԱა
+
+
+== Greetings in various languages
+
+Hello world, Καλημέρα κόσμε, コンニチハ
+
+
+== Box drawing alignment tests
+
+---------------------------------------------------------------------
+ █
+ ▉
+ ╔══╦══╗ ┌──┬──┐ ╭──┬──╮ ╭──┬──╮ ┏━━┳━━┓ ┎┒┏┑ ╷ ╻ ┏┯┓ ┌┰┐ ▊ ╱╲╱╲╳╳╳
+ ║┌─╨─┐║ │╔═╧═╗│ │╒═╪═╕│ │╓─╁─╖│ ┃┌─╂─┐┃ ┗╃╄┙ ╶┼╴╺╋╸┠┼┨ ┝╋┥ ▋ ╲╱╲╱╳╳╳
+ ║│╲ ╱│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╿ │┃ ┍╅╆┓ ╵ ╹ ┗┷┛ └┸┘ ▌ ╱╲╱╲╳╳╳
+ ╠╡ ╳ ╞╣ ├╢ ╟┤ ├┼─┼─┼┤ ├╫─╂─╫┤ ┣┿╾┼╼┿┫ ┕┛┖┚ ┌┄┄┐ ╎ ┏┅┅┓ ┋ ▍ ╲╱╲╱╳╳╳
+ ║│╱ ╲│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╽ │┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▎
+ ║└─╥─┘║ │╚═╤═╝│ │╘═╪═╛│ │╙─╀─╜│ ┃└─╂─┘┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▏
+ ╚══╩══╝ └──┴──┘ ╰──┴──╯ ╰──┴──╯ ┗━━┻━━┛ ▗▄▖▛▀▜ └╌╌┘ ╎ ┗╍╍┛ ┋ ▁▂▃▄▅▆▇█
+ ▝▀▘▙▄▟
+---------------------------------------------------------------------
diff --git a/doc/asciidoc/tests/testasciidoc.conf b/doc/asciidoc/tests/testasciidoc.conf
new file mode 100644
index 0000000..62dc7f4
--- /dev/null
+++ b/doc/asciidoc/tests/testasciidoc.conf
@@ -0,0 +1,652 @@
+% globals
+{
+ 'datadir': 'data',
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Test cases
+
+% source
+data/testcases.txt
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Filters
+
+% source
+data/filters-test.txt
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Tables
+
+% source
+../examples/website/newtables.txt
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Old tables
+
+% source
+data/oldtables.txt
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Source highlighter
+
+% source
+../doc/source-highlight-filter.txt
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Example article
+
+% options
+['--section-numbers', ('--attribute','css-signature=article-test')]
+
+% attributes
+# So document date in footer doesn't generate an error.
+{'docdate':None}
+
+% source
+../doc/article.txt
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Example article with embedded images (data URIs)
+
+% source
+../doc/article.txt
+
+% name
+article-data-uri
+
+% backends
+['xhtml11','html5']
+
+% options
+['--section-numbers']
+
+% attributes
+{'docdate':None, 'data-uri':True, 'icons':True}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Example article with included docinfo file.
+
+% source
+../doc/article.txt
+
+% name
+article-docinfo
+
+% backends
+['docbook']
+
+% options
+['--section-numbers']
+
+% attributes
+{'docdate':None, 'docinfo':True}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Example book
+
+% options
+['--section-numbers']
+
+% source
+../doc/book.txt
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Example multi-part book
+
+% options
+['--section-numbers']
+
+% source
+../doc/book-multi.txt
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Man page
+
+% attributes
+# So document date in footer doesn't generate an error.
+{'docdate':None}
+
+% source
+../doc/asciidoc.1.txt
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Example slideshow
+
+% backends
+['slidy']
+
+% source
+../doc/slidy-example.txt
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ASCIIMathML
+
+% attributes
+{'asciimath':'','deprecated-quotes':''}
+
+% backends
+['xhtml11','html5']
+
+% source
+../doc/asciimathml.txt
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+LaTeXMathML
+
+% attributes
+{'latexmath':''}
+
+% backends
+['xhtml11','html5']
+
+% source
+../doc/latexmathml.txt
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+LaTeX Math
+
+% backends
+['docbook']
+
+% source
+../doc/latexmath.txt
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+LaTeX Filter
+
+% source
+../doc/latex-filter.txt
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+!User Guide
+
+% options
+['--section-numbers']
+
+% source
+../doc/asciidoc.txt
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+UTF-8 Examples
+
+% source
+data/utf8-examples.txt
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Additional Open Block and Paragraph styles
+
+% source
+data/open-block-test.txt
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+English language file (article)
+
+% backends
+['docbook','xhtml11','html4','html5']
+
+% name
+lang-en-article-test
+
+% source
+data/lang-en-test.txt
+
+% options
+[('--doctype','article')]
+
+% attributes
+{'toc':True}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+English language file (book)
+
+% backends
+['docbook','xhtml11','html4','html5']
+
+% name
+lang-en-book-test
+
+% source
+data/lang-en-test.txt
+
+% options
+[('--doctype','book')]
+
+% attributes
+{'toc':True}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+English language file (manpage)
+
+% backends
+['docbook']
+
+% source
+data/lang-en-man-test.txt
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Russian language file (article)
+
+% backends
+['docbook','xhtml11','html4','html5']
+
+% name
+lang-ru-article-test
+
+% source
+data/lang-ru-test.txt
+
+% options
+[('--doctype','article')]
+
+% attributes
+{'toc':True}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Russian language file (book)
+
+% backends
+['docbook','xhtml11','html4','html5']
+
+% name
+lang-ru-book-test
+
+% source
+data/lang-ru-test.txt
+
+% options
+[('--doctype','book')]
+
+% attributes
+{'toc':True}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Russian language file (manpage)
+
+% backends
+['docbook']
+
+% source
+data/lang-ru-man-test.txt
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+French language file (article)
+
+% backends
+['docbook','xhtml11','html4','html5']
+
+% name
+lang-fr-article-test
+
+% source
+data/lang-fr-test.txt
+
+% options
+[('--doctype','article')]
+
+% attributes
+{'toc':True}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+French language file (book)
+
+% backends
+['docbook','xhtml11','html4','html5']
+
+% name
+lang-fr-book-test
+
+% source
+data/lang-fr-test.txt
+
+% options
+[('--doctype','book')]
+
+% attributes
+{'toc':True}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+French language file (manpage)
+
+% backends
+['docbook']
+
+% source
+data/lang-fr-man-test.txt
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+German language file (article)
+
+% backends
+['docbook','xhtml11','html4','html5']
+
+% name
+lang-de-article-test
+
+% source
+data/lang-de-test.txt
+
+% options
+[('--doctype','article')]
+
+% attributes
+{'toc':True}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+German language file (book)
+
+% backends
+['docbook','xhtml11','html4','html5']
+
+% name
+lang-de-book-test
+
+% source
+data/lang-de-test.txt
+
+% options
+[('--doctype','book')]
+
+% attributes
+{'toc':True}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+German language file (manpage)
+
+% backends
+['docbook']
+
+% source
+data/lang-de-man-test.txt
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Hungarian language file (article)
+
+% backends
+['docbook','xhtml11','html4','html5']
+
+% name
+lang-hu-article-test
+
+% source
+data/lang-hu-test.txt
+
+% options
+[('--doctype','article')]
+
+% attributes
+{'toc':True}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Hungarian language file (book)
+
+% backends
+['docbook','xhtml11','html4','html5']
+
+% name
+lang-hu-book-test
+
+% source
+data/lang-hu-test.txt
+
+% options
+[('--doctype','book')]
+
+% attributes
+{'toc':True}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Hungarian language file (manpage)
+
+% backends
+['docbook']
+
+% source
+data/lang-hu-man-test.txt
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Spanish language file (article)
+
+% backends
+['docbook','xhtml11','html4','html5']
+
+% name
+lang-es-article-test
+
+% source
+data/lang-es-test.txt
+
+% options
+[('--doctype','article')]
+
+% attributes
+{'toc':True}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Spanish language file (book)
+
+% backends
+['docbook','xhtml11','html4','html5']
+
+% name
+lang-es-book-test
+
+% source
+data/lang-es-test.txt
+
+% options
+[('--doctype','book')]
+
+% attributes
+{'toc':True}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Spanish language file (manpage)
+
+% backends
+['docbook']
+
+% source
+data/lang-es-man-test.txt
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Brazilian Portuguese language file (article)
+
+% backends
+['docbook','xhtml11','html4','html5']
+
+% name
+lang-pt-BR-article-test
+
+% source
+data/lang-pt-BR-test.txt
+
+% options
+[('--doctype','article')]
+
+% attributes
+{'toc':True}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Brazilian Portuguese language file (book)
+
+% backends
+['docbook','xhtml11','html4','html5']
+
+% name
+lang-pt-BR-book-test
+
+% source
+data/lang-pt-BR-test.txt
+
+% options
+[('--doctype','book')]
+
+% attributes
+{'toc':True}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Brazilian Portuguese language file (manpage)
+
+% backends
+['docbook']
+
+% source
+data/lang-pt-BR-man-test.txt
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Ukrainian language file (article)
+
+% backends
+['docbook','xhtml11','html4','html5']
+
+% name
+lang-uk-article-test
+
+% source
+data/lang-uk-test.txt
+
+% options
+[('--doctype','article')]
+
+% attributes
+{'toc':True}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Ukrainian language file (book)
+
+% backends
+['docbook','xhtml11','html4','html5']
+
+% name
+lang-uk-book-test
+
+% source
+data/lang-uk-test.txt
+
+% options
+[('--doctype','book')]
+
+% attributes
+{'toc':True}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Ukrainian language file (manpage)
+
+% backends
+['docbook']
+
+% source
+data/lang-uk-man-test.txt
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Dutch language file (article)
+
+% backends
+['docbook','xhtml11','html4','html5']
+
+% name
+lang-nl-article-test
+
+% source
+data/lang-nl-test.txt
+
+% options
+[('--doctype','article')]
+
+% attributes
+{'toc':True}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Dutch language file (book)
+
+% backends
+['docbook','xhtml11','html4','html5']
+
+% name
+lang-nl-book-test
+
+% source
+data/lang-nl-test.txt
+
+% options
+[('--doctype','book')]
+
+% attributes
+{'toc':True}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Dutch language file (manpage)
+
+% backends
+['docbook']
+
+% source
+data/lang-nl-man-test.txt
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Italian language file (article)
+
+% backends
+['docbook','xhtml11','html4','html5']
+
+% name
+lang-it-article-test
+
+% source
+data/lang-it-test.txt
+
+% options
+[('--doctype','article')]
+
+% attributes
+{'toc':True}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Italian language file (book)
+
+% backends
+['docbook','xhtml11','html4','html5']
+
+% name
+lang-it-book-test
+
+% source
+data/lang-it-test.txt
+
+% options
+[('--doctype','book')]
+
+% attributes
+{'toc':True}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Italian language file (manpage)
+
+% backends
+['docbook']
+
+% source
+data/lang-it-man-test.txt
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+RCS $Id$ marker test
+
+% source
+data/rcs-id-marker-test.txt
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+UTF-8 BOM test
+
+% source
+data/utf8-bom-test.txt
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+Deprecated quote attributes
+
+% attributes
+{'deprecated-quotes':''}
+
+% source
+data/deprecated-quotes.txt
+
diff --git a/doc/asciidoc/tests/testasciidoc.py b/doc/asciidoc/tests/testasciidoc.py
new file mode 100755
index 0000000..679ad35
--- /dev/null
+++ b/doc/asciidoc/tests/testasciidoc.py
@@ -0,0 +1,420 @@
+#!/usr/bin/env python
+
+USAGE = '''Usage: testasciidoc.py [OPTIONS] COMMAND
+
+Run AsciiDoc conformance tests specified in configuration FILE.
+
+Commands:
+ list List tests
+ run [NUMBER] [BACKEND] Execute tests
+ update [NUMBER] [BACKEND] Regenerate and update test data
+
+Options:
+ -f, --conf-file=CONF_FILE
+ Use configuration file CONF_FILE (default configuration file is
+ testasciidoc.conf in testasciidoc.py directory)
+ --force
+ Update all test data overwriting existing data'''
+
+
+__version__ = '0.1.1'
+__copyright__ = 'Copyright (C) 2009 Stuart Rackham'
+
+
+import os, sys, re, difflib
+
+if sys.platform[:4] == 'java':
+ # Jython cStringIO is more compatible with CPython StringIO.
+ import cStringIO as StringIO
+else:
+ import StringIO
+
+import asciidocapi
+
+
+BACKENDS = ('html4','xhtml11','docbook','wordpress','html5') # Default backends.
+BACKEND_EXT = {'html4':'.html', 'xhtml11':'.html', 'docbook':'.xml',
+ 'wordpress':'.html','slidy':'.html','html5':'.html'}
+
+
+def iif(condition, iftrue, iffalse=None):
+ """
+ Immediate if c.f. ternary ?: operator.
+ False value defaults to '' if the true value is a string.
+ False value defaults to 0 if the true value is a number.
+ """
+ if iffalse is None:
+ if isinstance(iftrue, basestring):
+ iffalse = ''
+ if type(iftrue) in (int, float):
+ iffalse = 0
+ if condition:
+ return iftrue
+ else:
+ return iffalse
+
+def message(msg=''):
+ print >>sys.stderr, msg
+
+def strip_end(lines):
+ """
+ Strip blank strings from the end of list of strings.
+ """
+ for i in range(len(lines)-1,-1,-1):
+ if not lines[i]:
+ del lines[i]
+ else:
+ break
+
+def normalize_data(lines):
+ """
+ Strip comments and trailing blank strings from lines.
+ """
+ result = [ s for s in lines if not s.startswith('#') ]
+ strip_end(result)
+ return result
+
+
+class AsciiDocTest(object):
+
+ def __init__(self):
+ self.number = None # Test number (1..).
+ self.name = '' # Optional test name.
+ self.title = '' # Optional test name.
+ self.description = [] # List of lines followoing title.
+ self.source = None # AsciiDoc test source file name.
+ self.options = []
+ self.attributes = {}
+ self.backends = BACKENDS
+ self.datadir = None # Where output files are stored.
+ self.disabled = False
+
+ def backend_filename(self, backend):
+ """
+ Return the path name of the backend output file that is generated from
+ the test name and output file type.
+ """
+ return '%s-%s%s' % (
+ os.path.normpath(os.path.join(self.datadir, self.name)),
+ backend,
+ BACKEND_EXT[backend])
+
+ def parse(self, lines, confdir, datadir):
+ """
+ Parse conf file test section from list of text lines.
+ """
+ self.__init__()
+ self.confdir = confdir
+ self.datadir = datadir
+ lines = Lines(lines)
+ while not lines.eol():
+ l = lines.read_until(r'^%')
+ if l:
+ if not l[0].startswith('%'):
+ if l[0][0] == '!':
+ self.disabled = True
+ self.title = l[0][1:]
+ else:
+ self.title = l[0]
+ self.description = l[1:]
+ continue
+ reo = re.match(r'^%\s*(?P<directive>[\w_-]+)', l[0])
+ if not reo:
+ raise (ValueError, 'illegal directive: %s' % l[0])
+ directive = reo.groupdict()['directive']
+ data = normalize_data(l[1:])
+ if directive == 'source':
+ if data:
+ self.source = os.path.normpath(os.path.join(
+ self.confdir, os.path.normpath(data[0])))
+ elif directive == 'options':
+ self.options = eval(' '.join(data))
+ for i,v in enumerate(self.options):
+ if isinstance(v, basestring):
+ self.options[i] = (v,None)
+ elif directive == 'attributes':
+ self.attributes = eval(' '.join(data))
+ elif directive == 'backends':
+ self.backends = eval(' '.join(data))
+ elif directive == 'name':
+ self.name = data[0].strip()
+ else:
+ raise (ValueError, 'illegal directive: %s' % l[0])
+ if not self.title:
+ self.title = self.source
+ if not self.name:
+ self.name = os.path.basename(os.path.splitext(self.source)[0])
+
+ def is_missing(self, backend):
+ """
+ Returns True if there is no output test data file for backend.
+ """
+ return not os.path.isfile(self.backend_filename(backend))
+
+ def is_missing_or_outdated(self, backend):
+ """
+ Returns True if the output test data file is missing or out of date.
+ """
+ return self.is_missing(backend) or (
+ os.path.getmtime(self.source)
+ > os.path.getmtime(self.backend_filename(backend)))
+
+ def get_expected(self, backend):
+ """
+ Return expected test data output for backend.
+ """
+ f = open(self.backend_filename(backend))
+ try:
+ result = f.readlines()
+ # Strip line terminators.
+ result = [ s.rstrip() for s in result ]
+ finally:
+ f.close()
+ return result
+
+ def generate_expected(self, backend):
+ """
+ Generate and return test data output for backend.
+ """
+ asciidoc = asciidocapi.AsciiDocAPI()
+ asciidoc.options.values = self.options
+ asciidoc.attributes = self.attributes
+ infile = self.source
+ outfile = StringIO.StringIO()
+ asciidoc.execute(infile, outfile, backend)
+ return outfile.getvalue().splitlines()
+
+ def update_expected(self, backend):
+ """
+ Generate and write backend data.
+ """
+ lines = self.generate_expected(backend)
+ if not os.path.isdir(self.datadir):
+ print('CREATING: %s' % self.datadir)
+ os.mkdir(self.datadir)
+ f = open(self.backend_filename(backend),'w+')
+ try:
+ print('WRITING: %s' % f.name)
+ f.writelines([ s + os.linesep for s in lines])
+ finally:
+ f.close()
+
+ def update(self, backend=None, force=False):
+ """
+ Regenerate and update expected test data outputs.
+ """
+ if backend is None:
+ backends = self.backends
+ else:
+ backends = [backend]
+ for backend in backends:
+ if force or self.is_missing_or_outdated(backend):
+ self.update_expected(backend)
+
+ def run(self, backend=None):
+ """
+ Execute test.
+ Return True if test passes.
+ """
+ if backend is None:
+ backends = self.backends
+ else:
+ backends = [backend]
+ result = True # Assume success.
+ self.passed = self.failed = self.skipped = 0
+ print('%d: %s' % (self.number, self.title))
+ if self.source and os.path.isfile(self.source):
+ print('SOURCE: asciidoc: %s' % self.source)
+ for backend in backends:
+ fromfile = self.backend_filename(backend)
+ if not self.is_missing(backend):
+ expected = self.get_expected(backend)
+ strip_end(expected)
+ got = self.generate_expected(backend)
+ strip_end(got)
+ lines = []
+ for line in difflib.unified_diff(got, expected, n=0):
+ lines.append(line)
+ if lines:
+ result = False
+ self.failed +=1
+ lines = lines[3:]
+ print('FAILED: %s: %s' % (backend, fromfile))
+ message('+++ %s' % fromfile)
+ message('--- got')
+ for line in lines:
+ message(line)
+ message()
+ else:
+ self.passed += 1
+ print('PASSED: %s: %s' % (backend, fromfile))
+ else:
+ self.skipped += 1
+ print('SKIPPED: %s: %s' % (backend, fromfile))
+ else:
+ self.skipped += len(backends)
+ if self.source:
+ msg = 'MISSING: %s' % self.source
+ else:
+ msg = 'NO ASCIIDOC SOURCE FILE SPECIFIED'
+ print(msg)
+ print('')
+ return result
+
+
+class AsciiDocTests(object):
+
+ def __init__(self, conffile):
+ """
+ Parse configuration file.
+ """
+ self.conffile = os.path.normpath(conffile)
+ # All file names are relative to configuration file directory.
+ self.confdir = os.path.dirname(self.conffile)
+ self.datadir = self.confdir # Default expected files directory.
+ self.tests = [] # List of parsed AsciiDocTest objects.
+ self.globals = {}
+ f = open(self.conffile)
+ try:
+ lines = Lines(f.readlines())
+ finally:
+ f.close()
+ first = True
+ while not lines.eol():
+ s = lines.read_until(r'^%+$')
+ s = [ l for l in s if l] # Drop blank lines.
+ # Must be at least one non-blank line in addition to delimiter.
+ if len(s) > 1:
+ # Optional globals precede all tests.
+ if first and re.match(r'^%\s*globals$',s[0]):
+ self.globals = eval(' '.join(normalize_data(s[1:])))
+ if 'datadir' in self.globals:
+ self.datadir = os.path.join(
+ self.confdir,
+ os.path.normpath(self.globals['datadir']))
+ else:
+ test = AsciiDocTest()
+ test.parse(s[1:], self.confdir, self.datadir)
+ self.tests.append(test)
+ test.number = len(self.tests)
+ first = False
+
+ def run(self, number=None, backend=None):
+ """
+ Run all tests.
+ If number is specified run test number (1..).
+ """
+ self.passed = self.failed = self.skipped = 0
+ for test in self.tests:
+ if (not test.disabled or number) and (not number or number == test.number) and (not backend or backend in test.backends):
+ test.run(backend)
+ self.passed += test.passed
+ self.failed += test.failed
+ self.skipped += test.skipped
+ if self.passed > 0:
+ print('TOTAL PASSED: %s' % self.passed)
+ if self.failed > 0:
+ print('TOTAL FAILED: %s' % self.failed)
+ if self.skipped > 0:
+ print('TOTAL SKIPPED: %s' % self.skipped)
+
+ def update(self, number=None, backend=None, force=False):
+ """
+ Regenerate expected test data and update configuratio file.
+ """
+ for test in self.tests:
+ if (not test.disabled or number) and (not number or number == test.number):
+ test.update(backend, force=force)
+
+ def list(self):
+ """
+ Lists tests to stdout.
+ """
+ for test in self.tests:
+ print '%d: %s%s' % (test.number, iif(test.disabled,'!'), test.title)
+
+
+class Lines(list):
+ """
+ A list of strings.
+ Adds eol() and read_until() to list type.
+ """
+
+ def __init__(self, lines):
+ super(Lines, self).__init__()
+ self.extend([s.rstrip() for s in lines])
+ self.pos = 0
+
+ def eol(self):
+ return self.pos >= len(self)
+
+ def read_until(self, regexp):
+ """
+ Return a list of lines from current position up until the next line
+ matching regexp.
+ Advance position to matching line.
+ """
+ result = []
+ if not self.eol():
+ result.append(self[self.pos])
+ self.pos += 1
+ while not self.eol():
+ if re.match(regexp, self[self.pos]):
+ break
+ result.append(self[self.pos])
+ self.pos += 1
+ return result
+
+
+def usage(msg=None):
+ if msg:
+ message(msg + '\n')
+ message(USAGE)
+
+
+if __name__ == '__main__':
+ # Process command line options.
+ import getopt
+ try:
+ opts,args = getopt.getopt(sys.argv[1:], 'f:', ['force'])
+ except getopt.GetoptError:
+ usage('illegal command options')
+ sys.exit(1)
+ if len(args) == 0:
+ usage()
+ sys.exit(1)
+ conffile = os.path.join(os.path.dirname(sys.argv[0]), 'testasciidoc.conf')
+ force = False
+ for o,v in opts:
+ if o == '--force':
+ force = True
+ if o in ('-f','--conf-file'):
+ conffile = v
+ if not os.path.isfile(conffile):
+ message('missing CONF_FILE: %s' % conffile)
+ sys.exit(1)
+ tests = AsciiDocTests(conffile)
+ cmd = args[0]
+ number = None
+ backend = None
+ for arg in args[1:3]:
+ try:
+ number = int(arg)
+ except ValueError:
+ backend = arg
+ if backend and backend not in BACKENDS:
+ message('illegal BACKEND: %s' % backend)
+ sys.exit(1)
+ if number is not None and number not in range(1, len(tests.tests)+1):
+ message('illegal test NUMBER: %d' % number)
+ sys.exit(1)
+ if cmd == 'run':
+ tests.run(number, backend)
+ if tests.failed:
+ exit(1)
+ elif cmd == 'update':
+ tests.update(number, backend, force=force)
+ elif cmd == 'list':
+ tests.list()
+ else:
+ usage('illegal COMMAND: %s' % cmd)