summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStuart Rackham <srackham@methods.co.nz>2010-08-30 15:40:09 +1200
committerStuart Rackham <srackham@methods.co.nz>2010-08-30 15:40:09 +1200
commitc38ebc05cf5c30a0c5da0c0f0f467670a007e3b0 (patch)
treee70170bf4f0eed2246fe121c6e4d7c300f3e4dff
parent9b1bc976655edd9170c74da4a521e12d099ffe3c (diff)
downloadasciidoc-c38ebc05cf5c30a0c5da0c0f0f467670a007e3b0.tar.gz
Implemented 'backend aliases', renamed docbook.conf to docbook45.conf and
aliased 'docbook45' backend to 'docbook'.
-rw-r--r--asciidoc.conf2
-rwxr-xr-xasciidoc.py15
-rw-r--r--doc/asciidoc.1.txt7
-rw-r--r--doc/asciidoc.txt100
-rw-r--r--docbook45.conf (renamed from docbook.conf)0
-rw-r--r--filters/source/source-highlight-filter.conf22
6 files changed, 87 insertions, 59 deletions
diff --git a/asciidoc.conf b/asciidoc.conf
index cb04008..7309cd8 100644
--- a/asciidoc.conf
+++ b/asciidoc.conf
@@ -12,6 +12,8 @@ textwidth=70
newline=\r\n
[attributes]
+backend-alias-html=xhtml11
+backend-alias-docbook=docbook45
toclevels=2
sectids=
iconsdir=./images/icons
diff --git a/asciidoc.py b/asciidoc.py
index 9742b71..91b9799 100755
--- a/asciidoc.py
+++ b/asciidoc.py
@@ -16,7 +16,7 @@ MIN_PYTHON_VERSION = 2.4 # Require this version of Python or better.
#---------------------------------------------------------------------------
# Program constants.
#---------------------------------------------------------------------------
-DEFAULT_BACKEND = 'xhtml11'
+DEFAULT_BACKEND = 'html'
DEFAULT_DOCTYPE = 'article'
# Allowed substitution options for List, Paragraph and DelimitedBlock
# definition subs entry.
@@ -2027,7 +2027,7 @@ class Section:
if Title.level == 0 and document.doctype != 'book':
message.error('only book doctypes can contain level 0 sections')
if Title.level > document.level \
- and document.backend == 'docbook' \
+ and document.attributes.get('basebackend') == 'docbook' \
and prev_sectname in ('colophon','abstract', \
'dedication','glossary','bibliography'):
message.error('%s section cannot contain sub-sections' % prev_sectname)
@@ -4338,7 +4338,15 @@ class Config:
if dirs is None:
dirs = self.get_load_dirs()
for d in dirs:
+ # asciidoc.conf's take precedence over other conf files.
self.load_file('asciidoc.conf',d)
+ alias = 'backend-alias-' + document.backend
+ if alias in document.attributes:
+ document.backend = document.attributes[alias]
+ document.update_attributes() # Update backend related attributes.
+ f = document.backend + '.conf'
+ if not self.find_in_dirs(f):
+ message.warning('missing backend conf file: %s' % f, linenos=False)
for d in dirs:
conf = document.backend + '.conf'
self.load_file(conf,d)
@@ -5233,9 +5241,6 @@ def asciidoc(backend, doctype, confiles, infile, outfile, options):
if doctype not in ('article','manpage','book'):
raise EAsciiDoc,'illegal document type'
document.backend = backend
- f = backend+'.conf'
- if not config.find_in_dirs(f):
- message.warning('missing backend conf file: %s' % f, linenos=False)
document.doctype = doctype
document.infile = infile
document.update_attributes()
diff --git a/doc/asciidoc.1.txt b/doc/asciidoc.1.txt
index f91376c..c343abc 100644
--- a/doc/asciidoc.1.txt
+++ b/doc/asciidoc.1.txt
@@ -33,8 +33,11 @@ OPTIONS
'trace' controls the output of diagnostic information.
*-b, --backend*='BACKEND'::
- Backend output file format: 'docbook', 'xhtml11' or 'html4'.
- Defaults to 'xhtml11'.
+ Backend output file format: 'docbook45', 'xhtml11', 'html4',
+ 'wordpress' or 'latex' (the 'latex' backend is experimental).
+ You can also the backend alias names 'html' (aliased to 'xhtml11')
+ or 'docbook' (aliased to 'docbook45').
+ Defaults to 'html'.
*-f, --conf-file*='CONF_FILE'::
Use configuration file 'CONF_FILE'.Configuration files processed
diff --git a/doc/asciidoc.txt b/doc/asciidoc.txt
index 89999ea..b5d6c8d 100644
--- a/doc/asciidoc.txt
+++ b/doc/asciidoc.txt
@@ -152,13 +152,47 @@ formats, all translation rules are contained in customizable cascading
configuration files. Backend specific attributes are listed in the
<<X88,Backend Attributes>> section.
-AsciiDoc ships with the following predefined backend output formats:
+docbook45::
+ Outputs DocBook XML 4.5 markup.
-docbook
+html4::
+ This backend generates plain HTML 4.01 Transitional markup.
+
+xhtml11::
+ This backend generates XHTML 1.1 markup styled with CSS2. Output
+ files have an `.html` extension.
+
+wordpress::
+ A minor variant of the 'html4' backend to support
+ http://srackham.wordpress.com/blogpost1/[blogpost].
+
+latex::
+ Experimental LaTeX backend.
+
+Backend Aliases
+~~~~~~~~~~~~~~~
+Backend aliases are alternative names for AsciiDoc backends. AsciiDoc
+comes with two backend aliases: 'html' (aliased to 'xhtml11') and
+'docbook' (aliased to 'docbook45').
+
+You can assign (or reassign) backend aliases by setting an AsciiDoc
+attribute named like `backend-alias-<alias>` to an AsciiDoc backend
+name. For example, the following backend alias attribute definitions
+appear in the `[attributes]` section of the global `asciidoc.conf`
+configuration file:
+
+ backend-alias-html=xhtml11
+ backend-alias-docbook=docbook45
+
+NOTE: Backend aliases must be assigned in one of the `asciidoc.conf`
+configuration files because these files are loaded first (before the
+backend configuration files).
+
+DocBook
~~~~~~~
-AsciiDoc generates the following DocBook document types: article, book
-and refentry (corresponding to the AsciiDoc 'article', 'book' and
-'manpage' document types).
+AsciiDoc generates 'article', 'book' and 'refentry'
+http://www.docbook.org/[DocBook] documents (corresponding to the
+AsciiDoc 'article', 'book' and 'manpage' document types).
DocBook documents are not designed to be viewed directly. Most Linux
distributions come with conversion tools (collectively called a
@@ -166,21 +200,9 @@ toolchain) for <<X12,converting DocBook files>> to presentation
formats such as Postscript, HTML, PDF, EPUB, DVI, PostScript, LaTeX,
roff (the native man page format), HTMLHelp, JavaHelp and text.
-The AsciiDoc <<X86,Preamble>> element generates a DocBook book
-'preface'.
-
-[[X33]]
-xhtml11
-~~~~~~~
-The default asciidoc(1) backend is `xhtml11` -- XHTML 1.1 markup
-styled with CSS2. Output files have a `.html` extension. 'xhtml11'
-document generation is influenced by the following optional attributes
-(the default behavior is to generate XHTML with no section numbers,
-embedded CSS and no linked admonition icon images):
-
[[X35]]
-Stylesheets
-^^^^^^^^^^^
+XHTML Stylesheets
+~~~~~~~~~~~~~~~~~
AsciiDoc XHTML output is styled using CSS2 stylesheets from the
distribution `./stylesheets/` directory.
@@ -215,10 +237,6 @@ Use the 'stylesheet' attribute to include an additional stylesheet in
XHTML documents. For example, the command-line option `-a
stylesheet=newsletter.css` will use stylesheets `newsletter.css`.
-html4
-~~~~~
-This backend generates plain (unstyled) HTML 4.01 Transitional markup.
-
Document Structure
------------------
@@ -3425,9 +3443,9 @@ single line formatted like:
<special_character>=<translated_characters>
Special characters are normally confined to those that resolve
-markup ambiguity (in the case of SGML/XML markups the ampersand, less
-than and greater than characters). The following example causes all
-occurrences of the `<` character to be replaced by `&lt;`.
+markup ambiguity (in the case of HTML and XML markups the ampersand,
+less than and greater than characters). The following example causes
+all occurrences of the `<` character to be replaced by `&lt;`.
<=&lt;
@@ -3935,11 +3953,11 @@ Conditional attributes are mainly used in AsciiDoc configuration
files -- see the distribution `.conf` files for examples.
Attribute equality test::
- If `{backend}` is `docbook` or `xhtml11` the example evaluates to
- ``DocBook or XHTML backend'' otherwise it evaluates to ``some other
- backend'':
+ If `{backend}` is `docbook45` or `xhtml11` the example evaluates to
+ ``DocBook 4.5 or XHTML 1.1 backend'' otherwise it evaluates to ``some
+ other backend'':
- {backend@docbook|xhtml11:DocBook or XHTML backend:some other backend}
+ {backend@docbook45|xhtml11:DocBook 4.5 or XHTML 1.1 backend:some other backend}
Attribute value map::
This example maps the `frame` attribute values [`topbot`, `all`,
@@ -4119,8 +4137,8 @@ predefined intrinsic attributes:
effectively read-only (you can set them but it won't affect the
input or output file paths).
-3. See also the <<X33,xhtml11>> subsection for attributes that relate
- to AsciiDoc XHTML file generation.
+3. See also the <<X88,Backend Attributes>> section for attributes
+ that relate to AsciiDoc XHTML file generation.
4. The entries that translate to blank strings are designed to be used
for conditional text inclusion. You can also use the `ifdef`,
@@ -5015,9 +5033,9 @@ liking you can:
Supporting minor DocBook DTD variations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The conditional inclusion of DocBook SGML markup at the end of the
-distribution `docbook.conf` file illustrates how to support minor DTD
-variations. The included sections override corresponding entries from
-preceding sections.
+distribution `docbook45.conf` file illustrates how to support minor
+DTD variations. The included sections override corresponding entries
+from preceding sections.
Creating stand-alone HTML documents
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -5075,7 +5093,7 @@ example includes a DocBook glossary division at the top section level
(level 0):
---------------------------------------------------------------------
-\ifdef::backend-docbook[]
+\ifdef::basebackend-docbook[]
\eval::[Section.setlevel(0)]
@@ -5087,7 +5105,7 @@ example includes a DocBook glossary division at the top section level
</glossdiv>
</glossary>
+++++++++++++++++++++++++++++++
-\endif::backend-docbook[]
+\endif::basebackend-docbook[]
---------------------------------------------------------------------
Validating output files
@@ -5465,10 +5483,10 @@ dated to output this attribute.
The name of the directory containing linked JavaScripts. Defaults to
`.` (the same directory as the linking document).
-|sgml |docbook |
-The `--backend=docbook` command-line option produces DocBook XML. You
-can produce the older DocBook SGML format using the `--attribute sgml`
-command-line option.
+|sgml |docbook45 |
+The `--backend=docbook45` command-line option produces DocBook 4.5
+XML. You can produce the older DocBook SGML format using the
+`--attribute sgml` command-line option.
|stylesdir |xhtml11 |
The name of the directory containing linked stylesheets. Defaults to
diff --git a/docbook.conf b/docbook45.conf
index 8b4d175..8b4d175 100644
--- a/docbook.conf
+++ b/docbook45.conf
diff --git a/filters/source/source-highlight-filter.conf b/filters/source/source-highlight-filter.conf
index f1d92e4..f89aca2 100644
--- a/filters/source/source-highlight-filter.conf
+++ b/filters/source/source-highlight-filter.conf
@@ -41,14 +41,14 @@ ifdef::backend-xhtml11[]
endif::backend-xhtml11[]
# Use DocBook programlisting element.
-ifdef::backend-docbook[]
+ifdef::basebackend-docbook[]
[source-highlight-block]
<formalpara{id? id="{id}"}{role? role="{role}"}{reftext? xreflabel="{reftext}"}><title>{title}</title><para>
<programlisting language="{language}" linenumbering="{src_numbered=unnumbered}">
|
</programlisting>
{title#}</para></formalpara>
-endif::backend-docbook[]
+endif::basebackend-docbook[]
#########################
# Source paragraph styles
@@ -63,9 +63,9 @@ ifndef::pygments[source-style=template="source-highlight-block",presubs=(),posts
ifdef::pygments[source-style=template="source-highlight-block",presubs=(),postsubs=("callouts",),posattrs=("style","language","src_numbered"),filter="pygmentize -f html -l {language} {src_numbered?-O linenos=table}"]
endif::backend-xhtml11[]
-ifdef::backend-docbook[]
+ifdef::basebackend-docbook[]
source-style=template="source-highlight-block",presubs=(),postsubs=("specialcharacters","callouts"),posattrs=("style","language","src_numbered","src_tab"),filter=""
-endif::backend-docbook[]
+endif::basebackend-docbook[]
#########################
# Source block styles
@@ -80,9 +80,9 @@ ifndef::pygments[source-style=template="source-highlight-block",presubs=(),posts
ifdef::pygments[source-style=template="source-highlight-block",presubs=(),postsubs=("callouts",),posattrs=("style","language","src_numbered"),filter="pygmentize -f html -l {language} {src_numbered?-O linenos=table}"]
endif::backend-xhtml11[]
-ifdef::backend-docbook[]
+ifdef::basebackend-docbook[]
source-style=template="source-highlight-block",presubs=(),postsubs=("specialcharacters","callouts"),posattrs=("style","language","src_numbered","src_tab")
-endif::backend-docbook[]
+endif::basebackend-docbook[]
#
@@ -100,18 +100,18 @@ template=source-highlight-block
presubs=none
posattrs=language,src_numbered,src_tab
-ifndef::backend-docbook[]
+ifndef::basebackend-docbook[]
postsubs=callouts
# GNU Source Highlight filter.
-filter=source-highlight -f {backend-xhtml11?xhtml}{backend-html4?html}{backend-docbook?docbook} -s {language} {src_numbered?--line-number} {src_tab?--tab={src_tab}}
-endif::backend-docbook[]
+filter=source-highlight -f {backend-xhtml11?xhtml}{backend-html4?html} -s {language} {src_numbered?--line-number} {src_tab?--tab={src_tab}}
+endif::basebackend-docbook[]
-ifdef::backend-docbook[]
+ifdef::basebackend-docbook[]
postsubs=specialcharacters,callouts
# In the case of DocBook just pass the listing through and let the DocBook
# toolchain handle it.
filter=
-endif::backend-docbook[]
+endif::basebackend-docbook[]
#
# DEPRECATED: End