PageRenderTime 54ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/doc/English/userguide/userguide.t2t

http://txt2tags.googlecode.com/
Unknown | 2382 lines | 1736 code | 646 blank | 0 comment | 0 complexity | 624b7a76d66597c9069fb55d09b7b17e MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0, WTFPL
  1. Txt2tags User Guide
  2. Aurelio, %%mtime(%c)
  3. %!target: html
  4. %!options: --toc --toc-level 2 --css-sugar
  5. % TRANSLATOR:
  6. % - The HTML output is optimized for the htmldoc tool
  7. % - Just comment the following lines when translating
  8. %!options: --css-sugar --no-toc --style userguide.css
  9. %!postproc(html): '<HTML>' '<!-- This document was generated from userguide.t2t -->\n<HTML>'
  10. %!postproc: '<H1>Txt2tags User Guide.*' ''
  11. %!postproc: '<H3>Aurelio, .*' ''
  12. % TRANSLATOR:
  13. % - Don't worry about the PDF cover page
  14. % - Don't worry about PDF at all, translate and check on HTML
  15. % - Don't worry about the images
  16. % TRANSLATOR:
  17. % You can take new screenshots and make new images for the program
  18. % interface and "first conversion" section. Remember to send them
  19. % to the author!
  20. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  21. %%% activate those lines when converting to HTML for PDF generation
  22. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  23. %%% htmldoc does TOC
  24. %pdf%!options(html): --no-toc --no-css-sugar -o userguide-pdf.html
  25. %%% mask the 'nopdf' marks so they will not be removed
  26. %pdf%!preproc(html): ^%nopdf %yespdf
  27. %%% border for all images
  28. %pdf%!postproc: '(<IMG [^>]*BORDER)="0"' '\1="1"'
  29. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  30. % easy way to change all image locations once, when changing file location
  31. %!preproc: IMGPATH .
  32. % TRANSLATOR
  33. % - Please translate the following macro contents and leave them alone
  34. % - Remember they are expanded in conversion time, don't remove them
  35. % normalizing common text
  36. %!preproc: CONFAREA Config Area
  37. %!preproc: HEADAREA Header Area
  38. %!preproc: BODYAREA Body Area
  39. %!preproc: MARKPROP **Properties:**
  40. %!preproc: MARKCONT **Contains:**
  41. %!preproc: MARKDESC **Description:**
  42. %!preproc: MARKSYN **Syntax:**
  43. %!preproc: MARKDET **Details:**
  44. %!preproc: NOMARKS Marks are NOT interpreted
  45. %!preproc: NOMACRO Macros are NOT interpreted
  46. %!preproc: URLMARKUP URLWEBSITE/markup.html
  47. %!preproc: URLWEBSITE http://txt2tags.org
  48. %!postproc: URLWEBSITE http://txt2tags.org
  49. % activate the areas disabled on the PDF version
  50. %!preproc(html): ^%nopdf ''
  51. % remove separator lines and strong lines
  52. %!preproc(html): '^ *--------*' ''
  53. %!preproc(html): '^ *========*' ''
  54. % highlight NEW topic on TOC
  55. %%!postproc(html): '(<LI>.*Mastering Macros</A>)$' '\1 <b>[NEW!]</b>'
  56. %%% Little clean up for less large tables
  57. %!postproc: /pessoal/sourceforge.net ''
  58. % 26/Nov/2003: revised by anamimts
  59. % 26/Jun/2004: updated to v2, new embedded CSS
  60. % 17/Jul/2004: revised by anamimts
  61. % 01/Nov/2004: updated to v2.0 and 2.1, new chapters, PDF version
  62. % 31/Aug/2006: little changes to use htmldoc for splitted HTML
  63. % TODO Mastering Options [option-help], [option-css-sugar], ...
  64. ========================================================================
  65. %%nopdf "Hi! I'm the txt2tags User Guide. Here you'll find all available
  66. %%nopdf information about the txt2tags text conversion tool. You can
  67. %%nopdf find my latest version at URLWEBSITE/userguide/. For
  68. %%nopdf more information please visit
  69. %%nopdf [the txt2tags website URLWEBSITE]. Enjoy!"
  70. %%nopdf
  71. %%nopdf [Download PDF version URLWEBSITE/userguide/userguide.pdf]
  72. %nopdf= About =
  73. %nopdf
  74. %nopdfThis is the [txt2tags URLWEBSITE] User Guide, the
  75. %nopdfcomplete manual about the program.
  76. %nopdf
  77. %nopdf- User Guide official address:
  78. %nopdf URLWEBSITE/userguide
  79. %nopdf
  80. %nopdf- User Guide PDF download:
  81. %nopdf URLWEBSITE/userguide/userguide.pdf
  82. %nopdf-
  83. ========================================================================
  84. %%nopdf%**This Guide Contains:**
  85. %%toc
  86. ========================================================================
  87. = Part I - Introducing Txt2tags =[intro]
  88. == The First Questions You May Have ==[1st-questions]
  89. This chapter is a txt2tags overview, that will introduce the program
  90. purpose and features.
  91. ------------------------------------------------------------------------
  92. === What is it? ===
  93. Txt2tags is a text formatting and conversion tool.
  94. : **A text formatting tool**: The txt2tags wiki-like syntax is easy to use and to remember. You can use it for every purpose, like storing your notes and formatting your documents.
  95. : **A conversion tool**: You can use the txt2tags python program to converts your txt2tags documents to several supported [targets #targets]. //(Further reference to the txt2tags python program will simply be labelled "txt2tags".)//
  96. Amongs others, there are:
  97. - popular Wiki markups, such as bbcode, wikipedia pages, markdown, restructuredtext and spip.
  98. - html variations: html transitional, xhtml, html5...
  99. - office documents: RTF, LaTeX documents, Open Document Spreadsheet, SQLite database (imported from tables)
  100. - plain text, including ASCII art variations.
  101. //See the [targets chapter #targets] to discover the full list.//
  102. : **And more**: Beyond those 2 aspects, which deals with defined features and syntax, txt2tags can also manipulate your document with [powerful input and output filters #setting-preproc].
  103. ------------------------------------------------------------------------
  104. === Why should I use it? ===
  105. You'll find txt2tags really useful if you:
  106. - Need to publish documents in different formats
  107. - Need to maintain updated documents in different formats
  108. - Write technical documents or guides
  109. - Don't know how to write a document in a specific format
  110. - Don't have an editor for a specific format
  111. - Want to use a simple text editor to update your documents
  112. And the main motivation is:
  113. - Save time, writing **contents** and forgetting about **formatting**
  114. ------------------------------------------------------------------------
  115. === Why is it a good choice among other tools? ===
  116. Txt2tags has a very straight way of growing, following basic concepts.
  117. These are the highlights:
  118. | //Source File Readable// | Txt2tags marks are very simple, almost natural.
  119. | //Target Document Readable// | The target document is also readable, with indentation and spacing.
  120. | //Consistent Marks// | Txt2tags marks are simple symbols, designed to be unique enough to don't mix up with the document contents.
  121. | //Consistent Rules// | As the marks, the rules that applies to them are tied to each other, there are no "exceptions" or "special cases".
  122. | //Simple Structures// | All the supported formatting are **simple**, with no extra-options or complicated behavior modifiers. A mark is just a mark, with no options at all.
  123. | //Easy to Learn// | With simple marks and readable source, the txt2tags learning curve is user friendly.
  124. | //Nice Examples// | The **sample files** included on the package gives real life examples of documents written for txt2tags.
  125. | //Valuable Tools// | The **syntax files** included on the package help you to write documents with no syntax errors.
  126. | //Three User Interfaces// | There is a user friendly **Graphical interface**, a handy **Web interface** easy to install in intranets and a **Command Line interface** for power-users and scripting.
  127. | //Scripting// | With the full featured command line mode, an experienced user can **automatize** tasks and do **post-editing** on the converted files.
  128. | //Download and Run / Multi-platform// | Txt2tags is a single **Python script**. There is no need to compile it or download extra modules. So it runs nicely on *NIX, Linux, Windows and Macs.
  129. | //Mature// | First released in 2001, txt2tags is now a mature program with years of improvements and bug fixes, extensive documentation, translations and an loyal user base.
  130. ------------------------------------------------------------------------
  131. === Do I have to pay for it? ===
  132. Absolutely NO!
  133. It's free, GPL licensed.
  134. % It's free, GPL, open source, public domain,
  135. % //<put-your-favorite-buzzword-here>//.
  136. %
  137. % You can copy, use, modify, sell, release as yours. Software
  138. % politics/copyright is not one of the author's major concerns.
  139. ------------------------------------------------------------------------
  140. == Supported Formatting Structures ==[structures]
  141. The following is a list of all the structures supported by txt2tags.
  142. - header (document title, author name, date)
  143. - section title (numbered or not)
  144. - paragraphs
  145. - font beautifiers
  146. - bold
  147. - italic
  148. - underline
  149. - strike
  150. - monospaced font (verbatim)
  151. - monospaced inside paragraph
  152. - monospaced line
  153. - monospaced area (multiline)
  154. - quoted area
  155. - link
  156. - URL/Internet links
  157. - e-mail links
  158. - local links
  159. - named links
  160. - lists
  161. - bulleted list
  162. - numbered list
  163. - definition list
  164. - horizontal separator line
  165. - image (with smart alignment)
  166. - table (with or without border, smart alignment, column span)
  167. - macros (with flexible formatting):
  168. - current date
  169. - file modification time
  170. - input and output file name and path
  171. - automatic table of contents
  172. - special mark for raw text (no marks parsed inside)
  173. - special mark for tagged text (no parsing, sent directly to output)
  174. - comments (for self notes, TODO, FIXME)
  175. ------------------------------------------------------------------------
  176. == Supported Targets ==[targets]
  177. === Wiki ===
  178. : **adoc**
  179. AsciiDoc document
  180. : **bbcode**
  181. BBCode document
  182. : **creole**
  183. Creole 1.0 document
  184. : **DOKU**
  185. [DokuWiki http://www.dokuwiki.org/dokuwiki] is a standards
  186. compliant, simple to use Wiki, mainly aimed at creating documentation
  187. of any kind. It is targeted at developer teams, workgroups and small
  188. companies. It has a simple but powerful syntax which makes sure the
  189. data files remain readable outside the Wiki and eases the creation of
  190. structured texts. All data is stored in plain text files - no
  191. database is required.
  192. : **Foswiki / TWiki**
  193. [Foswiki http://foswiki.org/] or [TWiki http://twiki.org], is a flexible, powerful,
  194. and easy to use enterprise wiki and collaboration platform.
  195. The structured wiki is typically used to run a project development
  196. space, a document management system, a knowledge base, or any other
  197. groupware tool, on an intranet or on the internet.
  198. : **GWIKI**
  199. Now you can easily paste your project's current documentation into the
  200. [Google Code http://code.google.com/] Wiki.
  201. : **md**
  202. Markdown document
  203. : **MOIN**
  204. You don't know what [MoinMoin http://moinmo.in/] is?
  205. It is a [WikiWiki http://www.c2.com/cgi/wiki]!
  206. Moin syntax is kinda boring when you need to keep
  207. ``{{{'''''adding braces and quotes'''''}}}``, so txt2tags comes with the
  208. simplified marks and unified solution: one source, multi targets.
  209. : **[PMWIKI http://en.wikipedia.org/wiki/PmWiki]**
  210. [PmWiki http://www.pmwiki.org/] is a light and free wiki software written in PHP, and using no SQL database.
  211. : **red**
  212. Redmine Wiki page
  213. : **rst**
  214. ReStructuredText document
  215. : **spip**
  216. SPIP article
  217. : **txt2t**
  218. Txt2tags document
  219. : **WIKI**
  220. You've heard about the [Wikipedia http://wikipedia.org], right? So you
  221. don't need to learn yet-another markup syntax. Just stick with txt2tags
  222. and let it convert your text to the Wikipedia format, called
  223. [MediaWiki http://en.wikipedia.org/wiki/MediaWiki].
  224. === HTML ===
  225. : **aapw**
  226. ASCII Art Presentation Web
  227. : **aasw**
  228. ASCII Art Spreadsheet Web
  229. : **aatw**
  230. ASCII Art Text Web
  231. : **[HTML http://en.wikipedia.org/wiki/HTML]**
  232. You maybe know what HTML is. (hint: Internet)
  233. Txt2tags generates clean HTML documents, that look pretty and have
  234. its source readable. It DOES NOT use javascript, frames or other
  235. futile formatting techniques, that aren't required for simple, techie
  236. documents. But a separate CSS file can be used if wanted. Txt2tags
  237. generates "//HTML 4.0 Transitional//" code.
  238. Txt2tags HTML generated code is 100% approved by the [w3c validator http://validator.w3.org/].
  239. : **html5**
  240. HTML5 page
  241. : **htmls**
  242. HTML Spreadsheet
  243. : **wp**
  244. WordPress post
  245. : **[XHTML http://en.wikipedia.org/wiki/XHTML]**
  246. It is the new generation of HTML, with more strict rules.
  247. This makes the code easier to parse and
  248. understand. For the general purpose, consider it HTML. Txt2tags
  249. generates "//XHTML 1.0 Transitional//" code.
  250. Txt2tags XHTML generated code is 100% approved by the [w3c validator http://validator.w3.org/].
  251. : **xhtmls**
  252. XHTML Strict page
  253. === Office ===
  254. : **csv**
  255. CSV spreadsheet
  256. : **db**
  257. SQLite database
  258. : **dbk**
  259. DocBook document
  260. : **LOUT**
  261. Very similar to LaTeX in power, but with an easier syntax using "@"
  262. instead "\" and avoiding the need of braces in common situations. Its
  263. approach of everything-is-an-object makes the tagging much saner.
  264. Txt2tags generates ready-to-use Lout files, which can be converted do
  265. PS or PDF files using the "lout" command.
  266. : **MGP**
  267. [MagicPoint http://en.wikipedia.org/wiki/MagicPoint] is a very handy presentation tool
  268. (hint: Microsoft PowerPoint), that uses a tagged language to define all
  269. the screens. So you can do complex presentations in vi/emacs/notepad.
  270. Txt2tags generates a ready-to-use .mgp file, defining all the
  271. necessary headers for fonts and appearance definitions, as long as
  272. international characters support.
  273. Txt2tags creates "diet" .mgp files: they use the Type1 fonts, so you do not
  274. need to carry TrueType fonts files with your presentation. Also, the color
  275. definitions are simple, so even on a poor color palette system (such as
  276. ``startx -- -bpp 8``), the presentation will look pretty!
  277. The key is: convert and use. No quick fixes or requirements needed.
  278. : **ods**
  279. Open Document Spreadsheet
  280. : **PM6**
  281. Adobe PageMaker 6.0 has its own tagged
  282. language. Styles, color table, beautifiers, and most of all the
  283. PageMaker mouse-clicking features are also available on its tagged language.
  284. You just need to access the "Import tagged text" menu item. Just for
  285. the records, it's an <HTML "like"> tag format.
  286. Txt2tags generates all the tags and already defines a extensive and
  287. working header, setting paragraph styles and formatting. This is the
  288. hard part.
  289. **Author's note:**
  290. My entire portuguese [regular expression's book http://guia-er.sf.net]
  291. was written in VI, then converted to PageMaker with txt2tags and went to
  292. the publisher. It works :)
  293. : **rtf**
  294. RTF document
  295. : **[SGML http://en.wikipedia.org/wiki/SGML]**
  296. It is a common document format which has powerful conversion applications
  297. ([linuxdoc-tools http://packages.debian.org/linuxdoc-tools]). From a
  298. single SGML file you can generate HTML, PDF, PostScript, Info, LaTeX, LyX, RTF
  299. and XML documents. The tools also does automatic TOC and break
  300. sections into subpages.
  301. Txt2tags generates SGML files in the LinuxDoc system type, ready to
  302. be converted with linuxdoc-tools without any extra catalog files or any
  303. SGML annoying requirements.
  304. : **[LATEX http://en.wikipedia.org/wiki/LaTeX]**
  305. The preferred academic document format, it is more powerful than you
  306. ever wondered. Full books, complicated formulas and any complex text
  307. can be written in LaTeX. But prepare to loose your hair when you try
  308. to write the tags by hand...
  309. Txt2tags generates ready-to-use LaTeX files, doing all the complex
  310. escaping tricks and exceptions. The writer just need to worry about
  311. the text.
  312. : **texs**
  313. LaTeX Spreadsheet
  314. === Text ===
  315. : **aap**
  316. ASCII Art Presentation
  317. : **aas**
  318. ASCII Art Spreadsheet
  319. : **aat**
  320. ASCII Art Text
  321. : **MAN**
  322. UNIX man pages resist over the years. Document formats come and go,
  323. and there they are, unbeatable.
  324. There are other tools to generate man documents, but txt2tags has
  325. one advantage: one source, multi targets. So the same man page
  326. contents can be converted to an HTML page, Wiki document and plain text.
  327. : **TXT**
  328. TXT is text. Simple, pure, beautiful.
  329. Although txt2tags marks are very intuitive and discrete, you can remove
  330. them by converting the file to pure TXT.
  331. The titles are underlined, and the text is basically left as is on the
  332. source.
  333. Tip: Use the ``--targets`` command line option to get a complete list of
  334. all the available targets.
  335. ------------------------------------------------------------------------
  336. == Status of Supported Structures by Target ==[struct-support]
  337. || Structure | html | xhtml | sgml | dbk | tex | lout | man | mgp | creole | wiki | gwiki | pmw | doku | moin | pm6 | adoc | art | txt | tml |
  338. | headers | Y | Y | Y | Y | Y | Y | Y | Y | - | - | - | Y | - | - | N | - | Y | Y | Y |
  339. | section title | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |
  340. | paragraphs | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |
  341. | bold | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | - | - | Y |
  342. | italic | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | - | - | Y |
  343. | underline | Y | Y | - | Y | Y | Y | - | Y | - | Y | - | Y | Y | Y | Y | N | - | - | Y |
  344. | strike | Y | Y | N | N | Y | - | - | - | - | Y | Y | Y | Y | Y | N | N | - | - | Y |
  345. | monospaced font | Y | Y | Y | Y | Y | Y | - | Y | - | Y | Y | Y | Y | Y | Y | Y | - | - | Y |
  346. | verbatim line | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | - | - | - |
  347. | verbatim area | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | - | - | Y |
  348. | quoted area | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | N | Y | Y | - |
  349. | internet links | Y | Y | Y | Y | - | - | - | - | Y | Y | Y | Y | Y | Y | - | Y | - | - | Y |
  350. | e-mail links | Y | Y | Y | Y | - | - | - | - | Y | Y | Y | Y | Y | Y | - | Y | - | - | Y |
  351. | local links | Y | Y | Y | Y | N | N | - | - | N | N | N | Y | Y | Y | - | N | - | - | Y |
  352. | named links | Y | Y | Y | Y | - | - | - | - | Y | Y | Y | Y | Y | Y | - | Y | - | - | Y |
  353. | bulleted list | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |
  354. | numbered list | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |
  355. | definition list | Y | Y | Y | Y | Y | Y | Y | N | Y | Y | - | Y | - | Y | N | N | Y | Y | Y |
  356. | horizontal line | Y | Y | - | N | Y | Y | - | Y | Y | Y | - | Y | Y | Y | N | N | Y | Y | Y |
  357. | image | Y | Y | Y | Y | Y | Y | - | Y | Y | Y | Y | Y | Y | Y | N | Y | - | - | Y |
  358. | table | Y | Y | Y | N | Y | N | Y | N | Y | Y | Y | Y | Y | Y | N | N | N | N | Y |
  359. || Extras | html | xhtml | sgml | dbk | tex | lout | man | mgp | creole | wiki | gwiki | pmw | doku | moin | pm6 | adoc | art | txt | Y |
  360. | image align | Y | Y | N | N | N | Y | - | Y | N | Y | - | N | Y | N | N | N | - | - | Y |
  361. | table cell align | Y | Y | Y | N | Y | N | Y | N | N | N | - | N | - | Y | N | N | N | N | Y |
  362. | table column span | Y | Y | N | N | Y | N | N | N | N | N | - | N | - | N | N | N | N | N | Y |
  363. || | Legend
  364. | **Y** | //Supported//
  365. | **N** | //Not supported (may be in future releases)//
  366. | **-** | //Not supported (can't be done on this target)//
  367. ------------------------------------------------------------------------
  368. == The Three User Interfaces: Gui, Web and Command Line ==[interfaces]
  369. As different users have different needs and environments, txt2tags is
  370. very flexible on how it runs.
  371. There are three User Interfaces for the program, each one with its own
  372. purpose and features.
  373. - **Gui**: Written in Tk, brings the windowing and clicking to txt2tags.
  374. - **Web**: Written in PHP, allows users to run txt2tags on the browser,
  375. requiring no installation on the client side.
  376. - **Command Line**: Written in Python, it's the program core. All
  377. features are available as command line options.
  378. ------------------------------------------------------------------------
  379. === Graphical Interface ===[gui]
  380. Since version 1.0, there is a nice Graphical Interface, that works on
  381. Linux, Windows, Mac and others. Just call txt2tags with the ``--gui``
  382. option to open it.
  383. % If some resources are missing, the program will tell.
  384. %
  385. % **Note:** The Tkinter module is needed. As it comes with the
  386. % standard Python distribution, you may already have it.
  387. The interface is pretty simple and intuitive:
  388. [IMGPATH/gui.png]
  389. + You locate the source .t2t file on the disk and its options are
  390. loaded.
  391. + If the target is still empty, you must choose one.
  392. + Then there are some options you may choose, but none of them are
  393. required.
  394. + Finally, press the "Convert!" button.
  395. A nice option is the "//Dump to screen//", so you can check
  396. the resulting code on a separate window, no file is saved at all. When
  397. the code is OK, you uncheck it and the file will be saved.
  398. The default interface colors can be changed on the [configuration file #rc],
  399. using the ``%!guicolors`` settings. For example:
  400. ```
  401. % set my own colors for the graphical interface (bg1, fg1, bg2, fg2)
  402. %!guicolors: blue white brown yellow
  403. ```
  404. ------------------------------------------------------------------------
  405. === Web Interface ===
  406. The Web Interface is up and running on the Internet at
  407. URLWEBSITE/online.php, so you can use and test the program
  408. instantly, before download.
  409. [IMGPATH/web.png]
  410. One can also put this interface on the local intranet avoiding to
  411. install txt2tags in all machines.
  412. ------------------------------------------------------------------------
  413. === Command Line Interface ===[cmdline]
  414. For command line power users, the --help should be enough:
  415. ```
  416. Usage: txt2tags [OPTIONS] [infile.t2t ...]
  417. --targets print a list of all the available targets and exit
  418. -t, --target=TYPE set target document type. currently supported:
  419. adoc, art, creole, dbk, doku, gwiki, html, lout, man,
  420. mgp, moin, pm6, pmw, sgml, tex, txt, wiki, xhtml
  421. -i, --infile=FILE set FILE as the input file name ('-' for STDIN)
  422. -o, --outfile=FILE set FILE as the output file name ('-' for STDOUT)
  423. --encoding=ENC set target file encoding (utf-8, iso-8859-1, etc)
  424. --toc add an automatic Table of Contents to the output
  425. --toc-level=N set maximum TOC level (depth) to N
  426. --toc-only print the Table of Contents and exit
  427. -n, --enum-title enumerate all titles as 1, 1.1, 1.1.1, etc
  428. --style=FILE use FILE as the document style (like HTML CSS)
  429. --css-sugar insert CSS-friendly tags for HTML/XHTML
  430. --css-inside insert CSS file contents inside HTML/XHTML headers
  431. -H, --no-headers suppress header and footer from the output
  432. --mask-email hide email from spam robots. x@y.z turns <x (a) y z>
  433. --slides format output as presentation slides (used by -t art)
  434. --width=N set the output's width to N columns (used by -t art)
  435. --height=N set the output's height to N rows (used by -t art)
  436. -C, --config-file=F read configuration from file F
  437. --gui invoke Graphical Tk Interface
  438. -q, --quiet quiet mode, suppress all output (except errors)
  439. -v, --verbose print informative messages during conversion
  440. -h, --help print this help information and exit
  441. -V, --version print program version and exit
  442. --dump-config print all the configuration found and exit
  443. --dump-source print the document source, with includes expanded
  444. Turn OFF options:
  445. --no-css-inside, --no-css-sugar, --no-dump-config, --no-dump-source,
  446. --no-encoding, --no-enum-title, --no-headers, --no-infile,
  447. --no-mask-email, --no-outfile, --no-quiet, --no-rc, --no-slides,
  448. --no-style, --no-targets, --no-toc, --no-toc-only
  449. Example:
  450. txt2tags -t html --toc file.t2t
  451. By default, converted output is saved to 'infile.<target>'.
  452. Use --outfile to force an output file name.
  453. If input file is '-', reads from STDIN.
  454. If output file is '-', dumps output to STDOUT.
  455. ```
  456. Please read the txt2tags man page for detailed information about options and command line use.
  457. Examples:
  458. | **Convert to HTML** | ``$ txt2tags -t html file.t2t``
  459. | **The same, using redirection** | ``$ txt2tags -t html -o - file.t2t > file.html``
  460. | | .
  461. | **Including Table Of Contents** | ``$ txt2tags -t html --toc file.t2t``
  462. | **And also, numbering titles** | ``$ txt2tags -t html --toc --enum-title file.t2t``
  463. | | .
  464. | **Contents quick view** | ``$ txt2tags --toc-only file.t2t``
  465. | **Maybe enumerate them?** | ``$ txt2tags --toc-only --enum-title file.t2t``
  466. | | .
  467. | **One liners from STDIN** | ``$ echo -e "\n**bold**" | txt2tags -t html --no-headers -``
  468. | **Testing Mask Email feature** | ``$ echo -e "\njohn.wayne@farwest.com" | txt2tags -t txt --mask-email --no-headers -``
  469. ========================================================================
  470. = Part II - Install =[install]
  471. Just download the program and run it on your machine.
  472. == Download & Install Python ==[download-python]
  473. First of all, you must download and install [Python http://www.python.org] on
  474. your system. Txt2tags requires Python version 2.2 or newer.
  475. Note that Python is already installed by default in Linux and Mac systems. If you're using those, you're done, just skip this step.
  476. If you are not sure if you have Python or not, open a console (tty,
  477. xterm, MSDOS, Terminal.app) and type ``python``. If it is not installed, the system
  478. will tell you.
  479. == Download txt2tags ==[download-txt2tags]
  480. The official location for txt2tags distribution is on the program
  481. site, at URLWEBSITE. Just download and uncompress the package (.tgz file).
  482. If you're in Linux, you can also use the automatic installer of your system. Some examples:
  483. - yum install txt2tags
  484. - sudo apt-get install txt2tags
  485. -
  486. % All the program's files are on the tarball (.tgz file), which can be
  487. % expanded by most of the compression utilities (including Winzip).
  488. % Just get the **latest** one (more recent date, higher version number).
  489. % The previous versions remains for historical purposes only.
  490. == Install txt2tags ==[install-txt2tags]
  491. As a single Python script, txt2tags needs no installation at all.
  492. The only file needed to use the program is the txt2tags script. The
  493. other files of the package are documentation, tools and sample files.
  494. The fail-proof way to run txt2tags, is calling Python with it:
  495. ``` prompt$ python txt2tags
  496. If you want to install txt2tags on the system as a stand alone
  497. program, just copy the txt2tags script to a system PATH
  498. directory and make sure the system knows how to run it.
  499. : **UNIX/Linux/Mac**
  500. Make the script executable (``chmod +x txt2tags``) and copy it to a
  501. $PATH directory (``cp txt2tags /usr/local/bin``)
  502. : **Windows**
  503. Rename the script adding the .py extension
  504. and copy it to a system PATH directory, such as ``C:\Windows\System32``.
  505. After that, you can create an icon on your desktop for it, if you want to
  506. use the program's Graphical Interface.
  507. % === Special Packages for Windows Users ===
  508. %
  509. % There is also two .EXE distribution files for txt2tags, which install
  510. % the program on Windows machines with just a few clicks:
  511. %
  512. % - The single txt2tags script for those who already have the Python
  513. % interpreted installed
  514. % - The stand alone version, which doesn't require Python interpreter to
  515. % run (it has a diet version embedded)
  516. %
  517. %
  518. % Please visit the //Txt2tags-Win// site to download this packages:
  519. % http://txt2tags-win.sf.net
  520. == Install Text Editor Syntax Highlighting File (optional)==[editor-syntax]
  521. Txt2tags comes with handy syntax highlighting files to be used by the
  522. following text editors:
  523. - Vim
  524. - Emacs
  525. - Nano
  526. - Kate
  527. - Gedit
  528. - JOE
  529. - le
  530. - ne
  531. - TextMate
  532. This syntax highlighting files have all the txt2tags rules and marks
  533. registered, helping the user to write error-free documents. Showing the
  534. marks in colors, you see on-the-fly if you wrote it right.
  535. | [IMGPATH/vim.png]
  536. | Sample file opened in Vim Editor
  537. Each editor has a different install procedure for a syntax highlighting
  538. file, please read the syntax file headers and the editor documentation.
  539. ========================================================================
  540. = Part III - Writing and Converting Your First Document =[your-1st-doc]
  541. == Check the Tools ==
  542. To make the first conversion you will need three things: txt2tags, a
  543. text editor and a web browser.
  544. + Make sure txt2tags is installed and running on your system.
  545. - **Command Line Interface:** Call "txt2tags" on the command line and
  546. the program should give you a "Missing input file" message. If it is
  547. not working, try ``python /path/to/txt2tags`` or even
  548. ``/path/to/python /path/to/txt2tags`` if Python is not on your PATH.
  549. - **Gui Interface:** Click on the program icon to launch the Gui
  550. Interface or call ``txt2tags --gui``.
  551. + Open the text editor your are comfortable with. It can be **any** text
  552. editor, from the good old VI to MS Word or OpenOffice.org. Create a
  553. brand new empty document to be your first txt2tags one and remember to
  554. save it as plain text.
  555. + Launch your favorite web browser to see the results of the conversion.
  556. ------------------------------------------------------------------------
  557. == Write the Document Header ==
  558. + Go to the text editor and on the very first line type the document
  559. main title: //My First Document//
  560. + On the second line make a subtitle, inserting this text:
  561. //A txt2tags test//
  562. + Then, on the third line, put some time information:
  563. //Sunday, 2004//
  564. If everything went right, you should be seeing a three line document
  565. with this contents:
  566. ```
  567. My First Document
  568. A txt2tags test
  569. Sunday, 2004
  570. ```
  571. This is just a part of the document, but we can already convert it and
  572. check the results.
  573. Now save this document with the name ``test.txt``. Remember to save it
  574. as plain text. Pay attention to which folder you are saving the file,
  575. you will need to remember it soon.
  576. ------------------------------------------------------------------------
  577. == The First Conversion - Gui Interface ==
  578. If you are in the Command Line Interface, please skip this step and read
  579. the next one.
  580. If you are in the Gui Interface, follow this steps:
  581. [IMGPATH/firstdoc.png]
  582. + Press the "Browse" button and choose the ``test.txt`` you just saved
  583. (remember the folder!).
  584. + Back to the first screen, select "HTML page" on the "Target document
  585. type" combo.
  586. + Press the "Convert!" button.
  587. [IMGPATH/firstdoc-done.png]
  588. A dialog box will appear, telling you that the file was converted
  589. successfully. Note that the generated HTML page was saved on the same
  590. folder as the text file, with the "html" extension.
  591. ------------------------------------------------------------------------
  592. == The First Conversion - Command Line Interface ==
  593. If you are in the Command Line Interface, move to the folder where the
  594. file was saved and type this command:
  595. ``` txt2tags --target html test.txt
  596. The option ``--target`` is followed
  597. by the "html" string, which tells the program to what format your text
  598. file will be converted. The last item is the text filename.
  599. The results were saved to the ``test.html``
  600. file and then the program will show you the
  601. "//txt2tags wrote test.html//" message.
  602. If some error occurred, read the message carefully.
  603. Here is a sample of how it will be shown on your screen:
  604. ```
  605. prompt$ txt2tags --target html test.txt
  606. txt2tags wrote test.html
  607. prompt$
  608. ```
  609. ------------------------------------------------------------------------
  610. == Check the Results ==
  611. Open the ``test.html`` file on the web browser to check if everything
  612. is ok.
  613. [IMGPATH/firstdoc-html.png]
  614. Here it is! You just typed three simple lines of text and txt2tags made
  615. all the work to set the HTML page heading information, text alignment,
  616. sizes, spacing and appearance. See that the main title is also placed at the
  617. browser title bar.
  618. You write text, txt2tags does the rest ;)
  619. Tip: You can also use CSS files on HTML pages generated by txt2tags, so the
  620. page appearance is 100% configurable.
  621. ------------------------------------------------------------------------
  622. == Writing the Document Body ==
  623. Now back to the text editor, the next step is to type the document
  624. contents. You can write plain text as you normally do on email messages.
  625. You will see that txt2tags recognizes paragraphs and list of items
  626. automatically, you don't have to "mark" them.
  627. Then again: save it, convert and check the results. This is the
  628. development cycle of a document in txt2tags. You just focus on the
  629. document contents, finishing documents faster than other editors. No
  630. mouse clicking, no menus, no windows, no distraction.
  631. Considering the following contents for the ``test.txt`` file, which is
  632. only plain text, compare the generated HTML page:
  633. ```
  634. My First Document
  635. A txt2tags test
  636. Sunday, 2004
  637. Well, let's try this txt2tags thing.
  638. I don't know what to write.
  639. Mmmmmm, I know what I need to do now:
  640. - Take a shower
  641. - Eat a pizza
  642. - Sleep
  643. ```
  644. [IMGPATH/firstdoc-fullhtml.png]
  645. You can write a full homepage with 0% of HTML knowledge. You don't need
  646. to insert any tags. And more, the same text file can be converted to any
  647. of the other txt2tags supported formats.
  648. Besides plain text, txt2tags has some very simple marks, that you'll
  649. use when you need some other formatting or structures like bold, italic,
  650. title, images, table and other. As a quick sample,
  651. ``**stars for bold**`` and ``== equals for title ==``. You can learn the
  652. marks on the [Txt2tags Markup Demo URLWEBSITE/markup.html].
  653. =======================================================================
  654. = Part IV - Mastering Txt2tags Concepts =[concepts]
  655. == The .t2t document Areas ==[areas]
  656. Txt2tags marked files are divided in 3 areas. Each area has its own
  657. rules and purpose. They are:
  658. : //HEADAREA//
  659. Place for Document Title, Author, Version and Date information.
  660. : //CONFAREA//
  661. Place for general Document Settings and Parser behavior modifiers.
  662. : //BODYAREA//
  663. Place for the Document Content.
  664. All areas are optional. You can write a txt2tags document with just
  665. headers (such as our first example), or a document with no headers or settings.
  666. The areas are delimited by special rules, which will be seen in detail
  667. on the next chapter. For now, this is a representation of the
  668. areas on a document:
  669. ```
  670. ____________
  671. | |
  672. | HEADERS | 1. First, the Headers
  673. | |
  674. | CONFIG | 2. Then the Settings
  675. | |
  676. | BODY | 3. And finally the Document Body,
  677. | |
  678. | ... | which goes until the end
  679. | ... |
  680. |____________|
  681. ```
  682. In short, this is how the areas are defined:
  683. | **Headers** | First 3 lines of the file, or the first line blank for No Headers.
  684. | **Config** | Begins right after the Header (4th or 2nd line) and ends when the //BODYAREA// starts.
  685. | **Body** | The first valid text line (not comment or setting) after the //HEADAREA//.
  686. === Full Example ===
  687. ```
  688. My nice doc Title
  689. Mr. John Doe
  690. Last Updated: %%mtime(%c)
  691. %!target : html
  692. %!style : fancy.css
  693. %!encoding: UTF-8
  694. %!options : --toc --enum-title
  695. Hi! This is my test document.
  696. Its content will end here.
  697. ```
  698. ------------------------------------------------------------------------
  699. == HEADAREA ==[headers-area]
  700. Location:
  701. - Fixed position: **First 3 lines** of the file. Period.
  702. - Fixed position: **First line** of the file if it is blank. This
  703. means Empty Headers.
  704. The HEADAREA is the only one that has a fixed position, line
  705. oriented. They are located at the first three lines of the source file.
  706. These lines are content-free, with no static information type needed.
  707. But the following is recommended:
  708. - //line 1//: document title
  709. - //line 2//: author name and/or email
  710. - //line 3//: document date and/or version
  711. (nice place for ``%%date``)
  712. Keep in mind that the first 3 lines of the source document will be the
  713. first 3 lines on the target document, separated and with high contrast
  714. to the text body (i.e. big letters, bold). If paging is allowed, the
  715. headers will be alone and centralized on the first page.
  716. ==== Less (or None) Header lines ====
  717. Sometimes the user wants to specify less than three lines for headers,
  718. giving just the document title and/or date information.
  719. Just let the 2nd and/or the 3rd lines empty (blank) and this position
  720. will not be placed at the target document. But keep in mind that even
  721. blanks, these lines are still part of the headers, so the document body
  722. must start **after** the 3rd line anyway.
  723. The title is the only required header (the first line), but if you
  724. leave it blank, you are saying that your document has **no headers**.
  725. So the //BODYAREA// will begin right after, on the 2nd line.
  726. No headers on the document is often useful if you want to specify your
  727. own customized headers after converting. The command line option
  728. ``--no-headers`` is usually required for this kind of operation.
  729. ==== Straight to the point ====
  730. In short: **"Headers are just __positions__, not contents"**
  731. Place one text on the first line, and it will appear on the target's
  732. first line. The same for 2nd and 3rd header lines.
  733. ------------------------------------------------------------------------
  734. == CONFAREA ==[config-area]
  735. Location:
  736. - Begins right after the HEADAREA
  737. - Begins on the **4th line** of the file if **Headers** were specified
  738. - Begins on the **2nd line** of the file if **No Headers** were specified
  739. - Ends when the BODYAREA starts
  740. - Ends by a non Setting, Blank or Comment line
  741. The CONFAREA is optional. An average user can write lots of txt2tags
  742. files without even know it exists, but the experienced users will
  743. enjoy the power and control it provides.
  744. The CONFAREA is used to store document-specific settings, so you don't
  745. have to type them on the command line when converting the document. For
  746. example, you can set the default document target type and encoding.
  747. Please read the [Settings section #settings-overview] for more
  748. information about them.
  749. ----------------------------------------------------------------
  750. == BODYAREA ==[body-area]
  751. Location:
  752. - Begins on the first valid text line of the file
  753. - Headers, Settings and Comments are **not** valid text lines
  754. - Ends at the end of the file (EOF)
  755. The body is anything outside Headers and Config Areas.
  756. The body holds the document contents and all formatting and structures
  757. txt2tags can recognize. Inside the body you can also put comments for
  758. //TODOs// and self notes.
  759. You can use the ``--no-headers`` command line option to convert only the
  760. document body, suppressing the headers. This is useful to set your own
  761. headers on a separate file, then join the converted body.
  762. ----------------------------------------------------------------
  763. == Settings ==[settings-overview]
  764. Settings are special configurations placed at the source document's
  765. CONFAREA that can affect the conversion process. Their syntax is:
  766. ``` %! keyword : value
  767. List of valid keywords:
  768. || Keyword | Description |
  769. | Target | Set the default target to the document be converted to.
  770. | Options | Set the default options to be used on the conversion. The format is the same as the command line options.
  771. | Style | Set the document style. Used to define a CSS file for HTML/XHTML and to load a package in LaTeX.
  772. | Encoding | Set the document Character Set. Used if the document contains accented letters or other not-ASCII characters.
  773. | PreProc | Input filter. Sets "find and replace" rules to be applied on the BODYAREA of the source document.
  774. | PostProc | Output filter. Sets "find and replace" rules to be applied on the converted document.
  775. Example:
  776. ```
  777. %!target : html
  778. %!options : --toc --toc-level 3
  779. %!style : fancy.css
  780. %!encoding: UTF-8
  781. %!preproc : "AMJ" "Aurelio Marinho Jargas"
  782. %!postproc: '<BODY.*?>' '<BODY bgcolor="yellow">'
  783. ```
  784. Note that the spacing and capitalization of the keyword are ignored. So you can also do ``%!Target:html`` and ``%! TARGET :html``.
  785. Learn more about settings in [Part VII - Mastering Settings #settings].
  786. -----------------------------------------------------------------------
  787. == Command Line Options ==[options]
  788. The fastest way of changing the txt2tags default behavior is to use
  789. command line options. This options are available on the Command Line
  790. Interface only, not on Gui or Web.
  791. Just like the other system's tools, the program do accept a set of
  792. predefined options. An option is an hyphen followed by a letter or two
  793. hyphens followed by one or more words, like ``-t`` and ``--target``.
  794. % Talking about the target option, it is the only required one, the others
  795. % are optional.
  796. Options that are generally used are ``--outfile`` to define a customized
  797. output file name, ``--toc`` to turn on the automatic TOC generation and
  798. ``--encoding`` to set the document character set. Most of the options
  799. can be turned off prefixing a "no-" before its name, for example:
  800. ``--no-encoding`` and ``--no-toc``.
  801. You can register the desired options for a source file inside its
  802. CONFAREA, using the ``%!options`` setting. This way you don't have to
  803. type them on the command line anymore.
  804. Example:
  805. ``` %!options: --toc -o mydoc.html
  806. The exception is the target specification, that has its own setting:
  807. ``` %!target: html
  808. Use the ``--help`` option to get a complete list of all the options
  809. available in txt2tags.
  810. Learn more about [%!options #setting-options] and [%!target #setting-target].
  811. -----------------------------------------------------------------------
  812. == User Configuration File (RC File) ==[rc]
  813. The user configuration file (also called RC file) is a central place to
  814. store the settings that will be shared by ALL converted files. If you
  815. keep inserting the same settings on every .t2t file you write, move it
  816. to the RC file and it will be used globally, for existing and future
  817. source files.
  818. The default location of this file depends on your system. It can also be
  819. specified by the user, using an environment variable.
  820. || RC file location ||
  821. | Windows | ``%HOMEPATH%\_t2trc``
  822. | UNIX, Linux, Mac | ``$HOME/.txt2tagsrc``
  823. | User defined | ``T2TCONFIG`` variable
  824. The format of the settings is exactly the same as the ones used on the
  825. .t2t files CONFAREA. There is a sample RC file on the package at
  826. ``doc/txt2tagsrc``. Example:
  827. ```
  828. % my configs
  829. %%% Always use CSS-friendly tags in HTML
  830. %!options(html): --css-sugar
  831. %%% Change the default TOC depth for all targets
  832. %!options: --toc-level 4
  833. %%% Set the default encoding for all documents
  834. %!options: --encoding UTF-8
  835. ```
  836. Any line that is not blank, a comment or a valid config line will raise
  837. error when txt2tags runs. So be careful when editing this file.
  838. Txt2tags automatically apply the RC file contents into any source file it
  839. is converting. If you want to disable this behavior for a specific
  840. file, use the ``--no-rc`` command line option.
  841. == Configuration Loading Order and Precedence ==[config-loading]
  842. There are three ways of telling txt2tags which options and settings to
  843. use, and this is the order that they are read and applied:
  844. + The user configuration file (RC) settings
  845. + The source document CONFAREA settings
  846. + The command line options
  847. First txt2tags reads the RC file contents (if any) and apply its
  848. configurations on the current source file. Then it scans the source
  849. document CONFAREA for settings and if found, they are applied also,
  850. overriding the RC ones in case of conflict. Finally comes the command
  851. line options, stronger than the other two.
  852. So, if the document encoding was defined on the three resources, the
  853. command line will be the one used.
  854. -----------------------------------------------------------------------
  855. == %!include command ==[include]
  856. The ``include`` command is used to paste the contents of an external
  857. file into the source document body. It is not a config, but a command,
  858. and it is valid on the document BODYAREA.
  859. The ``include`` command is useful to split a large document into smaller
  860. pieces (like chapters in a book) or to include the full contents of an
  861. external file into the document source. Sample:
  862. ```
  863. My first book
  864. Dr. John Doe
  865. 1st Edition
  866. %!include: intro.t2t
  867. %!include: chapter1.t2t
  868. %!include: chapter2.t2t
  869. ...
  870. %!include: chapter9.t2t
  871. %!include: ending.t2t
  872. ```
  873. You just inform the filename after the ``%!include`` string. The
  874. optional target specification is also supported, so this is valid
  875. either:
  876. ``` %!include(html): file.t2t
  877. Note that include will insert the file BODYAREA into the source
  878. document. The included file Header and Config Areas are ignored. This
  879. way you can convert the included file alone or inside the main document.
  880. But there's another three types of include:
  881. - Verbatim include
  882. - Raw include
  883. - Tagged include
  884. The **Verbatim** type includes a text file preserving its original
  885. spaces and formatting, just like if the text was inside the txt2tags
  886. Verbatim area (```). To specify this type, enclose the filename with
  887. backquotes:
  888. ``` %!include: ``/etc/fstab``
  889. The **Raw** type includes a text file as is, not trying to find and
  890. parse txt2tags marks on it, just like if the text was inside the Raw
  891. area ("""). To specify this type, enclose the filename with double
  892. quotes:
  893. ``` %!include: ""nice_text.txt""
  894. And the **Tagged** type is passed directly to the resulting document,
  895. with NO parsing or escaping performed by txt2tags. This way you can
  896. include additional tagged parts to your document. Useful for default
  897. header or footer information, or more complicated tagged code,
  898. unsupported by txt2tags:
  899. ``` %!include(html): ''footer.html''
  900. Note that the filename is enclosed with single quotes. As the text
  901. inserted is already parsed, you should specify the target to avoid
  902. mistakes.
  903. -----------------------------------------------------------------------
  904. == %!includeconf command ==[includeconf]
  905. The ``includeconf`` command is used to include configurations from an
  906. external file into the current one. This command is valid inside the
  907. source document CONFAREA only.
  908. It is useful to share the same config for multiple files, so you can
  909. centralize it. On any file do you want to include that central
  910. configuration, put a ``includeconf`` call. Example:
  911. ```
  912. My First Document
  913. John Doe
  914. July, 2004
  915. %!includeconf: config.t2t
  916. Hi, this is my first document.
  917. ```
  918. The format inside the included file is the same as in the
  919. [RC file #rc].
  920. Note that the optional target specification is NOT supported for this command.
  921. ```
  922. %!includeconf: config.t2t <--- OK
  923. %!includeconf(html): config.t2t <--- NOT OK
  924. ```
  925. =======================================================================
  926. = Part V - Mastering Marks =[marks]
  927. Overview of all txt2tags marks:
  928. || Basic || Beautifiers ||
  929. | //Headers// | First 3 lines | //Bold// | ""**words**""
  930. | //Title// | = words = | //Italic// | ""//words//""
  931. | //Numbered title// | + words + | //Underline// | ""__words__""
  932. | //Paragraph// | words | //Strike// | ""--words--""
  933. | //Links// | ""[label url]"" | //Monospaced// | ""``words``""
  934. | //Image// | ""[filename.jpg]"" | //Raw text// | """"words""""
  935. | || //Tagged text// | ""''words''""
  936. || Other ||||
  937. | //Quote// | <TAB>words | //Separator line// | ------------...
  938. | //List// | - words | //Strong line// | ============...
  939. | //Numbered list// | + words | //Table// | ""| cell1 | cell2 | cell3...""
  940. | //Definition list// | : words | //Anchor// | = title =[anchor]
  941. | //Comment line// | % comments | //Comment area// | %%%\n comments \n%%%
  942. | //Verbatim line// | ""```"" word | //Verbatim area// | ""```\n lines \n```""
  943. | //Raw line// | """"""" words | //Raw area// | """""""\n lines \n"""""""
  944. | //Tagged line// | ""'''"" words | //Tagged area// | ""'''""\n lines \n""'''""
  945. General Rules:
  946. - **Headers** are the first three document lines, marks are not interpreted.
  947. - **Titles** are balanced "=" or "+" chars around the title text. The more chars, more deep is the title.
  948. - **Beautifiers** don't accept spaces between the marks and its contents.
  949. - The **Comment** mark "%" must be at the line beginning (first column).
  950. - **Images** filename must end in GIF, JPG, PNG or similar.
  951. - The only **multiline** marks are the Comment, Verbatim, Raw and Tagged areas.
  952. - No mark is **interpreted** inside Verbatim, Raw and Tagged.
  953. - The **Separator/Strong lines** must have at least 20 chars.
  954. - Quote and lists **(un)nesting** is defined by indent.
  955. - A **Table title** line is defined by two || at the beginning of the line.
  956. ------------------------------------------------------------------------
  957. %- MARKPROP Multiline, FreeSpaces, Align, Nesting
  958. %- MARKCONT Macros, Beautifiers, Quote, Lists, Table, Verbatim, Raw, Tagged, Bars, Links, Image, Comment
  959. %-----------------------------------------------------------------------
  960. == Headers ==[mark-headers]
  961. - MARKDESC Identifies the document headers
  962. - MARKPROP Multiline, FreeSpaces, !Align, !Nesting
  963. - MARKCONT Macros
  964. - MARKSYN
  965. - The first 3 lines of the source file.
  966. - Leave the first line blank to not specify headers at all.
  967. Nice for command line one-liners or customized headers.
  968. - Leave the second and/or third lines blank to omit parts of header.
  969. - MARKDET
  970. - NOMARKS
  971. - The first 3 lines will be the first 3 lines on the target document,
  972. with high contrast to text body, or will be placed alone on the
  973. first page (if paging is allowed).
  974. - The headers are content-free, with no static information type
  975. needed. But the following is recommended for the most documents:
  976. - Line 1: Document title
  977. - Line 2: Author name and/or email
  978. - Line 3: Document date and/or version (nice place for ""%%mtime"")
  979. ------------------------------------------------------------------------
  980. == Title, Numbered Title ==[mark-title]
  981. - MARKDESC Identifies a (numbered or not) section title
  982. - MARKPROP !Multiline, FreeSpaces, !Align, !Nesting
  983. - MARKCONT -
  984. - MARKSYN
  985. - For Numbered Title, just change "=" by "+" on the following rules
  986. - Balanced equal signs around, ``=like this=``
  987. - More signs, more sublevels: ``=title=``, ``==subtitle==``,
  988. ``===subsubtitle===``, ...
  989. - There is a maximum of 5 levels, ``=====like this=====``
  990. - Unbalanced equals are not title, ``=like this===``
  991. - Free spacing inside the marks are allowed, ``= like this =``
  992. - Titles can have an anchor ``=like this=[anchor]``. To link to an anchor
  993. create a ``[local link #anchor]``
  994. - The anchor name can contain only letters, numbers, underscore
  995. and hyphen (A-Za-z0-9_-)
  996. - MARKDET
  997. - NOMARKS
  998. - NOMACRO
  999. ------------------------------------------------------------------------
  1000. == Paragraph ==[mark-paragraph]
  1001. - MARKDESC Identifies a paragraph of text
  1002. - MARKPROP Multiline, FreeSpaces, !Align, !Nesting
  1003. - MARKCONT Macros, Beautifiers, Raw, Tagged, Links, Image, Comment
  1004. - MARKSYN
  1005. - Paragraphs are groups of lines delimited by blank lines
  1006. - Other blocks like lists, quote, table or verbatim also ends a
  1007. paragraph
  1008. ------------------------------------------------------------------------
  1009. == Comment ==[mark-comment]
  1010. - MARKDESC Used to insert text that will not appear on the target
  1011. document
  1012. - MARKPROP !Multiline, !FreeSpaces, !Align, !Nesting
  1013. - MARKCONT -
  1014. - MARKSYN
  1015. - A line beginning with a percent char at the first column, ``% like this``
  1016. - NO leading spaces
  1017. - MARKDET
  1018. - As comments, they're not showed on the converted text
  1019. - Not a block, so each comment line must begin with %
  1020. - Useful for TODO and FIXME reminders and editor's notes
  1021. ------------------------------------------------------------------------
  1022. == Comment Area ==[mark-comment-block]
  1023. - MARKDESC Used to insert text that will not appear on the target
  1024. document
  1025. - MARKPROP Multiline, !FreeSpaces, !Align, !Nesting
  1026. - MARKCONT -
  1027. - MARKSYN
  1028. - A line with exactly 3 consecutive percents ``%%%``, followed by
  1029. text lines, followed by another line with exactly 3 consecutive
  1030. percents ``%%%``
  1031. - NO spaces allowed before or after the marks
  1032. - MARKDET
  1033. - As comments, they're not showed on the converted text
  1034. - Useful for deactivate (not delete) large portions of the contents
  1035. - If the end of the source file (EOF) is hit, the opened Comment Area
  1036. is closed
  1037. ---------------------------------------------------------------------
  1038. == Bold, Italic, Underline, Strike ==[mark-beautifiers]
  1039. - MARKDESC Used to insert a bold/italic/underline/strike text inside a
  1040. paragraph, table, list or quote
  1041. - MARKPROP !Multiline, !FreeSpaces, !Align, Nesting
  1042. - MARKCONT Macros, Beautifiers, Raw, Tagged, Links, Image
  1043. - MARKSYN
  1044. - Two starts around for bold, ``**like this**``
  1045. - Two slashes around for italic, ``//like this//``
  1046. - Two underlines around for underline, ``__like this__``
  1047. - Two hyphens around for strike, ``--like this--``
  1048. - The marks must be glued with the contents (no spaces):
  1049. ``** this ** is invalid``
  1050. - MARKDET
  1051. - All the beautified text must be on a single line of the source file,
  1052. no line breaks inside
  1053. - Macros are allowed inside beautifiers: ``**%%date**``
  1054. - You can mix beautifiers one inside another,
  1055. ``""**__like__ //this//**""``
  1056. ------------------------------------------------------------------------
  1057. == Monospaced ==[mark-monospaced]
  1058. - MARKDESC Used to insert a monospaced text inside a paragraph, table,
  1059. list or quote
  1060. - MARKPROP !Multiline, !FreeSpaces, !Align, !Nesting
  1061. - MARKCONT -
  1062. - MARKSYN
  1063. - Two backquotes around, ````like this````
  1064. - The marks must be glued with the contents (no spaces):
  1065. ```` this `` is invalid``
  1066. - MARKDET
  1067. - NOMARKS
  1068. - NOMACRO
  1069. - All the monospaced text must be on a single line of the source file,
  1070. no line breaks inside
  1071. - In some targets, the internal spacing is maintained, in others the
  1072. consecutive spaces are squeezed to one
  1073. - You can make a bold monospaced text enclosing it inside bold marks:
  1074. ``""**``monobold``**""``. The same applies to the other beautifiers
  1075. such as ``""//``italic``//""`` and ``""__``underline``__""``.
  1076. ---------------------------------------------------------------------
  1077. == Verbatim Line, Verbatim Area ==[mark-verbatim]
  1078. - MARKDESC Used to insert programming codes or other pre-formatted text,
  1079. preserving spacing and line breaks, and using a monospaced font
  1080. - MARKPROP Multiline, !FreeSpaces, !Align, !Nesting
  1081. - MARKCONT -
  1082. - MARKSYN **Verbatim Line:**
  1083. - A line beginning with 3 consecutive backquotes, followed by a space,
  1084. followed by the text, ``""```"" like this``
  1085. - The backquotes must be at the start of the line, no spaces before
  1086. - MARKSYN **Verbatim Area:**
  1087. - A line with exactly 3 consecutive backquotes ```````, followed by
  1088. text lines, followed by another line with exactly 3 consecutive
  1089. backquotes ```````
  1090. - NO spaces allowed before or after the marks
  1091. - MARKDET
  1092. - NOMARKS
  1093. - NOMACRO
  1094. - If the end of the source file (EOF) is hit, the opened Verbatim Area
  1095. is closed
  1096. ---------------------------------------------------------------------
  1097. == Separator Line, Strong Line ==[mark-separator]
  1098. - MARKDESC Identifies a separator or strong line
  1099. - MARKPROP !Multiline, FreeSpaces, !Align, !Nesting
  1100. - MARKCONT -
  1101. - MARKSYN
  1102. - The separator line can be composed by dashes "-" or underscores "_"
  1103. - The strong line is composed by equals "="
  1104. - Use at least least 20 dashes/underscores/equal signs
  1105. - Optional spaces can be placed at the line start or end
  1106. - Any other characters on the line invalidate the mark
  1107. - MARKDET
  1108. - If the target does not have separator line support, a commented line
  1109. is used instead
  1110. - The strong line may have different behaviors on some targets:
  1111. - A larger separator line
  1112. - A pause on presentation formats, like MagicPoint
  1113. - A page break in paged targets, like LaTeX
  1114. ---------------------------------------------------------------------
  1115. == Links, Named Links ==[mark-link]
  1116. - MARKDESC Identifies a remote (Internet) or local link
  1117. - MARKPROP !Multiline, !FreeSpaces, !Align, !Nesting
  1118. - MARKCONT Macros, Raw, Tagged, Image
  1119. - MARKSYN
  1120. - Any valid internet URL, ftp, news or email address is detected and
  1121. converted automatically
  1122. - The protocol (http, https, ftp) is optional, ``www.likethis.com``
  1123. - A name can be used for a link: ``[click here www.url.com]``
  1124. - An image can point to a link: ``[[image.jpg] www.url.com]``
  1125. - Macros are allowed on the link address: ``[see source %%infile]``
  1126. - Macros are allowed on the link name: ``[mirror of %%outfile www.url.com]``
  1127. % - Beautifiers are allowed on the link name: ``[**click** here www.url.com]``
  1128. - All the link specification must be on a single line of the source
  1129. file, no line breaks inside
  1130. - MARKDET
  1131. - If the target does not have link support, they're just underlined
  1132. ---------------------------------------------------------------------
  1133. == Quote ==[mark-quote]
  1134. - MARKDESC Identifies a quoted (indented) line
  1135. - MARKPROP Multiline, !FreeSpaces, !Align, Nesting
  1136. - MARKCONT Macros, Beautifiers, Quote, Raw, Tagged, Bars, Links, Image, Comment
  1137. - MARKSYN
  1138. - A line that starts with a tabulation (TAB) character
  1139. - More TABs at the start increase the quote depth
  1140. - Lists and tables are not allowed inside quote
  1141. - MARKDET
  1142. - If the end of the source file (EOF) is hit, the opened Quote is
  1143. closed
  1144. - Some targets may not support quote nesting, then the subquotes lines
  1145. are moved up to the mother quote level.
  1146. - There is not a limit for subquotes depth. But some targets may have
  1147. restrictions, so the subquotes than are deeper than the maximum level
  1148. are moved up.
  1149. ---------------------------------------------------------------------
  1150. == List, Numbered List, Definition List ==[mark-lists]
  1151. - MARKDESC Identifies the start of a list item
  1152. - MARKPROP Multiline, !FreeSpaces, !Align, Nesting
  1153. - MARKCONT Macros, Beautifiers, Lists, Table, Verbatim, Raw, Tagged, Bars, Links, Image, Comment
  1154. - MARKSYN
  1155. - A line that starts with a dash/plus/colon followed by exactly one
  1156. space
  1157. - The first list char can NOT be a space (exception: definition
  1158. lists)
  1159. - Optional spaces (regular spaces, not TAB) at the line beginning
  1160. define sublists depth (nesting)
  1161. - Sublists end with a less depth item (from parent list) or with an
  1162. empty item
  1163. - All opened lists are closed with two consecutive blank lines
  1164. - MARKDET
  1165. - If the end of the source file (EOF) is hit, all opened lists are
  1166. closed
  1167. - Lists can be mixed, like a definition list inside a numbered list.
  1168. - Some targets may not support list nesting, then the sublists items
  1169. are moved up to the mother list level.
  1170. - There is not a limit for sublists depth. But some targets may have
  1171. restrictions, so the sublists than are deeper than the maximum level
  1172. are moved up.
  1173. ---------------------------------------------------------------------
  1174. == Image ==[mark-image]
  1175. - MARKDESC Identifies an image
  1176. - MARKPROP !Multiline, !FreeSpaces, Align, !Nesting
  1177. - MARKCONT Macros
  1178. - MARKSYN
  1179. - An image filename enclosed between brackets, ``[likethis.jpg]``
  1180. - The filename must end in an image extension like PNG, JPG, GIF,
  1181. ... (case doesn't matter)
  1182. - Symbols are allowed on the filename, ``[likethis!~1.jpg]``
  1183. - Macros are allowed on the filename, ``[report-%%date(%Y-%m-%d).png]``
  1184. - NO spaces allowed on the filename, ``[like this.jpg]``
  1185. - NO spaces allowed on the brackets, ``[ likethis.jpg ]``
  1186. - MARKDET
  1187. - If the target does not have image support, the image filename is
  1188. shown inside (parenthesis).
  1189. - The position of the mark on the line defines the image alignment:
  1190. - ``[LEFT.jpg]`` blablablabla
  1191. - blablablabla ``[CENTER.jpg]`` blablablabla
  1192. - blablablabla ``[RIGHT.jpg]``
  1193. ---------------------------------------------------------------------
  1194. == Table ==[mark-table]
  1195. - MARKDESC Delimits a table row, with any number of columns
  1196. - MARKPROP Multiline, FreeSpaces, Align, !Nesting
  1197. - MARKCONT Macros, Beautifiers, Raw, Tagged, Links, Image, Comment
  1198. - MARKSYN
  1199. - A leading pipe "|" identifies a table row
  1200. - A leading double pipe "||" identifies a table title row
  1201. - Leading spaces before first pipe identifies table centered align
  1202. - The fields are separated by the " | " string (space pipe space)
  1203. - A final pipe "|" at the first table row sets visible borders
  1204. - A final pipe "|" at the other table rows are ignored (just cosmetic)
  1205. - Closing a cell with more than one pipe "|" identifies column span:
  1206. "||" for 2 columns, "|||" for 3 and so on
  1207. - Natural spaces inside each cell identifies its alignment
  1208. - Example: ``| table | row | with | five | columns |``
  1209. - MARKDET
  1210. - All the table row data must be on a single line of the source file,
  1211. no line breaks inside
  1212. - Targets with column-oriented align (like sgml and LaTeX), uses the
  1213. first table row align as the default for the other rows
  1214. - Any non-table line closes the opened table, except comment lines
  1215. - The cell count is flexible, each table row can have a different
  1216. number of cells
  1217. - Currently there's no way to specify row span
  1218. - If the target does not have table support, the table lines are
  1219. considered a Verbatim Area
  1220. ---------------------------------------------------------------------
  1221. == Raw, Raw Line, Raw Area ==[mark-raw]
  1222. - MARKDESC Used to "protect" some text from parsing, so marks and macros inside
  1223. it will not be expanded. But escapes are applied.
  1224. - MARKPROP !Multiline, !FreeSpaces, !Align, !Nesting
  1225. - MARKCONT -
  1226. - MARKSYN **Raw:**
  1227. - Two double quotes around, ``""like this""``
  1228. - Marks glued with the contents (no spaces)
  1229. - MARKSYN **Raw Line:**
  1230. - A line beginning with 3 consecutive double quotes, ``""" like this``
  1231. - The double quotes must be at the start of the line, no spaces before
  1232. - Use a space after the double quotes to separate them from the text
  1233. - MARKSYN **Raw Area:**
  1234. - A line with exactly 3 consecutive double quotes, followed by text
  1235. lines, followed by another line with exactly 3 consecutive
  1236. double quotes
  1237. - NO spaces allowed before or after the marks
  1238. - MARKDET
  1239. - NOMARKS
  1240. - NOMACRO
  1241. - If the end of the source file (EOF) is hit, the opened Raw Area is
  1242. closed
  1243. ---------------------------------------------------------------------
  1244. == Tagged, Tagged Line, Tagged Area ==[mark-tagged]
  1245. - MARKDESC Used to send text directly to the output, no parsing or escaping is made by txt2tags.
  1246. - MARKPROP !Multiline, !FreeSpaces, !Align, !Nesting
  1247. - MARKCONT -
  1248. - MARKSYN **Tagged:**
  1249. - Two apostrophes around, ``''like this''``
  1250. - Marks glued with the contents (no spaces)
  1251. - MARKSYN **Tagged Line:**
  1252. - A line beginning with 3 consecutive apostrophes, ``''' like this``
  1253. - The apostrophes must be at the start of the line, no spaces before
  1254. - Use a space after the apostrophes to separate them from the text
  1255. - MARKSYN **Tagged Area:**
  1256. - A line with exactly 3 consecutive apostrophes, followed by text
  1257. lines, followed by another line with exactly 3 consecutive
  1258. apostrophes
  1259. - NO spaces allowed before or after the marks
  1260. - MARKDET
  1261. - NOMARKS
  1262. - NOMACRO
  1263. - If the end of the source file (EOF) is hit, the opened Tagged Area is
  1264. closed
  1265. - Use this mark to insert target code. For example, in HTML you could use
  1266. it to insert manual line breaks ``''<br>''``,
  1267. custom DIVs ``''<div id="myfooter">''`` or even full blocks of code,
  1268. like the Google Analytics tracking code.
  1269. =======================================================================
  1270. = Part VI - Mastering Macros =[macros]
  1271. Macros are special purpose keywords, that are expanded on conversion
  1272. time. They are used to insert dynamic information, for example the
  1273. current date or information about the document source.
  1274. A macro is represented by the ``%%`` chars followed by its name, such as
  1275. ``%%date``. Some macros do accept an optional formatting string inside
  1276. parenthesis, right after the macro name, such as ``%%date(%Y-%m-%d)``. This
  1277. format string mixes common text with special directives, identified by a
  1278. percent sign % followed by an identification character. If no format
  1279. string is given, the default format is used.
  1280. || Macro Name | Expands to... | Default Format |
  1281. | ""%%date"" | The current date | %Y%m%d
  1282. | ""%%mtime"" | The source file modification time | %Y%m%d
  1283. | ""%%infile"" | The source file path | %f
  1284. | ""%%outfile"" | The output file path | %f
  1285. | ""%%toc"" | The document TOC (Table of Contents) | -
  1286. General rules:
  1287. - The macro name is case-insensitive, so ``%%date``, ``%%DaTe`` and
  1288. ``%%DATE`` are identical
  1289. - Macros are valid at the document HEADAREA and BODYAREA, except
  1290. %%toc that is valid on BODYAREA only
  1291. - A macro starts the BODYAREA if it is found in the CONFAREA
  1292. - A macro can be placed at any part of the line, including various per line
  1293. (except %%toc, valid when alone in a line)
  1294. - A macro can be used inside links and images marks (except %%toc)
  1295. - Macros are not expanded in Titles, Verbatim, Raw and Tagged Areas
  1296. Full example (bold text are expanded macros):
  1297. This is the Txt2tags User Guide, converted to **%%outfile(%e)**
  1298. by txt2tags from the **%%infile** source file. The conversion
  1299. was done at **%%date(%Y-%m-%d %X)**, but the last change on the
  1300. source document was made on **%%mtime(%Y-%m-%d %X)**. Both
  1301. source and converted file reside on the **%%infile(%D)**
  1302. directory.
  1303. -----------------------------------------------------------------------
  1304. == %%date ==[macro-date]
  1305. The ``%%date`` macro expands to the current date and time. It is very
  1306. useful on the document headers or footer, to register the date when the
  1307. document was generated. To expand to the source document last
  1308. modification time, see the [""%%mtime"" macro #macro-mtime].
  1309. This macros accepts several formatting directives. The full list can be
  1310. found in the
  1311. [Python site http://docs.python.org/library/time.html].
  1312. Here are the most commonly used:
  1313. || Directive | Description |
  1314. | %a | Locale's abbreviated weekday name.
  1315. | %A | Locale's full weekday name.
  1316. | %b | Locale's abbreviated month name.
  1317. | %B | Locale's full month name.
  1318. | %c | Locale's appropriate date and time representation.
  1319. | %d | Day of the month as a decimal number [01,31].
  1320. | %H | Hour (24-hour clock) as a decimal number [00,23].
  1321. | %I | Hour (12-hour clock) as a decimal number [01,12].
  1322. | %m | Month as a decimal number [01,12].
  1323. | %M | Minute as a decimal number [00,59].
  1324. | %p | Locale's equivalent of either AM or PM.
  1325. | %S | Second as a decimal number [00,61]. (1)
  1326. | %x | Locale's appropriate date representation.
  1327. | %X | Locale's appropriate time representation.
  1328. | %y | Year without century as a decimal number [00,99].
  1329. | %Y | Year with century as a decimal number.
  1330. | %% | A literal "%" character.
  1331. Examples:
  1332. || Macro | --> | Results for on %%date(%Y, %b %d at %H:%M) |
  1333. | ""%%date(Converted on: %c)"" | --> | %%date(Converted on: %c)
  1334. | ""%%date(%Y-%m-%d)"" | --> | %%date(%Y-%m-%d)
  1335. | ""%%date(%I:%M %p)"" | --> | %%date(%I:%M %p)
  1336. | ""%%date(Today is %A, on %B.)"" | --> | %%date(Today is %A, on %B.)
  1337. -----------------------------------------------------------------------
  1338. == %%mtime ==[macro-mtime]
  1339. The ``%%mtime`` macro expands to last modification time of the source
  1340. document. It is useful to register when the file was last changed.
  1341. This macro is a "sister" of the [""%%date"" macro #macro-date], so it
  1342. accepts exactly the same formatting directives.
  1343. As an example, this User Guide source file was last edited on
  1344. **%%mtime(%c)**. This date was expanded from ``%%mtime(%c)``.
  1345. -----------------------------------------------------------------------
  1346. == %%infile ==[macro-infile]
  1347. The ``%%infile`` macro expands to the source file location on the
  1348. system. It is useful to make those "//see the source of this file//"
  1349. links on HTML pages. Providing such link is a friendly attitude with
  1350. beginners, so they can use your source as a sample for their own page.
  1351. This macro accepts the following formatting directives:
  1352. || %<char> | Description | Output for this User Guide source |
  1353. | %f | File name | %%infile(%f)
  1354. | %F | File name (without extension) | %%infile(%F)
  1355. | %e | File extension | %%infile(%e)
  1356. | %p | Absolute file path | %%infile(%p)
  1357. | %d | File path (directories only) | %%infile(%d)
  1358. | %D | File path (parent dir only) | %%infile(%D)
  1359. | %% | Literal percent char | %%infile(%%)
  1360. Examples:
  1361. || Source | --> | Expanded |
  1362. | This Guide parent dir is ""%%infile(%D)"". | --> | This Guide parent dir is %%infile(%D). |
  1363. | I do use the ""%%infile(%e)"" file extension. | --> | I do use the %%infile(%e) file extension. |
  1364. | ""[See the source %%infile]"" | --> | [See the source %%infile]
  1365. | Converted to XHTML, I'll be ""%%infile(%F)"".xhtml | --> | Converted to XHTML, I'll be %%infile(%F).xhtml
  1366. **Note:** The macro is expanded to "-" if the source file is STDIN.
  1367. -----------------------------------------------------------------------
  1368. == %%outfile ==[macro-outfile]
  1369. The ``%%outfile`` macro expands to the converted file location on the
  1370. system. It is useful to its name inside the document Body or Headers.
  1371. This macro is a sister of the [""%%infile"" macro #macro-infile] and
  1372. do accept exactly the same formatting directives.
  1373. Examples:
  1374. || Source | --> | Expanded |
  1375. | You are reading the ""%%outfile"" file. | --> | You are reading the %%outfile file.
  1376. | txt2tags -t ""%%outfile(%e)"" -i ""%%infile"" -o ""%%outfile"" | --> | txt2tags -t %%outfile(%e) -i %%infile -o %%outfile
  1377. **Note:** The macro is expanded to "-" if the output file is STDOUT.
  1378. -----------------------------------------------------------------------
  1379. == %%toc ==[macro-toc]
  1380. The ``%%toc`` macro expands to the document's Table of Contents. It is
  1381. useful for you to specify exactly where you want the TOC to be placed.
  1382. You can even use the macro more than one time and place the TOC at the
  1383. end of the document also, for example. This Guide is using ""%%toc""
  1384. to position the TOC.
  1385. Different from the other macros, this one does not accept a format
  1386. string and has its own special rules:
  1387. - Valid at the document BODYAREA only
  1388. - Must be alone on the line (leading and trailing spaces are allowed)
  1389. - Must be used together with --toc command line option, or it will be
  1390. ignored
  1391. - The default automatic TOC positioning/formatting is disabled when a
  1392. %%toc is found
  1393. =======================================================================
  1394. = Part VII - Mastering Settings =[settings]
  1395. Settings are special configurations placed at the source document's
  1396. CONFAREA that can affect the conversion process. The Settings are all
  1397. optional. The average user can live fine without them. But they are
  1398. addictive, if you start using them, you'll never stop :)
  1399. Setting lines are //special comment lines//, marked by a leading
  1400. identifier ("!") that makes them different from plain comments. The
  1401. syntax is just as simple as variable setting, composed by a keyword
  1402. and a value, separated from each by a colon (":").
  1403. **%! keyword : value**
  1404. Syntax details:
  1405. - The exclamation mark must be placed together with the comment char
  1406. (%!), no spaces between them.
  1407. - The spaces around the keyword and the separator are optional.
  1408. - Keywords are case insensitive (case doesn't matter).
  1409. Rules:
  1410. - Settings are valid only inside the CONFAREA, and are considered
  1411. plain comments if found on the document Body.
  1412. - If the same keyword appears more than one time on the CONFAREA, the
  1413. last found will be the one used. Exception: options, preproc and
  1414. postproc, which are cumulative.
  1415. - A setting line with an invalid keyword will be considered a plain
  1416. comment line.
  1417. - This settings have precedence over RC file, but not on command line
  1418. options.
  1419. -----------------------------------------------------------------------
  1420. == %!target ==[setting-target]
  1421. Using the target setting, a default target format is defined for the
  1422. document:
  1423. ``` %!target: html
  1424. This way the user can just call
  1425. ``` $ txt2tags file.t2t
  1426. And the conversion will be done, to the specified target.
  1427. The target setting does not support optional target specification.
  1428. That doesn't make sense, such as ``%!target(tex): html``.
  1429. -----------------------------------------------------------------------
  1430. == %!options ==[setting-options]
  1431. Writing long command lines every time you need to convert a document
  1432. is boring and error prone. The Options setting let the user save
  1433. all the converting options together with the source document. This also
  1434. ensures that the document will always be converted the same way, with
  1435. the same options.
  1436. Just write it with no syntax errors, as you were on the real command
  1437. line. But omit the "txt2tags" program call on the beginning, the target
  1438. specification and the source filename from the ending.
  1439. For example, if you do use this command line to convert your document:
  1440. ``` $ txt2tags -t html --toc --toc-level 2 --enum-title file.t2t
  1441. You can save yourself from typing pain using this Options setting inside
  1442. the document source:
  1443. ```
  1444. %!target: html
  1445. %!options(html): --toc --toc-level 2 --enum-title
  1446. ```
  1447. Now the options are registered inside the source file, so you can convert it with this simple command:
  1448. ``` $ txt2tags file.t2t
  1449. Tip for Vim users: To convert the document right inside the editor, just run ``:!txt2tags %``
  1450. -----------------------------------------------------------------------
  1451. == %!encoding ==[setting-encoding]
  1452. The Encoding setting is needed by non-english writers, who uses
  1453. accented letters and other locale specific details, so the target
  1454. document //Character Set// must be customized (if allowed).
  1455. The valid values for the Encoding setting are the same charset names
  1456. valid for HTML documents, like //iso-8859-1// and //koi8-r//. If
  1457. you're not sure which encoding you should use, try //utf-8//. If that doesn't work,
  1458. [this complete (and long!) list http://www.iana.org/assignments/character-sets]
  1459. should help.
  1460. The LaTeX target uses alias names for encoding. This is not a problem
  1461. for the user, because txt2tags translate the names internally. Some
  1462. examples:
  1463. || txt2tags/HTML | > | LaTeX |
  1464. | windows-1250 | >>> | cp1250 |
  1465. | windows-1252 | >>> | cp1252 |
  1466. | ibm850 | >>> | cp850 |
  1467. | ibm852 | >>> | cp852 |
  1468. | iso-8859-1 | >>> | latin1 |
  1469. | iso-8859-2 | >>> | latin2 |
  1470. | koi8-r | >>> | koi8-r |
  1471. If the value is unknown to txt2tags, it will be passed "as is",
  1472. allowing the user to specify custom encodings.
  1473. -----------------------------------------------------------------------
  1474. == %!preproc ==[setting-preproc]
  1475. The PreProc is an input filter that changes the BODYAREA of the source document. It is a "find
  1476. and replace" feature, applied right after the line is read from the
  1477. document source, before any parsing by txt2tags.
  1478. It is useful to define some abbreviations for common typed text, as:
  1479. ```
  1480. %!preproc: JJS "John J. Smith"
  1481. %!preproc: RELEASE_DATE "2003-05-01"
  1482. %!preproc: BULLET "[images/tiny/bullet_blue.png]"
  1483. ```
  1484. So the user can write a line like:
  1485. ``` Hi, I'm JJS. Today is RELEASE_DATE.
  1486. And txt2tags will "see" this line as:
  1487. ``` Hi, I'm John J. Smith. Today is 2003-05-01.
  1488. This filter is a component that acts between the document author
  1489. and the txt2tags conversion. It's like a first conversion before the
  1490. "real" one. This behavior is similar to an external Sed/Perl filter,
  1491. called this way:
  1492. ``` $ cat file.t2t | preproc-script.sh | txt2tags -
  1493. So the txt2tags parsing will begin after all the PreProc substitutions
  1494. were applied.
  1495. **Note:** Remember that the preprocessing is applied only to the BODY of the source document, not including the HEADAREA and CONFAREA.
  1496. -----------------------------------------------------------------------
  1497. == %!postproc ==[setting-postproc]
  1498. The PostProc is an output filter that changes the converted document. It is a
  1499. "find and replace" feature, applied after all txt2tags parsing and
  1500. processing is done.
  1501. It is useful to do some refinements on the generated document, change
  1502. tags and add extra text or tags. Quick samples:
  1503. ```
  1504. %!postproc(html): '<BODY.*?>' '<BODY BGCOLOR="green">'
  1505. %!postproc(tex) : "\\newpage" ""
  1506. ```
  1507. These filters change the background color of the HTML page and remove
  1508. the page breaks on the LaTeX target.
  1509. The PostProc rules are just like an external Sed/Perl filter, called
  1510. this way:
  1511. ``` $ txt2tags -t html -o- file.t2t | postproc-script.sh > file.html
  1512. Before this feature was introduced, it was very common to have little
  1513. scripts to "adjust" the txt2tags results. These scripts were in fact
  1514. just lots of sed (or alike) commands, to do "substitute this for that"
  1515. actions. Now this replacement strings can be saved together with the
  1516. document text, and the plus is to use the Python powerful Regular
  1517. Expression machine to find patterns.
  1518. -----------------------------------------------------------------------
  1519. == %!style ==[setting-style]
  1520. - Useful in HTML and XHTML targets, it defines a CSS file for the target
  1521. document.
  1522. - Useful in LaTeX target, to load ``\usepackage`` modules.
  1523. - The same effect is achieved with the command line option ``--style``.
  1524. - The --style option is stronger than %!style. If both are used, --style
  1525. wins.
  1526. -----------------------------------------------------------------------
  1527. == Defining a Setting for a Specific Target ==[setting-specific]
  1528. All the settings (except %!target) can be glued with a specific target
  1529. using the ``%!key(target): value`` syntax. This way user can define
  1530. different config for different targets.
  1531. This is specially useful in the pre/postproc filters, but is applicable
  1532. to all settings. For example, defining different styles for HTML and
  1533. LaTeX:
  1534. ```
  1535. %!style(html): fancy.css
  1536. %!style(tex) : amssymb
  1537. ```
  1538. For the options setting it's very useful to adjust the converted
  1539. document:
  1540. ```
  1541. %!target: sgml
  1542. %!options(sgml): --toc
  1543. %!options(html): --style foo.css
  1544. %!options(txt ): --toc-only --toc-level 2
  1545. ```
  1546. In this example, the default target is Sgml and it will use TOC. If the
  1547. user run ``txt2tags -t html file.t2t``, only the HTML options will be
  1548. used, so the converted file will use "foo.css" style file and will
  1549. have no TOC.
  1550. -----------------------------------------------------------------------
  1551. == Details for PreProc and PostProc Filters ==[filters-details]
  1552. - Filters are a "find and replace" feature (think SED)
  1553. - Filters do not follow the "last found, one used" schema, they're
  1554. cumulative. You can define as many filters as needed, with no limit.
  1555. They will be applied on the same order as defined.
  1556. - Different from other settings, both the target specific filters and
  1557. the generic ones (all targets) are used. On the following example,
  1558. both filters are used on the HTML target:
  1559. ```
  1560. %!postproc : this that
  1561. %!postproc(html): that other
  1562. ```
  1563. - The filters must receive exactly TWO arguments
  1564. - Special escapes as ``\n`` (line break) and ``\t`` (tabulation) are
  1565. interpreted
  1566. - To delete some text, change it by an empty string
  1567. ``` %!postproc: "undesired string" ""
  1568. - To avoid problems, always use the explicit target form when using
  1569. PostProc to change tags: ``%!postproc(target): <this> <that>``
  1570. - PREproc is applied right after the line is read, and POSTproc is
  1571. applied after all the parsing was made. This is similar to
  1572. (UUOC ahead):
  1573. ``` $ cat file.t2t | preproc.sh | txt2tags | postproc.sh
  1574. - The first part of a filter (the "search for" part) is not read as a
  1575. regular string, but as a Regular Expression pattern. If you don't know
  1576. what these expressions do, don't worry, you may never have to. Just
  1577. keep in mind that you will need to "escape" some characters to use
  1578. them. To escape is to prefix the character with a backslash "\". Here
  1579. is the list:
  1580. ``` \* \+ \. \^ \$ \? \( \) \{ \[ \| \\
  1581. - Python Regular Expressions are available! They're similar to Perl
  1582. Regexes (PCRE). Example: Change all opening and closing "B" tags to
  1583. "STRONG" on HTML:
  1584. ``` %!postproc(html): '(</?)B>' '\1STRONG>'
  1585. - The filter arguments can be passed on 3 ways:
  1586. + A single unquoted word such as FOO (no spaces)
  1587. + A string double quoted such as "FOO"
  1588. + A string single quoted such as 'FOO'
  1589. - If your pattern has double quotes, protect it with single quotes and
  1590. vice-versa. Some valid samples:
  1591. ```
  1592. %!postproc: PATT REPLACEMENT
  1593. %!postproc: "PATT" "REPLACEMENT"
  1594. %!postproc: 'PATT' 'REPLACEMENT'
  1595. %!postproc: PATT "REPLACEMENT"
  1596. %!postproc: "PATT" 'REPLACEMENT'
  1597. ```
  1598. =======================================================================
  1599. = Part VIII - Black Magic =[black-magic]
  1600. This chapter is really not recommended for newbies. It demonstrates how
  1601. to do strange things with txt2tags filters, abusing of complex
  1602. patterns and Regular Expressions.
  1603. **BEWARE!** The following procedures are NOT encouraged and can
  1604. break things. Even some text from the document source can be
  1605. lost on the conversion process, not appearing on the target
  1606. document. Just use these tactics if you really need them and
  1607. know what you are doing.
  1608. **Note:** Filters are a powerful feature, but can be dangerous!
  1609. **Note:** Bad filters do generate unexpected results.
  1610. Keep that in mind, please.
  1611. -----------------------------------------------------------------------
  1612. == Inserting Multiple Lines with %!postproc (such as CSS rules) ==[postproc-multiline]
  1613. In filters, the replacement pattern can include multiple lines using the
  1614. ``\n`` line break char.
  1615. This can be handy for including really short CSS rules on HTML target,
  1616. with no need to create a separate file:
  1617. ```
  1618. %!postproc: <HEAD> '<HEAD>\n<STYLE TYPE="text/css">\n</STYLE>'
  1619. %!postproc: (</STYLE>) 'body { margin:3em ;} \n\1'
  1620. %!postproc: (</STYLE>) 'a { text-decoration:none ;} \n\1'
  1621. %!postproc: (</STYLE>) 'pre,code { background-color:#ffffcc ;} \n\1'
  1622. %!postproc: (</STYLE>) 'th { background-color:yellow ;} \n\1'
  1623. ```
  1624. All the filters are tied to the first one, by replacing a string that it
  1625. has inserted. So a single "<HEAD>" turns to:
  1626. ```
  1627. <HEAD>
  1628. <STYLE TYPE="text/css">
  1629. body { margin:3em ;}
  1630. a { text-decoration:none ;}
  1631. pre,code { background-color:#ffffcc ;}
  1632. th { background-color:yellow ;}
  1633. </STYLE>
  1634. ```
  1635. -----------------------------------------------------------------------
  1636. == Creating "Target-Specific" Contents with %!preproc ==[target-specific-contents]
  1637. Sometimes you need to insert some text on a specific target, but not on
  1638. the others. This kind of strange behavior can be done using some
  1639. PreProc tricks.
  1640. The idea is to insert this extra text on the document source as
  1641. comments, but mark it in a way that a target-specific filter will
  1642. "uncomment" those lines.
  1643. For example, if an extra paragraph must be added only in HTML target.
  1644. Place the text as special comments, like this:
  1645. ```
  1646. %html% This HTML page is Powered by [txt2tags http://txt2tags.org].
  1647. %html% See the source TXT file [here source.t2t].
  1648. ```
  1649. As those lines start with ``%``, they are plain comments lines and will be
  1650. ignored. But when adding this special filter:
  1651. ``` %preproc(html): '^%html% ' ''
  1652. The leading string is removed and those lines will be "activated", not
  1653. being comments anymore. As a explicit target config, this filter will be
  1654. processed for HTML targets only.
  1655. -----------------------------------------------------------------------
  1656. == Changing Txt2tags Marks with %!preproc ==[creating-marks]
  1657. Being a Regular Expressions guru, the user can customize the document
  1658. source syntax, changing the txt2tags default marks to some he find more
  1659. comfortable.
  1660. For example, a leading TAB is the Quotation mark. If the user doesn't
  1661. like it, or his text editor has some strange relationship with TABs, he
  1662. can define a new mark for Quoted text. Say a leading ">>> " was his
  1663. choice. Then he will do this simple filter:
  1664. ``` %!preproc: '^>>> ' '\t'
  1665. And on the document source, the quoted text will be something like:
  1666. ```
  1667. >>> This is a quoted text.
  1668. >>> The user defined this strange mark.
  1669. >>> But they will be converted to TABs by PreProc.
  1670. ```
  1671. Before the parsing begins, the strange ">>> " will be converted to
  1672. TABs and txt2tags will recognize the Quote mark.
  1673. **BEWARE!** Extreme PreProc rules could eventually
  1674. change the entire marks syntax, even generating conflicts
  1675. between marks. Be really really careful when doing this.
  1676. =======================================================================
  1677. = The End =
  1678. Thanks for reading! :)
  1679. URLWEBSITE
  1680. %nopdf([see source userguide.t2t])
  1681. %nopdf[../../img/t2tpowered.png]
  1682. % TRANSLATOR: You can stop here.
  1683. %%%% OLD TEXTS, NOT USED ANYMORE
  1684. %
  1685. % == Split and language features (only for HTML target) ==
  1686. %
  1687. % ---
  1688. % usage: txt2tags -t html --split <split level> --lang <lang> file.t2t
  1689. %
  1690. % --split split documents. values: 0, 1, 2 (default 0)
  1691. % --lang document language (default english)
  1692. % ---
  1693. %
  1694. % For those who have [sgml-tools http://www.sgmltools.org] installed and
  1695. % running on the system, when generating HTML documents, the split and
  1696. % language features are available. First a SGML text is generated and the
  1697. % sgml2html binary is called.
  1698. %
  1699. % From sgml2html man page:
  1700. % | 0 | don't split |
  1701. % | 1 | split by major sections |
  1702. % | 2 | split by subsections |
  1703. %
  1704. %
  1705. % ------------------------------------------------------------------------
  1706. %
  1707. % == EXTRA I ==
  1708. %
  1709. % Cool Vim and Emacs syntax files sync'ed with all the rules.
  1710. % See `txt2tags.vim` and `txt2tags-mode.el` on the `extras` dir.
  1711. %
  1712. % BONUS: there's also a `pagemaker.vim` for the .pm6 files.
  1713. %
  1714. % ------------------------------------------------------------------------
  1715. %
  1716. % == EXTRA II ==
  1717. %
  1718. % For those who have the (1) package installed, the (2) target
  1719. % is available! The package is found here: (3)
  1720. %
  1721. % | 1 | 2 | 3 |
  1722. % | sgml-tools | ps | http://www.sgmltools.org |
  1723. % | ghostscript | pdf | http://www.cs.wisc.edu/~ghost |
  1724. %
  1725. %
  1726. % And remember, from SGML you can convert to lots of types, see sgml2* on
  1727. % the sgml-tools package.
  1728. %
  1729. % PostScript Example:
  1730. % --- prompt$ sgml2latex -o ps --language=english file.sgml
  1731. %
  1732. % PDF Example:
  1733. % --- prompt$ ps2pdf file.ps
  1734. %
  1735. %
  1736. % ------------------------------------------------------------------------