diff options
author | Stuart Rackham <srackham@methods.co.nz> | 2011-05-31 15:41:52 +1200 |
---|---|---|
committer | Stuart Rackham <srackham@methods.co.nz> | 2011-05-31 15:41:52 +1200 |
commit | 41cc734ea0b2b0966a5af111b5beb66581186986 (patch) | |
tree | 3052239c7b530ee0a20a397452a77f1d38a6fd20 | |
parent | 122ce40edf03b4ce6b13880f3079ce3fec67ad2d (diff) | |
download | asciidoc-41cc734ea0b2b0966a5af111b5beb66581186986.tar.gz |
- html5,xhtml11: Implemented themes directory structure.
- html5,xhtml11: Implemented asciidoc --theme themes management option
(install, list and remove commands).
- html5,xhtml11: A theme can now optionally include a JavaScript file
<theme>.js
- html5,xhtml11: If the 'data-uri' attribute is defined then icons from the the
theme icons directory (if they exist) will be embedded in the generated
document.
- Added optional 'warnings' argument to include macros.
- The asciidoc --verbose option now prints file inclusion messages.
-rw-r--r-- | MANIFEST | 1 | ||||
-rw-r--r-- | Makefile.in | 10 | ||||
-rwxr-xr-x | asciidoc.py | 167 | ||||
-rw-r--r-- | doc/asciidoc.1.txt | 49 | ||||
-rw-r--r-- | doc/asciidoc.dict | 67 | ||||
-rw-r--r-- | doc/asciidoc.txt | 476 | ||||
-rw-r--r-- | html5.conf | 5 | ||||
-rw-r--r-- | themes/flask/flask.css (renamed from stylesheets/flask.css) | 2 | ||||
-rw-r--r-- | themes/volnitsky/volnitsky.css (renamed from stylesheets/volnitsky.css) | 0 | ||||
-rw-r--r-- | xhtml11.conf | 5 |
10 files changed, 431 insertions, 351 deletions
@@ -84,5 +84,6 @@ tests/testasciidoc.conf tests/asciidocapi.py tests/data/*.conf tests/data/*.txt +themes/* vim/syntax/asciidoc.vim vim/ftdetect/asciidoc_filetype.vim diff --git a/Makefile.in b/Makefile.in index eb0fcfb..d8672c3 100644 --- a/Makefile.in +++ b/Makefile.in @@ -60,6 +60,14 @@ latexfilterdir = $(filtersdir)/latex latexfilterconf = filters/latex/latex-filter.conf latexfilterconfdir = $(filtersdir)/latex +themesdir = $(ASCIIDOCCONF)/themes + +flasktheme = themes/flask/flask.css +flaskthemedir = $(themesdir)/flask + +volnitskytheme = themes/volnitsky/volnitsky.css +volnitskythemedir = $(themesdir)/volnitsky + docbook = $(wildcard docbook-xsl/*.xsl) docbookdir = $(ASCIIDOCCONF)/docbook-xsl @@ -80,7 +88,7 @@ iconsdir = $(ASCIIDOCCONF)/images/icons doc = $(wildcard README*) $(wildcard BUGS*) $(wildcard INSTALL*) $(wildcard CHANGELOG*) -DATATARGETS = manp conf docbook dblatex css js callouts icons codefilterconf musicfilterconf sourcefilterconf graphvizfilterconf latexfilterconf +DATATARGETS = manp conf docbook dblatex css js callouts icons codefilterconf musicfilterconf sourcefilterconf graphvizfilterconf latexfilterconf flasktheme volnitskytheme PROGTARGETS = prog codefilter musicfilter graphvizfilter latexfilter TARGETS = $(DATATARGETS) $(PROGTARGETS) doc diff --git a/asciidoc.py b/asciidoc.py index 7846de3..c76a610 100755 --- a/asciidoc.py +++ b/asciidoc.py @@ -273,15 +273,12 @@ def is_safe_file(fname, directory=None): def safe_filename(fname, parentdir): """ Return file name which must reside in the parent file directory. - Return None if file is not found or not safe. + Return None if file is not not safe. """ if not os.path.isabs(fname): # Include files are relative to parent document # directory. fname = os.path.normpath(os.path.join(parentdir,fname)) - if not os.path.isfile(fname): - message.warning('include file not found: %s' % fname) - return None if not is_safe_file(fname, parentdir): message.unsafe('include file: %s' % fname) return None @@ -3641,7 +3638,7 @@ class Macros: if mo: if m.name == name: return mo - if re.match(name,mo.group('name')): + if re.match(name, mo.group('name')): return mo return None def extract_passthroughs(self,text,prefix=''): @@ -3977,8 +3974,12 @@ class Reader1: del self.next[0] result = self.cursor[2] # Check for include macro. - mo = macros.match('+',r'include[1]?',result) + mo = macros.match('+',r'^include[1]?$',result) if mo and not skip: + # Parse include macro attributes. + attrs = {} + parse_attributes(mo.group('attrlist'),attrs) + warnings = attrs.get('warnings', True) # Don't process include macro once the maximum depth is reached. if self.current_depth >= self.max_depth: return result @@ -3991,20 +3992,23 @@ class Reader1: fname = safe_filename(fname, os.path.dirname(self.fname)) if not fname: return Reader1.read(self) # Return next input line. + if not os.path.isfile(fname): + if warnings: + message.warning('include file not found: %s' % fname) + return Reader1.read(self) # Return next input line. if mo.group('name') == 'include1': if not config.dumping: - # Store the include file in memory for later - # retrieval by the {include1:} system attribute. - config.include1[fname] = [ - s.rstrip() for s in open(fname)] + if fname not in config.include1: + message.verbose('include1: ' + fname, linenos=False) + # Store the include file in memory for later + # retrieval by the {include1:} system attribute. + config.include1[fname] = [ + s.rstrip() for s in open(fname)] return '{include1:%s}' % fname else: # This is a configuration dump, just pass the macro # call through. return result - # Parse include macro attributes. - attrs = {} - parse_attributes(mo.group('attrlist'),attrs) # Clone self and set as parent (self assumes the role of child). parent = Reader1() assign(parent,self) @@ -4022,6 +4026,7 @@ class Reader1: 'illegal include macro depth argument')) self.max_depth = self.current_depth + attrs['depth'] # Process included file. + message.verbose('include: ' + fname, linenos=False) self.open(fname) self.current_depth = self.current_depth + 1 result = Reader1.read(self) @@ -4554,6 +4559,29 @@ class Config: if re.match(r'^.+\.conf$',f): self.load_file(f,dirpath) + def find_config_dir(self, *dirnames): + """ + Return path of configuration directory. + Try all the well known locations. + Return None if directory not found. + """ + for d in [os.path.join(d, *dirnames) for d in self.get_load_dirs()]: + if os.path.isdir(d): + return d + return None + + def set_theme_attributes(self): + theme = document.attributes.get('theme') + if theme and 'themedir' not in document.attributes: + themedir = config.find_config_dir('themes', theme) + if themedir: + document.attributes['themedir'] = themedir + iconsdir = os.path.join(themedir, 'icons') + if 'data-uri' in document.attributes and os.path.isdir(iconsdir): + document.attributes['iconsdir'] = iconsdir + else: + message.warning('missing theme: %s' % theme, linenos=False) + def load_miscellaneous(self,d): """Set miscellaneous configuration entries from dictionary 'd'.""" def set_misc(name,rule='True',intval=False): @@ -5389,7 +5417,7 @@ class Tables_OLD(AbstractBlocks): #--------------------------------------------------------------------------- #--------------------------------------------------------------------------- -# Filter commands. +# filter and theme plugin commands. #--------------------------------------------------------------------------- import shutil, zipfile @@ -5422,96 +5450,98 @@ def unzip(zip_file, destdir): finally: zipo.close() -class Filter: +class Plugin: """ - --filter option commands. + --filter and --theme option commands. """ + type = None # 'filter' or 'theme'. + @staticmethod - def get_filters_dir(): + def get_dir(): """ - Return path of .asciidoc/filters in user's home direcory or None if - user home not defined. + Return plugins path (.asciidoc/filters or .asciidoc/themes) in user's + home direcory or None if user home not defined. """ result = userdir() if result: - result = os.path.join(result,'.asciidoc','filters') + result = os.path.join(result, '.asciidoc', Plugin.type+'s') return result @staticmethod def install(args): """ - Install filter Zip file. - args[0] is filter zip file path. - args[1] is optional destination filters directory. + Install plugin Zip file. + args[0] is plugin zip file path. + args[1] is optional destination plugins directory. """ if len(args) not in (1,2): - die('invalid number of arguments: --filter install %s' - % ' '.join(args)) + die('invalid number of arguments: --%s install %s' + % (Plugin.type, ' '.join(args))) zip_file = args[0] if not os.path.isfile(zip_file): die('file not found: %s' % zip_file) reo = re.match(r'^\w+',os.path.split(zip_file)[1]) if not reo: - die('filter file name does not start with legal filter name: %s' - % zip_file) - filter_name = reo.group() + die('file name does not start with legal %s name: %s' + % (Plugin.type, zip_file)) + plugin_name = reo.group() if len(args) == 2: - filters_dir = args[1] - if not os.path.isdir(filters_dir): - die('directory not found: %s' % filters_dir) + plugins_dir = args[1] + if not os.path.isdir(plugins_dir): + die('directory not found: %s' % plugins_dir) else: - filters_dir = Filter.get_filters_dir() - if not filters_dir: + plugins_dir = Plugin.get_dir() + if not plugins_dir: die('user home directory is not defined') - filter_dir = os.path.join(filters_dir, filter_name) - if os.path.exists(filter_dir): - die('filter is already installed: %s' % filter_dir) + plugin_dir = os.path.join(plugins_dir, plugin_name) + if os.path.exists(plugin_dir): + die('%s is already installed: %s' % (Plugin.type, plugin_dir)) try: - os.makedirs(filter_dir) + os.makedirs(plugin_dir) except Exception,e: - die('failed to create filter directory: %s' % str(e)) + die('failed to create %s directory: %s' % (Plugin.type, str(e))) try: - unzip(zip_file, filter_dir) + unzip(zip_file, plugin_dir) except Exception,e: - die('failed to extract filter: %s' % str(e)) + die('failed to extract %s: %s' % (Plugin.type, str(e))) @staticmethod def remove(args): """ - Delete filter from .asciidoc/filters/ in user's home directory. - args[0] is filter name. - args[1] is optional filters directory. + Delete plugin directory. + args[0] is plugin name. + args[1] is optional plugin directory (defaults to ~/.asciidoc/<plugin_name>). """ if len(args) not in (1,2): - die('invalid number of arguments: --filter remove %s' - % ' '.join(args)) - filter_name = args[0] - if not re.match(r'^\w+$',filter_name): - die('illegal filter name: %s' % filter_name) + die('invalid number of arguments: --%s remove %s' + % (Plugin.type, ' '.join(args))) + plugin_name = args[0] + if not re.match(r'^\w+$',plugin_name): + die('illegal %s name: %s' % (Plugin.type, plugin_name)) if len(args) == 2: d = args[1] if not os.path.isdir(d): die('directory not found: %s' % d) else: - d = Filter.get_filters_dir() + d = Plugin.get_dir() if not d: die('user directory is not defined') - filter_dir = os.path.join(d, filter_name) - if not os.path.isdir(filter_dir): - die('cannot find filter: %s' % filter_dir) + plugin_dir = os.path.join(d, plugin_name) + if not os.path.isdir(plugin_dir): + die('cannot find %s: %s' % (Plugin.type, plugin_dir)) try: - message.verbose('removing: %s' % filter_dir) - shutil.rmtree(filter_dir) + message.verbose('removing: %s' % plugin_dir) + shutil.rmtree(plugin_dir) except Exception,e: - die('failed to delete filter: %s' % str(e)) + die('failed to delete %s: %s' % (Plugin.type, str(e))) @staticmethod def list(): """ - List all filter directories (global and local). + List all plugin directories (global and local). """ - for d in [os.path.join(d,'filters') for d in config.get_load_dirs()]: + for d in [os.path.join(d, Plugin.type+'s') for d in config.get_load_dirs()]: if os.path.isdir(d): for f in os.walk(d).next()[1]: message.stdout(os.path.join(d,f)) @@ -5602,6 +5632,7 @@ def asciidoc(backend, doctype, confiles, infile, outfile, options): has_header = document.parse_header(doctype,backend) # doctype is now finalized. document.attributes['doctype-'+document.doctype] = '' + config.set_theme_attributes() # Load backend configuration files. if '-e' not in options: f = document.backend + '.conf' @@ -5656,7 +5687,7 @@ def asciidoc(backend, doctype, confiles, infile, outfile, options): # Document header attributes override conf file attributes. document.attributes.update(AttributeEntry.attributes) document.update_attributes() - # Configuration is fully loaded so can expand templates. + # Configuration is fully loaded. config.expand_all_templates() # Check configuration for consistency. config.validate() @@ -5868,7 +5899,7 @@ if __name__ == '__main__': ['attribute=','backend=','conf-file=','doctype=','dump-conf', 'help','no-conf','no-header-footer','out-file=', 'section-numbers','verbose','version','safe','unsafe', - 'doctest','filter']) + 'doctest','filter','theme']) except getopt.GetoptError: message.stderr('illegal command options') sys.exit(1) @@ -5882,19 +5913,27 @@ if __name__ == '__main__': sys.exit(0) else: sys.exit(1) + plugin= None if '--filter' in [opt[0] for opt in opts]: + plugin = 'filter' + if '--theme' in [opt[0] for opt in opts]: + if plugin: + die('--filter and --theme options are mutually exclusive') + plugin = 'theme' + if plugin: + Plugin.type = plugin config.init(sys.argv[0]) config.verbose = bool(set(['-v','--verbose']) & set([opt[0] for opt in opts])) if not args: - die('missing --filter command') + die('missing --%s command' % plugin) elif args[0] == 'install': - Filter.install(args[1:]) + Plugin.install(args[1:]) elif args[0] == 'remove': - Filter.remove(args[1:]) + Plugin.remove(args[1:]) elif args[0] == 'list': - Filter.list() + Plugin.list() else: - die('illegal --filter command: %s' % args[0]) + die('illegal --%s command: %s' % (plugin,args[0])) sys.exit(0) try: execute(sys.argv[0],opts,args) diff --git a/doc/asciidoc.1.txt b/doc/asciidoc.1.txt index f6b3db6..9b9d18b 100644 --- a/doc/asciidoc.1.txt +++ b/doc/asciidoc.1.txt @@ -56,7 +56,7 @@ OPTIONS Dump configuration to stdout. *--filter*:: - Manage asciidoc(1) filters (see <<X1,*FILTER COMMANDS*>>). + Manage asciidoc(1) filters (see <<X1,*PLUGIN COMMANDS*>>). *-h, --help* ['TOPIC']:: Print help TOPIC. *--help* 'topics' will print a list of help @@ -86,6 +86,9 @@ OPTIONS 'safe mode' skips potentially dangerous scripted sections in AsciiDoc source files. +*--theme*:: + Manage asciidoc(1) themes (see <<X1,*PLUGIN COMMANDS*>>). + *-v, --verbose*:: Verbosely print processing information and configuration file checks to stderr. @@ -95,45 +98,47 @@ OPTIONS [[X1]] -FILTER COMMANDS +PLUGIN COMMANDS --------------- -The *--filter* option is used to install, remove and list AsciiDoc -filter plugins. Filter commands syntax: +The *--filter* and *--theme* options are used to install, remove and +list AsciiDoc filter and theme plugins. Syntax: - asciidoc --filter install ZIP_FILE [FILTERS_DIR] - asciidoc --filter remove FILTER_NAME [FILTERS_DIR] - asciidoc --filter list + asciidoc --filter|--theme install ZIP_FILE [PLUGINS_DIR] + asciidoc --filter|--theme remove PLUGIN_NAME [PLUGINS_DIR] + asciidoc --filter|--theme list Where: -*FILTER_NAME*:: - A unique filter name containing only alphanumeric or underscore +*PLUGIN_NAME*:: + A unique plugin name containing only alphanumeric or underscore characters. *ZIP_FILE*:: - A Zip file containing filter resources, the name must start with the - filter name e.g. `my_filter-1.0.zip` packages filter `my_filter`. + A Zip file containing plugin resources, the name must start with the + plugin name e.g. `my_filter-1.0.zip` packages filter `my_filter`. -*FILTERS_DIR*:: - The directory containing installed filters. Each filter is contained +*PLUGINS_DIR*:: + The directory containing installed plugins. Each plugin is contained in its own separate subdirectory which has the same name as the - filter. - *FILTERS_DIR* defaults to the `.asciidoc/filters` directory in the + plugin. + *PLUGINS_DIR* defaults to the `.asciidoc/filters` directory (for + filter plugins) or `.asciidoc/themes` (for theme plugins) in the user's home directory. -The filter commands perform as follows: +The plugin commands perform as follows: *install*:: - Create a subdirectory in *FILTERS_DIR* with the same name as the - filter then extract the *ZIP_FILE* into it. + Create a subdirectory in *PLUGINS_DIR* with the same name as the + plugin then extract the *ZIP_FILE* into it. *remove*:: - Delete the *FILTER_NAME* filter subdirectory and all its contents from - the *FILTERS_DIR*. + Delete the *PLUGIN_NAME* plugin subdirectory and all its contents + from the *PLUGINS_DIR*. *list*:: - List the names and locations of all installed filters (including - standard filters installed in the global configuration directory). + List the names and locations of all installed filter or theme + plugins (including standard plugins installed in the global + configuration directory). EXIT STATUS diff --git a/doc/asciidoc.dict b/doc/asciidoc.dict index c678533..ce43b5d 100644 --- a/doc/asciidoc.dict +++ b/doc/asciidoc.dict @@ -1,11 +1,11 @@ -personal_ws-1.1 en 1057 +personal_ws-1.1 en 1058 mandoc colspecs API testcases BSBEV -dapibus dblatex +dapibus mycss attributelist AttributeList @@ -33,8 +33,8 @@ BOM Bon ungenerated zipP -cmd des +cmd ListItems dev vulputate @@ -125,8 +125,8 @@ xreflabel PDF's PDFs pygmentize -pede MSIE +pede permalinks Boscombe Daly @@ -141,8 +141,8 @@ ShareSource epubtest projectname hoc -Maier ispum +Maier args TableFooter LiberationSerif @@ -196,8 +196,8 @@ mea jqs PassthroughBlocks blockdef -javascript JavaScript +javascript nam OEBPS symlinks @@ -240,12 +240,12 @@ odt Cygwin ogg ultrices -IndentedParagraph indentedparagraph +IndentedParagraph ltr doctests -asciidocapi AsciiDocAPI +asciidocapi itemtag Dvips Jython @@ -286,9 +286,9 @@ lobortis Broberg Bowlin navPoint -ASCIIMathML -AsciiMathML asciimathml +AsciiMathML +ASCIIMathML conf RCS UnicodeDecodeError @@ -345,8 +345,8 @@ pgwide RevisionDate crlf tex -Bolido Bólido +Bolido tabsize colpcwidth Orry @@ -363,8 +363,8 @@ Tsawassen Aenean postsubs src -lastname LastName +lastname OpenBlocks toc tmp @@ -426,6 +426,7 @@ htmlhelp HTMLHelp cellspacing Citeaux +themedir srackham Lulea Luleå @@ -439,9 +440,9 @@ staticfree Morbi Blauer footdata -cb -bg al +bg +cb cd xsl backmatter @@ -459,16 +460,16 @@ fb fermentum fi cellcount -fo et +fo eu hg guimenu fugiat toclevels xzf -JB gq +JB refactored sgml backcolor @@ -485,14 +486,14 @@ lf defacto mb IndentedBlocks -js md +js erat blogpost xsltproc jw -nd ln +nd ne oa Terje @@ -517,8 +518,8 @@ runtime tcqn ePub epub -td px +td vivamus py getElementById @@ -527,8 +528,8 @@ th ru docname ifeval -uk su +uk expandtab autolabel LinuxDoc @@ -537,8 +538,8 @@ tt VM Frédérique SidebarBlock -ut wj +ut Efros param Movet @@ -760,15 +761,15 @@ pagebreak VariableList LiteralBlocks Donec -dbook BLONP +dbook asciimath interesset pellentesque formatlistpat IMGs -attributeentry AttributeEntry +attributeentry Zuckschwerdt autoindent sectids @@ -794,8 +795,8 @@ emacs consetetur JIMI newtables -DocBook docbook +DocBook callout fileextension programlisting @@ -811,11 +812,11 @@ Mihai KeyboardInterrupt justo hexdump -sectionbody SectionBody +sectionbody nnoremap -VerbatimBlock verbatimblock +VerbatimBlock BulletedList html unchunked @@ -843,8 +844,8 @@ basebackend urna rowsep checksums -blockmacro BlockMacro +blockmacro mailto Sagittis plugins @@ -890,16 +891,16 @@ ifdef Shanahan's manmanual Konqueror -firstname FirstName -latexmathml +firstname LaTeXMathML +latexmathml sectnum BlockMacros cceeff unfloat -snabbkop snabbköp +snabbkop NumberedList everti multi @@ -970,8 +971,8 @@ cellpadding entrytbl Ornare authorinitials -JavaScripts javascripts +JavaScripts undefining leveloffset CustomBlock @@ -1031,8 +1032,8 @@ Redhat datadir Kumar IndentedParagraphs -Berguvsvägen Berguvsvagen +Berguvsvägen executables tabledef ftdetect @@ -1053,6 +1054,6 @@ lectus JavaHelp unescaped mydoc -MiddleName middlename +MiddleName Jimmac's diff --git a/doc/asciidoc.txt b/doc/asciidoc.txt index 443ea25..1bb38c9 100644 --- a/doc/asciidoc.txt +++ b/doc/asciidoc.txt @@ -202,7 +202,7 @@ configuration file: backend-alias-docbook=docbook45 DocBook -~~~~~~~ +------- AsciiDoc generates 'article', 'book' and 'refentry' http://www.docbook.org/[DocBook] documents (corresponding to the AsciiDoc 'article', 'book' and 'manpage' document types). @@ -215,41 +215,225 @@ JavaHelp and text. There are also programs that allow you to view DocBook files directly, for example http://live.gnome.org/Yelp[Yelp] (the GNOME help viewer). -[[X35]] -HTML Stylesheets -~~~~~~~~~~~~~~~~ -The 'xhtml11' and 'html5' backends include or link CSS files into -their outputs. The CSS2 stylesheets are located in the distribution -`./stylesheets/` directory. +[[X12]] +Converting DocBook to other file formats +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +DocBook files are validated, parsed and translated various +presentation file formats using a combination of applications +collectively called a DocBook 'tool chain'. The function of a tool +chain is to read the DocBook markup (produced by AsciiDoc) and +transform it to a presentation format (for example HTML, PDF, HTML +Help, EPUB, DVI, PostScript, LaTeX). -`./stylesheets/asciidoc.css`:: - The main stylesheet. +A wide range of user output format requirements coupled with a choice +of available tools and stylesheets results in many valid tool chain +combinations. -Use the 'theme' attribute to select an alternative set of stylesheets. -For example, the command-line option `-a theme=foo` will use -stylesheet `foo.css` instead of the default `asciidoc.css` stylesheet. +[[X43]] +a2x Toolchain Wrapper +~~~~~~~~~~~~~~~~~~~~~ +One of the biggest hurdles for new users is installing, configuring +and using a DocBook XML toolchain. `a2x(1)` can help -- it's a +toolchain wrapper command that will generate XHTML (chunked and +unchunked), PDF, EPUB, DVI, PS, LaTeX, man page, HTML Help and text +file outputs from an AsciiDoc text file. `a2x(1)` does all the grunt +work associated with generating and sequencing the toolchain commands +and managing intermediate and output files. `a2x(1)` also optionally +deploys admonition and navigation icons and a CSS stylesheet. See the +`a2x(1)` man page for more details. In addition to `asciidoc(1)` you +also need <<X40,xsltproc(1)>>, <<X13,DocBook XSL Stylesheets>> and +optionally: <<X31,dblatex>> or <<X14,FOP>> (to generate PDF); +`w3m(1)` or `lynx(1)` (to generate text). -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`. +The following examples generate `doc/source-highlight-filter.pdf` from +the AsciiDoc `doc/source-highlight-filter.txt` source file. The first +example uses `dblatex(1)` (the default PDF generator) the second +example forces FOP to be used: -[[X99]] -HTML Stylesheets and JavaScript file locations -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -'xhtml11' and 'html5' backends use CSS stylesheets and JavaScripts. -CSS and JavaScript files are either embedded in the output document -(when it is generated by AsciiDoc) or linked to the output document -(when it is viewed). - -- If the AsciiDoc 'linkcss' attribute is defined CSS and JavaScript - files are linked otherwise they are embedded (the default behavior). + $ a2x -f pdf doc/source-highlight-filter.txt + $ a2x -f pdf --fop doc/source-highlight-filter.txt + +See the `a2x(1)` man page for details. + +TIP: Use the `--verbose` command-line option to view executed +toolchain commands. + +HTML generation +~~~~~~~~~~~~~~~ +AsciiDoc produces nicely styled HTML directly without requiring a +DocBook toolchain but there are also advantages in going the DocBook +route: + +- HTML from DocBook can optionally include automatically generated + indexes, tables of contents, footnotes, lists of figures and tables. +- DocBook toolchains can also (optionally) generate separate (chunked) + linked HTML pages for each document section. +- Toolchain processing performs link and document validity checks. +- If the DocBook 'lang' attribute is set then things like table of + contents, figure and table captions and admonition captions will be + output in the specified language (setting the AsciiDoc 'lang' + attribute sets the DocBook 'lang' attribute). + +On the other hand, HTML output directly from AsciiDoc is much faster, +is easily customized and can be used in situations where there is no +suitable DocBook toolchain (for example, see the {website}[AsciiDoc +website]). + +PDF generation +~~~~~~~~~~~~~~ +There are two commonly used tools to generate PDFs from DocBook, +<<X31,dblatex>> and <<X14,FOP>>. + +.dblatex or FOP? +- 'dblatex' is easier to install, there's zero configuration + required and no Java VM to install -- it just works out of the box. +- 'dblatex' source code highlighting and numbering is superb. +- 'dblatex' is easier to use as it converts DocBook directly to PDF + whereas before using 'FOP' you have to convert DocBook to XML-FO + using <<X13,DocBook XSL Stylesheets>>. +- 'FOP' is more feature complete (for example, callouts are processed + inside literal layouts) and arguably produces nicer looking output. + +HTML Help generation +~~~~~~~~~~~~~~~~~~~~ +. Convert DocBook XML documents to HTML Help compiler source files + using <<X13,DocBook XSL Stylesheets>> and <<X40,xsltproc(1)>>. +. Convert the HTML Help source (`.hhp` and `.html`) files to HTML Help + (`.chm`) files using the <<X67,Microsoft HTML Help Compiler>>. + +Toolchain components summary +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +AsciiDoc:: + Converts AsciiDoc (`.txt`) files to DocBook XML (`.xml`) files. + +[[X13]]http://docbook.sourceforge.net/projects/xsl/[DocBook XSL Stylesheets]:: + These are a set of XSL stylesheets containing rules for converting + DocBook XML documents to HTML, XSL-FO, manpage and HTML Help files. + The stylesheets are used in conjunction with an XML parser such as + <<X40,xsltproc(1)>>. + +[[X40]]http://www.xmlsoft.org[xsltproc]:: + An XML parser for applying XSLT stylesheets (in our case the + <<X13,DocBook XSL Stylesheets>>) to XML documents. + +[[X31]]http://dblatex.sourceforge.net/[dblatex]:: + Generates PDF, DVI, PostScript and LaTeX formats directly from + DocBook source via the intermediate LaTeX typesetting language -- + uses <<X13,DocBook XSL Stylesheets>>, <<X40,xsltproc(1)>> and + `latex(1)`. + +[[X14]]http://xml.apache.org/fop/[FOP]:: + The Apache Formatting Objects Processor converts XSL-FO (`.fo`) + files to PDF files. The XSL-FO files are generated from DocBook + source files using <<X13,DocBook XSL Stylesheets>> and + <<X40,xsltproc(1)>>. + +[[X67]]Microsoft Help Compiler:: + The Microsoft HTML Help Compiler (`hhc.exe`) is a command-line tool + that converts HTML Help source files to a single HTML Help (`.chm`) + file. It runs on MS Windows platforms and can be downloaded from + http://www.microsoft.com. + +AsciiDoc dblatex configuration files +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The AsciiDoc distribution `./dblatex` directory contains +`asciidoc-dblatex.xsl` (customized XSL parameter settings) and +`asciidoc-dblatex.sty` (customized LaTeX settings). These are examples +of optional <<X31,dblatex>> output customization and are used by +<<X43,a2x(1)>>. + +AsciiDoc DocBook XSL Stylesheets drivers +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +You will have noticed that the distributed HTML and HTML Help +documentation files (for example `./doc/asciidoc.html`) are not the +plain outputs produced using the default 'DocBook XSL Stylesheets' +configuration. This is because they have been processed using +customized DocBook XSL Stylesheets along with (in the case of HTML +outputs) the custom `./stylesheets/docbook-xsl.css` CSS stylesheet. + +You'll find the customized DocBook XSL drivers along with additional +documentation in the distribution `./docbook-xsl` directory. The +examples that follow are executed from the distribution documentation +(`./doc`) directory. These drivers are also used by <<X43,a2x(1)>>. + +`common.xsl`:: + Shared driver parameters. This file is not used directly but is + included in all the following drivers. + +`chunked.xsl`:: + Generate chunked XHTML (separate HTML pages for each document + section) in the `./doc/chunked` directory. For example: + + $ python ../asciidoc.py -b docbook asciidoc.txt + $ xsltproc --nonet ../docbook-xsl/chunked.xsl asciidoc.xml + +`epub.xsl`:: + Used by <<X43,a2x(1)>> to generate EPUB formatted documents. + +`fo.xsl`:: + Generate XSL Formatting Object (`.fo`) files for subsequent PDF + file generation using FOP. For example: + + $ python ../asciidoc.py -b docbook article.txt + $ xsltproc --nonet ../docbook-xsl/fo.xsl article.xml > article.fo + $ fop article.fo article.pdf + +`htmlhelp.xsl`:: + Generate Microsoft HTML Help source files for the MS HTML Help + Compiler in the `./doc/htmlhelp` directory. This example is run on + MS Windows from a Cygwin shell prompt: + + $ python ../asciidoc.py -b docbook asciidoc.txt + $ xsltproc --nonet ../docbook-xsl/htmlhelp.xsl asciidoc.xml + $ c:/Program\ Files/HTML\ Help\ Workshop/hhc.exe htmlhelp.hhp + +`manpage.xsl`:: + Generate a `roff(1)` format UNIX man page from a DocBook XML + 'refentry' document. This example generates an `asciidoc.1` man + page file: + + $ python ../asciidoc.py -d manpage -b docbook asciidoc.1.txt + $ xsltproc --nonet ../docbook-xsl/manpage.xsl asciidoc.1.xml + +`xhtml.xsl`:: + Convert a DocBook XML file to a single XHTML file. For example: + + $ python ../asciidoc.py -b docbook asciidoc.txt + $ xsltproc --nonet ../docbook-xsl/xhtml.xsl asciidoc.xml > asciidoc.html + +If you want to see how the complete documentation set is processed +take a look at the A-A-P script `./doc/main.aap`. + + +Generating Plain Text Files +--------------------------- +AsciiDoc does not have a text backend (for most purposes AsciiDoc +source text is fine), however you can convert AsciiDoc text files to +formatted text using the AsciiDoc <<X43,a2x(1)>> toolchain wrapper +utility. + + +[[X35]] +HTML5 and XHTML 1.1 +------------------- +The 'xhtml11' and 'html5' backends embed or link CSS and JavaScript +files in their outputs, there is also a <<X99,themes>> plugin +framework. + +- If the AsciiDoc 'linkcss' attribute is defined then CSS and + JavaScript files are linked to the output document, otherwise they + are embedded (the default behavior). - The default locations for CSS and JavaScript files can be changed by setting the AsciiDoc 'stylesdir' and 'scriptsdir' attributes respectively. - The default locations for embedded and linked files differ and are - calculated at different times -- embedded files are located when - AsciiDoc generates the output document, linked files are located - when the user views the output document. + calculated at different times -- embedded files are loaded when + asciidoc(1) generates the output document, linked files are loaded + by the browser when the user views the output document. +- Embedded files are automatically inserted in the output files but + you need to manually copy linked CSS and Javascript files from + AsciiDoc <<X27,configuration directories>> to the correct location + relative to the output document. .Stylesheet file locations [cols="3*",frame="topbot",options="header"] @@ -289,6 +473,36 @@ directory containing the backend conf file). |==================================================================== +[[X99]] +Themes +~~~~~~ +The AsciiDoc 'theme' attribute is used to select an alternative CSS +stylesheet and to optionally include additional JavaScript code. + +- Theme files reside in an AsciiDoc <<X27,configuration directory>> + named `themes/<theme>/` (where `<theme>` is the the theme name set + by the 'theme' attribute). asciidoc(1) sets the 'themedir' attribute + to the theme directory path name. +- Themes can be installed, listed and removed using the asciidoc(1) + `--theme` option. +- AsciiDoc ships with two themes: 'flask' and 'volnitsky'. +- The `<theme>.css` file replaces the default `asciidoc.css` CSS file. +- The `<theme>.js` file is included in addition to the default + `asciidoc.js` JavaScript file. +- If the <<X66,data-uri>> attribute is defined then icons are loaded + from the theme's `icons` sub-directory if it exists (i.e. the + 'iconsdir' attribute is set to that location). +- Embedded theme files are automatically inserted in the output files + but you need to manually copy linked CSS and Javascript files to the + location of the output documents. +- Linked CSS and JavaScript theme files are linked to the same linked + locations as <<X35,other CSS and JavaScript files>>. + +For example, the command-line option `-a theme=foo` will cause +asciidoc(1) to search <<X27,well known configuration file locations>> +for a sub-directory called `themes/foo` containing the stylesheet +`foo.css` and optionally a JavaScript file name `foo.js`. + Document Structure ------------------ @@ -2515,6 +2729,10 @@ headers. Example: does not process nested includes). Setting 'depth' to '1' disables nesting inside the included file. By default, nesting is limited to a depth of five. +- If the he 'warnings' attribute is set to 'False' (or any other Python + literal that evaluates to boolean false) then no warning message is + printed if the included file does not exist. By default 'warnings' + are enabled. - Internally the `include1` macro is translated to the `include1` system attribute which means it must be evaluated in a region where attribute substitution is enabled. To inhibit nested substitution in @@ -4760,204 +4978,6 @@ You can find a list of filter plugins on the {website}filters.html[AsciiDoc website]. -[[X12]] -Converting DocBook to other file formats ----------------------------------------- -DocBook files are validated, parsed and translated various -presentation file formats using a combination of applications -collectively called a DocBook 'tool chain'. The function of a tool -chain is to read the DocBook markup (produced by AsciiDoc) and -transform it to a presentation format (for example HTML, PDF, HTML -Help, EPUB, DVI, PostScript, LaTeX). - -A wide range of user output format requirements coupled with a choice -of available tools and stylesheets results in many valid tool chain -combinations. - -[[X43]] -a2x Toolchain Wrapper -~~~~~~~~~~~~~~~~~~~~~ -One of the biggest hurdles for new users is installing, configuring -and using a DocBook XML toolchain. `a2x(1)` can help -- it's a -toolchain wrapper command that will generate XHTML (chunked and -unchunked), PDF, EPUB, DVI, PS, LaTeX, man page, HTML Help and text -file outputs from an AsciiDoc text file. `a2x(1)` does all the grunt -work associated with generating and sequencing the toolchain commands -and managing intermediate and output files. `a2x(1)` also optionally -deploys admonition and navigation icons and a CSS stylesheet. See the -`a2x(1)` man page for more details. In addition to `asciidoc(1)` you -also need <<X40,xsltproc(1)>>, <<X13,DocBook XSL Stylesheets>> and -optionally: <<X31,dblatex>> or <<X14,FOP>> (to generate PDF); -`w3m(1)` or `lynx(1)` (to generate text). - -The following examples generate `doc/source-highlight-filter.pdf` from -the AsciiDoc `doc/source-highlight-filter.txt` source file. The first -example uses `dblatex(1)` (the default PDF generator) the second -example forces FOP to be used: - - $ a2x -f pdf doc/source-highlight-filter.txt - $ a2x -f pdf --fop doc/source-highlight-filter.txt - -See the `a2x(1)` man page for details. - -TIP: Use the `--verbose` command-line option to view executed -toolchain commands. - -HTML generation -~~~~~~~~~~~~~~~ -AsciiDoc produces nicely styled HTML directly without requiring a -DocBook toolchain but there are also advantages in going the DocBook -route: - -- HTML from DocBook can optionally include automatically generated - indexes, tables of contents, footnotes, lists of figures and tables. -- DocBook toolchains can also (optionally) generate separate (chunked) - linked HTML pages for each document section. -- Toolchain processing performs link and document validity checks. -- If the DocBook 'lang' attribute is set then things like table of - contents, figure and table captions and admonition captions will be - output in the specified language (setting the AsciiDoc 'lang' - attribute sets the DocBook 'lang' attribute). - -On the other hand, HTML output directly from AsciiDoc is much faster, -is easily customized and can be used in situations where there is no -suitable DocBook toolchain (for example, see the {website}[AsciiDoc -website]). - -PDF generation -~~~~~~~~~~~~~~ -There are two commonly used tools to generate PDFs from DocBook, -<<X31,dblatex>> and <<X14,FOP>>. - -.dblatex or FOP? -- 'dblatex' is easier to install, there's zero configuration - required and no Java VM to install -- it just works out of the box. -- 'dblatex' source code highlighting and numbering is superb. -- 'dblatex' is easier to use as it converts DocBook directly to PDF - whereas before using 'FOP' you have to convert DocBook to XML-FO - using <<X13,DocBook XSL Stylesheets>>. -- 'FOP' is more feature complete (for example, callouts are processed - inside literal layouts) and arguably produces nicer looking output. - -HTML Help generation -~~~~~~~~~~~~~~~~~~~~ -. Convert DocBook XML documents to HTML Help compiler source files - using <<X13,DocBook XSL Stylesheets>> and <<X40,xsltproc(1)>>. -. Convert the HTML Help source (`.hhp` and `.html`) files to HTML Help - (`.chm`) files using the <<X67,Microsoft HTML Help Compiler>>. - -Toolchain components summary -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -AsciiDoc:: - Converts AsciiDoc (`.txt`) files to DocBook XML (`.xml`) files. - -[[X13]]http://docbook.sourceforge.net/projects/xsl/[DocBook XSL Stylesheets]:: - These are a set of XSL stylesheets containing rules for converting - DocBook XML documents to HTML, XSL-FO, manpage and HTML Help files. - The stylesheets are used in conjunction with an XML parser such as - <<X40,xsltproc(1)>>. - -[[X40]]http://www.xmlsoft.org[xsltproc]:: - An XML parser for applying XSLT stylesheets (in our case the - <<X13,DocBook XSL Stylesheets>>) to XML documents. - -[[X31]]http://dblatex.sourceforge.net/[dblatex]:: - Generates PDF, DVI, PostScript and LaTeX formats directly from - DocBook source via the intermediate LaTeX typesetting language -- - uses <<X13,DocBook XSL Stylesheets>>, <<X40,xsltproc(1)>> and - `latex(1)`. - -[[X14]]http://xml.apache.org/fop/[FOP]:: - The Apache Formatting Objects Processor converts XSL-FO (`.fo`) - files to PDF files. The XSL-FO files are generated from DocBook - source files using <<X13,DocBook XSL Stylesheets>> and - <<X40,xsltproc(1)>>. - -[[X67]]Microsoft Help Compiler:: - The Microsoft HTML Help Compiler (`hhc.exe`) is a command-line tool - that converts HTML Help source files to a single HTML Help (`.chm`) - file. It runs on MS Windows platforms and can be downloaded from - http://www.microsoft.com. - -AsciiDoc dblatex configuration files -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The AsciiDoc distribution `./dblatex` directory contains -`asciidoc-dblatex.xsl` (customized XSL parameter settings) and -`asciidoc-dblatex.sty` (customized LaTeX settings). These are examples -of optional <<X31,dblatex>> output customization and are used by -<<X43,a2x(1)>>. - -AsciiDoc DocBook XSL Stylesheets drivers -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -You will have noticed that the distributed HTML and HTML Help -documentation files (for example `./doc/asciidoc.html`) are not the -plain outputs produced using the default 'DocBook XSL Stylesheets' -configuration. This is because they have been processed using -customized DocBook XSL Stylesheets along with (in the case of HTML -outputs) the custom `./stylesheets/docbook-xsl.css` CSS stylesheet. - -You'll find the customized DocBook XSL drivers along with additional -documentation in the distribution `./docbook-xsl` directory. The -examples that follow are executed from the distribution documentation -(`./doc`) directory. These drivers are also used by <<X43,a2x(1)>>. - -`common.xsl`:: - Shared driver parameters. This file is not used directly but is - included in all the following drivers. - -`chunked.xsl`:: - Generate chunked XHTML (separate HTML pages for each document - section) in the `./doc/chunked` directory. For example: - - $ python ../asciidoc.py -b docbook asciidoc.txt - $ xsltproc --nonet ../docbook-xsl/chunked.xsl asciidoc.xml - -`epub.xsl`:: - Used by <<X43,a2x(1)>> to generate EPUB formatted documents. - -`fo.xsl`:: - Generate XSL Formatting Object (`.fo`) files for subsequent PDF - file generation using FOP. For example: - - $ python ../asciidoc.py -b docbook article.txt - $ xsltproc --nonet ../docbook-xsl/fo.xsl article.xml > article.fo - $ fop article.fo article.pdf - -`htmlhelp.xsl`:: - Generate Microsoft HTML Help source files for the MS HTML Help - Compiler in the `./doc/htmlhelp` directory. This example is run on - MS Windows from a Cygwin shell prompt: - - $ python ../asciidoc.py -b docbook asciidoc.txt - $ xsltproc --nonet ../docbook-xsl/htmlhelp.xsl asciidoc.xml - $ c:/Program\ Files/HTML\ Help\ Workshop/hhc.exe htmlhelp.hhp - -`manpage.xsl`:: - Generate a `roff(1)` format UNIX man page from a DocBook XML - 'refentry' document. This example generates an `asciidoc.1` man - page file: - - $ python ../asciidoc.py -d manpage -b docbook asciidoc.1.txt - $ xsltproc --nonet ../docbook-xsl/manpage.xsl asciidoc.1.xml - -`xhtml.xsl`:: - Convert a DocBook XML file to a single XHTML file. For example: - - $ python ../asciidoc.py -b docbook asciidoc.txt - $ xsltproc --nonet ../docbook-xsl/xhtml.xsl asciidoc.xml > asciidoc.html - -If you want to see how the complete documentation set is processed -take a look at the A-A-P script `./doc/main.aap`. - - -Generating Plain Text Files ---------------------------- -AsciiDoc does not have a text backend (for most purposes AsciiDoc -source text is fine), however you can convert AsciiDoc text files to -formatted text using the AsciiDoc <<X43,a2x(1)>> toolchain wrapper -utility. - - [[X36]] Help Commands ------------- @@ -5785,7 +5805,7 @@ dated to output this attribute. |scriptsdir |html5, xhtml11 | The name of the directory containing linked JavaScripts. -See <<X99,HTML stylesheets and JavaScript locations>>. +See <<X35,HTML stylesheets and JavaScript locations>>. |sgml |docbook45 | The `--backend=docbook45` command-line option produces DocBook 4.5 @@ -5795,7 +5815,7 @@ XML. You can produce the older DocBook SGML format using the |stylesdir |html5, xhtml11 | The name of the directory containing linked or embedded <<X35,stylesheets>>. -See <<X99,HTML stylesheets and JavaScript locations>>. +See <<X35,HTML stylesheets and JavaScript locations>>. |stylesheet |html5, xhtml11 | The file name of an optional additional CSS <<X35,stylesheet>>. @@ -547,7 +547,8 @@ ifdef::toc2[<link rel="stylesheet" href="{stylesdir=.}/toc2.css" type="text/css" endif::linkcss[] ifndef::linkcss[] <style type="text/css"> -include1::{stylesdir=./stylesheets}/{theme=asciidoc}.css[] +include1::{theme%}{stylesdir=./stylesheets}/asciidoc.css[] +include1::{themedir}/{theme}.css[] ifdef::pygments[] include1::{stylesdir=./stylesheets}/pygments.css[] endif::pygments[] @@ -560,6 +561,7 @@ endif::linkcss[] ifndef::disable-javascript[] ifdef::linkcss[] <script type="text/javascript" src="{scriptsdir=.}/asciidoc.js"></script> +<script type="text/javascript" src="{scriptsdir=.}/{theme}.js"></script> <script type="text/javascript"> #TODO: Escape not necessary in HTML5? # Escape as CDATA to pass validators. @@ -573,6 +575,7 @@ ifndef::linkcss[] # Escape as CDATA to pass validators. /*<![CDATA[*/ include1::{scriptsdir=./javascripts}/asciidoc.js[] +include1::{themedir}/{theme}.js[warnings=False] asciidoc.install({toc,toc2?{toclevels}}); /*]]>*/ </script> diff --git a/stylesheets/flask.css b/themes/flask/flask.css index b7bc823..03abe3b 100644 --- a/stylesheets/flask.css +++ b/themes/flask/flask.css @@ -557,7 +557,7 @@ h1 { font-size: 240%; } h2 { font-size: 180%; } h3 { font-size: 150%; } h4 { font-size: 130%; } -h5 { font-size: 100%; } +h5 { font-size: 115%; } h6 { font-size: 100%; } #header h1 { margin-top: 0; } #toc { diff --git a/stylesheets/volnitsky.css b/themes/volnitsky/volnitsky.css index b6c4a15..b6c4a15 100644 --- a/stylesheets/volnitsky.css +++ b/themes/volnitsky/volnitsky.css diff --git a/xhtml11.conf b/xhtml11.conf index 5592164..e0c58ab 100644 --- a/xhtml11.conf +++ b/xhtml11.conf @@ -540,7 +540,8 @@ ifdef::toc2[<link rel="stylesheet" href="{stylesdir=.}/toc2.css" type="text/css" endif::linkcss[] ifndef::linkcss[] <style type="text/css"> -include1::{stylesdir=./stylesheets}/{theme=asciidoc}.css[] +include1::{theme%}{stylesdir=./stylesheets}/asciidoc.css[] +include1::{themedir}/{theme}.css[] ifdef::quirks[] include1::{stylesdir=./stylesheets}/xhtml11-quirks.css[] endif::quirks[] @@ -556,6 +557,7 @@ endif::linkcss[] ifndef::disable-javascript[] ifdef::linkcss[] <script type="text/javascript" src="{scriptsdir=.}/asciidoc.js"></script> +<script type="text/javascript" src="{scriptsdir=.}/{theme}.js"></script> <script type="text/javascript"> # Escape as CDATA to pass validators. /*<![CDATA[*/ @@ -568,6 +570,7 @@ ifndef::linkcss[] # Escape as CDATA to pass validators. /*<![CDATA[*/ include1::{scriptsdir=./javascripts}/asciidoc.js[] +include1::{themedir}/{theme}.js[warnings=False] asciidoc.install({toc,toc2?{toclevels}}); /*]]>*/ </script> |