~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Deplate 0.8.1 -- convert wiki-like markup to latex, docbook, html,
or "html-slides"
Thomas Link
01. Nov 2007
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Table of Contents
=================
1 Introduction
1.1 Goals
2 Getting deplate
2.1 Requirements
2.2 Download
2.3 Support
3 Installation
3.1 Gem
3.2 Win32
3.3 ZIP Archive
4 Usage
4.1 Editor support
4.1.1 General remark
4.1.2 VIM
5 Configuration
5.1 User configuration of the standard setup
5.2 Configuration of wiki names
5.3 Configuration via deplate.ini
5.4 Options
5.5 Templates
5.5.1 Template variables (obsolete)
5.5.2 Template files
6 Input Formats
6.1 deplate
6.2 deplate-restricted
6.3 deplate-headings
6.4 rdoc
6.4.1 heading (rdoc, level 3)
6.5 play -- Hypothetical support for screen-plays and stage-plays
6.5.1 EXT. Beach -- Day
6.6 template
7 Output Formats
7.1 HTML, single-file (no chunks) output
7.2 HTML Site, multi-page (chunky) output
7.3 HTML Slides, abbreviated online presentations
7.4 HTML Website
7.5 XHTML 1.0-transitional (xhtml10t)
7.6 Php, PhpSite
7.7 LaTeX
7.7.1 latex-dramatist: Typeset stage plays with the dramatist
package
7.8 Docbook: article, book, reference pages
7.9 Plain text
7.10 Template
8 Modules
8.1 Localization: lang-en, lang-de, lang-ru-koi8-r, lang-zh_CN
8.1.1 guesslanguage: Guess the locale
8.2 General
8.2.1 anyword: Turn specified words into hyperlinks
8.2.2 code-gvim, code-gvim71: Highlight #Code regions using
gvim
8.2.3 code-highlight: Highlight #Code regions using gvim
8.2.4 endnotes: Turn footnotes into endnotes
8.2.5 iconv: Convert text between encodings
8.2.6 imgurl: Insert urls/links to images as images
8.2.7 linkmap: Define labels refering to URLs
8.2.8 makefile: Create Makefiles
8.2.9 mark-external-urls: Mark external references with icons
8.2.10 numpara: Numbered paragraphs
8.2.11 particle-math: LaTeX-like $\math$ markup
8.2.12 smart-dash: Insert long or short dashes depending
on the context
8.2.13 smiley: Replace text smileys with images
8.2.14 utf8: Improve unicode awareness
8.2.15 xmlrpc: Work as a xmlrpc server
8.3 Syntax
8.3.1 syntax-region-alt: Alternative syntax for regions
8.3.2 markup-1: Re-enable pre0.6 text styles
8.4 LaTeX
8.4.1 inlatex-compound: Compile LaTeX bits as one file
8.4.2 koma: Support for the Koma-Script class
8.4.3 latex-emph-table-head: Emphasize head rows
8.4.4 latex-verbatim-small: Print verbatim regions in small
font size
8.4.5 latex-styles: Styled LaTeX output
8.5 HTML
8.5.1 soffice: Support for Star/Sun/OpenOffice HTML
8.5.2 html-asciimath: Support for ASCIIMathML.js
8.5.3 html-headings-navbar: Insert a navigation bar before
level 1-headings
8.5.4 html-jsmath: Support for jsMath.js
8.5.5 html-obfuscate-email: Obfuscate e-mail
8.5.6 html-sidebar: Display a sidebar containing a small
table of contents
8.5.7 navbar-png: Display images in the navigation bar
8.6 HTML Slides
8.6.1 htmlslides-navbar-fh: Modified navigation bar
8.7 Docbook
8.7.1 symbols-*: Modify the representation of symbols
8.7.2 noindent: Avoid insertion of spaces and newlines
8.8 Miscellaneous
8.8.1 DeplateString
8.8.2 Nukumi2
9 Markup
9.1 The Basics
9.1.1 Elements and Particles
9.1.2 Backslashes
9.1.3 Special Characters
9.1.4 Argument Values
9.2 Comments (whole lines)
9.3 Paragraphs
9.4 Headings
9.5 Lists (indented)
9.6 Description lists (indented)
9.7 Tables
9.8 Anchors
9.9 Wiki Names, URLs
9.10 Symbols
9.11 Markers
9.12 Notes
9.13 Strings, Smart Quotes
9.14 Textstyles
9.15 Breaks
9.16 Whitespace
10 Regions
10.1 Abstract
10.2 Code
10.3 Define: DefRegion, DefCommand, DefMacro, DefElement, DefRegionN,
DefCommandN, DefMacroN
10.3.1 Elements
10.3.2 Particles
10.3.3 Native templates
10.4 Doc, Var
10.5 For
10.6 Header, Footer
10.7 Img
10.8 Inlatex, Ltx
10.9 Native
10.10 Quote
10.11 Set, Get
10.12 R generated tables
10.13 Region
10.14 Ruby
10.15 Swallow, Skip
10.16 Table
10.17 Verbatim
10.18 Write
11 Commands
11.1 Getting or setting data about the document
11.2 Flow control, document management
11.3 Bibliography
11.4 Abbreviations, index
11.5 Dynamic text, elements
12 Macros
12.1 Getting or setting data about the document
12.2 References, labels, index
12.3 Bibliography
12.4 Textstyles
12.5 Dynamic text, particles
13 Skeletons
14 Variables and options
14.1 Document variables
14.1.1 Pre-defined variables
14.1.2 General
14.1.3 Output Format
14.1.3.1 HTML
14.1.3.2 LaTeX
14.1.3.3 Docbook
14.1.3.4 Plain Text
14.1.4 Module
14.1.4.1 Anyword
14.1.4.2 CJK
14.1.4.3 html-headings-navbar
14.1.4.4 html-sidebar
14.1.4.5 latex-verbatim-small
14.1.4.6 Mark External URLs
14.1.4.7 navbar-png
14.1.4.8 Obfuscate E-Mail
14.1.4.9 pstoedit
14.1.4.10 Smileys
14.1.4.11 validate-html
14.1.4.12 XMLRPC
14.1.5 Legacy
14.2 Strings, booleans, arrays, and hashes
14.3 Template "services"
14.4 Element properties
14.4.1 Global properties
14.5 Tags and filters
14.5.1 Foo
14.6 Special arguments
14.7 Clips
15 Internals
15.1 Document structure
16 Extending deplate
16.1 Line/Elements
16.2 Text/Particles
16.2.1 Symbols
16.2.2 Macros
16.3 Formatters
17 Bibliography
18 Index
List of Tables
==============
8.1 How the zh_CN modules set spaces
9.1 Key arguments
9.2 This Table
10.1 A clipped table
10.2 An example from the xtable manual using the tli data set
10.3 Summary of the tli data set
10.4 Summary of the tli data set (guessing cell borders)
10.5 An example of an char separated table
List of Figures
===============
10.1 Example based on the dot manual
10.2 Example plot based on Venables/Ripley (2003)
10.3 An example from the xypic-user guide
11.1 A nice drawing
List of Examples
================
4.1 Using the Deplate::Converter class
5.1 deplate.ini
5.2 A letter template
6.1 RDoc input
6.2 Play input
7.1 Php output
8.1 The makefile module
8.2 The numpara module: Don't number specific buffers
8.3 The numpara module: Change numbering style
8.4 Invoke as a xmlrpc server
8.5 The syntax-region-alt module
9.1 Text styles, backslash
9.2 Comments
9.3 Paragraphs
9.4 List
9.5 Description list
9.6 Table
9.7 Table styles
9.8 Anchors
9.9 Wiki names
9.10 Symbols
9.11 Markers
9.12 Notes
9.13 Quotes
9.14 Text styles
10.1 Abstract
10.2 Code, syntax highlighting
10.3 Define a new region
10.4 Example region
10.5 Example region
10.6 Literate programming
10.7 Define an element
10.8 Define a new particle
10.9 Insert text literally
10.10 For
10.11 Image created with dot
10.12 Inline LaTeX
10.13 "Native" text
10.14 Quotations
10.15 Clip
10.16 Tables created with R
10.17 Inline ruby
10.18 Create a table from tab-separated input
10.19 Verbatim
10.20 Write something to a file
11.1 Commands
12.1 Macro written in Ruby
12.2 Macros
13.1 Skeletons (1)
13.2 Skeletons (2)
14.1 Defining variables
14.2 Variable types
14.3 Templates
14.4 Global properties
14.5 Tags and filters
This manual was created with deplate version 0.8.1.
1 Introduction
==============
deplate is a ruby[1] based tool for converting documents written in
wiki-like markup to LaTeX, HTML, "HTML slides", or docbook. It supports
page templates, embedded LaTeX code, footnotes, citations, bibliographies,
automatic generation of an index, table of contents etc. It can be
used to create web pages and (via LaTeX or Docbook) high-quality printouts
from the same source.
Although originally created as a LaTeX (or word-processor) replacement
for "everyday use", deplate probably isn't suited for highly technical
documents or documents that require sophisticated graphical layout.
For other purposes it should work fine. As the html output filter provides
menus, templates, indexes, and the like, within some limits, it could
also qualify as offline CMS for maintaining small websites. If you
want to do something bigger you might want to use a different programm
though.
deplate aims to be modular and easily extensible. It is the accompanying
converter for the Vim viki plugin[2]. In the family of wiki engines,
the "native" deplate markup originated from the emacs-wiki[3].
deplate reads:
* deplate markup (viki vim plugin) in several variants: full, restricted,
template (this markup is explained in Markup[4] and the following
chapters)
* ruby's rdoc[5]
deplate writes:
* HTML: single page, web site (chunked), web-based presentation
(chunked & condensed), as PHP page
* LaTeX (which can be converted to dvi, postscript, pdf ...)
* Docbook (which can be converted to html, rtf, pdf, xml-fo, man
...)
* Really plain text
A note on code quality: This is a personal/private pet project that
started off as a miniscule script to quickly convert emacs-wiki pages
without emacs. This program is the result of a long series of early
morning pre-coffee plumbing and patch-work. It works well for me tough
and has proven quite useful.
In case deplate doesn't meet your needs, there are plenty of similar
tools you might want to give a try.
For converting mostly plain text to HTML, LaTeX etc.:
* aft[6]
* PlainDoc (pd2tex)[7]
* reStructuredText[8]
* sisu[9]
* txt2tags[10]
* yodl[11]
With respect to website generation, you might also be interested in
these tools:
* webgen[12]
* rote[13]
The authors of zoem (Stijn van Dongen and Joost van Baal) compiled
a comprehensive list of similar efforts[14].
1.1 Goals
~~~~~~~~~
1. Use it as a personal wiki (via the Vim viki plugin[2])
2. Be able to publish to many other formats -- but do it in a way
so that the output looks nice and can be edited and shared with
other people
3. Use a syntax that is convenient to use with all sorts of non-specialized
text editors (the most basic markup should be wiki-style; more complex
things should be done using a more structured approach or by embedding
ruby code)
4. Support all the tags needed to write not-too-technical documents
(i.e., headings, footnotes, citations, indices, page headers/footers,
tables, figures, verbatim text, basic text styles etc.)
5. Conditionally allow the dynamic/on-the-fly generation of content
(e.g., statistical analyses via R, concept maps via dot ...)
6. Use other programs for tasks they perform well
7. Make it customizable
2 Getting deplate
=================
2.1 Requirements
~~~~~~~~~~~~~~~~
Ruby interpreter[1]
deplate was tested with Ruby/Cygwin 1.8.6 under WinXP; the win32
binary was generated with exerb and doesn't require neither a ruby
interpreter nor the deplate sources to be installed
Optional (you only need these if you want deplate to do certain things,
i.e. use certain modules):
LaTeX[15], dvips[16], Ghostscript[17]
For support of inline LaTeX
dvipng
For rendering LaTeX snippets as png
kpsewhich (most likely part of your LaTeX distribution)
For searching bibliography files
ImageMagick[18]
The LaTeX-formatter uses the identify tool to guess image dimensions
if you don't provide them; see also 7.7
hpricot[19]
HPricot is required by code-gvim71[20] module.
Jave[21]
For converting images to ASCII representations to be used in plain
text output.
dot, neato[22]
For on-the-fly generation of figures and plots
R[23]
For on-the-fly generation of plots and tables
ASCIIMathML.js[24]
For use with the html-asciimath[25] module
jsMath.js[26]
For use with the html-jsmath[27] module
Term::ANSIColor[28]
For colored log output (when using the --color command line option)
highlight[29]
For syntax highlighting (see 8.2.3 and 10.2)
GVIM[30]
For syntax highlighting (see 8.2.2 and 10.2) and maybe also for
editing [:-)]
Under MS Windows, the Cygwin[31] environment comes with a convenient
installer and provides ruby, latex, divps, gs, and ImageMagick.
2.2 Download
~~~~~~~~~~~~
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License[32] as published
by the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Download the most current version from the sourceforge project site:
http://sourceforge.net/projects/deplate/[33]
The win32 binary was created using exerb[34] and should work without
ruby being installed. Be aware that some modules don't work with the
win32 binary version.
If you have ruby installed, you might want to use the rubygem[35] version.
2.3 Support
~~~~~~~~~~~
If you have any questions, please post them to the support forum at:
http://sourceforge.net/forum/forum.php?forum_id=371484[36]
3 Installation
==============
3.1 Gem
~~~~~~~
This is the recommended way to install deplate. You need a ruby distribution
and the rubygems[35] package[37]. On the command line type:
gem install deplate-VERSION.gem
3.2 Win32
~~~~~~~~~
Copy the win32 executable to a directory included in the PATH variable.
3.3 ZIP Archive
~~~~~~~~~~~~~~~
On the command line, go to the root directory of the deplate sources,
where setup.rb resides.
cd PATHTODEPLATE
See which options are available.
ruby setup.rb --help
Setup the ruby library and the bash or batch script (depending on RUBY_PLATFORM).
Copy the ruby files to ruby's site-lib directory, and the script to
an appropriate directory in $PATH.
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install
or just:
ruby setup.rb
Check if the modules show up correctly. At the bottom of the help text,
there is a list of available formatting backends and modules. If this
list is empty, something went wrong.
deplate --help
In case something goes wrong, here are the starter scripts. As shell
script
#!/usr/bin/env ruby
require 'deplate'
Deplate::Core.deplate
and as batch script:
@echo off
ruby -rdeplate -e Deplate::Core.deplate -- %*
If you use an "older" version of MS Win & command.exe instead of cmd.exe,
you might have to replace %* with %1 %2 %3 %4 %5 %6 %7 %8 %9.
In case you want to customize deplate, you should also build the api
documentation.
rdoc -S -N lib/deplate
This will install the following files/directories:
* [RUBY_BIN]/deplate[.bat]
* [RUBY_SITELIB]/deplate.rb
* [RUBY_SITELIB]/deplate/...
setup.rb doesn't provide an automatic uninstall routine. In order to
remove deplate from your harddisk, you can either remove these directories
and files by hand or you could try the following command:
rm -fv `cat InstalledFiles`
This requires of course that you keep the file "InstalledFiles" which
is generated during installation.
4 Usage
=======
The command-line options:
Usage: deplate.rb [OPTIONS] FILE [OTHER FILES ...]
deplate is a free software with ABSOLUTELY NO WARRANTY under
the terms of the GNU General Public License version 2.
General Options:
-a, --[no-]ask On certain actions, query
user before overwriting files
-A, --allow ALLOW Allow certain things: l,
r, t, w, W, x, X, $
-c, --config FILE Alternative user cfg file
--[no-]clean Clean up temporary files
--color Colored output
--css NAME Copy NAME.css to the destination
directory, if inexistent
--copy-css NAME Copy NAME.css to the destination
directory
-d, --dir DIR Output directory
-D, --define NAME=VALUE Define a document option
-e, --[no-]each Handle each file separately
--[no-]force Force output
-f, --format FORMAT Output format (default:
html)
--[no-]included Output body only
-i, --input NAME Input definition
--list FILE A file that contains a list
of input files
--log FILE A file (or - for stdout)
where to put the log
--[no-]loop Read from stdin forever
and ever
--metadata [NAME] Save metadata in this format
(default: yaml)
-m, --module MODULE Load a module
-o, --out FILE Output to file or stdout
('-')
-p, --pattern GLOBPATTERN File name pattern
-P, --exclude GLOBPATTERN Excluded file name pattern
-r, --[no-]recurse Recurse into directories
--reset-filecache Reset the file database
-R, --[no-]Recurse Recurse and rebuild hierarchy
-s, --skeleton NAME Make skeleton available
--[no-]simple-names Disable simple wiki names
--split-level LEVEL Heading level for splitting
--suffix SUFFIX Suffix for output files
-t, --template NAME Template to use
--[no-]vanilla Ignore user configuration
-x, --allow-ruby [RUBY SAFE] Allow the execution of ruby
code
-X, --[no-]allow-exec Allow the execution of helper
applications
--[no-]external
LaTeX Formatter:
--[no-]pdf Prepare for use with pdf(la)tex
Available input defintions:
deplate, deplate-headings, deplate-restricted, play, rdoc, template
Available formatters:
dbk-article, dbk-article-4.1.2, dbk-book, dbk-ref, dbk-slides,
dbk-snippet, html, html-snippet, htmlsite, htmlslides, htmlwebsite,
latex, latex-dramatist, latex-snippet, null, php, phpsite, plain,
template, xhtml10t
Available metadata formats:
marshal, xml, yaml
Available modules:
anyword, babelfish, code-gvim, code-gvim71, code-highlight, colored-log,
endnotes, guesslanguage, html-asciimath, html-deplate-button,
html-headings-navbar, html-highstep, html-jsmath, html-obfuscate-email,
html-sidebar, htmlslides-navbar-fh, iconv, imgurl, inlatex-compound,
koma, lang-de, lang-en, lang-ru, lang-ru-koi8-r, lang-zh_CN,
lang-zh_CN-autospace, latex-emph-table-head, latex-styles, latex-verbatim-small,
linkmap, makefile, mark-external-urls, markup-1, markup-1-warn,
navbar-png, noindent, numpara, particle-math, php-extra, pstoedit,
recode, smart-dash, smiley, soffice, symbols-latin1, symbols-od-utf-8,
symbols-plain, symbols-sgml, symbols-utf-8, symbols-xml, syntax-region-alt,
utf8, validate-html, xmlrpc
Available css files:
article, deplate, heading-navbar, highstep, htmldoc, layout-deplate,
layout-deplate-print, play, sans-serif, serif, serif-e, serif-rel,
slides, styles, tabbar, tabbar-left, tabbar-right, tabbar-right-ie,
tabbar-top, text-sans-serif, text-serif
Available templates:
html-doc.html, html-left-tabbar-js.html, html-left-tabbar.html,
html-tabbar-right-pcomments.php, html-tabbar-right-step.html,
html-tabbar-right-table.html, html-tabbar-right.html, html-tabbar-top.html,
html-tabbar.html
Other Options:
--debug [LEVEL] Show debug messages
--[no-]profile Profile execution
--[no-]quiet Be quiet
-v, --[no-]verbose Run verbosely
-h, --help Show this message
--list-modules [REGEXP] List modules matching a
pattern
--list-css [REGEXP] List css files matching
a pattern
--version Show version
--microversion Show version
Typical uses of deplate are:
deplate -D auxiliaryDirSuffix=_files text.txt
Convert the file to html; put auxiliary files that are created
during the conversion process into a subdirectory called "text_files"
deplate -d DESTDIR -f htmlslides text*.txt
Convert a bunch of files to "html slides"; put the output into
"DESTDIR"
deplate -f latex --pdf -D suffix=txt text*.txt
Convert a bunch of files to a single LaTeX file and prepare for
pdflatex; assume that the wiki files have a "txt" extension; wiki
names referring to included files are transformed to internal references
deplate -R -p '\*.txt' -D suffix=txt -o ../Wiki.tex WikiIndex.txt
*
Convert all files in the current directory and below to a single
LaTeX file; include only files with "txt" as suffix; put WikiIndex.txt
first
deplate -R -e -d ../Wiki_html *
Convert all files in the current directory and its subdirectories
to html; save the output in directory Wiki_html; rebuild the directory
structure of the input files
deplate - < INPUT > OUTPUT
Work as a filter by converting the input from stdin; this doesn't
actually work like a pipe though because all the input has to be
read in order to generate the output
deplate -x -X file.txt
Convert a file and allow the evaluation of embedded ruby code
and the execution of external applications, e.g., latex. These
command switches are necessary for some language elements to work.
Notes:
-D VAR, -D VAR=VALUE
You can define document variables via the command line; if no
value is provided the variable is set to "1".
The option parser library, which deplate uses, doesn't deal well
with spaces in command line arguments. This is why spaces have
to be replaced with tildes; a tilde and backslashes have to be
preceded with backslashes. Example: -D text=bla~bla\~bla sets the
document variable text to "bla bla~bla". As a shell usually interpretes
backslashes too, you would usually have to type -D text=bla~bla\\~bla.
-e
Process each file separately
-m, --module MODULE
Load an add-on/module (after loading the core and the formatter);
modules reside in the deplate library directory or in the user
configuration directory ("~/.deplate/mod/"); type deplate --help
to see a list of available modules.
After loading the module, deplate searches for the file "~/.deplate/after/mod/NAME.rb"
which will be loaded if found.
German, Chinese, and Russian localizations are provided as modules.
-p PATTERN, -P PATTERN
Backslashes in the pattern must come in doubles; backslashes can
be used to prevent the shell from expanding the pattern; e.g.,
in case you're using bash, you would usually type something like
-p "\\*.txt"
-x, --allow-ruby [RUBY SAFE]
Ruby's SAFE variable has 5 levels (0=no checks/default .. 4=sandbox;
at present, this also sets the SAFE variable for deplate itself,
which doesn't work with SAFE set to 4)
-X, --[no-]allow-exec, --[no-]external
Allow the execution of external applications, e.g., LaTeX. You
won't be able to translate inline LaTeX unless you call deplate
with this command line option. In order to make this permanent,
see 5.1.
-A, --allow FLAGS
Flags is a list of comma separated letters which may contain:
l
Allow the #LANG command to automatically load a module of the
language's name (this would make it possible for a malicious
user to load any module as deplate cannot distinguish localization
modules from other modules)
r
Check files in $PWD/deplate.rc in some cases (e.g. check for
a local config.rb); templates, css files, and library snippets
are always searched in the deplate.rc directory too; if you
want to allow a deplate.ini file in this directory, you have
the add allow r to your private deplate.ini file (usually in
~/.deplate/)
t
Unfiltered (La)TeX
w
Enable the #Write region (directory local file names only)
W
Enable the #Write region (allow relative & absolute file names)
x
Same as -x
X
Same as -X
.
Allow sending methods to objects in the arg macro and friends.
:
Allow referencing options by prepending a name with ":" in
some situations (e.g. #IF tests).
You can remove the permission to do something by prepending a minus
to the flag, e.g. by setting --allow -x on the command line after
having allowed x in the deplate.ini file.
Some variables change the way deplate works.
autoFileNames
In multi-file output, the file name is constructed from the top
heading unless explicitely defined (id, caption, shortcaption)
auxiliaryDirSuffix
If defined, auxiliary files are saved in the subdirectory #{basename
FILENAME}#{auxiliaryDirSuffix}. E.g., if auxiliaryDirSuffix is
"_files" and the current file is "Test", then auxiliary files
(images, on-the-fly generated files that are passed to external
applications etc.) are saved in "Test_files".
If you are a ruby programmer, you can also use deplate as a library
for formatting strings. You could use the convenience classes Deplate::Converter
or DeplateString for this.
Example 4.1: Using the Deplate::Converter class
require 'deplate/converter'
t = <\n(c) 2004, Me']
end
@@deplate_template << '#AU: My Name'
end
end
5.5.2 Template files
--------------------
Via the -t or --template command-line option or by setting the template
document variable (see 14.1), you can define simple text templates
that will be filled in with content from your deplate file.
Since version 0.7, deplate uses a specialized formatter for handling
templates. Before 0.7, this was done by search & replace. If you have
pre 0.7 templates which don't work any more, you can switch back to
the old template mechanism by setting the document option[39] template_version
to 1.
In templates, only a small number of statements are available:
Commands
GET, ARG, XARG, VAR, OPT, PREMATTER, POSTMATTER, BODY, IF, ELSE,
ELSEIF, ENDIF, INC/INCLUDE
Regions
Foreach, Mingle, Ruby, Var
Macros
get, clip, opt, arg, xarg, doc, ruby
The commands PREMATTER, POSTMATTER, BODY as well as the Mingle region
are specific to templates.
PREMATTER, POSTMATTER, and BODY can be used to fill in formatted content
for an explanation of deplate's document structure):
#PREMATTER
The file header, the beginning of the document definition, some
text that in multi-file mode should appear in every output file
#BODY
The text body
#POSTMATTER
Some text that in multi-file mode should appear in every output
file, the end of document definition
These commands take a list of slots (named or as numbers) as arguments.
The slots can be single slots or ranges. They can be positive (add
selectively) or negative (add with the exception of certain content).
Examples:
#PREMATTER: -doc_def
add the prematter without the document type definition
#PREMATTER: doc_def mod_packages mod_head
add the document type definition, and stuff added by modules
#PREMATTER: head_beg..prematter_end
add everything from the head on downwards
A slot cannot be consumed twice. I.e., if you use several template
commands, the latter will not insert the content that was already inserted
by the previous command.
The Mingle region can be used to add some text to a specific slot in
the original document. Filling in templates takes place after the document
was produced. A template actually processed by deplate like normal
text but with a different active rule set. Thus, if you define a slot
or a type for a region in the template file these definitions refer
to the template output which usually is not quite what you want. You
can use Mingle to make them refer to the original document. See html-left-tabbar-js.html
in the templates subdirectory of the distribution for an example.
Curly braces in templates could cause problems because deplate maybe
interpretes them as macros. If deplate mixes up your template, you
should prefix these curly braces that cause problems with a backslash.
Backslashes have always to be doubled.
Example 5.2: A letter template
In this example, we use get for the author's name because the corresponding
clip is automatically defined by the standard #AU(THOR) command. For
other data we use variables.
Template: tmpl_letter.tex
\\documentclass[12pt,a4paper,english]{letter}
#PREMATTER: -doc_def
\\address{{get: author}\\\\
{val escapebackslash!: address}}
\\signature{{get: author}}
\\begin{letter}{{val: addresseeName}\\\\
{val escapebackslash!: addresseeAddress}}
\\opening{Dear {val: addresseeName},}
#BODY
\\closing{Sincerly,}
\\vfill{}
\\encl{{val: enclosure}}
\\end{letter}
#POSTMATTER
Input file: example-letter.txt
#AU: John Smith
#DATE: today
#VAR id=address: Cool Place 1{nl inline!}Hiptown 10000
#VAR id=enclosure: Important Document
#VAR: addresseeName=Max Mustermann
#VAR: addresseeAddress=Tolle Straße 2{nl}Neustadt 20000
I would like to say thanks for your last letter which I read with much joy. I
hope to be hearing from you soon.
Command line:
deplate -t tmpl_letter.tex -f latex example-letter.txt
pdflatex example-letter.tex
Result: example-letter.pdf[40]
6 Input Formats
===============
The -i command-line option allows to select an input definition file.
6.1 deplate
~~~~~~~~~~~
This is deplate's "native" markup as defined in the following pages
(see 9). This is the markup that corresponds to the Vim viki plugin.
6.2 deplate-restricted
~~~~~~~~~~~~~~~~~~~~~~
This is a restricted version of deplate's "native" markup. The following
elements are disabled:
Commands:
* INC
* MODULE
* WITH
* ABBREV
Regions:
* Any Define type of region
* Native
* Img
* R
* Ruby
Macros:
* ins
* ruby
Setting variables not beginning with an underscore is disabled. I.e.
you can't set any variables listed in 14.1.
6.3 deplate-headings
~~~~~~~~~~~~~~~~~~~~
Print headings only; filter any other text.
6.4 rdoc
~~~~~~~~
This input definition reads a subset of ruby's rdoc format. For an
examples of a documents created from rdoc input please see:
* http://constraint.rubyforge.org/[41] (source[42])
* http://websitiary.rubyforge.org/[43]
Limitations:
* The :main: and the :call-seq: directives are not implemented yet
* deplate doesn't distinguish between bold and italic
* There maybe are some deviations from rdoc, e.g., in the way list
items with interleaved verbatim text are handled
deplate supports the following addition(s), which rdoc doesn't:
* extra directives
+ :maketitle: (the title is automatically created when using
the :title: directive)
+ :author: (place this above a :title: directive if you want
the names to appear on the page)
Example 6.1: RDoc input
=== heading (rdoc, level 3)
_italic_, italic,
*bold*, bold,
+typewriter+, typewriter
http://deplate.sf.net
http://deplate.sourceforge.net/linked.png
link:index
Homepage[http://deplate.sf.net]
{Deplate Homepage}[http://deplate.sf.net]
verbatim
1. numbered
a. alpha
- bullet
* bullet
label:: text
+label+:: text
[label] text
[+label+] text
yields:
6.4.1 heading (rdoc, level 3)
-----------------------------
italic, italic, bold, bold, typewriter, typewriter
http://deplate.sf.net[44]
[http://deplate.sourceforge.net/linked.png]
index[45]
Homepage[44]
Deplate Homepage[44]
verbatim
1.. numbered
a.. alpha
* bullet
* bullet
label
text
label
text
label
text
label
text
6.5 play -- Hypothetical support for screen-plays and stage-plays
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! This input filter is in a state of flux. You probably don't
!!! want to use it yet. There currently is no appropriate output
!!! filter anyway.
play is a subset of the standard deplate markup with some additional
styling and conventions. Currently only a CSS file is provided.
This can be formatted as stage play using the latex-dramatist[46] formatter.
Output via LaTeX's screenplay class is planned.
Formatting rules:
Headings (Level 1)
Scenes (see below for the format)
Paragraphs
Stage directions
Description list
Dialog lines
Bullet lists
Inserted stage directions (their meaning depends on the formatter)
[TEXT]
Minor directions.
Extra commands:
#CAST
The cast (if supported by the formatter). The casting is defined
as a description list that is tagged as "cast". Setting the property
"cast" works too but is deprecated due to problems when applying
X_speaks filters (see below).
#ACT
Begin a new act (if supported by the formatter)
NOTE: Don't rely on the availability of syntax elements not mentioned
above. Most of them are disabled for this input filter.
Dialog lines are automatically tagged with #{Name}_speaks and can be
filtered using the efilter variable (see 14.5). This way you can get
a quick overview of whether a person speaks in a consistent tone.
The scene headings have the following format: Title :: Location --
INTEXT/TIME. How scene headings are actually printed depends on the
output format.
INTEXT can have the following values:
Exterior
E, EXT, EXT., >, A (German "außen")
Interior
I, INT, INT., <
TIME can be abbreviated with:
Day
D, T (German "Tag" = Day)
Night
N
Example 6.2: Play input
#PUSH: css=+play.css
#ABBREV word=Mm: Michael
#ABBREV word=M: {mark1st: Michael}
#ABBREV word=Ms: {mark1st: Michael}\'s
#ABBREV word=Nn: Nora
#ABBREV word=N: {mark1st: Nora}
#ABBREV word=Ns: {mark1st: Nora}\'s
Mm :: man
Nn :: woman
#PP: tag=cast
#CAST
#ACT
* Exciting News :: Beach -- E/D
N reads a book.
M is half buried in the sand. He looks at the cover of Ns book.
N :: What a wonderful day this is.
M [mumbles] :: Maybe.
- The sun drops from the sky.
N :: And what an interesting book this is I'm reading. I cannot
remember having read such breathtaking action scenes since last
summer.
M [mumbles] :: Possible.
- The sky drops into the sea.
+ Fade out
yields:
Michael
man
Nora
woman
6.5.1 EXT. Beach -- Day
-----------------------
NORA reads a book.
MICHAEL is half buried in the sand. He looks at the cover of Nora's
book.
Nora
What a wonderful day this is.
Michael (mumbles)
Maybe.
* The sun drops from the sky.
Nora
And what an interesting book this is I'm reading. I cannot remember
having read such breathtaking action scenes since last summer.
Michael (mumbles)
Possible.
* The sky drops into the sea.
* Fade out
6.6 template
~~~~~~~~~~~~
Works like normal templates as describe in 5.5. Best used in conjunction
with the template output filter[47].
7 Output Formats
================
Some cursory remarks. The output can be fine tuned by setting certain
variables -- see 14.1.
7.1 HTML, single-file (no chunks) output
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is the default formatter. It generates plain html; tidy gives
some warnings (mostly about nested lists), but no errors. Formatting
has to/should be done via a css.
Notes:
Citations
Currently only some kind of APA-look-alike style is provided.
The bibliography is compiled directly from a set of BibTeX files.
It probably fails on some entries.
Headings
Set the document variable "headings" (see 11.1) or the headings
option (see 14.4) to "plain" to turn off numbering.
7.2 HTML Site, multi-page (chunky) output
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is a variant of the HTML formatter that can be used to generate
websites. The output is broken at first level heading so that each
chapter is saved in its own file. By default the file names are numbered
(e.g., basename.html, basename00001.html, basename00002.html ...).
If you give a first level heading an id (see 9.4), this id will be
used instead -- as it was done for deplate's online documentation.
If docNavbar variable is defined and true (i.e., "1"), a navigation
bar is added to the top and the bottom. If docNavbar equals top, only
the top navigation bar is displayed; if it equals bottom only the bottom
navigation bar. In general, using templates is a much more convenient
and flexible way to add navigation bars. Take a look, e.g., at deplate/templates/html-left-tabbar-js.html
for the template that was used to create the online documentation.
If JavaScript is enabled, you can navigate through the slides by pressing:
Previous page
Front page
,
Next page (double clicking on a heading moves to the next page,
too)
Navigation was originally inspired by html slides by Gervase Markham[48].
7.3 HTML Slides, abbreviated online presentations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is a variant of htmlsite that can be used to create html based
presentations. In its default setting, it "swallows" paragraphs (unless
the noSwallow variable[38] is given). This way you can easily generate
a full paper and an abridged presentation version (just the lists,
the figures, and the tables) from the same source.
7.4 HTML Website
~~~~~~~~~~~~~~~~
This is a variant of the htmlslides formatter that places a tabbar
at the top of the page. htmlwebsite was kindly contributed by Fritz
Heinrichmeyer.
NOTE: This formatter is obsolete. Fritz Heinrichmeyer now uses his
htmlslides-navbar-fh[49] module in conjunction with the html-slides
formatter and page templates.
7.5 XHTML 1.0-transitional (xhtml10t)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is a minor variant of the HTML formatter that improves XML conformance.
7.6 Php, PhpSite
~~~~~~~~~~~~~~~~
This is a simple variant of the HTML formatter that can be used for
generating php output. PhpSite is based on HTML Site.
The following additional elements are provided by the php-extra module.
Additional region:
#Php
Insert the body as php code
Additional command:
#PHP
Insert the body as php code
Additional macros:
{php: BODY}
Insert as php code ()
{=BODY}
print_r the php code ()
Example 7.1: Php output
* Test Php-Output
#Php <<--
$mod = "absolutely";
echo '
Here we go!
';
--
Mixing php control constructs and ''deplate'' markup:
#PHP: foreach(array('doing', 'saying', 'writing about') as $action):
I have {php: echo $mod} no idea{fn: none} what I'm __{=$action}__.
#PHP: endforeach;
#Fn: none <<--
None whatsoever.
--
7.7 LaTeX
~~~~~~~~~
If you give the --pdf option, some packages are marked for use with
pdflatex.
The LaTeX-formatter assumes the use of the natbib-package for citations
(see DeplateMacro#formatted_citation).
The graphicx package is used for displaying graphics, the hyperref
package for hyperlinks.
If you set the useBooktabs variable, the booktabs package is used.
This results in prettier ready-to-print tables but interferes with
table styles.
If you don't provide image dimensions (bw, bh options), deplate uses
ImageMagick's identify to guess its width and height.
* If you prefer a different tool, redefine Deplate::External.image_dimension(filename),
which returns the bounding box as [bw, bh, bx, by] (bx and by are
most likely ignored)
You can set the DIV variable to change the typearea. This uses koma's
typearea package.
7.7.1 latex-dramatist: Typeset stage plays with the dramatist package
---------------------------------------------------------------------
In conjunction with the play[50] input filter, this formatter generates
nicely formatted stage plays, thanks to the dramatist[51] package.
* Scene titles won't be printed.
* Groups can be defined as follows:
Name One :: A man
- Group A
Name Two :: A woman
Name Three :: Another man
Name Four:: Another woman
7.8 Docbook: article, book, reference pages
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The docbook formatter currently is able to generate proper xml for
the deplate manual but it doesn't perform any validation and doesn't
try to modify the input in order to attain valid output. It should
work most of the time though.
The formatter currently comes in the following flavors:
dbk-article
Format as an article
+ use the headings: "sect1", "sect2" ...
dbk-book
Format as a book
+ use the headings: "chapter", "sect1", "sect2" ...
dbk-ref
Format as a reference or man page
+ use the headings: "refsect1", "refsect2" ...
+ make uses of the following doc variables if provided
- refentry (or use the filename)
- manvol (defaults to "1")
+ the document title (defined with #TI) is used as refpurpose
+ there is currently no way to define a synopsis in deplate
7.9 Plain text
~~~~~~~~~~~~~~
Wow! deplate can also convert mostly markup-free text formats to plain
text.
If the asciiArt variable is set (or if it set to "jave"), deplate uses
Jave[21] to convert images to ascii representations. You can use the
additional ascii_algorithm and ascii_width arguments to tweak jave's
output.
This requires a jave command to be in the path. Such a command could
look like this:
#!/bin/bash
exec java -jar $JAVE_HOME/jave5.jar $@
or (for Windows):
@echo off
%JAVA_HOME%\bin\java.exe -jar %JAVE_HOME%\jave5.jar %*
7.10 Template
~~~~~~~~~~~~~
This formatter is used by deplate for filling in templates as described
in 5.5. From a user perspective, it could be useful in conjunction
with the template input filter[52].
8 Modules
=========
8.1 Localization: lang-en, lang-de, lang-ru-koi8-r, lang-zh_CN
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
With these modules, messages like "Bibliography", "Table of Contents"
are translated to a localized equivalent.
Available localizations are:
de
German
+ In LaTeX output, this module makes use of the "german" package
ru-koi8-r
Russian (kindly contributed by Maxim Komar)
zh_CN
Chinese (kindly contributed by Jjgod Jiang)
+ When used with LaTeX output, this module uses the following
packages: CJK, CJKnumb, indentfirst; the text is set in a CJK*
environment
+ Like in the CJK* environment in LaTeX, a tilde denotes a space
between an English and non-English word (in HTML, this will become
a normal space, though)
- Wiki names should not contain tildes but only normal space
+ Spaces and newlines will be swallowed
+ The following document variables can be used to parametize
this module
- cjk_family (default: gbsn)
- cjk_encoding (default: GB)
In LaTeX output, the CJK* environment will be: \begin{CJK*}{ENCODING}{FAMILY}
In order to change these variables permanently, add something
like variables["cjk_encoding"] = "GBK" to your definition of
Deplate#user_initialize[53].
+ If you want to keep blanks as they appear in the document,
you have to set Deplate::Formatter.cjk_smart_blanks to true
or set the document option noSmartBlanks. If you want to change
this setting for some modes only, add your settings to ~/.deplate/after/fmt/FORMATTER.rb.
zh_CN-autospace
Like zh_CN but tries to figure out which spaces it should set
and which ones it should swallow
+ this module requires the encoding to be gb2312 or, to be more
precise, it requires an encoding where CJK-characters are made
up of double byte characters in the range 0xA1-0xFE
+ what was said about Deplate::Formatter.cjk_smart_blanks for
zh_CN applies too
Table 8.1: How the zh_CN modules set spaces
+--------------+------------------------+--------------+---------------+
| Input: zh_CN | Input: zh_CN-autospace | Output: HTML | Output: LaTeX |
+--------------+------------------------+--------------+---------------+
| C C | C C | CC | CC or C C[54] |
| C\nC | C\nC | CC | CC or C C |
| C~a | C a | C a | C~a |
| a~C | a C | a C | a~C |
| C\n~a | C\na | C a | C~a |
| a~\nC | a\nC | a C | a~C |
+--------------+------------------------+--------------+---------------+
8.1.1 guesslanguage: Guess the locale
-------------------------------------
The algorithm of this plugin is based on D Benedetto & E Caglioti &
V Loreto "Language Trees and Zipping"[55]. It's a direct port of Dirk
Holtwick's "Guess language of text using ZIP"[56].
In order to make this work, you'll have to save some sample files as
~/.deplate/locale/LANG.ENCODING_data. I.e., in order to enable autodetection
for German documents, find some German sample, save it as de.latin1_data,
and make sure the guesslanguage module gets loaded. You'll also have
to allow l (see 5.3 and 4).
If you want to see your locale/language supported, send me translations
of the message file and freely distributable text samples.
8.2 General
~~~~~~~~~~~
8.2.1 anyword: Turn specified words into hyperlinks
---------------------------------------------------
A list of words that should be turned into wiki names can be defined
via the document options:
anyword_list
a list a names separated by ","
anyword_catalog
a file name that contains automatically generated wiki names one
per line
anyword_pattern
a glob file pattern
anyword_suffix
remove this suffix from file names to get the corresponding wiki
names
If no wiki names are defined, all files in the source files' directories
will be used.
8.2.2 code-gvim, code-gvim71: Highlight #Code regions using gvim
----------------------------------------------------------------
This modules make use of gvim to highlight code regions for html output.
The code-gvim71 is suitable for newer versions of gvim (7.1+).
NOTE: This module relies on an external program. You thus have to allow
deplate to run programs, e.g. by using the -X command line switch.
8.2.3 code-highlight: Highlight #Code regions using gvim
--------------------------------------------------------
This modules make use of André Simon's highlight[29] to highlight code
regions for html, xhtml, and LaTeX output.
Type highlight --list-langs to get a list of supported languages.
The style information is currently not included in the output itself.
You have to save the style definition in an auxiliary file -- highlight-#{STYLE}.css
for HTML output, highlight-#{STYLE}.sty for LaTeX. Consequently, it's
only possible to use one style per file, which is why you should probably
set the style via the codeStyle document variable. If no style is defined,
the file names are highlight.css and highlight.sty.
NOTE: This module relies on an external program. You thus have to allow
deplate to run programs, e.g. by using the -X command line switch.
8.2.4 endnotes: Turn footnotes into endnotes
--------------------------------------------
This module turns footnotes into endnotes that can be listed using
the command:
#LIST: endnotes
The module uses the "endnotes" package in LaTeX format.
8.2.5 iconv: Convert text between encodings
-------------------------------------------
The source encoding is defined in the encoding variable (default: "latin1"),
the target encoding in the recodeEncoding variable (default: "utf-8").
So, your input text file can be in latin-1 and your docbook output
in utf-8.
8.2.6 imgurl: Insert urls/links to images as images
---------------------------------------------------
Insert urls/links to images as images and not as references.
8.2.7 linkmap: Define labels refering to URLs
---------------------------------------------
Jeff Barczewski took the idea of markdown to not include URLs in the
text but labels that are replaced with the URLs and adapted it for
deplate.
This module also modifies the ref macro (see 12.2) to use these labels.
Example:
Syntax for using links in map (any of following):
- [[Example]]
- [[Example][This example]]
- [[Example][Example in a box]*], i.e. in a new window
- [[Example]$] no follow rel
or to embed raw URL using macro{ref: Example} foo.
Use the ref macro but display the URL{ref p!: Example}.
Use the ref macro but display a different name{ref name=this example:
Example}.
#LinkMap <<---
Example: http://www.example.com/foo.php&bar=123#abc
---
yields:
Syntax for using links in map (any of following):
* Example[57]
* This example[57]
* Example in a box[57], i.e. in a new window
* Example[57] no follow rel
or to embed raw URL using macro Example[57] foo.
Use the ref macro but display the URL http://www.example.com/foo.php&bar=123#abc[57].
Use the ref macro but display a different name this example[57].
NOTE: The LinkMap environment can be located anywhere in the current
source. Labels are effective only in the current source unless global!
is set.
8.2.8 makefile: Create Makefiles
--------------------------------
This module creates a Makefile and exits from the current run. The
Makefile should be suitable for most tasks.
Example 8.1: The makefile module
First run:
deplate -m makefile -m de -m html-obfuscate-email index.txt
This will create Makefile and Makefile.config. Then, you can run, e.g.,
make website
to create a multi-page website (HTML output, using the htmlsite formatter).
NOTE: In case you want to create new make goals, put them into Makefile.config.
If you run the above command again, the Makefile will be overwritten
but not Makefile.config.
The following goals might be of use:
cleantex
Remove temporary LaTeX files
dbk
Create docbook output
dvi
Create dvi output (via LaTeX)
dviclean
Create dvi output and remove temporary files
html
Create single-page HTML output (the default)
man
Create a man page (via DocBook & xmlto)
pdf
Create PDF output (via LaTeX)
pdfclean
Create PDF output and remove temporary files
php
Create PHP output
tex
Create LaTeX output
text
Create plain text output
website
Create multi-page HTML output
The generated Makefile supports implicit, suffix-based rules. Example:
make extra.html
This will convert the file extra.txt (because in the above example
the suffix was txt) and convert it to single-page HTML, using the command
line options defined when creating the makefile.
8.2.9 mark-external-urls: Mark external references with icons
-------------------------------------------------------------
URLs will be marked with images -- "mailto.png" or "url.png" depending
on the type. The image names can be redefined by setting the document
options "mailtoIcon" or "urlIcon". In this manual I use icons from
the QBullets set[58].
8.2.10 numpara: Numbered paragraphs
-----------------------------------
This module adds a running number to each formatted paragraph. The
paragraphs are numbered as they are formatted, which means that clipped
paragraphs, non-standard document slots, or pragraphs in headers of
footers are likely to result in a "non-linear" sequence. Add the attribute/option
noNum to these "out-of-order" paragraphs.
Example 8.2: The numpara module: Don't number specific buffers
#Clip id=clippedParagraph <<--
Some text that forms a paragraph.
#OPT: noNum!
--
If you want to change the way paragraphs are numbered redefine the
method Deplate::Element::Paragraph#add_number like in this example:
Example 8.3: The numpara module: Change numbering style
class Deplate::Formatter
def numbered_paragraph(text, number)
return [plain_text("§"), number, " ", text].join
end
end
8.2.11 particle-math: LaTeX-like $\math$ markup
-----------------------------------------------
This module provides a particle that enables you to markup mathematical
text by enclosing it in dollar signs as it is used in LaTeX. This is
not enabled by default in order to reduce the number of special characters.
The text is converted as if you had used the math macro (see 12.5).
8.2.12 smart-dash: Insert long or short dashes depending on the context
-----------------------------------------------------------------------
This module defines a single dash ("-") as a symbol and turns it into
a long dash (i.e. "--") in some situations:
* when preceding character is a digit
* when the next character is a digit
* when the preceding and the next character are wiki word characters
This module also removes the double dash -- (see 9.10) from the symbol
table. You can force long dashes by using `--.
8.2.13 smiley: Replace text smileys with images
-----------------------------------------------
Currently only the basic smiley is being recognized.
+-----+-------+
| :-) | [:-)] |
+-----+-------+
You can define you own smileys by adding something like this to ~/.deplate/after/mod/smiley.rb:
Deplate::Particle::Smiley.def_smiley(':-(', 'smiley_sad')
The suffix of the image file is controlled by the smileySfx or imgSfx
variables.
8.2.14 utf8: Improve unicode awareness
--------------------------------------
When using this module, deplate takes care of UTF-8 multibyte sequences
when sorting the index and similar occassions. This module also sets
the output encoding to "UTF-8".
8.2.15 xmlrpc: Work as a xmlrpc server
--------------------------------------
This modules makes deplate work as an xmlrpc server. The xmlrpc server
could run in an protected context and make deplate formatting capabilities
available in an unsafe environment.
This module is experimental and not well tested. The module takes no
precautions with respect to concurrent formatting requests.
The xmlrpc server knows the following handlers/methods:
convert(format, text)
return the converted string
convert_string(format, text)
same as above
convert_file(format, filename)
convert the file FILENAME and return the name of the output file
(this requires the server and the client to work on a shared directory
string_to_fileset(format, filename, text)
convert text and return a hash (or whatever) that contains filenames
and their contents; this hash comprises auxiliary files too; it's
up to the client to save them in a proper place; cross-references
assume that these files reside in the same directory
fileset_to_fileset(format, main_filename, fileset_as_hash)
convert a fileset (a hash of names and contents) to a fileset
NOTE: The xmlrpc server creates a new converter for each request unless
the xmlrpcReuseInterpreter variable ist defined, which will make it
reuse the previous converter (the consequence of which is that abbreviations,
indexes and the like from earlier documents are still active). This
was the default behaviour before version 0.7.3.
NOTE: This module isn't available in the win32-exe distribution. You
have to use the source distribution or the ruby gem.
Example 8.4: Invoke as a xmlrpc server
The server (we must give a file name as argument so that deplate doesn't
complain about missing arguments):
a> deplate -m xmlrpc -
[2005-01-28 20:02:15] INFO WEBrick 1.3.1
[2005-01-28 20:02:15] INFO ruby 1.8.1 (2003-12-25) [i386-cygwin]
[2005-01-28 20:02:15] INFO WEBrick::HTTPServer#start: pid=2536 port=2000
[...]
A client:
b> irb
irb(main):001:0> require 'xmlrpc/client'
irb(main):002:0> deplate = XMLRPC::Client.new("localhost", "/deplate", 2000)
irb(main):003:0> puts deplate.call("convert", "html", "Some text ...")
[...]
irb(main):004:0> puts deplate.call("convert", "latex", "Some text ...")
\documentclass[11pt,a4paper,english]{article}
\usepackage[latin1]{inputenc}
\usepackage[]{suppl}
[...]
There are some variables to change the port and the path:
xmlrpcAllow
a space separated list of IP addresses or regular expressions
matching valid IP addresses
xmlrpcPort
default is 2000
xmlrpcPath
default is "/deplate"
8.3 Syntax
~~~~~~~~~~
8.3.1 syntax-region-alt: Alternative syntax for regions
-------------------------------------------------------
This module provides an alternative Syntax for regions.
Example 8.5: The syntax-region-alt module
====== Region options: args
content
====== Optional Comment
There have to be at least 4 equal signs at the beginning of the line.
The number of equal signs in the end statement has to match the number
in the begin statement.
8.3.2 markup-1: Re-enable pre0.6 text styles
--------------------------------------------
Since 0.6 the markup for textstyles was changed in order to choose
characters that are less likely to be appearing in ordinary text for
markup. Use this module to re-enable the old pre 0.6 markup:
Emphasize
*word*, **any text**
Typewriter, Code
=word=, ==any text==
8.4 LaTeX
~~~~~~~~~
8.4.1 inlatex-compound: Compile LaTeX bits as one file
------------------------------------------------------
This (still experimental) module changes the way deplate compiles LaTeX
bits (e.g., when using the ltx or math macros). Usually deplate would
save each bit into one file and run this file through LaTeX. This approach
is simple to manage but has the disadvantage that LaTeX commands defined
in one bit are unknown in another.
This module makes deplate collect all LaTeX bits in one file. Afterwards,
the resulting postscript file is split in pieces it order to create
one image per page.
If a LaTeX bit covers more than one page, this module fails.
8.4.2 koma: Support for the Koma-Script class
---------------------------------------------
Some support for koma script's document classes:
* Use scrartcl instead of article
* Use scrpage2 for headers and footers
8.4.3 latex-emph-table-head: Emphasize head rows
------------------------------------------------
Emphasize header cells and add a ruler after a header row.
8.4.4 latex-verbatim-small: Print verbatim regions in small font size
---------------------------------------------------------------------
In order to make it easier for LaTeX, this module prints verbatim regions
in small font size.
8.4.5 latex-styles: Styled LaTeX output
---------------------------------------
This module provides the infrastructure for styling LaTeX output. Currently,
only a few table styles are supported. Please see 9.7 for examples.
8.5 HTML
~~~~~~~~
8.5.1 soffice: Support for Star/Sun/OpenOffice HTML
---------------------------------------------------
Not much yet:
* Footnotes, headers, and footers are marked in OpenOffice compatible
format by default
* Make the pagenumber macro insert a reference to the PAGE field
8.5.2 html-asciimath: Support for ASCIIMathML.js
------------------------------------------------
ASCIIMathML.js[24] by Peter Jipsen[59] translates plain text formulas
to MathML. As it happens to know some LaTeX syntax, it can be used
to translate the math macro[60] to MathML.
ASCIIMathML.js does the translation when viewing the document in your
browser which could result in some delay when viewing large files.
ASCIIMathML requires JavaScript to be enabled and works with the following
browser:
* Internet Explorer 6 + MathPlayer
* Netscape7.1/Mozilla/Firefox
If you don't use this module, the LaTeX code will be embedded as image.
Don't forget to copy ASCIIMathML.js to the output directory.
8.5.3 html-headings-navbar: Insert a navigation bar before level 1-headings
---------------------------------------------------------------------------
This module defines a style which insert a simple navigation bar with
a drop-down menu and forward/backward buttons before every level-1
heading.
You can set headingsNavbarMaxLevel (default=1) in order to add a navbar
for deeper nested headings too.
8.5.4 html-jsmath: Support for jsMath.js
----------------------------------------
jsMath.js[26] serves a similar purpose as ASCIIMathML[25].
8.5.5 html-obfuscate-email: Obfuscate e-mail
--------------------------------------------
This module replaces e-mail adresses (but only those that have a mailto
prefix) with some presumably harvester-safe representation. The JavaScript
representation is an array of hex chars, which is a method used by
several other tools. The no-script representation has the mailto prefix
removed and the characters @ and . are replaced with AT and DOT.
8.5.6 html-sidebar: Display a sidebar containing a small table of contents
--------------------------------------------------------------------------
If JavaScript is enabled, you can move the mouse to the left side to
view a small table of contents.
8.5.7 navbar-png: Display images in the navigation bar
------------------------------------------------------
This module redefines the buttons in the navigation bar for using images:
prev.png, home.png, next.png
8.6 HTML Slides
~~~~~~~~~~~~~~~
8.6.1 htmlslides-navbar-fh: Modified navigation bar
---------------------------------------------------
This module, which was contributed by Fritz Heinrichmeyer, provides
a modified navigation bar using span tags instead of a table and is
meant as a replacement for the html-website formatter.
If you want this navigation bar to be the default, you can either require
it in your config.rb file or copy/move/link it to ~/.deplate/after/fmt/htmlslides/.
8.7 Docbook
~~~~~~~~~~~
8.7.1 symbols-*: Modify the representation of symbols
-----------------------------------------------------
If you define the document option "sgml", then the formatter won't
insert symbols in plain utf-8 but in something programs like jade deal
with more docile.
When writing man pages, you might want to include the module "symbols-plain"
instead.
8.7.2 noindent: Avoid insertion of spaces and newlines
------------------------------------------------------
If you define the document option "sgml", the formatter will also load
this module which avoids inserting spaces and newlines. This make programs
like jade output more nicely formatted documents.
8.8 Miscellaneous
~~~~~~~~~~~~~~~~~
8.8.1 DeplateString
-------------------
The file deplate/deplate-string provides the class DeplateString, which
is a subclass of String and has methods like #to_html, #to_latex etc.
for easier use of this whole thing from within another program.
puts DeplateString.new('bar __foo__ bar').to_html
8.8.2 Nukumi2
-------------
There is a somewhat experimental support to use deplate as markup language
for a Nukumi2[61] maintained site. In order to enable deplate for Nukumi2,
you have to add this line to your Nukumi2 config.rb:
require 'deplate/nukumi2'
and maybe also, in order to enable inline LaTeX, Ruby code etc.:
DeplateString.deplate_options.allow += ['x', 'X']
A blog entry could then look like this:
#TITLE: Deplate Test
#DATE
#KEYWORDS: deplate
* It works!
Yes, this article was converted using ''deplate''.
This hack was written for Nukumi2 v0.5. It's not guaranteed to work
with other versions.
NOTE: There must be an empty line after the header section.
9 Markup
========
The markup corresponds to the markup of Vim's viki-plugin. There are
some minor deviations, though.
This chapter is mainly a test course.
9.1 The Basics
~~~~~~~~~~~~~~
9.1.1 Elements and Particles
----------------------------
A deplate document is made up of elements (a.k.a. block elements in
HTML, XML etc.) that consist of particles (a.k.a. inline elements).
No particle can cross element boundaries. This distinction is important
to understand, as commands[62] and regions[63] yield elements, but
macros[64] yield particles.
Although deplate has some facitilities for program control (conditional
or repeated output), it really is rather a markup language but no programming
language. Although you can define new elements right within a deplate
document using deplate markup, this only works for really simple elements.
If a line matches an element pattern (usually defined by the beginning
of the line), it marks the end of the previous element and starts a
new element. If a line matches no pattern, it either starts a new paragraph
or is added to the previous element. Elements like headings, anchors,
or table rows are one-line patterns to which no unmatched line will
be added. Other elements like list items or paragraphs can be made
up of more than one line.
9.1.2 Backslashes
-----------------
The deplate markup is based on inserting special characters into the
text as in this example: __emphasized__, which will be printed as emphasized.
If you want to prevent deplate from interpreting these markers, they
must be preceded by a backslash.
* The backslash is used as escape character that prevents the wikification
of the following character.
* There are two exceptions:
1. A backslash at the end of the line makes a pattern include
the next line; any whitespace at the beginning of the following
line is removed.
2. A backslash in front of a blank results in non-breaking space.
* A backslash that should be printed must be preceded by a backslash.
9.1.3 Special Characters
------------------------
You should especially take care with the following characters:
Curly braces ({})
Curly braces usually enclose macros; in other contexts, they
should always be preceded by a backslash
+ There are some grey areas though that could cause problems,
e.g. when input to a macro (e.g. the ruby macro) contains an
unmatched curly brace
Backticks (`)
Backticks are used to insert some symbols and should be escaped
by a backslash in other contexts than inserting a special character.
Sequences of character you should notice:
Two underscores (__) followed by non-whitespace
Emphasized text
Two single quotes ('') followed by non-whitespace
Literal text set in typewriter font
Two colons (::) surrounded by whitespace
Used in definition lists
Characters with special meaning if they occur at the beginning of line:
Asterisks (*)
Headings, unordered lists
Sharp sign (#)
Anchors, commands, regions, ordered lists
Percent (%)
Comments
List markers
1., a., -, *, #, @, ?, ?.
Other:
The dollar sign ($)
Although it has currently to be enabled by loading a module, there
is a chance that this will become the standard delimiter for mathematical
expressions typed in latex (with the AMS packages enabled). The
standard markup will be either $a = x + y$ or with blanks $ a =
x + y $ as the dollar sign is most likely used before or after
a digit.
Be aware that your editors line wrap can inadvertently place these
characters at the beginning of a line.
Example 9.1: Text styles, backslash
__emphasize__, WikiName
\__noemphasize\__, \NoWikiName
One \
\
line
One\
word
unnnnnnnnnnnnnnnnnn\ breakkkkkkkkkkkkkkkkkk\ ableeeeeeeeeeeeeeeeeeeeeeee
yields:
emphasize, WikiName[65]
__noemphasize__, NoWikiName
One line
Oneword
unnnnnnnnnnnnnnnnnn breakkkkkkkkkkkkkkkkkk ableeeeeeeeeeeeeeeeeeeeeeee
9.1.4 Argument Values
---------------------
Arguments to macros, commands, and regions:
* In argument values, the characters !=: and single double quotes
must be preceded by a backslash
* Alternatively, you can enclose a value in double quotes (which
will be stripped off; doublequotes must be escaped using a backslash)
or parentheses (which will be retained)
* Argument values are stripped of whitespace; if you want an argument
to contain leading or trailing whitespace, you have to enclose the
argument in double quotes
Table 9.1: Key arguments
+-------------------------------+---------------------------------+-------+
| Example | Key Arguments | Body |
+-------------------------------+---------------------------------+-------+
| {macro} | {} | "" |
| {macro: foo} | {} | "foo" |
| {macro boo!: foo} | {"boo" => true} | "foo" |
| {macro boo! bar=1: foo} | {"boo" => true, "bar" => "1"} | "foo" |
| {macro bar=object(id=1): foo} | {"bar" => "object(id=1)"} | "foo" |
| {macro bar="foo := bar": foo} | {"bar" => "foo := bar"} | "foo" |
| {macro bar=( boo=boo): foo} | {"bar" => "( boo = boo)"} | "foo" |
| {macro bar=\( boo=boo): foo} | {"bar" => "(", "boo" => "boo)"} | "foo" |
| {macro bar="(" boo=boo): foo} | {"bar" => "(", "boo" => "boo)"} | "foo" |
+-------------------------------+---------------------------------+-------+
There are two special arguments (fmt and if) that allow some control
on whether an element will be included in the output. Please see 14.6
for details.
9.2 Comments (whole lines)
~~~~~~~~~~~~~~~~~~~~~~~~~~
* The percent sign has to be first non-blank character in the line.
Otherwise it's interpreted as a character.
* A comment separates lines as paragraphs.
* For intra-paragraph comments use the comment macro 12.2
Example 9.2: Comments
Line %1
%Comment
Line %2
yields:
Line %1 Line %2
9.3 Paragraphs
~~~~~~~~~~~~~~
A paragraph a sequence of non-empty lines that don't match anything
else.
Example 9.3: Paragraphs
Paragraph 1 finishes with an empty line. Paragraph 1 finishes with an
empty line. Paragraph 1 finishes with an empty line.
Paragraph 2 finishes with an unordered list. Paragraph 2 finishes with
an unordered list. Paragraph 2 finishes with an unordered list.
- Item 1
- Item 2
yields:
Paragraph 1 finishes with an empty line. Paragraph 1 finishes with
an empty line. Paragraph 1 finishes with an empty line.
Paragraph 2 finishes with an unordered list. Paragraph 2 finishes with
an unordered list. Paragraph 2 finishes with an unordered list.
* Item 1
* Item 2
9.4 Headings
~~~~~~~~~~~~
NOTE: Headings can span more than one line by putting a backslash ('\')
at the end of the line.
Known options:
noList!
prevent the heading from being listed in the toc; as you can see
from the current heading, the heading number is increased nevertheless
(which probably should be considered as a bug?)
caption
the display name in the table of contents
shortcaption
the display name in a minitoc; with multi-file output, this argument
defines the optional file name
id
similar to shortcaption; if an id and a shortcaption are given,
the id will be used for the filename and the sort caption for the
mini-toc
plain!
Don't add any numbering to the heading. (Set the variable headings
to "plain" if you want to turn off numbering for all headings.)
url=URL
Turn a heading into a hyperlink; this requires the hyperHeading
variable(see 14.1.2) to be set
If you set the variable autoFileNames, deplate will derive the file
name from the heading.
* Level 1
#OPT: id=foo
** Level 2
*** Level 3
#OPT: noList! plain!
...
9.5 Lists (indented)
~~~~~~~~~~~~~~~~~~~~
Example 9.4: List
- Item
* Item
+ Item
1. Item 1
a. Item a
B. Item B
#Verb <<---------
EMBEDDED VERBATIM TEXT
---------
2. Item 1
|| Embedded || Table ||
| x | 1 |
| y | 2 |
* Item
# Item 1
@ There is much to say about Item A, too much to be put
in words or to be written down.
What else is there to say about Item A?
@ Item B
# Item 2
- Do this
#A _ Some task
#B1 _ Some other task
- Do that
#A x11-11-2050 Something was done!
#B1 11-11-2050 Some other task
yields:
* Item
+ Item
- Item
1.. Item 1
a.. Item a
B.. Item B
EMBEDDED VERBATIM TEXT
2.. Item 1
+----------+-------+
| Embedded | Table |
+----------+-------+
| x | 1 |
| y | 2 |
+----------+-------+
+ Item
1. Item 1
a. There is much to say about Item A, too much to be
put in words or to be written down.
What else is there to say about Item A?
b. Item B
2. Item 2
* Do this
{A} Some task
{B1} Some other task
* Do that
{A 11-11-2050} Something was done!
{B1 11-11-2050} Some other task
NOTE: "#" (numbered, ordered lists), and "@" (ordered lists with letters)
are the preferred markers. If you use dashes as in LaTeX (i.e. "--"),
a dash appears to be okay too. Be aware that, like LaTeX, deplate concatenates
two normal dashes ("--") to one long dash ("--") -- see also 9.10.
NOTE: If you run into troubles when nesting lists, consider the use
of the list macro 12.5.
NOTE: Task lists are implemented as varlist in DocBook.
9.6 Description lists (indented)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Example 9.5: Description list
Item :: Description
yields:
Item
Description
9.7 Tables
~~~~~~~~~~
A table is marked as sequence of lines beginning and ending with one
or two "|" symbols. Two pipe symbols (or whatever its name is) define
a row belonging to the head or the foot.
A row containing only empty cells and cells with hyphens defines a
ruler.
A cell containing only "^" means concatenate with the cell above. A
cell containing only "<" means concatenate with the cell to the left.
Tables take the following options (via the OPT command):
head=N
The number of rows encompassing the table head
foot=N
The number of rows encompassing the table foot
hiRow=N1,N2,first,last,...
The rows to be highlighted
hiCol=N1,N2,first,last,...
The columns to be highlighted
rows=ROWDEF1, ROWDEF2, ...
Define a row's attributes
+ ROWDEF has the form: KEY1.VAL1 KEY2.VAL2 ...; KEY being one
of
h
The row height
+ a ruler counts as a row
cols=COLDEF1, COLDEF2, ...
Define a columns's attributes
+ COLDEF has the form: KEY1.VAL1 KEY2.VAL2 ...; KEY being one
of
w
The column width
j
The column's justification (left, right, center, or justified)
r
Add a left-handed vertical ruler (the value denotes the
number of rulers or its thickness)
* This option is currently only interpreted for LaTeX
output
long!, short!
Define whether the longtable environment should be used in LaTeX
output (by default, the longtable environment will be used for
tables with more than 20 rows).
+ Switching between the table and the longtable environment
has some effects on the layout. One consequence is that footnotes
are set properly only in the longtable environment. On the other
hand, the here, floatHere, align, and floatAlign options are
currently ignored.
style=NAME
The table style (but see below)
stylex=NAME
Like style but ignore tableStyle
note=TEXT
A short note concerning data source etc.
In addition, the following options for "floats" apply too:
here!, floatHere=1
In LaTeX output, add the h attribute to the table environment
align=[left|right|center], floatAlign=[left|right|center]
align the table; the first one is a table specific options, the
second a global document option
Joining cells: If a cell contains nothing but "^" or "<", the current
cell will be joined with the left one or with the cell above. (The
actual output depends on the formatter and the capabilities of the
target format, though.)
It depends on the formatter whether these options are interpeted.
Example 9.6: Table
|| ----------------------------- ||
|| Head || Categories || < ||
| Row1 | Value1 | Value1 |
| | ----------- | |
| Row2 | | Value2 |
| | ----------- | |
| Row3 | Value3 | ^ |
| ----------------------------- |
#OPT: hiCol=first hiRow=last cols=w.3cm j.right r.1, w.1cm,,r.1 rows=,h.3cm
#OPT: note=Source: My Head, 2004
#CAP: This Table
#thisTable
yields:
Table 9.2: This Table
+------+------------+--------+
| Head | Categories |
+------+------------+--------+
| Row1 | Value1 | Value1 |
| Row2 | | Value2 |
| Row3 | Value3 | |
+------+------------+--------+
Source: My Head, 2004
NOTE: Rows can span more than one line by putting a backslash ('\')
at the end of the line.
NOTE: An empty cell is marked by at least 3 consecutive blanks.
You can also define a style for a table. The style attribute is currently
only interpreted by the latex-styles module and to some degree emulated
in HTML output -- not so surprisingly, this works better in Firefox
than in MS IExplorer.
The following styles are known (for one or another output format):
grid
Draw all table borders/rulers
formal
Draw a ruler at the top and the bottom of the table, as well as
between groups
box
Like formal but add vertical rulers on both sides
overlay
Like box but draw the background of some rows and columns in gray
or in colours
list
Horizontal rulers between each row
small, footnotesize, scriptsize
Smaller font sizes
dense08
decreased intercell spacing (there is a minor problem with line
spacing)
landscape
rotate the table (LaTeX only, I assume)
Example 9.7: Table styles
#Var id=styledTableExample <<---
|| Head || A || B ||
| Row1 | 1 | 2 |
| Row2 | 3 | 4 |
|| Foot || X || Y ||
#OPT: hiCol=first
---
Test ''grid'' & ''scriptsize'' styles:
#INCLUDE var=styledTableExample
#OPT: style=grid,scriptsize
Test ''formal'' & ''footnotesize'' styles:
#INCLUDE var=styledTableExample
#OPT: style=formal,footnotesize
Test ''box'' & ''small'' styles:
#INCLUDE var=styledTableExample
#OPT: style=box,small
Test ''overlay'' style:
#INCLUDE var=styledTableExample
#OPT: style=overlay,landscape
yields:
Test grid & scriptsize styles:
+------+---+---+
| Head | A | B |
+------+---+---+
| Row1 | 1 | 2 |
| Row2 | 3 | 4 |
+------+---+---+
| Foot | X | Y |
+------+---+---+
Test formal & footnotesize styles:
+------+---+---+
| Head | A | B |
+------+---+---+
| Row1 | 1 | 2 |
| Row2 | 3 | 4 |
+------+---+---+
| Foot | X | Y |
+------+---+---+
Test box & small styles:
+------+---+---+
| Head | A | B |
+------+---+---+
| Row1 | 1 | 2 |
| Row2 | 3 | 4 |
+------+---+---+
| Foot | X | Y |
+------+---+---+
Test overlay style:
+------+---+---+
| Head | A | B |
+------+---+---+
| Row1 | 1 | 2 |
| Row2 | 3 | 4 |
+------+---+---+
| Foot | X | Y |
+------+---+---+
9.8 Anchors
~~~~~~~~~~~
Anchor (or labels respectively) are attached to the previous element,
save if the previous element is a whitespace. In this case the anchor
will be attached to the following element.
The name must begin with a lower letter. There mustn't be non-whitespace
character before the sharp sign.
Example 9.8: Anchors
* This is section one
#labSectOne
Some text.
#labSomeText
#labSectTwo
* This is section two
9.9 Wiki Names, URLs
~~~~~~~~~~~~~~~~~~~~
deplate is inspired by several wiki engines. It thus also provides
formatting of wiki names and URLs as hyperlinks. There are about four
types of wiki names.
Simple
Any word in CamelCase is turned into a wiki name -- save if wikification
is prevented with a backslash -- see 9.1.2.
Quoted
Any text between [- and -] will be turned into a hyperlink.
Extended
An extended wiki name has the form: [[DESTINATION][OPTIONAL NAME]MODIFIER].
+ MODIFIER is optional.
"*"
open page in new window
"$"
set rel="nofollow"
"!"
prevents deplate from adapting the reference's suffix
* deplate was created as the publishing framework (or
so) for a personal wiki (namely the Vim viki plugin).
As such it assumes that the files being referenced to
are converted to the same target format as the current
file, which is why deplate modfies an extended wiki destination's
suffix. Use this modifier to prevent deplate from doing
so.
* Often the chosen deplate output is only an intermediary
file; in order to make deplate append the suffix of the
final output file, set the document option suffix to
the desired value. E.g. if you convert to docbook and
then from docbook to html, pass the option -D suffix=html
to deplate when converting the text sources.
+ If you want a hyperlink to have an image, use: [[http://www.example.com][{img:
example_image}]]. See also 12.5.
InterWikis
An interwiki name is a shortcut to a different wiki. Any simple
and quoted wiki name can be deferred to an interwiki by prepending
NAMEINCAPITALS::. You have to define an interwiki before referring
to it by adding something like this to your configuration file:
InterWiki.add("ID", "http://BASEURL/", ".SUFFIX")
Wiki Names are automatically marked as index entries -- see 11.4 and
11.5.
Example 9.9: Wiki names
WikiName
WikiName#anchor
[-name-]
[-some name-]#there
[--]#here
OTHERWIKI::WikiName
OTHERWIKI::WikiName#there
OTHERWIKI::[-some name-]
OTHERWIKI::[-some name-]#there
[[destination]]
[[destination][name]]
[[destination#anchor][name]]
[[destination.suffix]!]
[[OTHERWIKI::destination#anchor][name]]
[[#anchor]]
[[#anchor][name]]
9.10 Symbols
~~~~~~~~~~~~
The backtick (`) is used to introduce some symbols like quotation marks
(e.g., in positions where deplate would choose the wrong one).
Symbols are not expanded in text marked as typewriter/code and in verbatim
regions.
Example 9.10: Symbols
<-, ->, <=, =>, <~, ~>, <->, <=>, <~>, !=, ~~, ..., --, ==, ```, `'', ``, `'
''->'', ''<-''
#Verb <<--
<-, ->, <=, =>
--
#Code id=symbolsTest syntax=ruby <<--
<-, ->, <=, =>
--
yields:
<-, ->, <=, =>, <~, ~>, <->, <=>, <~>, !=, ~~, ..., --, ==, ", ", ',
'
->, <-
<-, ->, <=, =>
<-, ->, <=, =>
NOTE: If you want to disable some of these symbols, you could add some
ruby code like this to your config.rb:
class Deplate::Particle::Symbol
@@symbols_table.delete_if {|k,v| ['<->', '<=>', '<~>'].include?(k)}
reset_symbols
end
9.11 Markers
~~~~~~~~~~~~
Markers are meant to highlight a position in the text. In order to
avoid ambiguities with notes (see below), there should not be a space
before or after the marker -- i.e. it should immediately follow or
precede the word it is referring to.
Example 9.11: Markers
- elaborate+++
- here###
- questionable???
- attention!!!
yields:
* elaborate+++
* here###
* questionable???
* attention!!!
9.12 Notes
~~~~~~~~~~
Indented paragraphs that begin with a marker and a subsequent space
start an annotation, i.e. the text of paragraph will be turned in
a margin note or similar -- depending on the output format.
Example 9.12: Notes
Indented paragraphs that begin with a marker and a subsequent space
start an annotation.
!!! Something like this.
yields:
Indented paragraphs that begin with a marker and a subsequent space
start an annotation.
!!! Something like this.
9.13 Strings, Smart Quotes
~~~~~~~~~~~~~~~~~~~~~~~~~~
Example 9.13: Quotes
"Text in quotes"
yields:
"Text in quotes"
NOTE: Quotes are handled by two classes: Deplate::Particle::DoubleQuote
and Deplate::Particle::SingleQuote. In order to disable smart quotes
add this code to your config.rb:
Deplate::Particle.disable_particle(
Deplate::Particle::DoubleQuote,
Deplate::Particle::SingleQuote
)
9.14 Textstyles
~~~~~~~~~~~~~~~
Example 9.14: Text styles
__emphasize__, ''typewriter''
yields:
emphasize, typewriter
NOTE: There must not be a whitespace after the opening mark.
NOTE: Text in typewriter style is basically set verbatim with the expection
of backslashes.
9.15 Breaks
~~~~~~~~~~~
A break is marked by at least 2 dashes, "8<", and again at least 2
dashes.
I say so.
----8<--------------
Summary:
In HTML output, a break is represented by a horizontal line. In other
output formates, a break actually denotes a page break.
9.16 Whitespace
~~~~~~~~~~~~~~~
A line of whitespace usually separates text elements -- e.g. paragraphs,
10 Regions
==========
The text marked by a region is interpreted according to the region's
rules. The text could be normal deplate source, but it could also be
ruby code, LaTeX, or whatsoever.
Check for end pattern:
#Type [OPTIONS] <<----
Text ...
----
Match until next empty line:
#Type [OPTIONS] <<
Text ...
Deprecated:
#Type [OPTIONS]:
Text ...
#End
This form can't be nested.
"Type" being one of:
* Abstract
* Code
* Define
* Doc, Var
* Footnote, Fn
* For
* Header, Footer
* Img
* Inlatex, Ltx
* Native or the name of the chosen formatter
* Quote
* Set
* R (tables)
* Region (generic)
* Ruby
* Swallow, Skip
* Table
* Verbatim, Verb
* Write
10.1 Abstract
~~~~~~~~~~~~~
Example 10.1: Abstract
#Abstract <{arg: name}
#ARG: @body
---
#DefCommandN id=LISTPAIR <<---
{arg: @body}
---
#DefMacroN id=pair args=name @body <<---
{arg: name}
{arg: @body}
---
#Pairs name=A list of pairs <<---
#LISTPAIR: {pair name=: }
#LISTPAIR: {pair name=: &}
#LISTPAIR: {pair name=: }
---
#ELSE
Sorry, the example is defined for HTML output only.
#ENDIF
yields:
Sorry, the example is defined for HTML output only.
10.4 Doc, Var
~~~~~~~~~~~~~
Defining a document variable using the #Var can come handy in conjunction
with #For[69]. It's important to understand that a variable defined
by the #Var region is internally represented as an array (one entry
per line). If you simply insert this array into a document, the result
might not look like what you expected it to be. Also, if you write
your own modules, using the #Var region is a convenient way to pass
around information.
10.5 For
~~~~~~~~
This region provides a simple way of looping through lists.
Arguments:
id
The doc variables the values should be assigned to.
sep
The list separator (if the argument is a string)
var
The document variable, which holds the list (if this isn't defined,
the text after the colon will be used)
Example 10.10: For
#Var: Fruits:
1kg, apples
2kg, peaches
#End
#For id=listentry doc=Fruits <<--
\#For id=kg,fruit sep=, doc=listentry:
I would like to buy \{arg: kg} of \{arg: fruit}.
#End
--
yields:
I would like to buy 1kg of apples.
I would like to buy 2kg of peaches.
It is necessary to escape the inner #For region and the arg macros
with backslashes, because the body is passed through the template filter.
You can prevent this by using the noTemplate! argument or by setting
the legacyFor1 variable.
10.6 Header, Footer
~~~~~~~~~~~~~~~~~~~
The argument to these regions is either a paragraph or a table with
up to three columns. The result of the header and footer region depends
on the formatter.
HTML
Insert the argument at the top/bottom of the document
LaTeX
Ignore footer, add the header using \markright{}
LaTeX + koma module
Use koma's scrpage2 package to format the header and the footer;
with the koma module these regions take some optional arguments
+ center, right (only if the text is a paragraph; the default
is to put the header/footer in the left column)
+ linesep=\d+, linesep=\d+pt, linesep! (defaults to 0.4pt)
- or use the abbreviation "sep"
See also notes on the pagenumber[70] macro.
10.7 Img
~~~~~~~~
deplate provides support for including graphics generated "on the fly"
by other programs.
Synonyms
Image, Fig, Figure
Options:
id
the basis for the filenames (RECOMMENDED, default: deplatxImgAuto%02d);
if you don't provide an id, deplate uses an automatically generated
one. Anyway, if you make changes to the document, it's possible
that the generated graphics get messed up
sfx
the graphic file's suffix
Argument (after the colon): PROGRAM_NAME COMMANDLINE_OPTIONS ...
* PROGRAM_NAME is the program name known to deplate, currently
+ dot
+ neato
+ R
- Note: Options for the R devices can be defined as arguments
to the region. In the form "DEV_OPTION" the option is specific
to a chosen device (e.g. "png_width=700"). In the form "_OPTION",
it is applicable to all devices (e.g. "_pointsize=10"). This
is necessary as some devices expect dimensions to be given
in inches, other in pixels. Please refer to the R manual
to find out which options are applicable.
* COMMANDLINE_OPTIONS are pasted somewhere into the command call
-- how this exactly happens depends on the calling method
The region Img returns an object of the same type as the command IMG
(see 11.5). All arguments are passed on to the resulting object.
Example 10.11: Image created with dot
Using ''dot'':
#Img id=dot_example: dot <<---
digraph structs {
node [shape=record];
struct1 [shape=record,label=" A| B| C"];
struct2 [shape=record,label=" D| E"];
struct3 [shape=record,label=" F| G"];
struct1:f1 -> struct2:f0;
struct1:f2 -> struct3:here;
}
---
#OPT fmt=latex: w=6cm
#CAP: Example based on the dot manual
Using ''R'':
#Img id=r_geyser: R <<---
attach(geyser)
truehist(duration, nbins=20, xlim=c(0.5, 6), ymax=1.2)
lines(density(duration, width="nrd"))
---
#OPT fmt=latex: w=6cm
#CAP: Example plot based on Venables/Ripley{cite y!: mass4}
yields:
Using dot:
Figure 10.1: Example based on the dot manual
.............,......
| | | |
| | | |
| /\ | '[[ | /'''|
| ,' . | .\.' | `.. |
| | | |
| | | |
`------.-------------.
/ `.
/ ".
/ \
_' '
/ . . |
,________.- _ ________[`________
| | `'''''''| | '| |
| | | | | |
| .`. | , | | .<: | , v |
| |_' | / | | | | [ | |
| '' | ''' | | '' | ' |
| | | | | |
`......../........./ `.........\.........'
Using R:
Figure 10.2: Example plot based on Venables/Ripley (2003)
T: .
| .
,. | ||
. | ||
| ||
.' | ||
-- | ||
| /\ ||
]: | ||. ||
| || | ||-.
.. | || | ||'[|,
.' | || | ,\| |||
| | .| ,'|| |||
,/ | /|| f. .' || |||.
`- | ,'||| |`\ ,' |\| ||| f.
| / ||| v.:v`'__/||| ||| | ._
:| ^---------^---^----^---^----^------'---
"'''''\''''''/'''''\''''''/''''')
) : ,. < .
//_:o:
10.8 Inlatex, Ltx
~~~~~~~~~~~~~~~~~
deplate contains primitive support for including LaTeX as graphics
in non-latex documents. This requires latex, dvips, and ghostscript
to be installed.
Synonyms
Ltx
Options:
id
the basis for the filenames (RECOMMENDED, default: deplateLtxAuto%02d);
if you don't provide an id, deplate uses an automatically generated
one. Anyway, if you make changes to the document, it's possible
that the generated graphics get messed up
sfx
the suffix/device for the graphic file (default: jpeg)
rx
the resolution of the graphic file (default: 140)
type
"fig" (the default) or "table"
All the options if #IMG 11.5 apply, too.
By default the following packages are loaded:
* amsmath
* amsfonts
* amssymb
* mathabx
If the LaTeX formatter was chosen anyway, the source is inserted literally
in the output document.
See the ltx macro 12.5 for an alternative for inserting smaller pieces
of LaTeX-code.
The id is the basis for the filenames being used during conversion.
The following files are generated:
* by deplate: FILE.tex
* by latex: FILE.dvi + auxiliary files
* by dvips: FILE.ps
* by ps2ppm: FILE.%02d.SFX
+ this depends on the sfx option
Lines that match /^\\(usepackage|input)(\[.*\])?\{.+\}$/ are put in
the prematter of the latex file, the rest is put in the body.
Lines ending with %%% are moved to the prematter too.
Example 10.12: Inline LaTeX
#Set: InlatexExampleClip <}[dr]|-{(x,y)} \\
& X \times_Z Y \ar[d]^q \ar[r]_p
& X \ar[d]_f \\
& Y \ar[r]^g & Z }
}
-----
#CAP: An example from the xypic-user guide
yields:
This is a test ([InlatexExample.01.jpeg]) of a clipped Inlatex region
as an inline graphic.
Figure 10.3: An example from the xypic-user guide
||
`<' `''---..__
\ ' `--..__ ,x.
\ `--.._
\ | | ,/| `-..
\ ' ``/ ``-._
\ `-._
\ '`- `^,
\ ' `' ., \`' ___________ -v-
`. - - - _ ' - .. . Y.
// \ | | |
`. | |
\ | . / |
`. | ' / |
`. | \
-^. | ,. /
, '' <')
/ ''''''''''`''''`'' /L'
10.9 Native
~~~~~~~~~~~
Example 10.13: "Native" text
#Native fmt=html <<native> html
EON
#Native fmt=latex < As I said earlier ...
10.11 Set, Get
~~~~~~~~~~~~~~
There are two ways of storing text for later use: clips and variables.
Clips should be used for moving around parsed text within the document.
Variables should be used for passing text to macros, commands etc.
The Set region and the SET command can be used to store clips. They
differ in that the region results in an array of (block) elements and
the command in a sequence of text particles/inline elements. This is
important as there are also two corresponding ways to insert clips
later on. The GET command, which is supposed to insert a block element,
and the get macro, which works on the inline/text particle level.
+---------+--------+---------+-------+
| Level | Region | Command | Macro |
+---------+--------+---------+-------+
| Element | Set | GET | |
| Text | | SET | get |
+---------+--------+---------+-------+
Example 10.15: Clip
#Set: clip < F) |
+--+----+--------+---------+---------+---------+
+--+----+--------+---------+---------+---------+
Table 10.3: Summary of the tli data set
+--------------------------------------------------------------+
| grade sex disadvg ethnicty tlimth |
| Min. :3.00 F:51 NO :65 BLACK :23 Min. :17.0 |
| 1st Qu.:4.00 M:49 YES:35 HISPANIC:20 1st Qu.:69.0 |
| Median :6.00 OTHER : 2 Median :80.0 |
| Mean :5.56 WHITE :55 Mean :76.4 |
| 3rd Qu.:7.00 3rd Qu.:87.0 |
| Max. :8.00 Max. :93.0 |
+--------------------------------------------------------------+
Table 10.4: Summary of the tli data set (guessing cell borders)
+--------------+------+---------+-------------+--------------+
| grade | sex | disadvg | ethnicty | tlimth |
| Min. :3.00 | F:51 | NO :65 | BLACK :23 | Min. :17.0 |
| 1st Qu.:4.00 | M:49 | YES:35 | HISPANIC:20 | 1st Qu.:69.0 |
| Median :6.00 | | | OTHER : 2 | Median :80.0 |
| Mean :5.56 | | | WHITE :55 | Mean :76.4 |
| 3rd Qu.:7.00 | | | | 3rd Qu.:87.0 |
| Max. :8.00 | | | | Max. :93.0 |
+--------------+------+---------+-------------+--------------+
The same inserted verbatim:
grade sex disadvg ethnicty tlimth
Min. :3.00 F:51 NO :65 BLACK :23 Min. :17.0
1st Qu.:4.00 M:49 YES:35 HISPANIC:20 1st Qu.:69.0
Median :6.00 OTHER : 2 Median :80.0
Mean :5.56 WHITE :55 Mean :76.4
3rd Qu.:7.00 3rd Qu.:87.0
Max. :8.00 Max. :93.0
10.13 Region
~~~~~~~~~~~~
This is a generic region that can be used, e.g., to attach a style
to some blocks. For HTML output, this would wrap the blocks in a div
and define a class attribute.
10.14 Ruby
~~~~~~~~~~
If a ruby region returns an array, its elements are treated as lines
that are joined with "\n".
Options:
plain!
reformat ruby's output as a plain text paragraph (default)
verb!
put ruby's output in a verbatim region
image=FILENAME
the result is a FILENAME to be included
native!
if neither the verb! nor the plain! option are given, consider
the output to be already formatted.
context=ruby|deplate|self
sets the context and the method that are used to evaluate the
code
ruby
use eval
deplate
use the current instance of Deplate::Core
self
use the invoking instance
The ruby code is currently simply evaluated in the context of the Deplate::Core.eval_ruby
method. Inline ruby code can thus access a variable "caller" that refers
to the instance, which invoked this evaluation. In future releases,
the evaluation of ruby code will take place in a secured thread.
Example 10.17: Inline ruby
#Ruby context=deplate <<---
def a(x)
return x*2
end
"Evaluated for #{@formatter.formatter_name}:
Ruby output: #{a(3)}"
---
yields:
Evaluated for plain: Ruby output: 6
10.15 Swallow, Skip
~~~~~~~~~~~~~~~~~~~
Swallow/Skip (= don't display) the text in this region. Process it
nevertheless for possible side-effect -- i.e., variables being set
etc.
10.16 Table
~~~~~~~~~~~
This region takes some kind of text and transforms it into a table.
Currently, only character/string separated tables are supported
Options:
sep
the cell separator regexp (default: "\t")
Example 10.18: Create a table from tab-separated input
#Table sep=\\. caption=An example of an char separated table <<---
Foo.Bar
1.2
---
yields:
Table 10.5: An example of an char separated table
+-----+-----+
| Foo | Bar |
| 1 | 2 |
+-----+-----+
10.17 Verbatim
~~~~~~~~~~~~~~
The verbatim region inserts text as seen on the screen. Arguments:
wrap=N
The wrap margin
Example 10.19: Verbatim
#Verbatim wrap=10 <<---
Long long long long long long long line
---
yields:
Long long long
long long long
long line
10.18 Write
~~~~~~~~~~~
You have to set the "w" or "W" allow flag(see 4) in order to enable
this region.
Write or append (append! option) an expanded template to a file.
If file is "-", the body will be printed on STDOUT.
Example 10.20: Write something to a file
#Write file=test.txt <<---
Foo {arg: myvar} bar.
---
11 Commands
===========
deplate scans a text for line-elements and parses lines for text-particles.
Commands are situated at the line-element-level, macros (see below)
on the text-particle-level.
#COMMAND [OPTIONS]: ARGS
NOTE: It doesn't all work yet. It's a matter of trial and error to
find out if deplate already supports a specific command. Most of this
is untested and will fail or not work at all.
OPTIONS have the form:
* OPTION!
+ set option to true
* OPTION=VALUE
* the characters "!" and "=" have to be escaped with a backslash
Commands are applied only if the "fmt" and "if" options/conditions
are met -- see 14.6.
11.1 Getting or setting data about the document
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#AUTHOR: TEXT
define the document's author
+ Synonym: #AU
+ Each #AUTHOR command should take only one author
+ Or separate authors like this:
- AUTHOR1; AUTHOR2 ...
- AUTHOR1 and AUTHOR2 ...
- AUTHOR1 & AUTHOR2 ...
- AUTHOR1/AUTHOR2 ...
+ An author's name can have the form
- FIRSTNAMES SURNAME
- SURNAMES, FIRSTNAMES
+ Alternatively, you can define the name as #AUTHOR firstname=FIRSTNAME
surname=SURNAME note=AUTHORNOTE
- If you attach a note this way, you have to call #AUTHORNOTE
nevertheless in order to update the "authornote" clip
#AUTHORNOTE: TEXT
define an author note
+ Synonym: #AN
+ The note should follow immediately the #AUTHOR command it is
referring to
#CAPTION [above!|below!]: TEXT
add a caption to the previous element
+ Synonym: #CAP
+ refers to the previous element
+ can be attached to: Table, Figure, Heading
#DATE: [TEXT|now|today|none]
Define the document's creation date.
+ Use none if you don't want to include a time stamp in the
document's meta data.
+ now is the default value.
#DEFCOUNTER id=NAME
Define a new counter. Known arguments:
parent
The parent list/and counter
- Has the format: NAME.LEVEL
- If no level is provided only the top numbering is used.
- If no parent is provided, the counter is "global".
#DEFLIST id=NAME
Define a new list and an associated counter. The lists can be
printed using the #LIST command (possibly depending on the formatter).
The standard lists, which should not be redefined, are:
toc
Table of Contents
lot
List of Tables
lof
List of Figures
Custom lists may have the following attributes, which default to
the list name:
counter
The counter name
entity
The name of the entities that are registered in the list
prefix
The prefix used for labels
parent
See #DEFCOUNTER.
#GET: ID or GET id=NAME
Insert a clip at block/element level -- see also 10.11.
#KEYWORDS: WORDS
Set the document's keywords. This really is the same as #VAR id=keywords:
WORDS. Keywords should be separated by [;,] (preferably ";").
#LANG: language
Change the document's language. The language argument is the language
identifier of the corresponding module, i.e., de for German, ru
for Russian, zh-cn for Chinese and Chinese with automatic whitespace
...
+ Unless you load the language module from within the document
or load more than one language module, there is no need to explicitely
set the document's language.
#OPT: KEY=VALUE
Attach some metainformation to the previous element (see 14.4).
+ Synonyms: #PROP, #PP
#PUSH: KEY=VALUE ...
Basically the same as #VAR add=,: KEY=VALUE.
#REGISTER list=NAME: CAPTION
Register the previous element in list NAME, using an (optional)
caption.
#SET id=NAME: TEXT
define a clip -- see also 10.11
#TITLE: TEXT
define the document's title; the same as #VAR: title=TEXT
+ Synonym: #TI
#VAL: NAME
retrieve an argument (used in DefRegion[71])
+ The XVAL command is a variant of this and can be used to insert
preformatted text.
+ See 12.1 for additional arguments.
#VAR: KEY=VALUE ...
define a document option (see 14.1)
+ Synonym: #DOC (for document variable/option)
+ You can also write: #VAR id=KEY: VALUE which is basically
the same as the above form but you don't have to escape colons
in the value string with a backslash.
11.2 Flow control, document management
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#BEGIN: ID and END: ID
when reading from stdin (and when using the command line option
--loop), you can use these two pseudo commands to fragment the
input; if the first line matches #BEGIN: ID, the input will end
at the line #END: ID
+ If you define the variable stdoutSeparator, its content will
be added to each output document sent to stdout.
#IF: TEST, ELSEIF: TEST, ELSE, ENDIF
include the following lines only if TEST is okay
+ Operators: ==, !=, =~, !=~
+ The fmt variable is matched against the current formatter's
name
+ A test is one of (VAR refers to a document option):
- fmt==FORMAT
- fmt!=FORMAT
- fmt=~FORMAT
- fmt!=~FORMAT
- VAR, VAR! (i.e., VAR is set and non-null)
- VAR==VALUE
- VAR!=VALUE
- VAR=~VALUE
- VAR!=~VALUE
+ If ":" is set by the --allow command line option, you can
access internal options by prepending the name with a colon (":").
See 5.4 for possible option names.
#INCLUDE: FILENAME
textually include a file
+ Synonym: #INC
+ FILENAME is a relative file name
+ The file is searched for in:
1. ./deplate.rc/FORMATTER/
2. ./deplate.rc/
3. ./
4. ~/.deplate/lib/FORMATTER/
5. ~/.deplate/lib/
6. ~/.deplate/
7. DATADIR/deplate/lib/FORMATTER/
8. DATADIR/deplate/lib/
9. RUBYLIB/deplate/lib/FORMATTER/
10. RUBYLIB/deplate/lib/
+ Arguments:
file=FILENAME
Alternatively you can use the file argument. If an explicit
file argument and an anonymous argument are given, the
explicit one overrides the anonymous one.
var=VARNAME
You can also "include" the contents of a variable.
inputFormat=INPUTFILTER (experimental)
Set the input filter (see 6) for the included file.
$embeddedTextRx=REGEXP
Transfor the included text using this regular expression.
This could be useful when including source files. embeddedVerbatim
can be used to define what type of region should be used
for formatting other text.
$embeddedVerbatim=REGIONNAME
When using embeddedTextRx, use this region for formatting
non-embedded text (e.g., Code)
$codeSyntax=SYNTAX
Temporarily set the codeSyntax variable when using embeddedVerbatim
- any other argument prepended with $ will be used to temporarily
set the variable of the same name.
+ Variables:
- You can also set variables in includeVars (a hash) that
will be passed on to the command as if provided on the command
line.
#MODULE: NAME
require a module
+ Synonym: #MOD
#WITH file=FILE: REGION HEADER
create a region with input from file
11.3 Bibliography
~~~~~~~~~~~~~~~~~
#BIB: FILENAME
a filename of a BibTeX database
#MAKEBIB: [BIBSTYLE]
insert a formatted biblography
+ If the BIBSTYLE argument is missing, the bibStyle variable
will be used. If the bibStyle variable doesn't exist, it will
be set to the BIBSTYLE argument.
+ In html mode, MAKEBIB works directly on the bibtex file. The
main reason for this that it is easier to parse the bibtex file
than to deal with the variety of bibtex-related styles and packages.
Due to my simple-minded approach to parsing, MAKEBIB sometimes
failes on some records and it doesn't cope well with entries
other than books.
- The html formatter stubbornly uses some kind of APA-based
style.
11.4 Abbreviations, index
~~~~~~~~~~~~~~~~~~~~~~~~~
#ABBREV [native!|ins!|plain!] DEFINITION: FULL TEXT
replace an abbreviation (defined as a word, a backtick symbol,
or a regular expession) with the full title
+ DEFINITION can be one of
- symbol=SYMBOL ... a symbol will preceded by a backtick,
i.e. if SYMBOL is Sigma, then the abbreviation matches `Sigma
- word=WORD ... the WORD is surrounded by matches for word
boundaries
- rx=REGEXP
+ if the option plain! is given, the full text won't be parsed
+ if the options native! or ins! is given, the full text will
be inserted as is
#IDX: INDEX_ENTRY|SPELLINGS...; OTHER_ENTRY
add an index entry; use "|" to mark alternative spellings when
using autoindexing; separate different entries with a semi-colon
+ If autoindexing isn't switched off, you have to use this command
only once to indicate that a certain word should be added to
the index; all occurences downwards will be indexed automatically
+ You can mark a word for autoindexing without inserting an
index at the current position with the #AUTOIDX command
AUTOIDX: INDEX_ENTRY|SPELLINGS...; OTHER_ENTRY
this can help avoiding certain problems with docbook output
+ Use the following commands to selectively disable the automatically
generation of an index
NOIDX: INDEX_ENTRY|SPELLINGS...; OTHER_ENTRY
remove the last matching (auto)index entries
DONTIDX: INDEX_ENTRY|SPELLINGS...; OTHER_ENTRY
avoid the next automatically generated index to be recorded
11.5 Dynamic text, elements
~~~~~~~~~~~~~~~~~~~~~~~~~~~
#IMG [here!|top!|bottom!] [noGuess!] [bw=N|bh=N|w=N|h=N]: FILENAME
insert an image from a file
+ Synonyms: #IMAGE, #FIG, #FIGURE
+ Other options (depends on the formatter):
w=LENGTH, width=LENGTH
Image width
h=LENGTH, height=LENGTH
Image height
noGuess!
Usually deplate ignores any suffix and test the filename
against a list of suffixes that supposedly work for the
gived output format. Use this option to keep deplate from
trying to be smart.
+ for LaTeX output there are some extra arguments:
rotate=ANGLE
Rotate the image
bw, bh
define the bounding box in latex
#LIST page! min=N max=N top=PREFIX sub!: [contents|toc|minitoc|tables|figures|index]
insert a table of [contents|tables|figures] or the index; the
output depends on the formatter
+ The LIST: index command should be placed in the last of the
included files so that all indexes are defined.
+ toc is a synonym for contents
+ minitoc display the top headings only and uses the shortcaption
argument if provided (in html output only)
page!
Display the table/list on a new page
min=N
List only elements with a level greater or equal N (HTML only)
max=N
List only elements with a level less or equal N (HTML only)
sub!
List only elements under the current heading (HTML only)
top=PREFIX
List only elements the numbering of which begins with PREFIX
(HTML only)
levels=MIN..MAX, MIN.., ..MAX
Same as min and max
#MAKETITLE [page!]
insert a title or titlepage
#PAGE
start a new page
#TABLE: FILE
read a table from FILE -- takes the same options as the table region
(see 10.16)
The commands TITLE, AUTHOR, AUTHORNOTE, and DATE define clips of the
same name in lower cases (see the get macro for an example 12.1).
Example 11.1: Commands
#VAR: myvar=foo
#PUSH: myvar=bar
After: myvar={arg: myvar}
#IMG center! bw=110 bh=162: linked
#OPT fmt=latex: w=4cm
#CAP: A nice drawing
#SET id=foo: bar
Test SET: {get: foo}.
#IF: fmt==latex
This is in latex.
#ELSEIF: fmt=~^html
This is in html.
#ELSE
This is interesting.
#ENDIF
The file "calculations.txt" contains: 1 + 1. Let's see what R has to say
about this:
#WITH file=calculations.txt: R id=r_calculations: verb
#ABBREV sym=Sigma fmt=html ins!: Σ
#ABBREV sym=Sigma fmt=dbk if=noSgml ins!: Σ
#ABBREV sym=Sigma fmt=dbk if=sgml ins!: Σ
#ABBREV sym=Sigma fmt=latex ins!: $\Sigma$
The greek letter `Sigma is called sigma.
#DEFLIST list=books title=Some Books parent=toc.1
#LIST: books
#DefElement id=books: ^BOOK:\s+(.*) <<--
{counter: books} {arg escapebackslash=2: 1}
\#OPT: style=book
\#REGISTER list=books name={arg escapebackslash=4 escape="!=:": 1}
--
#Native fmt=html type=pre slot=css <<--
--
BOOK: Max Frisch: Stiller
BOOK: William Shakespeare: Much Ado About Nothing
BOOK: Don \DeLillo: The Body Artist
yields:
After: myvar=foo,bar
Figure 11.1: A nice drawing
__ _
.. -` ,Y_\
_' ...,..'> . _
| `,,":=,['` ' `,
| ''YY`-- ". .\
'`-\ . ` -.'/ =:
_-''`-. `.;.__ ,:='
' ' |\ \ :/-
b L '\.\ /| ||
` ,.\-.`\ , :'][ '\._
L [| `.[.[-,'.. .-,., = ___
|'] `.--L., /','`--.....- \
',| | b . /_[-' , .,..L' |,
L | ``.|'| \ ]"/---^"-! _./
\ | '`\]\-v,:.' \. |
,'],`+/'\ `] |]-> |] | -
//`,. | `-. . | ')' `||| '
['`L_v..u:;'_.: .|_,'/ | | ,=
,'\.-- ]. _, \`]L -|| |>Y ,
-._' \::``.u' .`|P` |'--. ||[\ '
`,, - .o.|/^-`_`--_ _-, |`
`|' -._ `--- ,- `-L,':.'--- [
--]] _"=[ _ |, \ _/:`. .-`=.'-.
. | '` v_-,__`,|',-,/-'-'"|:.` i
' ,'-,V:.L'\-_'_'' .; J 'P -'
f.. `\' `,' -.' \=d
... /-,'=L. _ __U`/. _
: |`,.^' | | -P'\ ..
,]' - ' ' /o ,' ] | ,' ' -
` // ,[/' '/.'.--: `=
|/ / o",. _`Y ' |
\-, / _/'- |/] | ` /// _
`,`.,',' - _'_/ /v
\- :`\ :b' _ `=.=
'' `-.:.`. . ''''
' '`.--
Test SET: bar.
This is interesting.
The file "calculations.txt" contains: 1 + 1. Let's see what R has to
say about this:
[1] 2
The greek letter `Sigma is called sigma.
Some Books
==========
11.1 Max Frisch
11.2 William Shakespeare
11.3 Don DeLillo
11.1 Max Frisch: Stiller
11.2 William Shakespeare: Much Ado About Nothing
11.3 Don DeLillo: The Body Artist
12 Macros
=========
Curly braces should be escaped with a backslash (i.e., \{ and \}),
as they usually mark macros:
{COMMAND [OPTIONS]: ARGS...}
NOTE: Macros cannot cross paragraph boundaries, i.e., they must not
contain empty lines. Using newlines in a macro argument is useless,
as the macro text will be collapsed to one single line.
NOTE: These aren't macros in the sense of read-time expansions/replacements.
They are called macros here because the (original) term commands is
now used for #CMD type of commands only.
NOTE: If the macro name is unknown, a clip or a variable will be used
instead. The order is: macros > clips > variables.
NOTE: Some macros parse their arguments, which then can contain other
macros -- e.g., list and item. "Parsing" is done with a simple nested
regular expression. This appears to work quite well but could yield
unintended results in some situations. The maximum of nested macros
currently is 5 (which should really enough due to the primitivity of
the macro language). If you want more (e.g., 10), add this to your
config file:
Deplate::Particle::Macro.build_rx(10)
Example 12.1: Macro written in Ruby
#Ruby context=ruby <<--
class Deplate::Macro::Test < Deplate::Macro
register_as 'test'
def setup(text)
@elt = @deplate.parse(@container, '<' + text + '>')
end
end
--
Bla {test: [1
{test: 2
{test: 3
{test: 4}
}
}
inner bla
{test: a
{test: b
{test: c
{test: d}
}
}
}]
}
Bla
yields:
Bla <[1 <2 <3 <4>>> inner bla >>>]> Bla
NOTE: You could run into problems if an macro argument contains unbalanced
curly braces. It should work by preceding them with a backslash, but
...
12.1 Getting or setting data about the document
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Attributes: {attrib: KEY=VALUE ...}
Change the previous particle's (inline element) attributes; this
command does on a text level what #OPT does for block elements
Clips, variables: {get [default=TEXT]: ID}, {get id=ID [default=TEXT]}
see also 10.11; access "clips", e.g. the document's author: {get:
author}
Counters: {counter [depth=N] [delta=N]: NAME}
access a counter; see 11.5 for an example
Element properties: {eprop ...}
Set the container element's properties (as if using the #PROP
command).
Document variables: {var: ID}
access document variable. See also the comments below on the arg
macro. The difference between var and arg is that the var macro
returns a value in a format can read.
Element options: {opt: ID}
access element (paragraph, table etc.) options
Retrieving variables : {arg: NAME}
Retrieve an argument (used in DefRegion[71] or similar)
+ Variables can also be accessed as in {varname} which will
expand to {arg: varname}. {varname!} will expand to {var: varname}.
Thus, {varname capitalize!} is equivalent to {arg capitalize!:
varname}.
+ The xarg macro is a variant of this that can be used to retrieve
preformatted text.
+ Synonyms: val, xval
+ If the . allow flag is set, the NAME may have the form NAME[METHOD]
to send methods to an object.
+ Options:
join=SEPARATOR
Join the values of strings and hashes
values! keys!
Return a hashes values of strings
sub=/pattern/replacement/
Replace a pattern (the '/' is an arbitrary separator in
this example; this can be any character)
tr=/pattern/replacement/
Character translation
upcase!
Put the text in upper case letters
downcase
Put the text in lower case letters
capitalize!
Capitalize the text
escape="CHARACTERS"
Escape some characters with a backslash
escapebackslash!
Escape backslashes with a backslash
+ The execution order of the text transformations arguments is
fixed: sub > tr > upcase > downcase > capitalize
Localized messages: {msg: TEXT}
Insert a localized message (can be used in templates).
12.2 References, labels, index
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Anchors: {anchor: NAME}
Inserts an anchor at this very position; this should only used
in inline position within a list item, a paragraph etc. It should
be also used within lists or similar compound elements.
+ Synonyms: label, lab
Comments: {cmt: TEXT}
insert an empty string
Index: {idx: NAME}
Inserts an index at this very position; this should only used
in inline position within a list item, a paragraph etc. It should
be also used within lists or similar compound elements.
Reference: {ref [prefix=TEXT] [p!]: ANCHOR}
insert a reference to an anchor
p
Reference to page
prefix
Prepend this text to the reference (default: non-breaking
space)
12.3 Bibliography
~~~~~~~~~~~~~~~~~
Citation: {cite [p=PAGE] [n=NOTE] [np!] [y!]: ID1[;ID2...]}
output depends on the formatter
np
No parentheses
y
Year only
p
The page number
n
A note to be inserted before the citation (but within the
parentheses)
12.4 Textstyles
~~~~~~~~~~~~~~~
Code: {code: CODE} or {'CODE}, or {verb: CODE}
the same as ''CODE''
Emphasized text: {_TEXT} or {em: TEXT} or {emph: TEXT}
emphasized text (the same as __TEXT__)
Plain text: {plain: UNPARSED TEXT} or {\UNPARSED TEXT}
insert the text without intepreting deplate markup
Subscript: {sub: TEXT} or {,TEXT}
Put TEXT in subscript
Superscript: {super: TEXT} or {sup: TEXT} or {^TEXT}
Put TEXT in superscript
Stacked: {stacked:{:SUPER}{:SUB}}} or {%{:SUPER}{:SUB}}
Print SUPER on top of SUB (the HTML formatter uses css inline
tables, which are displayed as expected with Firefox/Mozilla)
Text: {text: TEXT} or {:TEXT}
Parsed TEXT. This macro can also be used to attach a style to
some inline text.
Mark 1st occurrence: {~text} {mark1st: text}
Mark TEXT, when the text is inserted for the first time. If the
variable mark1stStyle is defined, this style will be used. Otherwise,
the string's first occurrence will be printed in upper case letters.
Arguments
text=TEXT
Text used for lookup
alt=STYLE
Mark other occurrences with this style
always!, anyway!
Always mark as 1st occurrence, even if it isn't.
Case: {downcase: TEXT} {upcase: TEXT} {capitalize: TEXT}
Change TEXT's case
12.5 Dynamic text, particles
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Date: {date: [format string|now|time|today|month|year]}
the format string uses ruby's strftime method.
Footnote: {fn: ID} or {fn id=ID: TEXT}
The first form refers to a footnote defined by a Fn or Footnote
region. The second form defines the footnote inline. The output
depends on the formatter. The footnotes generated by the html
formatter are compatible with OpenOffice.
Images: {img [IMG arguments]: FILE}
insert an image; takes the same options as IMG (see 11.5)
Inline LaTeX: {ltx id=ID [other Inlatex options]: LATEX CODE}
Insert small pieces of latex code.
+ See also 10.8.
Pagenumber: {pagenumber [hd!]: [TEXT]}
Returns the current page number. The result depends on the formatter.
TEXT is appended to the pagenumber if the result is non-empty.
HTML
Insert nothing
LaTeX
Insert \thepage if the macro isn't used in a header region
(the optional hd! argument)
LaTeX + koma
Insert \pagemark
Small lists: {list type=[ol|ul|dl]: ITEMS}
A convenience macro for inlining small lists into other elements.
Items can defined with the following two macros: * {item: TEXT}
* {term id=TERM: TEXT}
Native text: {ins: LITERALLY INSERTED TEXT}
e.g., {ins fmt=html: <<}
Mathematical text: {math: LATEX FORMULA}
insert a small mathematical expression in latex syntax
+ Synonyms: $
+ See also 8.2.11 and 10.8.
+ You can set the variable mathPrelude in order to prepend some
LaTeX code to all mathematical formulaes
Newline: {nl}
start a new line
Ruby code: {ruby [context=CONTEXT] [alt=ALTERNATE OUTPUT]: RUBY CODE}
* if the evaluation of ruby code is disabled, the text given in
the
alt option or an empty string will be inserted
* a sequence of ruby commands must be separated by semicolons
+ for the CONTEXT argument please see 10.14
Example 12.2: Macros
Footnotes:
Foo bar{fn: x} foo bar.
#Fn: x <