File: userguide.t2t

package info (click to toggle)
txt2tags 3.9-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,160 kB
  • sloc: python: 3,002; sh: 45; makefile: 35
file content (1646 lines) | stat: -rw-r--r-- 61,447 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
Txt2tags User Guide

Aurelio Jargas
%!target: html
%!options: --toc --style userguide.css

% easy way to change all image locations once, when changing file location
%!preproc: IMGPATH .

% normalizing common text
%!preproc: CONFAREA Config Area
%!preproc: HEADAREA Header Area
%!preproc: BODYAREA Body Area
%!preproc: MARKPROP **Properties:**
%!preproc: MARKCONT **Contains:**
%!preproc: MARKDESC **Description:**
%!preproc: MARKSYN  **Syntax:**
%!preproc: MARKDET  **Details:**
%!preproc: NOMARKS  Marks are NOT interpreted

%!preproc: URLMARKUP    URLWEBSITE/markup.html
%!preproc: URLWEBSITE   http://txt2tags.org

% remove separator lines and strong lines
%!preproc(html): '^ *--------*'  ''
%!preproc(html): '^ *========*'  ''

========================================================================

= About =

This is the [txt2tags URLWEBSITE] User Guide, the
complete manual about the program.

========================================================================

= Part I - Introducing Txt2tags =[intro]

== The First Questions You May Have ==[1st-questions]

This chapter is a txt2tags overview, that will introduce the program
purpose and features.

------------------------------------------------------------------------

=== What is it? ===

Txt2tags is a text formatting and conversion tool.

Txt2tags converts a plain text file with markup to a number of
target formats (see below for the list of targets).

------------------------------------------------------------------------

=== Why should I use it? ===

You'll find txt2tags really useful if you:
- Need to publish documents in different formats
- Need to maintain updated documents in different formats
- Write technical documents or guides
- Don't know how to write a document in a specific format
- Don't have an editor for a specific format
- Want to use a simple text editor to update your documents


And the main motivation is:
- Save time, writing **contents** and forgetting about **formatting**


------------------------------------------------------------------------

=== Why is it a good choice among other tools? ===

Txt2tags has a very straight way of growing, following basic concepts.
These are the highlights:

| //Source File Readable// | Txt2tags marks are very simple, almost natural.
| //Target Document Readable// | The target document is also readable, with indentation and spacing.
| //Consistent Marks// | Txt2tags marks are simple symbols, designed to be unique enough to don't mix up with the document contents.
| //Consistent Rules// | As the marks, the rules that applies to them are tied to each other, there are no "exceptions" or "special cases".
| //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.
| //Easy to Learn// | With simple marks and readable source, the txt2tags learning curve is user friendly.
| //Nice Examples// | The **sample files** included on the package gives real life examples of documents written for txt2tags.
| //Valuable Tools// | The **syntax files** included on the package help you to write documents with no syntax errors.
| //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.
| //Scripting// | With the full featured command line mode, an experienced user can **automatize** tasks and do **post-editing** on the converted files.
| //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.
| //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.


------------------------------------------------------------------------

=== Do I have to pay for it? ===

Txt2tags is free under the GPL license version 2 or later.

------------------------------------------------------------------------


== Supported Formatting Structures ==[structures]

The following is a list of all the structures supported by txt2tags.

- header (document title, author name, date)
- section title (numbered or not)
- paragraphs
- font beautifiers
  - bold
  - italic
  - underline
  - strike
- monospaced font (verbatim)
  - monospaced inside paragraph
  - monospaced line
  - monospaced area (multiline)
- quoted area
- link
  - URL/Internet links
  - e-mail links
  - local links
  - named links
- lists
  - bulleted list
  - numbered list
  - definition list
- horizontal separator line
- image (with smart alignment)
- table (with or without border, smart alignment, column span)
- special mark for raw text (no marks parsed inside)
- special mark for tagged text (no parsing, sent directly to output)
- comments (for self notes, TODO, FIXME)


------------------------------------------------------------------------

== Supported Targets ==[targets]

: **HTML**

  Txt2tags generates clean HTML documents, that look pretty and have
  its source readable. It DOES NOT use javascript, frames or other
  futile formatting techniques, that aren't required for simple, techie
  documents. But a separate CSS file can be used if wanted.

  Txt2tags HTML generated code is 100% approved by the [w3c validator http://validator.w3.org/].

: **SGML**
  It is a common document format which has powerful conversion applications
  ([linuxdoc-tools http://packages.debian.org/linuxdoc-tools]). From a
  single SGML file you can generate HTML, PDF, PostScript, Info, LaTeX, LyX, RTF
  and XML documents. The tools also does automatic TOC and break
  sections into subpages.

  Txt2tags generates SGML files in the LinuxDoc system type, ready to
  be converted with linuxdoc-tools without any extra catalog files or any
  SGML annoying requirements.

: **LATEX**
  The preferred academic document format, it is more powerful than you
  ever wondered. Full books, complicated formulas and any complex text
  can be written in LaTeX. But prepare to loose your hair when you try
  to write the tags by hand...

  Txt2tags generates ready-to-use LaTeX files, doing all the complex
  escaping tricks and exceptions. The writer just need to worry about
  the text.

: **LOUT**
  Very similar to LaTeX in power, but with an easier syntax using "@"
  instead "\" and avoiding the need of braces in common situations. Its
  approach of everything-is-an-object makes the tagging much saner.

  Txt2tags generates ready-to-use Lout files, which can be converted do
  PS or PDF files using the "lout" command.

: **MAN**
  UNIX man pages resist over the years. Document formats come and go,
  and there they are, unbeatable.

  There are other tools to generate man documents, but txt2tags has
  one advantage: one source, multi targets. So the same man page
  contents can be converted to an HTML page, Wiki document and plain text.

: **MGP**
  [MagicPoint http://en.wikipedia.org/wiki/MagicPoint] is a very handy presentation tool
  (hint: Microsoft PowerPoint), that uses a tagged language to define all
  the screens. So you can do complex presentations in vi/emacs/notepad.

  Txt2tags generates a ready-to-use .mgp file, defining all the
  necessary headers for fonts and appearance definitions, as long as
  international characters support.

  Txt2tags creates "diet" .mgp files: they use the Type1 fonts, so you do not
  need to carry TrueType fonts files with your presentation. Also, the color
  definitions are simple, so even on a poor color palette system (such as
  ``startx -- -bpp 8``), the presentation will look pretty!

  The key is: convert and use. No quick fixes or requirements needed.

: **WIKI**
  You've heard about the [Wikipedia http://wikipedia.org], right? So you
  don't need to learn yet-another markup syntax. Just stick with txt2tags
  and let it convert your text to the Wikipedia format, called
  [MediaWiki http://en.wikipedia.org/wiki/MediaWiki].

: **GWIKI**
  Now you can easily paste your project's current documentation into the
  [Google Code http://code.google.com/] Wiki.

: **DOKU**
  [DokuWiki http://www.dokuwiki.org/dokuwiki] is a standards
  compliant, simple to use Wiki, mainly aimed at creating documentation
  of any kind. It is targeted at developer teams, workgroups and small
  companies. It has a simple but powerful syntax which makes sure the
  data files remain readable outside the Wiki and eases the creation of
  structured texts. All data is stored in plain text files - no
  database is required.

: **MOIN**
  You don't know what [MoinMoin http://moinmo.in/] is?
  It is a [WikiWiki http://www.c2.com/cgi/wiki]!

  Moin syntax is kinda boring when you need to keep
  ``{{{'''''adding braces and quotes'''''}}}``, so txt2tags comes with the
  simplified marks and unified solution: one source, multi targets.

: **TXT**
  TXT is text. Simple, pure, beautiful.

  Although txt2tags marks are very intuitive and discrete, you can remove
  them by converting the file to pure TXT.

  The titles are underlined, and the text is basically left as is on the
  source.


Tip: Use the ``--targets`` command line option to get a complete list of
all the available targets.

------------------------------------------------------------------------

== Status of Supported Structures by Target ==[struct-support]

  || Structure        | html | sgml | dbk | tex | lout | man | mgp | creole | wiki | gwiki | pmw | doku | moin | adoc | txt |
  | headers           |  Y   |  Y   |  Y  |  Y  |  Y   |  Y  |  Y  |   -    |  -   |   -   |  Y  |  -   |  -   |  -   |  Y  |
  | section title     |  Y   |  Y   |  Y  |  Y  |  Y   |  Y  |  Y  |   Y    |  Y   |   Y   |  Y  |  Y   |  Y   |  Y   |  Y  |
  | paragraphs        |  Y   |  Y   |  Y  |  Y  |  Y   |  Y  |  Y  |   Y    |  Y   |   Y   |  Y  |  Y   |  Y   |  Y   |  Y  |
  | bold              |  Y   |  Y   |  Y  |  Y  |  Y   |  Y  |  Y  |   Y    |  Y   |   Y   |  Y  |  Y   |  Y   |  Y   |  -  |
  | italic            |  Y   |  Y   |  Y  |  Y  |  Y   |  Y  |  Y  |   Y    |  Y   |   Y   |  Y  |  Y   |  Y   |  Y   |  -  |
  | underline         |  Y   |  -   |  Y  |  Y  |  Y   |  -  |  Y  |   -    |  Y   |   -   |  Y  |  Y   |  Y   |  N   |  -  |
  | strike            |  Y   |  N   |  N  |  Y  |  -   |  -  |  -  |   -    |  Y   |   Y   |  Y  |  Y   |  Y   |  N   |  -  |
  | monospaced font   |  Y   |  Y   |  Y  |  Y  |  Y   |  -  |  Y  |   -    |  Y   |   Y   |  Y  |  Y   |  Y   |  Y   |  -  |
  | verbatim line     |  Y   |  Y   |  Y  |  Y  |  Y   |  Y  |  Y  |   Y    |  Y   |   Y   |  Y  |  Y   |  Y   |  Y   |  -  |
  | verbatim area     |  Y   |  Y   |  Y  |  Y  |  Y   |  Y  |  Y  |   Y    |  Y   |   Y   |  Y  |  Y   |  Y   |  Y   |  -  |
  | quoted area       |  Y   |  Y   |  Y  |  Y  |  Y   |  Y  |  Y  |   Y    |  Y   |   Y   |  Y  |  Y   |  Y   |  N   |  Y  |
  | internet links    |  Y   |  Y   |  Y  |  -  |  -   |  -  |  -  |   Y    |  Y   |   Y   |  Y  |  Y   |  Y   |  Y   |  -  |
  | e-mail links      |  Y   |  Y   |  Y  |  -  |  -   |  -  |  -  |   Y    |  Y   |   Y   |  Y  |  Y   |  Y   |  Y   |  -  |
  | local links       |  Y   |  Y   |  Y  |  N  |  N   |  -  |  -  |   N    |  N   |   N   |  Y  |  Y   |  Y   |  N   |  -  |
  | named links       |  Y   |  Y   |  Y  |  -  |  -   |  -  |  -  |   Y    |  Y   |   Y   |  Y  |  Y   |  Y   |  Y   |  -  |
  | bulleted list     |  Y   |  Y   |  Y  |  Y  |  Y   |  Y  |  Y  |   Y    |  Y   |   Y   |  Y  |  Y   |  Y   |  Y   |  Y  |
  | numbered list     |  Y   |  Y   |  Y  |  Y  |  Y   |  Y  |  Y  |   Y    |  Y   |   Y   |  Y  |  Y   |  Y   |  Y   |  Y  |
  | definition list   |  Y   |  Y   |  Y  |  Y  |  Y   |  Y  |  N  |   Y    |  Y   |   -   |  Y  |  -   |  Y   |  N   |  Y  |
  | horizontal line   |  Y   |  -   |  N  |  Y  |  Y   |  -  |  Y  |   Y    |  Y   |   -   |  Y  |  Y   |  Y   |  N   |  Y  |
  | image             |  Y   |  Y   |  Y  |  Y  |  Y   |  -  |  Y  |   Y    |  Y   |   Y   |  Y  |  Y   |  Y   |  Y   |  -  |
  | table             |  Y   |  Y   |  N  |  Y  |  N   |  Y  |  N  |   Y    |  Y   |   Y   |  Y  |  Y   |  Y   |  N   |  N  |
  || Extras           | html | sgml | dbk | tex | lout | man | mgp | creole | wiki | gwiki | pmw | doku | moin | adoc | txt |
  | image align       |  Y   |  N   |  N  |  N  |  Y   |  -  |  Y  |   N    |  Y   |   -   |  N  |  Y   |  N   |  N   |  -  |
  | table cell align  |  Y   |  Y   |  N  |  Y  |  N   |  Y  |  N  |   N    |  N   |   -   |  N  |  -   |  Y   |  N   |  N  |
  | table column span |  Y   |  N   |  N  |  Y  |  N   |  N  |  N  |   N    |  N   |   -   |  N  |  -   |  N   |  N   |  N  |

  ||      | Legend
  | **Y** | //Supported//
  | **N** | //Not supported (may be in future releases)//
  | **-** | //Not supported (can't be done on this target)//

------------------------------------------------------------------------

== Command Line Interface ==[cmdline]

Please use ``txt2tags --help`` to see the command line options.

Examples:

| **Convert to HTML**             | ``$ txt2tags -t html file.t2t``
| **The same, using redirection** | ``$ txt2tags -t html -o - file.t2t > file.html``
|  | .
| **Including Table Of Contents** | ``$ txt2tags -t html --toc file.t2t``
| **And also, numbering titles**  | ``$ txt2tags -t html --toc --enum-title file.t2t``
|  | .
| **One liners from STDIN**       | ``$ echo -e "\n**bold**" | txt2tags -t html --no-headers -``


========================================================================



= Part II - Install =[install]

Just download the program and run it on your machine.

== Download & Install Python ==[download-python]

First of all, you must download and install [Python http://www.python.org] on
your system.

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.

If you are not sure if you have Python or not, open a console (tty,
xterm, MSDOS, Terminal.app) and type ``python``. If it is not installed, the system
will tell you.


== Download txt2tags ==[download-txt2tags]

The official location for txt2tags distribution is on the program
site, at URLWEBSITE. Just download and uncompress the package (.tgz file).

If you're in Linux, you can also use the automatic installer of your system. Some examples:
- yum install txt2tags
- sudo apt-get install txt2tags
-

% All the program's files are on the tarball (.tgz file), which can be
% expanded by most of the compression utilities (including Winzip).

% Just get the **latest** one (more recent date, higher version number).
% The previous versions remains for historical purposes only.



== Install txt2tags ==[install-txt2tags]

See README.md for installation instructions.


= Part III - Writing and Converting Your First Document =[your-1st-doc]

== Check the Tools ==

To make the first conversion you will need three things: txt2tags, a
text editor and a web browser.

+ Make sure txt2tags is installed and running on your system.

  - **Command Line Interface:** Call "txt2tags" on the command line and
    the program should give you a "Missing input file" message. If it is
    not working, try ``python /path/to/txt2tags`` or even
    ``/path/to/python /path/to/txt2tags`` if Python is not on your PATH.

+ Open the text editor your are comfortable with. Create a
  brand new empty document to be your first txt2tags one and remember to
  save it as plain text.

+ Launch your favorite web browser to see the results of the conversion.


------------------------------------------------------------------------

== Write the Document Header ==

+ Go to the text editor and on the very first line type the document
  main title: //My First Document//
+ On the second line make a subtitle, inserting this text:
  //A txt2tags test//
+ Then, on the third line, put some time information:
  //Sunday, 2004//


If everything went right, you should be seeing a three line document
with this contents:

```
My First Document
A txt2tags test
Sunday, 2004
```

This is just a part of the document, but we can already convert it and
check the results.

Now save this document with the name ``test.txt``. Remember to save it
as plain text. Pay attention to which folder you are saving the file,
you will need to remember it soon.


------------------------------------------------------------------------

== The First Conversion - Command Line Interface ==

If you are in the Command Line Interface, move to the folder where the
file was saved and type this command:

``` txt2tags --target html test.txt

The option ``--target`` is followed
by the "html" string, which tells the program to what format your text
file will be converted. The last item is the text filename.

The results were saved to the ``test.html``
file and then the program will show you the
"//txt2tags wrote test.html//" message.
If some error occurred, read the message carefully.

Here is a sample of how it will be shown on your screen:
```
prompt$ txt2tags --target html test.txt
txt2tags wrote test.html
prompt$
```

------------------------------------------------------------------------

== Check the Results ==

Open the ``test.html`` file on the web browser to check if everything
is ok.

[IMGPATH/firstdoc-html.png]

Here it is! You just typed three simple lines of text and txt2tags made
all the work to set the HTML page heading information, text alignment,
sizes, spacing and appearance. See that the main title is also placed at the
browser title bar.

    You write text, txt2tags does the rest ;)

Tip: You can also use CSS files on HTML pages generated by txt2tags, so the
page appearance is 100% configurable.

------------------------------------------------------------------------

== Writing the Document Body ==

Now back to the text editor, the next step is to type the document
contents. You can write plain text as you normally do on email messages.
You will see that txt2tags recognizes paragraphs and list of items
automatically, you don't have to "mark" them.

Then again: save it, convert and check the results. This is the
development cycle of a document in txt2tags. You just focus on the
document contents, finishing documents faster than other editors. No
mouse clicking, no menus, no windows, no distraction.

Considering the following contents for the ``test.txt`` file, which is
only plain text, compare the generated HTML page:

```
My First Document
A txt2tags test
Sunday, 2004

Well, let's try this txt2tags thing.
I don't know what to write.

Mmmmmm, I know what I need to do now:
- Take a shower
- Eat a pizza
- Sleep
```

[IMGPATH/firstdoc-fullhtml.png]


You can write a full homepage with 0% of HTML knowledge. You don't need
to insert any tags. And more, the same text file can be converted to any
of the other txt2tags supported formats.

Besides plain text, txt2tags has some very simple marks, that you'll
use when you need some other formatting or structures like bold, italic,
title, images, table and other. As a quick sample,
``**stars for bold**`` and ``== equals for title ==``. You can learn the
marks on the [Txt2tags Markup Demo URLWEBSITE/markup.html].

=======================================================================



= Part IV - Mastering Txt2tags Concepts =[concepts]

== The .t2t document Areas ==[areas]

Txt2tags marked files are divided in 3 areas. Each area has its own
rules and purpose. They are:

: //HEADAREA//
  Place for Document Title, Author, Version and Date information.
: //CONFAREA//
  Place for general Document Settings and Parser behavior modifiers.
: //BODYAREA//
  Place for the Document Content.


All areas are optional. You can write a txt2tags document with just
headers (such as our first example), or a document with no headers or settings.

The areas are delimited by special rules, which will be seen in detail
on the next chapter. For now, this is a representation of the
areas on a document:

```
             ____________
            |            |
            |   HEADERS  |       1. First, the Headers
            |            |
            |   CONFIG   |       2. Then the Settings
            |            |
            |    BODY    |       3. And finally the Document Body,
            |            |
            |    ...     |          which goes until the end
            |    ...     |
            |____________|

```

In short, this is how the areas are defined:

 |  **Headers**  | First 3 lines of the file, or the first line blank for No Headers.
 |  **Config**   | Begins right after the Header (4th or 2nd line) and ends when the //BODYAREA// starts.
 |   **Body**    | The first valid text line (not comment or setting) after the //HEADAREA//.


=== Full Example ===

```
My nice doc Title
Mr. John Doe
My Date

%!target  : html
%!style   : fancy.css
%!options : --toc --enum-title

Hi! This is my test document.
Its content will end here.
```

------------------------------------------------------------------------

== HEADAREA ==[headers-area]

Location:
- Fixed position: **First 3 lines** of the file. Period.
- Fixed position: **First line** of the file if it is blank. This
  means Empty Headers.


The HEADAREA is the only one that has a fixed position, line
oriented. They are located at the first three lines of the source file.

These lines are content-free, with no static information type needed.
But the following is recommended:

- //line 1//: document title
- //line 2//: author name and/or email
- //line 3//: document date and/or version


Keep in mind that the first 3 lines of the source document will be the
first 3 lines on the target document, separated and with high contrast
to the text body (i.e. big letters, bold). If paging is allowed, the
headers will be alone and centralized on the first page.


==== Less (or None) Header lines ====

Sometimes the user wants to specify less than three lines for headers,
giving just the document title and/or date information.

Just let the 2nd and/or the 3rd lines empty (blank) and this position
will not be placed at the target document. But keep in mind that even
blanks, these lines are still part of the headers, so the document body
must start **after** the 3rd line anyway.

The title is the only required header (the first line), but if you
leave it blank, you are saying that your document has **no headers**.
So the //BODYAREA// will begin right after, on the 2nd line.

No headers on the document is often useful if you want to specify your
own customized headers after converting. The command line option
``--no-headers`` is usually required for this kind of operation.

==== Straight to the point ====

In short: **"Headers are just __positions__, not contents"**

Place one text on the first line, and it will appear on the target's
first line. The same for 2nd and 3rd header lines.

------------------------------------------------------------------------

== CONFAREA ==[config-area]

Location:
- Begins right after the HEADAREA
  - Begins on the **4th line** of the file if **Headers** were specified
  - Begins on the **2nd line** of the file if **No Headers** were specified
- Ends when the BODYAREA starts
  - Ends by a non Setting, Blank or Comment line


The CONFAREA is optional. An average user can write lots of txt2tags
files without even know it exists, but the experienced users will
enjoy the power and control it provides.

The CONFAREA is used to store document-specific settings, so you don't
have to type them on the command line when converting the document. For
example, you can set the default document target type.

Please read the [Settings section #settings-overview] for more
information about them.

----------------------------------------------------------------

== BODYAREA ==[body-area]

Location:
- Begins on the first valid text line of the file
  - Headers, Settings and Comments are **not** valid text lines
- Ends at the end of the file (EOF)


The body is anything outside Headers and Config Areas.

The body holds the document contents and all formatting and structures
txt2tags can recognize. Inside the body you can also put comments for
//TODOs// and self notes.

You can use the ``--no-headers`` command line option to convert only the
document body, suppressing the headers. This is useful to set your own
headers on a separate file, then join the converted body.

----------------------------------------------------------------

== Settings ==[settings-overview]

Settings are special configurations placed at the source document's
CONFAREA that can affect the conversion process. Their syntax is:

``` %! keyword : value

List of valid keywords:

 || Keyword   | Description |
 |   Target   | Set the default target to the document be converted to.
 |  Options   | Set the default options to be used on the conversion. The format is the same as the command line options.
 |   Style    | Set the document style. Used to define a CSS file for HTML/XHTML and to load a package in LaTeX.
 |   PreProc  | Input filter. Sets "find and replace" rules to be applied on the BODYAREA of the source document.
 |  PostProc  | Output filter. Sets "find and replace" rules to be applied on the converted document.

Example:

```
%!target  : html
%!options : --toc
%!style   : fancy.css
%!preproc : "AMJ"        "Aurelio Marinho Jargas"
%!postproc: '<BODY.*?>'  '<BODY bgcolor="yellow">'
```

Note that the spacing and capitalization of the keyword are ignored. So you can also do ``%!Target:html`` and  ``%! TARGET :html``.

Learn more about settings in [Part VII - Mastering Settings #settings].

-----------------------------------------------------------------------

== Command Line Options ==[options]

The fastest way of changing the txt2tags default behavior is to use
command line options.

Just like the other system's tools, the program do accept a set of
predefined options. An option is an hyphen followed by a letter or two
hyphens followed by one or more words, like ``-t`` and ``--target``.
% Talking about the target option, it is the only required one, the others
% are optional.

Options that are generally used are ``--outfile`` to define a customized
output file name and ``--toc`` to turn on the automatic TOC generation.
Most of the options can be turned off prefixing a "no-" before its name,
for example: ``--no-toc``.

You can register the desired options for a source file inside its
CONFAREA, using the ``%!options`` setting. This way you don't have to
type them on the command line anymore.
Example:

``` %!options: --toc -o mydoc.html

The exception is the target specification, that has its own setting:

``` %!target: html

Use the ``--help`` option to get a complete list of all the options
available in txt2tags.

Learn more about [%!options #setting-options] and [%!target #setting-target].

-----------------------------------------------------------------------

== User Configuration File (RC File) ==[rc]

The user configuration file (also called RC file) is a central place to
store the settings that will be shared by ALL converted files. If you
keep inserting the same settings on every .t2t file you write, move it
to the RC file and it will be used globally, for existing and future
source files.

The default location of this file depends on your system. It can also be
specified by the user, using an environment variable.

  ||              RC file location             ||
  |          Windows | ``%HOMEPATH%\_t2trc``
  | UNIX, Linux, Mac | ``$HOME/.txt2tagsrc``
  |     User defined | ``T2TCONFIG`` variable


The format of the settings is exactly the same as the ones used on the
.t2t files CONFAREA. There is a sample RC file on the package at
``doc/txt2tagsrc``. Example:

```
% my configs

%%% Add a TOC for all targets.
%!options: --toc
```

Any line that is not blank, a comment or a valid config line will raise
error when txt2tags runs. So be careful when editing this file.

Txt2tags automatically apply the RC file contents into any source file it
is converting. If you want to disable this behavior for a specific
file, use the ``--no-rc`` command line option.

== Configuration Loading Order and Precedence ==[config-loading]

There are three ways of telling txt2tags which options and settings to
use, and this is the order that they are read and applied:

+ The user configuration file (RC) settings
+ The source document CONFAREA settings
+ The command line options


First txt2tags reads the RC file contents (if any) and apply its
configurations on the current source file. Then it scans the source
document CONFAREA for settings and if found, they are applied also,
overriding the RC ones in case of conflict. Finally comes the command
line options, stronger than the other two.

-----------------------------------------------------------------------

== %!include command ==[include]

The ``include`` command is used to paste the contents of an external
file into the source document body. It is not a config, but a command,
and it is valid on the document BODYAREA.

The ``include`` command is useful to split a large document into smaller
pieces (like chapters in a book) or to include the full contents of an
external file into the document source. Sample:

```
My first book
Dr. John Doe
1st Edition

%!include: intro.t2t
%!include: chapter1.t2t
%!include: chapter2.t2t
...
%!include: chapter9.t2t
%!include: ending.t2t
```

You just inform the filename after the ``%!include`` string. The
optional target specification is also supported, so this is valid
either:

``` %!include(html): file.t2t

Note that include will insert the file BODYAREA into the source
document. The included file Header and Config Areas are ignored. This
way you can convert the included file alone or inside the main document.

But there's another three types of include:
- Verbatim include
- Raw include
- Tagged include


The **Verbatim** type includes a text file preserving its original
spaces and formatting, just like if the text was inside the txt2tags
Verbatim area (```). To specify this type, enclose the filename with
backquotes:

``` %!include: ``/etc/fstab``

The **Raw** type includes a text file as is, not trying to find and
parse txt2tags marks on it, just like if the text was inside the Raw
area ("""). To specify this type, enclose the filename with double
quotes:

``` %!include: ""nice_text.txt""

And the **Tagged** type is passed directly to the resulting document,
with NO parsing or escaping performed by txt2tags. This way you can
include additional tagged parts to your document. Useful for default
header or footer information, or more complicated tagged code,
unsupported by txt2tags:

``` %!include(html): ''footer.html''

Note that the filename is enclosed with single quotes. As the text
inserted is already parsed, you should specify the target to avoid
mistakes.

-----------------------------------------------------------------------

== %!includeconf command ==[includeconf]

The ``includeconf`` command is used to include configurations from an
external file into the current one. This command is valid inside the
source document CONFAREA only.

It is useful to share the same config for multiple files, so you can
centralize it. On any file do you want to include that central
configuration, put a ``includeconf`` call. Example:

```
My First Document
John Doe
July, 2004

%!includeconf: config.t2t

Hi, this is my first document.
```

The format inside the included file is the same as in the
[RC file #rc].

Note that the optional target specification is NOT supported for this command.

```
%!includeconf: config.t2t            <--- OK
%!includeconf(html): config.t2t      <--- NOT OK
```

=======================================================================



= Part V - Mastering Marks =[marks]

Overview of all txt2tags marks:
 ||                   Basic                   ||               Beautifiers          ||
 |          //Headers// |  First 3 lines       |            //Bold// |  ""**words**""
 |            //Title// |  = words =           |          //Italic// |  ""//words//""
 |   //Numbered title// |  + words +           |       //Underline// |  ""__words__""
 |        //Paragraph// |  words               |          //Strike// |  ""--words--""
 |            //Links// |  ""[label url]""     |      //Monospaced// |  ""``words``""
 |            //Image// |  ""[filename.jpg]""  |        //Raw text// |  """"words""""
 |                                            ||     //Tagged text// |  ""''words''""
 ||                                          Other                                ||||
 |            //Quote// |  <TAB>words          |  //Separator line// |  ------------...
 |             //List// |  - words             |     //Strong line// |  ============...
 |    //Numbered list// |  + words             |           //Table// |  ""| cell1 | cell2 | cell3...""
 |  //Definition list// |  : words             |          //Anchor// |  = title =[anchor]
 |     //Comment line// |  % comments          |    //Comment area// |  %%%\n comments \n%%%
 |    //Verbatim line// |  ""```"" word        |   //Verbatim area// |  ""```\n lines \n```""
 |         //Raw line// |  """"""" words       |        //Raw area// |  """""""\n lines \n"""""""
 |      //Tagged line// |  ""'''"" words       |     //Tagged area// |  ""'''""\n lines \n""'''""


General Rules:

- **Headers** are the first three document lines, marks are not interpreted.
- **Titles** are balanced "=" or "+" chars around the title text. The more chars, more deep is the title.
- **Beautifiers** don't accept spaces between the marks and its contents.
- The **Comment** mark "%" must be at the line beginning (first column).
- **Images** filename must end in GIF, JPG, PNG or similar.
- The only **multiline** marks are the Comment, Verbatim, Raw and Tagged areas.
- No mark is **interpreted** inside Verbatim, Raw and Tagged.
- The **Separator/Strong lines** must have at least 20 chars.
- Quote and lists **(un)nesting** is defined by indent.
- A **Table title** line is defined by two || at the beginning of the line.


------------------------------------------------------------------------
%- MARKPROP Multiline, FreeSpaces, Align, Nesting
%- MARKCONT Beautifiers, Quote, Lists, Table, Verbatim, Raw, Tagged, Bars, Links, Image, Comment
%-----------------------------------------------------------------------

== Headers ==[mark-headers]

- MARKDESC Identifies the document headers
- MARKPROP Multiline, FreeSpaces, !Align, !Nesting
- MARKSYN
  - The first 3 lines of the source file.
  - Leave the first line blank to not specify headers at all.
    Nice for command line one-liners or customized headers.
  - Leave the second and/or third lines blank to omit parts of header.
- MARKDET
  - NOMARKS
  - The first 3 lines will be the first 3 lines on the target document,
    with high contrast to text body, or will be placed alone on the
    first page (if paging is allowed).
  - The headers are content-free, with no static information type
    needed. But the following is recommended for the most documents:
    - Line 1: Document title
    - Line 2: Author name and/or email
    - Line 3: Document date and/or version


------------------------------------------------------------------------

== Title, Numbered Title ==[mark-title]

- MARKDESC Identifies a (numbered or not) section title
- MARKPROP !Multiline, FreeSpaces, !Align, !Nesting
- MARKCONT -
- MARKSYN
  - For Numbered Title, just change "=" by "+" on the following rules
  - Balanced equal signs around, ``=like this=``
  - More signs, more sublevels: ``=title=``, ``==subtitle==``,
    ``===subsubtitle===``, ...
  - There is a maximum of 5 levels, ``=====like this=====``
  - Unbalanced equals are not title, ``=like this===``
  - Free spacing inside the marks are allowed, ``=       like this  =``
  - Titles can have an anchor ``=like this=[anchor]``. To link to an anchor
    create a ``[local link #anchor]``
  - The anchor name can contain only letters, numbers, underscore
    and hyphen (A-Za-z0-9_-)
- MARKDET
  - NOMARKS


------------------------------------------------------------------------

== Paragraph ==[mark-paragraph]

- MARKDESC Identifies a paragraph of text
- MARKPROP Multiline, FreeSpaces, !Align, !Nesting
- MARKCONT Beautifiers, Raw, Tagged, Links, Image, Comment
- MARKSYN
  - Paragraphs are groups of lines delimited by blank lines
  - Other blocks like lists, quote, table or verbatim also ends a
    paragraph


------------------------------------------------------------------------

== Comment ==[mark-comment]

- MARKDESC Used to insert text that will not appear on the target
  document
- MARKPROP !Multiline, !FreeSpaces, !Align, !Nesting
- MARKCONT -
- MARKSYN
  - A line beginning with a percent char at the first column, ``% like this``
  - NO leading spaces
- MARKDET
  - As comments, they're not showed on the converted text
  - Not a block, so each comment line must begin with %
  - Useful for TODO and FIXME reminders and editor's notes


------------------------------------------------------------------------

== Comment Area ==[mark-comment-block]

- MARKDESC Used to insert text that will not appear on the target
  document
- MARKPROP Multiline, !FreeSpaces, !Align, !Nesting
- MARKCONT -
- MARKSYN
  - A line with exactly 3 consecutive percents ``%%%``, followed by
    text lines, followed by another line with exactly 3 consecutive
    percents ``%%%``
  - NO spaces allowed before or after the marks
- MARKDET
  - As comments, they're not showed on the converted text
  - Useful for deactivate (not delete) large portions of the contents
  - If the end of the source file (EOF) is hit, the opened Comment Area
    is closed


---------------------------------------------------------------------

== Bold, Italic, Underline, Strike ==[mark-beautifiers]

- MARKDESC Used to insert a bold/italic/underline/strike text inside a
  paragraph, table, list or quote
- MARKPROP !Multiline, !FreeSpaces, !Align, Nesting
- MARKCONT Beautifiers, Raw, Tagged, Links, Image
- MARKSYN
  - Two starts around for bold, ``**like this**``
  - Two slashes around for italic, ``//like this//``
  - Two underlines around for underline, ``__like this__``
  - Two hyphens around for strike, ``--like this--``
  - The marks must be glued with the contents (no spaces):
    ``** this ** is invalid``
- MARKDET
  - All the beautified text must be on a single line of the source file,
    no line breaks inside
  - You can mix beautifiers one inside another,
    ``""**__like__ //this//**""``


------------------------------------------------------------------------

== Monospaced ==[mark-monospaced]

- MARKDESC Used to insert a monospaced text inside a paragraph, table,
  list or quote
- MARKPROP !Multiline, !FreeSpaces, !Align, !Nesting
- MARKCONT -
- MARKSYN
  - Two backquotes around, ````like this````
  - The marks must be glued with the contents (no spaces):
    ```` this `` is invalid``
- MARKDET
  - NOMARKS
  - All the monospaced text must be on a single line of the source file,
    no line breaks inside
  - In some targets, the internal spacing is maintained, in others the
    consecutive spaces are squeezed to one
  - You can make a bold monospaced text enclosing it inside bold marks:
    ``""**``monobold``**""``. The same applies to the other beautifiers
    such as ``""//``italic``//""`` and ``""__``underline``__""``.


---------------------------------------------------------------------

== Verbatim Line, Verbatim Area ==[mark-verbatim]

- MARKDESC Used to insert programming codes or other pre-formatted text,
  preserving spacing and line breaks, and using a monospaced font
- MARKPROP Multiline, !FreeSpaces, !Align, !Nesting
- MARKCONT -
- MARKSYN **Verbatim Line:**
  - A line beginning with 3 consecutive backquotes, followed by a space,
    followed by the text, ``""```"" like this``
  - The backquotes must be at the start of the line, no spaces before
- MARKSYN **Verbatim Area:**
  - A line with exactly 3 consecutive backquotes ```````, followed by
    text lines, followed by another line with exactly 3 consecutive
    backquotes ```````
  - NO spaces allowed before or after the marks
- MARKDET
  - NOMARKS
  - If the end of the source file (EOF) is hit, the opened Verbatim Area
    is closed


---------------------------------------------------------------------

== Separator Line, Strong Line ==[mark-separator]

- MARKDESC Identifies a separator or strong line
- MARKPROP !Multiline, FreeSpaces, !Align, !Nesting
- MARKCONT -
- MARKSYN
  - The separator line can be composed by dashes "-" or underscores "_"
  - The strong line is composed by equals "="
  - Use at least least 20 dashes/underscores/equal signs
  - Optional spaces can be placed at the line start or end
  - Any other characters on the line invalidate the mark
- MARKDET
  - If the target does not have separator line support, a commented line
    is used instead
  - The strong line may have different behaviors on some targets:
    - A larger separator line
    - A pause on presentation formats, like MagicPoint
    - A page break in paged targets, like LaTeX


---------------------------------------------------------------------

== Links, Named Links ==[mark-link]

- MARKDESC Identifies a remote (Internet) or local link
- MARKPROP !Multiline, !FreeSpaces, !Align, !Nesting
- MARKCONT Raw, Tagged, Image
- MARKSYN
  - Any valid internet URL, ftp, news or email address is detected and
    converted automatically
  - The protocol (http, https, ftp) is optional, ``www.likethis.com``
  - A name can be used for a link: ``[click here www.url.com]``
  - An image can point to a link: ``[[image.jpg] www.url.com]``
% - Beautifiers are allowed on the link name: ``[**click** here www.url.com]``
  - All the link specification must be on a single line of the source
    file, no line breaks inside
- MARKDET
  - If the target does not have link support, they're just underlined


---------------------------------------------------------------------

== Quote ==[mark-quote]

- MARKDESC Identifies a quoted (indented) line
- MARKPROP Multiline, !FreeSpaces, !Align, Nesting
- MARKCONT Beautifiers, Quote, Raw, Tagged, Bars, Links, Image, Comment
- MARKSYN
  - A line that starts with a tabulation (TAB) character
  - More TABs at the start increase the quote depth
  - Lists and tables are not allowed inside quote
- MARKDET
  - If the end of the source file (EOF) is hit, the opened Quote is
    closed
  - Some targets may not support quote nesting, then the subquotes lines
    are moved up to the mother quote level.
  - There is not a limit for subquotes depth. But some targets may have
    restrictions, so the subquotes than are deeper than the maximum level
    are moved up.


---------------------------------------------------------------------

== List, Numbered List, Definition List ==[mark-lists]

- MARKDESC Identifies the start of a list item
- MARKPROP Multiline, !FreeSpaces, !Align, Nesting
- MARKCONT Beautifiers, Lists, Table, Verbatim, Raw, Tagged, Bars, Links, Image, Comment
- MARKSYN
  - A line that starts with a dash/plus/colon followed by exactly one
    space
  - The first list char can NOT be a space (exception: definition
    lists)
  - Optional spaces (regular spaces, not TAB) at the line beginning
    define sublists depth (nesting)
  - Sublists end with a less depth item (from parent list) or with an
    empty item
  - All opened lists are closed with two consecutive blank lines
- MARKDET
  - If the end of the source file (EOF) is hit, all opened lists are
    closed
  - Lists can be mixed, like a definition list inside a numbered list.
  - Some targets may not support list nesting, then the sublists items
    are moved up to the mother list level.
  - There is not a limit for sublists depth. But some targets may have
    restrictions, so the sublists than are deeper than the maximum level
    are moved up.


---------------------------------------------------------------------

== Image ==[mark-image]

- MARKDESC Identifies an image
- MARKPROP !Multiline, !FreeSpaces, Align, !Nesting
- MARKSYN
  - An image filename enclosed between brackets, ``[likethis.jpg]``
  - The filename must end in an image extension like PNG, JPG, GIF,
    ... (case doesn't matter)
  - Symbols are allowed on the filename, ``[likethis!~1.jpg]``
  - NO spaces allowed on the filename, ``[like this.jpg]``
  - NO spaces allowed on the brackets, ``[ likethis.jpg ]``
- MARKDET
  - If the target does not have image support, the image filename is
    shown inside (parenthesis).
  - The position of the mark on the line defines the image alignment:
    - ``[LEFT.jpg]`` blablablabla
    - blablablabla ``[CENTER.jpg]`` blablablabla
    - blablablabla ``[RIGHT.jpg]``


---------------------------------------------------------------------

== Table ==[mark-table]

- MARKDESC Delimits a table row, with any number of columns
- MARKPROP Multiline, FreeSpaces, Align, !Nesting
- MARKCONT Beautifiers, Raw, Tagged, Links, Image, Comment
- MARKSYN
  - A leading pipe "|" identifies a table row
  - A leading double pipe "||" identifies a table title row
  - Leading spaces before first pipe identifies table centered align
  - The fields are separated by the " | " string (space pipe space)
  - A final pipe "|" at the first table row sets visible borders
  - A final pipe "|" at the other table rows are ignored (just cosmetic)
  - Closing a cell with more than one pipe "|" identifies column span:
    "||" for 2 columns, "|||" for 3 and so on
  - Natural spaces inside each cell identifies its alignment
  - Example: ``| table | row | with | five | columns |``
- MARKDET
  - All the table row data must be on a single line of the source file,
    no line breaks inside
  - Targets with column-oriented align (like sgml and LaTeX), uses the
    first table row align as the default for the other rows
  - Any non-table line closes the opened table, except comment lines
  - The cell count is flexible, each table row can have a different
    number of cells
  - Currently there's no way to specify row span
  - If the target does not have table support, the table lines are
    considered a Verbatim Area


---------------------------------------------------------------------

== Raw, Raw Line, Raw Area ==[mark-raw]

- MARKDESC Used to "protect" some text from parsing, so marks inside
  it will not be expanded. But escapes are applied.
- MARKPROP !Multiline, !FreeSpaces, !Align, !Nesting
- MARKCONT -
- MARKSYN **Raw:**
  - Two double quotes around, ``""like this""``
  - Marks glued with the contents (no spaces)
- MARKSYN **Raw Line:**
  - A line beginning with 3 consecutive double quotes, ``""" like this``
  - The double quotes must be at the start of the line, no spaces before
  - Use a space after the double quotes to separate them from the text
- MARKSYN **Raw Area:**
  - A line with exactly 3 consecutive double quotes, followed by text
    lines, followed by another line with exactly 3 consecutive
    double quotes
  - NO spaces allowed before or after the marks
- MARKDET
  - NOMARKS
  - If the end of the source file (EOF) is hit, the opened Raw Area is
    closed


---------------------------------------------------------------------

== Tagged, Tagged Line, Tagged Area ==[mark-tagged]

- MARKDESC Used to send text directly to the output, no parsing or escaping is made by txt2tags.
- MARKPROP !Multiline, !FreeSpaces, !Align, !Nesting
- MARKCONT -
- MARKSYN **Tagged:**
  - Two apostrophes around, ``''like this''``
  - Marks glued with the contents (no spaces)
- MARKSYN **Tagged Line:**
  - A line beginning with 3 consecutive apostrophes, ``''' like this``
  - The apostrophes must be at the start of the line, no spaces before
  - Use a space after the apostrophes to separate them from the text
- MARKSYN **Tagged Area:**
  - A line with exactly 3 consecutive apostrophes, followed by text
    lines, followed by another line with exactly 3 consecutive
    apostrophes
  - NO spaces allowed before or after the marks
- MARKDET
  - NOMARKS
  - If the end of the source file (EOF) is hit, the opened Tagged Area is
    closed
  - Use this mark to insert target code. For example, in HTML you could use
    it to insert manual line breaks ``''<br>''``,
    custom DIVs ``''<div id="myfooter">''`` or even full blocks of code,
    like the Google Analytics tracking code.


=======================================================================



= Part VI - Mastering Settings =[settings]

Settings are special configurations placed at the source document's
CONFAREA that can affect the conversion process. The Settings are all
optional. The average user can live fine without them. But they are
addictive, if you start using them, you'll never stop :)

Setting lines are //special comment lines//, marked by a leading
identifier ("!") that makes them different from plain comments. The
syntax is just as simple as variable setting, composed by a keyword
and a value, separated from each by a colon (":").

    **%! keyword : value**

Syntax details:

- The exclamation mark must be placed together with the comment char
  (%!), no spaces between them.

- The spaces around the keyword and the separator are optional.

- Keywords are case insensitive (case doesn't matter).


Rules:

- Settings are valid only inside the CONFAREA, and are considered
  plain comments if found on the document Body.

- If the same keyword appears more than one time on the CONFAREA, the
  last found will be the one used. Exception: options, preproc and
  postproc, which are cumulative.

- A setting line with an invalid keyword will be considered a plain
  comment line.

- This settings have precedence over RC file, but not on command line
  options.


-----------------------------------------------------------------------

== %!target ==[setting-target]

Using the target setting, a default target format is defined for the
document:

``` %!target: html

This way the user can just call

``` $ txt2tags file.t2t

And the conversion will be done, to the specified target.

The target setting does not support optional target specification.
That doesn't make sense, such as ``%!target(tex): html``.

-----------------------------------------------------------------------

== %!options ==[setting-options]

Writing long command lines every time you need to convert a document
is boring and error prone. The Options setting let the user save
all the converting options together with the source document. This also
ensures that the document will always be converted the same way, with
the same options.

Just write it with no syntax errors, as you were on the real command
line. But omit the "txt2tags" program call on the beginning, the target
specification and the source filename from the ending.

For example, if you do use this command line to convert your document:

``` $ txt2tags -t html --toc --enum-title file.t2t

You can save yourself from typing pain using this Options setting inside
the document source:

```
%!target: html
%!options(html): --toc --enum-title
```

Now the options are registered inside the source file, so you can convert it with this simple command:

``` $ txt2tags file.t2t

    Tip for Vim users: To convert the document right inside the editor, just run ``:!txt2tags %``

-----------------------------------------------------------------------

== %!preproc ==[setting-preproc]

The PreProc is an input filter that changes the BODYAREA of the source document. It is a "find
and replace" feature, applied right after the line is read from the
document source, before any parsing by txt2tags.

It is useful to define some abbreviations for common typed text, as:

```
%!preproc: JJS          "John J. Smith"
%!preproc: RELEASE_DATE "2003-05-01"
%!preproc: BULLET       "[images/tiny/bullet_blue.png]"
```

So the user can write a line like:

``` Hi, I'm JJS. Today is RELEASE_DATE.

And txt2tags will "see" this line as:

``` Hi, I'm John J. Smith. Today is 2003-05-01.

This filter is a component that acts between the document author
and the txt2tags conversion. It's like a first conversion before the
"real" one. This behavior is similar to an external Sed/Perl filter,
called this way:

``` $ cat file.t2t | preproc-script.sh | txt2tags -

So the txt2tags parsing will begin after all the PreProc substitutions
were applied.

    **Note:** Remember that the preprocessing is applied only to the BODY of the source document, not including the HEADAREA and CONFAREA.

-----------------------------------------------------------------------

== %!postproc ==[setting-postproc]

The PostProc is an output filter that changes the converted document. It is a
"find and replace" feature, applied after all txt2tags parsing and
processing is done.

It is useful to do some refinements on the generated document, change
tags and add extra text or tags. Quick samples:

```
%!postproc(html): '<BODY.*?>' '<BODY BGCOLOR="green">'
%!postproc(tex) : "\\newpage" ""
```

These filters change the background color of the HTML page and remove
the page breaks on the LaTeX target.

The PostProc rules are just like an external Sed/Perl filter, called
this way:

``` $ txt2tags -t html -o- file.t2t | postproc-script.sh > file.html

Before this feature was introduced, it was very common to have little
scripts to "adjust" the txt2tags results. These scripts were in fact
just lots of sed (or alike) commands, to do "substitute this for that"
actions. Now this replacement strings can be saved together with the
document text, and the plus is to use the Python powerful Regular
Expression machine to find patterns.

-----------------------------------------------------------------------

== %!style ==[setting-style]

- Useful in HTML and XHTML targets, it defines a CSS file for the target
  document.

- Useful in LaTeX target, to load ``\usepackage`` modules.

- The same effect is achieved with the command line option ``--style``.

- The --style option is stronger than %!style. If both are used, --style
  wins.


-----------------------------------------------------------------------

== Defining a Setting for a Specific Target ==[setting-specific]

All the settings (except %!target) can be glued with a specific target
using the ``%!key(target): value`` syntax. This way user can define
different config for different targets.

This is specially useful in the pre/postproc filters, but is applicable
to all settings. For example, defining different styles for HTML and
LaTeX:

```
%!style(html): fancy.css
%!style(tex) : amssymb
```

For the options setting it's very useful to adjust the converted
document:

```
%!target: sgml
%!options(sgml): --toc
%!options(html): --style foo.css
```

In this example, the default target is Sgml and it will use TOC. If the
user run ``txt2tags -t html file.t2t``, only the HTML options will be
used, so the converted file will use "foo.css" style file and will
have no TOC.

-----------------------------------------------------------------------

== Details for PreProc and PostProc Filters ==[filters-details]

- Filters are a "find and replace" feature (think SED)

- Filters do not follow the "last found, one used" schema, they're
  cumulative. You can define as many filters as needed, with no limit.
  They will be applied on the same order as defined.

- Different from other settings, both the target specific filters and
  the generic ones (all targets) are used. On the following example,
  both filters are used on the HTML target:
```
%!postproc      :   this   that
%!postproc(html):   that   other
```

- The filters must receive exactly TWO arguments

- Special escapes as ``\n`` (line break) and ``\t`` (tabulation) are
  interpreted

- To delete some text, change it by an empty string
``` %!postproc: "undesired string" ""

- To avoid problems, always use the explicit target form when using
  PostProc to change tags: ``%!postproc(target): <this> <that>``

- PREproc is applied right after the line is read, and POSTproc is
  applied after all the parsing was made. This is similar to
  (UUOC ahead):
``` $ cat file.t2t | preproc.sh | txt2tags | postproc.sh

- The first part of a filter (the "search for" part) is not read as a
  regular string, but as a Regular Expression pattern. If you don't know
  what these expressions do, don't worry, you may never have to. Just
  keep in mind that you will need to "escape" some characters to use
  them. To escape is to prefix the character with a backslash "\". Here
  is the list:
``` \*  \+  \.  \^  \$  \?  \(  \)  \{  \[  \|  \\

- Python Regular Expressions are available! They're similar to Perl
  Regexes (PCRE). Example: Change all opening and closing "B" tags to
  "STRONG" on HTML:
``` %!postproc(html):   '(</?)B>'   '\1STRONG>'

- The filter arguments can be passed on 3 ways:
    + A single unquoted word such as FOO (no spaces)
    + A string double quoted such as "FOO"
    + A string single quoted such as 'FOO'

- If your pattern has double quotes, protect it with single quotes and
  vice-versa. Some valid samples:
```
%!postproc:   PATT    REPLACEMENT
%!postproc:  "PATT"  "REPLACEMENT"
%!postproc:  'PATT'  'REPLACEMENT'
%!postproc:   PATT   "REPLACEMENT"
%!postproc:  "PATT"  'REPLACEMENT'
```


=======================================================================



= Part VII - Black Magic =[black-magic]

This chapter is really not recommended for newbies. It demonstrates how
to do strange things with txt2tags filters, abusing of complex
patterns and Regular Expressions.

    **BEWARE!** The following procedures are NOT encouraged and can
    break things. Even some text from the document source can be
    lost on the conversion process, not appearing on the target
    document. Just use these tactics if you really need them and
    know what you are doing.

    **Note:** Filters are a powerful feature, but can be dangerous!

    **Note:** Bad filters do generate unexpected results.

Keep that in mind, please.

-----------------------------------------------------------------------

== Inserting Multiple Lines with %!postproc (such as CSS rules) ==[postproc-multiline]

In filters, the replacement pattern can include multiple lines using the
``\n`` line break char.

This can be handy for including really short CSS rules on HTML target,
with no need to create a separate file:

```
%!postproc: <HEAD>      '<HEAD>\n<STYLE TYPE="text/css">\n</STYLE>'
%!postproc: (</STYLE>)  'body     { margin:3em               ;} \n\1'
%!postproc: (</STYLE>)  'a        { text-decoration:none     ;} \n\1'
%!postproc: (</STYLE>)  'pre,code { background-color:#ffffcc ;} \n\1'
%!postproc: (</STYLE>)  'th       { background-color:yellow  ;} \n\1'
```

All the filters are tied to the first one, by replacing a string that it
has inserted. So a single "<HEAD>" turns to:

```
<HEAD>
<STYLE TYPE="text/css">
body     { margin:3em               ;}
a        { text-decoration:none     ;}
pre,code { background-color:#ffffcc ;}
th       { background-color:yellow  ;}
</STYLE>
```

-----------------------------------------------------------------------

== Creating "Target-Specific" Contents with %!preproc ==[target-specific-contents]

Sometimes you need to insert some text on a specific target, but not on
the others. This kind of strange behavior can be done using some
PreProc tricks.

The idea is to insert this extra text on the document source as
comments, but mark it in a way that a target-specific filter will
"uncomment" those lines.

For example, if an extra paragraph must be added only in HTML target.
Place the text as special comments, like this:

```
%html% This HTML page is Powered by [txt2tags http://txt2tags.org].
%html% See the source TXT file [here source.t2t].
```

As those lines start with ``%``, they are plain comments lines and will be
ignored. But when adding this special filter:

``` %preproc(html): '^%html% ' ''

The leading string is removed and those lines will be "activated", not
being comments anymore. As a explicit target config, this filter will be
processed for HTML targets only.

-----------------------------------------------------------------------

== Changing Txt2tags Marks with %!preproc ==[creating-marks]

Being a Regular Expressions guru, the user can customize the document
source syntax, changing the txt2tags default marks to some he find more
comfortable.

For example, a leading TAB is the Quotation mark. If the user doesn't
like it, or his text editor has some strange relationship with TABs, he
can define a new mark for Quoted text. Say a leading ">>> " was his
choice. Then he will do this simple filter:

``` %!preproc: '^>>> ' '\t'

And on the document source, the quoted text will be something like:

```
>>> This is a quoted text.
>>> The user defined this strange mark.
>>> But they will be converted to TABs by PreProc.
```

Before the parsing begins, the strange ">>> " will be converted to
TABs and txt2tags will recognize the Quote mark.

    **BEWARE!** Extreme PreProc rules could eventually
    change the entire marks syntax, even generating conflicts
    between marks. Be really really careful when doing this.

=======================================================================

= The End =

Thanks for reading! :)

URLWEBSITE

([see source userguide.t2t])