File: source-highlight.html

package info (click to toggle)
source-highlight 3.1.7-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 10,332 kB
  • ctags: 5,233
  • sloc: sh: 11,270; cpp: 10,206; ansic: 9,515; makefile: 1,865; lex: 1,200; yacc: 1,021; php: 213; perl: 211; awk: 98; erlang: 94; lisp: 90; java: 75; ruby: 69; python: 61; asm: 43; ml: 38; ada: 36; haskell: 27; xml: 23; cs: 11; sql: 8; tcl: 6; sed: 4
file content (6505 lines) | stat: -rw-r--r-- 327,132 bytes parent folder | download
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
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
<html lang="en">
<head>
<title>GNU Source-highlight 3.1.7</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="GNU Source-highlight 3.1.7">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="top" href="#Top">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
This manual is for GNU Source-highlight
(version 3.1.7, 14 April 2012),
which given a source file, produces a document with syntax highlighting.

Copyright (C) 2005-2008 Lorenzo Bettini, `http://www.lorenzobettini.it'.

     Permission is granted to copy, distribute and/or modify this
     document under the terms of the GNU Free Documentation License,
     Version 1.1 or any later version published by the Free Software
     Foundation; with no Invariant Sections, with the Front-Cover Texts
     being "A GNU Manual," and with the Back-Cover Texts as in (a)
     below.  A copy of the license is included in the section entitled
     "GNU Free Documentation License."

     (a) The FSF's Back-Cover Text is: "You have freedom to copy and
     modify this GNU Manual, like GNU software.  Copies published by
     the Free Software Foundation raise funds for GNU development."
   -->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
  pre.display { font-family:inherit }
  pre.format  { font-family:inherit }
  pre.smalldisplay { font-family:inherit; font-size:smaller }
  pre.smallformat  { font-family:inherit; font-size:smaller }
  pre.smallexample { font-size:smaller }
  pre.smalllisp    { font-size:smaller }
  span.sc    { font-variant:small-caps }
  span.roman { font-family:serif; font-weight:normal; } 
  span.sansserif { font-family:sans-serif; font-weight:normal; } 
--></style>
</head>
<body>
<h1 class="settitle">GNU Source-highlight 3.1.7</h1>
   <div class="contents">
<h2>Table of Contents</h2>
<ul>
<li><a name="toc_Top" href="#Top">GNU Source-highlight</a>
<li><a name="toc_Introduction" href="#Introduction">1 Introduction</a>
<ul>
<li><a href="#Supported-languages">1.1 Supported languages</a>
<li><a href="#The-program-source_002dhighlight_002dsettings">1.2 The program <code>source-highlight-settings</code></a>
<li><a href="#Notes-on-some-languages">1.3 Notes on some languages</a>
<ul>
<li><a href="#Fortran">1.3.1 Fortran</a>
<li><a href="#Perl">1.3.2 Perl</a>
</li></ul>
<li><a href="#Using-source_002dhighlight-as-a-simple-formatter">1.4 Using source-highlight as a simple formatter</a>
<li><a href="#Related-Software-and-Links">1.5 Related Software and Links</a>
</li></ul>
<li><a name="toc_Installation" href="#Installation">2 Installation</a>
<ul>
<li><a href="#Building-with-qmake">2.1 Building with qmake</a>
<li><a href="#Download">2.2 Download</a>
<li><a href="#Anonymous-Git-Checkout">2.3 Anonymous Git Checkout</a>
<li><a href="#What-you-need-to-build-source_002dhighlight">2.4 What you need to build source-highlight</a>
<li><a href="#Tips-on-installing-Boost-Regex-library">2.5 Tips on installing Boost Regex library</a>
<li><a href="#Patching-from-a-previous-version">2.6 Patching from a previous version</a>
<li><a href="#Using-source_002dhighlight-with-less">2.7 Using source-highlight with less</a>
<li><a href="#Using-source_002dhighlight-as-a-CGI">2.8 Using source-highlight as a CGI</a>
<li><a href="#Building-_002erpm">2.9 Building .rpm</a>
</li></ul>
<li><a name="toc_Copying" href="#Copying">3 Copying Conditions</a>
<li><a name="toc_Simple-Usage" href="#Simple-Usage">4 Simple Usage</a>
<ul>
<li><a href="#HTML-and-XHTML-output">4.1 HTML and XHTML output</a>
<li><a href="#LaTeX-output">4.2 LaTeX output</a>
<li><a href="#Texinfo-output">4.3 Texinfo output</a>
<li><a href="#DocBook-output">4.4 DocBook output</a>
<li><a href="#ANSI-color-escape-sequences">4.5 ANSI color escape sequences</a>
<li><a href="#Odf-output">4.6 Odf output</a>
</li></ul>
<li><a name="toc_Configuration-files" href="#Configuration-files">5 Configuration files</a>
<ul>
<li><a href="#Output-format-style">5.1 Output format style</a>
<li><a href="#Output-format-style-using-CSS">5.2 Output format style using CSS</a>
<li><a href="#Default-Styles">5.3 Default Styles</a>
<li><a href="#Language-map">5.4 Language map</a>
<li><a href="#Language-definition-files">5.5 Language definition files</a>
<li><a href="#Output-Language-map">5.6 Output Language map</a>
<li><a href="#Output-Language-definition-files">5.7 Output Language definition files</a>
<li><a href="#Developing-your-own-definition-files">5.8 Developing your own definition files</a>
</li></ul>
<li><a name="toc_Invoking-source_002dhighlight" href="#Invoking-source_002dhighlight">6 Invoking <samp><span class="command">source-highlight</span></samp></a>
<ul>
<li><a href="#How-the-input-language-is-discovered">6.1 How the input language is discovered</a>
</li></ul>
<li><a name="toc_Language-Definitions" href="#Language-Definitions">7 Language Definitions</a>
<ul>
<li><a href="#Ways-of-specifying-regular-expressions">7.1 Ways of specifying regular expressions</a>
<li><a href="#Simple-definitions">7.2 Simple definitions</a>
<li><a href="#Line-wide-definitions">7.3 Line wide definitions</a>
<li><a href="#Order-of-definitions">7.4 Order of definitions</a>
<li><a href="#Delimited-definitions">7.5 Delimited definitions</a>
<li><a href="#Variable-definitions">7.6 Variable definitions</a>
<li><a href="#Dynamic-Backreferences">7.7 Dynamic Backreferences</a>
<li><a href="#File-inclusion">7.8 File inclusion</a>
<li><a href="#State_002fEnvironment-Definitions">7.9 State/Environment Definitions</a>
<li><a href="#Explicit-subexpressions-with-names">7.10 Explicit subexpressions with names</a>
<li><a href="#Redefinitions-and-Substitutions">7.11 Redefinitions and Substitutions</a>
<li><a href="#How-source_002dhighlight-works">7.12 How source-highlight works</a>
<li><a href="#Notes-on-regular-expressions">7.13 Notes on regular expressions</a>
<li><a href="#The-program-check_002dregexp">7.14 The program <samp><span class="command">check-regexp</span></samp></a>
<li><a href="#Listing-Language-Elements">7.15 Listing Language Elements</a>
<li><a href="#Concluding-Remarks">7.16 Concluding Remarks</a>
<li><a href="#Debugging">7.17 Debugging</a>
<li><a href="#Tutorials-on-Language-Definitions">7.18 Tutorials on Language Definitions</a>
<ul>
<li><a href="#Highlighting-C_002fC_002b_002b-and-C_0023">7.18.1 Highlighting C/C++ and C#</a>
<li><a href="#Highlighting-Diff-files">7.18.2 Highlighting Diff files</a>
<li><a href="#Pseudo-semantic-analysis">7.18.3 Pseudo semantic analysis</a>
</li></ul>
</li></ul>
<li><a name="toc_Output-Language-Definitions" href="#Output-Language-Definitions">8 Output Language Definitions</a>
<ul>
<li><a href="#File-extension">8.1 File extension</a>
<li><a href="#Text-styles">8.2 Text styles</a>
<li><a href="#Colors">8.3 Colors</a>
<li><a href="#Anchors-and-References">8.4 Anchors and References</a>
<li><a href="#One-style">8.5 One style</a>
<li><a href="#Style-template">8.6 Style template</a>
<li><a href="#Line-prefix">8.7 Line prefix</a>
<li><a href="#String-translation">8.8 String translation</a>
<li><a href="#Document-template">8.9 Document template</a>
<li><a href="#Generating-HTML-output">8.10 Generating HTML output</a>
</li></ul>
<li><a name="toc_Generating-References" href="#Generating-References">9 Generating References</a>
<li><a name="toc_Examples" href="#Examples">10 Examples</a>
<ul>
<li><a href="#Simple-example">10.1 Simple example</a>
<li><a href="#References">10.2 References</a>
<li><a href="#Line-ranges">10.3 Line ranges</a>
<li><a href="#Line-ranges-_0028with-context_0029">10.4 Line ranges (with context)</a>
<li><a href="#Regex-ranges">10.5 Regex ranges</a>
</li></ul>
<li><a name="toc_Problems" href="#Problems">11 Reporting Bugs</a>
<li><a name="toc_Mailing-Lists" href="#Mailing-Lists">12 Mailing Lists</a>
<li><a name="toc_Concept-Index" href="#Concept-Index">Concept Index</a>
</li></ul>
</div>



<div class="node">
<a name="Top"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Introduction">Introduction</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#dir">(dir)</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#dir">(dir)</a>

</div>

<h2 class="unnumbered">GNU Source-highlight</h2>

<p>GNU Source-highlight, given a source file, produces a document with
syntax highlighting.

   <p>This is Edition 3.1.7 of the Source-highlight manual.

   <p>This file documents GNU Source-highlight version 3.1.7.

   <p>This manual is for GNU Source-highlight
(version 3.1.7, 14 April 2012),
which given a source file, produces a document with syntax highlighting.

   <p>Copyright &copy; 2005-2008 Lorenzo Bettini, <a href="http://www.lorenzobettini.it">http://www.lorenzobettini.it</a>.

   <blockquote>
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with the Front-Cover Texts being &ldquo;A GNU Manual,&rdquo;
and with the Back-Cover Texts as in (a) below.  A copy of the
license is included in the section entitled &ldquo;GNU Free Documentation
License.&rdquo;

   <p>(a) The FSF's Back-Cover Text is: &ldquo;You have freedom to copy and modify
this GNU Manual, like GNU software.  Copies published by the Free
Software Foundation raise funds for GNU development.&rdquo;
</blockquote>

<!-- All the nodes can be updated using the EMACS command -->
<!-- texinfo-every-node-update, which is normally bound to C-c C-u C-e. -->
<!-- @node Top, Introduction, (dir), (dir) -->
<!-- All the menus can be updated with the EMACS command -->
<!-- texinfo-all-menus-update, which is normally bound to C-c C-u C-a. -->
<ul class="menu">
<li><a accesskey="1" href="#Introduction">Introduction</a>:                 What's it for? 
<li><a accesskey="2" href="#Installation">Installation</a>:                 Download and installation
<li><a accesskey="3" href="#Copying">Copying</a>:                      Licence issues
<li><a accesskey="4" href="#Simple-Usage">Simple Usage</a>:                 Very basic usage
<li><a accesskey="5" href="#Configuration-files">Configuration files</a>:          Files needed for execution
<li><a accesskey="6" href="#Invoking-source_002dhighlight">Invoking source-highlight</a>:    How to run <samp><span class="command">source-highlight</span></samp>. 
<li><a accesskey="7" href="#Language-Definitions">Language Definitions</a>:         How to define an input language
<li><a accesskey="8" href="#Output-Language-Definitions">Output Language Definitions</a>:   How to define an output format
<li><a accesskey="9" href="#Generating-References">Generating References</a>:        Anchors and cross references
<li><a href="#Examples">Examples</a>:                     Some output examples
<li><a href="#Problems">Problems</a>:                     Reporting bugs. 
<li><a href="#Mailing-Lists">Mailing Lists</a>
<li><a href="#Concept-Index">Concept Index</a>:                Index of concepts. 
</ul>

<div class="node">
<a name="Introduction"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Installation">Installation</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Top">Top</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">1 Introduction</h2>

<p><a name="index-introduction-1"></a><a name="index-features-2"></a>
GNU Source-highlight, given a source file, produces a document with
syntax highlighting.  The colors and the styles can be specified (bold,
italics, underline) by means of a configuration file, and some other
options can be specified at the command line.

   <p>The program already recognizes many programming languages (e.g., C++,
Java, Perl, etc.) and file formats (e.g., log files, ChangeLog, etc.),
and some output formats (e.g., HTML, ANSI color escape sequences,
LaTeX, etc.).  Since version 2.0, it allows you to specify your own
input source language via a simple syntax described later in this manual
(<a href="#Language-Definitions">Language Definitions</a>).  Since version 2.1,  it allows you to
specify your own output format language via a simple syntax described
later in this manual (<a href="#Output-Language-Definitions">Output Language Definitions</a>).  Since version
2.2, it is able to generate cross references (e.g., to variable names,
field names, etc.) by relying on the program <em>ctags</em>,
<a href="http://ctags.sourceforge.net">http://ctags.sourceforge.net</a> (<a href="#Generating-References">Generating References</a>).

   <p><a name="index-library-3"></a>Since version 3.0, GNU Source-highlight also provides a C++ library
(which is used by the main program itself), that can be used
by C++ programmers to add highlighting functionalities to their
programs.  see <a href="source-highlight-info.html#Introduction">Introduction</a>.

<ul class="menu">
<li><a accesskey="1" href="#Supported-languages">Supported languages</a>
<li><a accesskey="2" href="#The-program-source_002dhighlight_002dsettings">The program source-highlight-settings</a>
<li><a accesskey="3" href="#Notes-on-some-languages">Notes on some languages</a>
<li><a accesskey="4" href="#Using-source_002dhighlight-as-a-simple-formatter">Using source-highlight as a simple formatter</a>
<li><a accesskey="5" href="#Related-Software-and-Links">Related Software and Links</a>
</ul>

<div class="node">
<a name="Supported-languages"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#The-program-source_002dhighlight_002dsettings">The program source-highlight-settings</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Introduction">Introduction</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Introduction">Introduction</a>

</div>

<h3 class="section">1.1 Supported languages</h3>

<p>The complete list of languages (indeed, file extensions) natively
supported by this version of Source-highlight (3.1.7), as
reported by <code>--lang-list</code>, is the following:

<pre class="example">     C = cpp.lang
     H = cpp.lang
     ac = m4.lang
     ada = ada.lang
     adb = ada.lang
     am = makefile.lang
     applescript = applescript.lang
     asm = asm.lang
     autoconf = m4.lang
     awk = awk.lang
     bash = sh.lang
     bat = bat.lang
     batch = bat.lang
     bib = bib.lang
     bison = bison.lang
     c = c.lang
     caml = caml.lang
     cbl = cobol.lang
     cc = cpp.lang
     changelog = changelog.lang
     clipper = clipper.lang
     cls = latex.lang
     cobol = cobol.lang
     conf = conf.lang
     cpp = cpp.lang
     cs = csharp.lang
     csh = sh.lang
     csharp = csharp.lang
     css = css.lang
     ctp = php.lang
     d = d.lang
     desktop = desktop.lang
     diff = diff.lang
     dmd = d.lang
     docbook = xml.lang
     dtx = latex.lang
     el = lisp.lang
     eps = postscript.lang
     erl = erlang.lang
     erlang = erlang.lang
     errors = errors.lang
     fixed-fortran = fixed-fortran.lang
     flex = flex.lang
     fortran = fortran.lang
     free-fortran = fortran.lang
     glsl = glsl.lang
     h = cpp.lang
     haskell = haskell.lang
     haxe = haxe.lang
     hh = cpp.lang
     hpp = cpp.lang
     hs = haskell.lang
     htm = html.lang
     html = html.lang
     hx = haxe.lang
     in = makefile.lang
     ini = desktop.lang
     islisp = islisp.lang
     java = java.lang
     javalog = javalog.lang
     javascript = javascript.lang
     js = javascript.lang
     kcfg = xml.lang
     kdevelop = xml.lang
     kidl = xml.lang
     ksh = sh.lang
     l = flex.lang
     lang = langdef.lang
     langdef = langdef.lang
     latex = latex.lang
     ldap = ldap.lang
     ldif = ldap.lang
     lex = flex.lang
     lgt = logtalk.lang
     lhs = haskell_literate.lang
     lilypond = lilypond.lang
     lisp = lisp.lang
     ll = flex.lang
     log = log.lang
     logtalk = logtalk.lang
     lsm = lsm.lang
     lua = lua.lang
     ly = lilypond.lang
     m4 = m4.lang
     makefile = makefile.lang
     manifest = manifest.lang
     mf = manifest.lang
     ml = caml.lang
     mli = caml.lang
     moc = cpp.lang
     opa = opa.lang
     outlang = outlang.lang
     oz = oz.lang
     pas = pascal.lang
     pascal = pascal.lang
     patch = diff.lang
     pc = pc.lang
     perl = perl.lang
     php = php.lang
     php3 = php.lang
     php4 = php.lang
     php5 = php.lang
     pkgconfig = pc.lang
     pl = prolog.lang
     pm = perl.lang
     po = po.lang
     postscript = postscript.lang
     pot = po.lang
     prg = clipper.lang
     prolog = prolog.lang
     properties = properties.lang
     proto = proto.lang
     protobuf = proto.lang
     ps = postscript.lang
     py = python.lang
     python = python.lang
     r = asm.lang
     rb = ruby.lang
     rc = xml.lang
     ruby = ruby.lang
     s = asm.lang
     scala = scala.lang
     scheme = scheme.lang
     scm = scheme.lang
     scpt = applescript.lang
     sh = sh.lang
     shell = sh.lang
     sig = sml.lang
     sl = slang.lang
     slang = slang.lang
     slsh = slang.lang
     sml = sml.lang
     spec = spec.lang
     sql = sql.lang
     sty = latex.lang
     style = style.lang
     syslog = log.lang
     tcl = tcl.lang
     tcsh = sh.lang
     tex = latex.lang
     texi = texinfo.lang
     texinfo = texinfo.lang
     tk = tcl.lang
     tml = tml.lang
     txt = nohilite.lang
     ui = xml.lang
     upc = upc.lang
     vala = vala.lang
     vbs = vbscript.lang
     vbscript = vbscript.lang
     xhtml = xml.lang
     xml = xml.lang
     xorg = xorg.lang
     y = bison.lang
     yacc = bison.lang
     yy = bison.lang
</pre>
   <p>The complete list of output formats natively supported by this version
of Source-highlight (3.1.7), as reported by
<code>--outlang-list</code>, is the following:

<pre class="example">     docbook = docbook.outlang
     esc = esc.outlang
     esc256 = esc256.outlang
     html = html.outlang
     html-css = htmlcss.outlang
     htmltable = htmltable.outlang
     javadoc = javadoc.outlang
     latex = latex.outlang
     latexcolor = latexcolor.outlang
     mediawiki = mediawiki.outlang
     odf = odf.outlang
     texinfo = texinfo.outlang
     xhtml = xhtml.outlang
     xhtml-css = xhtmlcss.outlang
     xhtmltable = xhtmltable.outlang
</pre>
   <p class="noindent">The meaning of the suffix <code>-css</code> is explained in <a href="#Output-Language-map">Output Language map</a><a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>.

   <p>Please, keep in mind, that I haven't tested personally all these
language definitions: I actually checked that the definition files are
syntactically correct (with the command line option <code>--check-lang</code>
and <code>--check-outlang</code>, <a href="#Invoking-source_002dhighlight">Invoking source-highlight</a>), but I'm
not sure their definition actually respects that language syntax (e.g.,
I've put up together some language definitions by searching for
information in the Internet, but I've never programmed in that
language).  So, if you find that a language definition is not precise,
please let me know.  Moreover, if you have a program example in a
language that's not included in the <samp><span class="file">tests</span></samp> directory, please send
it to me so that I can include it in the test suite.

<div class="node">
<a name="The-program-source-highlight-settings"></a>
<a name="The-program-source_002dhighlight_002dsettings"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Notes-on-some-languages">Notes on some languages</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Supported-languages">Supported languages</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Introduction">Introduction</a>

</div>

<h3 class="section">1.2 The program <code>source-highlight-settings</code></h3>

<p><a name="index-source_002dhighlight_002dsettings-4"></a>Since version 3.0, GNU Source-highlight includes also the program
<code>source-highlight-settings</code>, which can be used to check whether
source-highlight will be able find its language definition files, and
other configuration files, and in case, to store the correct settings in
a configuration file, in the user home directory.

   <p><a name="index-source_002dhighlight_002econf-5"></a>In particular, the stored configuration file will be called
<samp><span class="file">source-highlight.conf</span></samp> and stored in
<samp><span class="file">$HOME/.source-highlight/</span></samp>.

   <p><a name="index-g_t_0040code_007b_002d_002ddata_002ddir_007d-6"></a>For the moment, this file only stores the default value for
the <code>--data-dir</code> option.

   <p>The user can always override the contents of this configuration file,
and the default hardcoded value, by using the environment variable
<a name="index-g_t_0040code_007bSOURCE_005fHIGHLIGHT_005fDATADIR_007d-7"></a><code>SOURCE_HIGHLIGHT_DATADIR</code>.

<div class="node">
<a name="Notes-on-some-languages"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Using-source_002dhighlight-as-a-simple-formatter">Using source-highlight as a simple formatter</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#The-program-source_002dhighlight_002dsettings">The program source-highlight-settings</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Introduction">Introduction</a>

</div>

<h3 class="section">1.3 Notes on some languages</h3>

<p>In this section I'd like to go into details on the highlighting of some
specific programming languages.  These notes might be useful when the
highlighted language has some &ldquo;dialects&rdquo; that might require some
further specification at the command line (e.g., to select a specific
dialect).

<ul class="menu">
<li><a accesskey="1" href="#Fortran">Fortran</a>
<li><a accesskey="2" href="#Perl">Perl</a>
</ul>

<div class="node">
<a name="Fortran"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Perl">Perl</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Notes-on-some-languages">Notes on some languages</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Notes-on-some-languages">Notes on some languages</a>

</div>

<h4 class="subsection">1.3.1 Fortran</h4>

<p><a name="index-Fortran-8"></a>As Toby White explained to me, Fortran comes into different &ldquo;flavors&rdquo;:
a fixed-format, where some characters have a different semantics
depending on their column position in the source file, and a free-format
where this is not true.  For instance, in the former, <code>*</code> and
<code>c</code> start a command line, but only if they are specified in the
first column (while this is not true in the free-format).

   <p>By default, the free-format is assumed for Fortran files; if you want to
use the fixed-format, you need to specify <code>fortran-fixed</code> at
the <code>--src-lang</code> command line option.

<div class="node">
<a name="Perl"></a>
<p><hr>
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Fortran">Fortran</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Notes-on-some-languages">Notes on some languages</a>

</div>

<h4 class="subsection">1.3.2 Perl</h4>

<p><a name="index-Perl-9"></a>Perl syntax forms, especially its regular expression specifications, are
quite a nightmare ;-)  I tried to specify as much as possible in the
<samp><span class="file">perl.lang</span></samp> but some particular regular expressions might not be
highlighted correctly.  Actually, I never programmed in Perl, so, if you
see that some parts of your Perl programs are not highlighted correctly,
please do not hesitate to contact me, so that I can improve Perl
highlighting.

   <p><a name="index-g_t_0040code_007b_002d_002dinfer_002dlang_007d-10"></a>Moreover, although the standard extension for Perl files is <code>.pl</code>,
since the Prolog language definition was implemented in source-highlight
before Perl, this extension is assigned, by default, to Prolog files. 
However, you can use <code>--infer-lang</code> command line option, so that
source-highlight can try to detect the language by inspecting the first
lines of the input file (<a href="#How-the-input-language-is-discovered">How the input language is discovered</a>);
you can also use <code>--src-lang=perl</code> command line specification to
explicitly require Perl highlighting.

<div class="node">
<a name="Using-source-highlight-as-a-simple-formatter"></a>
<a name="Using-source_002dhighlight-as-a-simple-formatter"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Related-Software-and-Links">Related Software and Links</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Notes-on-some-languages">Notes on some languages</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Introduction">Introduction</a>

</div>

<h3 class="section">1.4 Using source-highlight as a simple formatter</h3>

<p>You can also use source-highlight as a simple formatter of input file,
i.e., without performing any highlighting<a rel="footnote" href="#fn-2" name="fnd-2"><sup>2</sup></a>.

   <p><a name="index-nohilite_002elang-11"></a>You can achieve this by using, as the language definition file for input
sources the file <samp><span class="file">nohilite.lang</span></samp>, using the command line option
<code>--lang-def</code> (<a href="#Invoking-source_002dhighlight">Invoking source-highlight</a>).  Since that
language definition is empty, no highlighting will be performed;
however, source-highlight will transform the input file in the output
format.  Note, in the input language associations in <a href="#Supported-languages">Supported languages</a>, that <samp><span class="file">nohilite.lang</span></samp> is also associated to txt files.

   <p>This, for instance, makes source-highlight useful in cases you want to
transform a text file into HTML or LaTeX.  During the output, in
fact, source-highlight will correctly generate characters that have a
specific meanings in the output format.

   <p>For instance, in this Texinfo manual,
if I want to insert a @ or a {
I have to &ldquo;escape&rdquo; them to make them appear literally
since they have a special meaning in Texinfo. 
The same holds, e.g.,
for <code>&lt;</code>, <code>&gt;</code> or <code>&amp;</code> in HTML. 
If you use source-highlight,
it will take care of this, automatically for you. 
This is the Texinfo source of the above sentence:

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     For instance, in this Texinfo manual,
     if I want to insert a @@ or a @{
     I have to ``escape'' them to make them appear literally
     since they have a special meaning in Texinfo.
     The same holds, e.g.,
     for @code{&lt;}, @code{&gt;} or @code{&amp;} in HTML.
     If you use source-highlight,
     it will take care of this, automatically for you.
</pre>
   <p class="noindent">This was processed by source-highlight as a simple text file, without no
highlighting; however since it was formatted in Texinfo, all the
necessary escaping was automatically performed.  This way, it is very
easy to insert, in the same document, a code, and its result (as in this
example).

   <p>This is actually the formatting performed by source-highlight; except
for the comment, this is basically what you should have written yourself
to do all the escaping stuff manually:

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     @c Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite
     @example
     For instance, in this Texinfo manual,
     if I want to insert a @@@@ or a @@@{
     I have to ``escape'' them to make them appear literally
     since they have a special meaning in Texinfo.
     The same holds, e.g.,
     for @@code@{&lt;@}, @@code@{&gt;@} or @@code@{&amp;@} in HTML.
     If you use source-highlight,
     it will take care of this, automatically for you.
     @end example
</pre>
   <p><a name="index-failsafe-12"></a>In case source-highlight does not handle a specific input language, you
can still use the option <code>--failsafe</code> (<a href="#Invoking-source_002dhighlight">Invoking source-highlight</a>) and also in that case no highlighting will be
performed, but source-highlight will transform the input file in the
output format.

   <p><a name="index-default_002elang-13"></a>Note, however, that if the input language cannot be established, the
<samp><span class="file">default.lang</span></samp> will be used: an empty language definition file
which you might want to customize.

<div class="node">
<a name="Related-Software-and-Links"></a>
<p><hr>
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Using-source_002dhighlight-as-a-simple-formatter">Using source-highlight as a simple formatter</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Introduction">Introduction</a>

</div>

<h3 class="section">1.5 Related Software and Links</h3>

<p>Here we list some software related to source-highlight in the sense that
it uses it as a backend (i.e., provides an interface to
source-highlight) or it uses some of its features (e.g., definition
files):

     <ul>
<li><a name="index-Source_002dHighlight_002dQt-14"></a><a name="index-Qt-15"></a>Source-highlight-qt is a library for performing syntax highlighting in
Qt documents by relying on GNU Source-Highlight library.  This library
provides an implementation of the qt abstract class QSyntaxHighlighter
class, and it deals both with Qt3 and Qt4.

     <p><a href="http://srchiliteqt.sourceforge.net">http://srchiliteqt.sourceforge.net</a>.

     <li><a name="index-QSource_002dHighlight-16"></a><a name="index-Qt-17"></a>QSource-Highlight is a Qt4 front-end for GNU Source-Highlight (it relies
on the library Source-Highlight-Qt).  You can highlight your code on the
fly, and have the highlighted output in all the formats supported by
source-highlight (e.g., HTML, LaTeX, Texinfo, etc.). You can then copy
the formatted output and paste it (e.g., in your blog), or save it to a
file.  A preview of the highlighted output is available for some output
formats (e.g., HTML, XHTML, etc.).

     <p><a href="http://qsrchilite.sourceforge.net">http://qsrchilite.sourceforge.net</a>.

     <li><a name="index-SourceHighlightIDE-18"></a><a name="index-KDE-19"></a>SourceHighlightIDE is a small IDE (based on Qt4 and
Source-highlight-qt) I wrote for developing
and debugging new language definitions for source-highlight:

     <p><a href="http://srchighliteide.sourceforge.net">http://srchighliteide.sourceforge.net</a>.

     <li><a name="index-Ksrc2highlight-20"></a><a name="index-KDE-21"></a>Martin Gebert implemented a KDE interface to source-highlight programs
(and he did a wonderful job!), and it is called <em>Ksrc2highlight</em>;
if you want to test it:

     <p><a href="http://www.mgebert.de/Ksrc2highlight">http://www.mgebert.de/Ksrc2highlight</a>.

     <li><a name="index-java2html-22"></a>There's also a Java version of java2html, you can find it at

     <p><a href="http://www.generationjava.com/projects/Java2Html.shtml">http://www.generationjava.com/projects/Java2Html.shtml</a>.

     <li>This web site provides a web interface to source-highlight
so that you can highlight your code on-line:

     <p><a href="http://www.alaide.com/outils_colorsyntaxe.php">http://www.alaide.com/outils_colorsyntaxe.php</a>

     <li><a name="index-SHJS-23"></a>SHJS is a JavaScript program that highlights source code passages in
HTML documents. Documents using SHJS are highlighted on the client side
by the web browser.  SHJS uses language definitions from
Source-highlight.

     <p><a href="http://shjs.sourceforge.net">http://shjs.sourceforge.net</a>

     <li><a name="index-code2blog-24"></a>Code2blog is a pyGTK front-end to source-highlight for easy conversion
from source code to HTML.

     <p><a href="http://code.google.com/p/code2blog">http://code.google.com/p/code2blog</a>

     <li><a name="index-Apache-25"></a>Andy Buckley wrote a wrapper around source-highlight, which can be used
as an Apache filter to highlight source code in Web pages on the fly.

     <p><a href="http://www.insectnation.org/projects/filter-src-highlight">http://www.insectnation.org/projects/filter-src-highlight</a>

     <li><a name="index-RapidWeaver-26"></a>Roger Nilsson wrote a frontend for source-highlight that is used in a
popular webdesign app for OSX called RapidWeaver. The frontend is called
High-Light and allows users to easily add syntax-colored code inside
RapidWeaver.

     <p><a href="http://nilrogsplace.se/webdesign/rapidweaver/plugins/high-light/index_en.html">http://nilrogsplace.se/webdesign/rapidweaver/plugins/high-light/index_en.html</a>

     <li><a name="index-Firefox-27"></a>Mauricio Zepeda published in his blog an article with a script
to automatically highlight a file and show it in Firefox:

     <p><a href="http://chillorb.com/?p=122">http://chillorb.com/?p=122</a>

     <li><a name="index-Wiki-28"></a><a name="index-Ikiwiki-29"></a>Jason Blevins made a plugin for Ikiwiki that enables syntax highlighting
of source code fragments and whole files via source-highlight.

     <p><a href="http://jblevins.org/projects/ikiwiki/code">http://jblevins.org/projects/ikiwiki/code</a>

     <li><a name="index-Wiki-30"></a><a name="index-Php-31"></a>Pascal Bleser created a PHP extension that uses the GNU source-highlight
library directly from PHP, instead of relying on spawning a process or
using the source-highlight CGI.

     <p><a href="http://code.google.com/p/php-source-highlight/">http://code.google.com/p/php-source-highlight/</a>

     <li><a name="index-SIP-32"></a><a name="index-Python-33"></a><a name="index-PyQt-34"></a>Roberto Alsina made a partial python binding using SIP so
that you can use Source-Highlight-Qt in PyQt programs.

     <p><a href="http://marave.googlecode.com/svn/trunk/marave/highlight/">http://marave.googlecode.com/svn/trunk/marave/highlight/</a>

     <li><a name="index-Perl-35"></a>A perl binding for source-highlight is available at CPAN:

     <p><a href="http://search.cpan.org/perldoc?Syntax::SourceHighlight">http://search.cpan.org/perldoc?Syntax::SourceHighlight</a>

     <li><a name="index-Pastebin-36"></a>Danijel Tasov wrote a pastebin service based on
perl source-highlight binding:

     <p><a href="http://pb.rbfh.de">http://pb.rbfh.de</a>

   </ul>

<div class="node">
<a name="Installation"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Copying">Copying</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Introduction">Introduction</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">2 Installation</h2>

<p><a name="index-installation-37"></a>
<a name="index-compilation-38"></a>See the file <samp><span class="file">INSTALL</span></samp> for detailed building and  installation
instructions; anyway if you're used to compiling Linux software that
comes with sources you may simply follow the usual procedure, i.e., untar
the file you downloaded in a directory and then:

<pre class="example">     cd &lt;source code main directory&gt;
     ./configure
     make
     make install
</pre>
   <p><a name="index-shadow-build-39"></a>We strongly suggest to use shadow builds, thus, create a build
directory, say <samp><span class="file">build</span></samp> and run configuration and make in that
directory:

<pre class="example">     cd &lt;source code main directory&gt;
     mkdir build
     cd build
     ../configure
     make
     make install
</pre>
   <p>However, before you do this, please check that you have everything that
is needed to build source-highlight, <a href="#What-you-need-to-build-source_002dhighlight">What you need to build source-highlight</a>.

   <p>Note: unless you specify a different install directory by
<code>--prefix</code> option of
configure (e.g. <code>./configure --prefix=&lt;your home&gt;</code>),
you must be root to run <code>make install</code>.

   <p>You may want to run <code>./configure --help</code> to see all the possible
options that can be passed to the configuration script.

   <p><a name="index-directories-40"></a>Files will be installed in the following directories:

     <dl>
<dt><code>Executables</code><dd>        <code>prefix/bin</code>
<br><dt><code>docs and output examples</code><dd>        <code>prefix/share/doc/source-highlight</code>
<br><dt><code>library examples</code><dd>        <code>prefix/share/doc/source-highlight/examples</code>
<br><dt><code>library API documentation</code><dd>        <code>prefix/share/doc/source-highlight/api</code>
<br><dt><code>conf files</code><dd>        <code>prefix/share/source-highlight</code>
</dl>

   <p>Default value for prefix is <code>/usr/local</code>
but you may change it with <code>--prefix</code>
option to configure.  For further <code>configure</code> options, you
can run <code>configure --help</code>.

   <p><a name="index-bash-completion-41"></a>Tiziano Muller wrote a bash completion configuration file for
source-highlight; this will be installed by default in the directory
<code>sysconfdir/bash_completion.d</code>, where <code>sysconfdir</code> defaults to
<code>prefix/etc</code>; however, typically, the directory where the bash
completion script searches for configuration file is
<code>/etc/bash_completion.d</code>.  Thus, we suggest you explicitly specify
this directory with the configuration script command line option
<code>--with-bash-completion</code>.

   <p><a name="index-library-42"></a><a name="index-g_t_0040code_007b_002d_002dwith_002ddoxygen_007d-43"></a><a name="index-doxygen-44"></a>If you want to build and install the API documentation of
Source-highlight library, you need to run <code>configure</code> with the
option <code>--with-doxygen</code>, but you need the program <em>Doxygen</em>,
<a href="http://www.doxygen.org">http://www.doxygen.org</a>, to build the documentation. 
The documentation will be installed in the following directory:

     <dl>
<dt><code>Library API documentation</code><dd>        <code>prefix/share/doc/source-highlight/api</code>
</dl>

   <p><a name="index-java2html-45"></a><a name="index-cpp2html-46"></a>NOTE: Originally, instead of Source-highlight, there were  two
separate programs, namely <em>GNU java2html</em> and <em>GNU cpp2html</em>. 
There are two shell scripts with the same name that will be installed
together with Source-highlight in order to facilitate the migration
(however their use is not advised and it is deprecated).

<ul class="menu">
<li><a accesskey="1" href="#Building-with-qmake">Building with qmake</a>
<li><a accesskey="2" href="#Download">Download</a>
<li><a accesskey="3" href="#Anonymous-Git-Checkout">Anonymous Git Checkout</a>
<li><a accesskey="4" href="#What-you-need-to-build-source_002dhighlight">What you need to build source-highlight</a>
<li><a accesskey="5" href="#Tips-on-installing-Boost-Regex-library">Tips on installing Boost Regex library</a>
<li><a accesskey="6" href="#Patching-from-a-previous-version">Patching from a previous version</a>
<li><a accesskey="7" href="#Using-source_002dhighlight-with-less">Using source-highlight with less</a>
<li><a accesskey="8" href="#Using-source_002dhighlight-as-a-CGI">Using source-highlight as a CGI</a>
<li><a accesskey="9" href="#Building-_002erpm">Building .rpm</a>
</ul>

<div class="node">
<a name="Building-with-qmake"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Download">Download</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Installation">Installation</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Installation">Installation</a>

</div>

<h3 class="section">2.1 Building with qmake</h3>

<p><a name="index-qmake-47"></a>
Since version 3.1.2, Source-highlight can be built also using
<code>qmake</code>, the build tool from Qt libraries (<a href="http://qt.nokia.com">http://qt.nokia.com</a>). 
This was made available to build Source-highlight on Windows based systems
without using a Unix shell, and in particular to build Source-highlight
<a name="index-MSVC-48"></a>with Microsoft MSVC compiler.  You should use this method only if you
don't have a Unix shell or if you really need to use the MSVC compiler
(e.g., if you want to build Source-highlight library to be used in MSVC
based programs). 
<a name="index-boost-49"></a>You still need the boost regex library, and if you
use MSVC, you can find installation packages for this library at
<a href="http://www.boostpro.com">http://www.boostpro.com</a>.

   <p>This build mechanism is still experimental, and, when using MSVC, only
a static version of Source-highlight library can be built (not a .dll). 
<a name="index-MinGW-50"></a>You can also use this method if you have the MinGW compiler,
<a href="http://www.mingw.org">http://www.mingw.org</a>, (e.g.,
the one that comes with Qt Windows distribution) and you don't have
<a name="index-msys-51"></a>Msys (<a href="http://www.mingw.org/wiki/MSYS">http://www.mingw.org/wiki/MSYS</a>).  Otherwise, you should
still use the <code>configure</code> based mechanims.

   <p>Using <code>qmake</code>, only a few options can be specified during the building
(besides the ones you usually use with qmake), and these options can
be specified only using environment variables:

     <dl>
<dt><code>BOOST_REGEX</code><dd>By default, <code>boost_regex</code> will be used to link the boost library
(i.e., <code>-lboost_regex</code>); if your boost regex library has a different
name you must specify this name using this environment variable; e.g.,
if the library file is called <code>libboost_regex-mt.lib</code> or
<code>boost_regex-mt.dll</code> you must set this variable to
<code>boost_regex-mt</code>. 
<br><dt><code>INCPATH</code><dd>Specify the path of the boost header files. 
<br><dt><code>LIBS</code><dd>Specify the path of the boost lib files. 
</dl>

   <p>Please, take into consideration that specifying the boost library
include and library paths is completely up to you, using
<code>INCPATH</code> and <code>LIBS</code>, if they're not in the system
path directories.

   <p>Also remember to always use the option <code>-recursive</code> when running
qmake.

   <p>If you then want to run <code>make install</code>, you can use the
variable <code>INSTALL_ROOT</code> to prefix the installation path, which,
otherwise, is the root directory.

<div class="node">
<a name="Download"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Anonymous-Git-Checkout">Anonymous Git Checkout</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Building-with-qmake">Building with qmake</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Installation">Installation</a>

</div>

<h3 class="section">2.2 Download</h3>

<p><a name="index-download-52"></a>
You can download it from GNU's ftp site:
<a href="ftp://ftp.gnu.org/gnu/src-highlite">ftp://ftp.gnu.org/gnu/src-highlite</a> or from one of its mirrors (see
<a href="http://www.gnu.org/prep/ftp.html">http://www.gnu.org/prep/ftp.html</a>).

   <p>I do not distribute Windows binaries anymore; since, they can be built
by using Cygnus C/C++ compiler, available at
<a href="http://www.cygwin.com">http://www.cygwin.com</a>.  However, if you don't feel like
downloading such compiler or you experience problems with the Boost
Regex library (see also <a href="#Tips-on-installing-Boost-Regex-library">Tips on installing Boost Regex library</a>;
please also keep in mind that if you don't have these libraries
installed, and your C/C++ compiler distribution does not provide a
prebuilt package, it might take some time, even hours, to build the
Boost libraries from sources), you can request such binaries directly to
me, by e-mail (find my e-mail at my home page) and I'll be happy to send
them to you.  An MS-Windows port of Source-highlight is available from
<a href="http://gnuwin32.sourceforge.net">http://gnuwin32.sourceforge.net</a>; however, I don't maintain those
binaries personally, and they might be out of date.

   <p>Archives are digitally signed by me (Lorenzo Bettini) with GNU gpg
(<a href="http://www.gnupg.org">http://www.gnupg.org</a>). My GPG public key can be found at my home
page (<a href="http://www.lorenzobettini.it">http://www.lorenzobettini.it</a>).

   <p>You can also get the patches, if they are available for a particular
release (see below for patching from a previous version).

<div class="node">
<a name="Anonymous-Git-Checkout"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#What-you-need-to-build-source_002dhighlight">What you need to build source-highlight</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Download">Download</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Installation">Installation</a>

</div>

<h3 class="section">2.3 Anonymous Git Checkout</h3>

<p><a name="index-Git-53"></a>This project's git repository can be checked out through the following
clone instruction<a rel="footnote" href="#fn-3" name="fnd-3"><sup>3</sup></a>:

<pre class="example">     git clone git://git.savannah.gnu.org/src-highlite.git
</pre>
   <p>Further instructions can be found at the address:

   <p><a href="http://savannah.gnu.org/projects/src-highlite">http://savannah.gnu.org/projects/src-highlite</a>.

   <p>And the git repository can also browsed on-line at

   <p><a href="http://git.savannah.gnu.org/cgit/src-highlite.git">http://git.savannah.gnu.org/cgit/src-highlite.git</a>.

   <p>Please note that this way you will get the latest development sources
of Source-highlight, which may also be unstable.  This solution is the
best if you intend to correct/extend this program: you should send me
patches against the latest git repository sources.

   <p>If, on the contrary, you want to get the sources of a given release,
through git, say, e.g., version X.Y.Z, you must specify the tag
<code>rel_X_Y_Z</code>.

   <p>When you compile the sources that you get from the git repository,
before running the <code>configure</code> and <code>make</code> commands, for the
first time, you must run the command:

<pre class="example">     autoreconf -i
</pre>
   <p class="noindent">This will run the autotools commands in the correct order, and also copy
possibly missing files.  You should have installed recent versions of
<a name="index-automake-54"></a><a name="index-autoconf-55"></a><a name="index-libtool-56"></a><code>automake</code>, <code>autoconf</code> and <code>libtool</code> in order for this to
succeed.

   <p><a name="index-shadow-build-57"></a>We strongly suggest to use shadow builds, thus, create a build
directory, say <samp><span class="file">build</span></samp> and run configuration and make in that
directory:

<pre class="example">     cd &lt;source code main directory&gt;
     mkdir build
     cd build
     ../configure
     make
     make install
</pre>
   <p>To summarize, the steps to get the sources from git and make the first build
are:

<pre class="example">     git clone git://git.savannah.gnu.org/src-highlite.git
     cd src-highlite
     autoreconf -i
     mkdir build
     cd build
     ../configure
     make
</pre>
   <div class="node">
<a name="What-you-need-to-build-source-highlight"></a>
<a name="What-you-need-to-build-source_002dhighlight"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Tips-on-installing-Boost-Regex-library">Tips on installing Boost Regex library</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Anonymous-Git-Checkout">Anonymous Git Checkout</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Installation">Installation</a>

</div>

<h3 class="section">2.4 What you need to build source-highlight</h3>

<p><a name="index-compilation-requirements-58"></a><a name="index-building-requirements-59"></a>
<a name="index-boost-60"></a>Since version 2.0 Source-highlight relies on regular expressions as
provided by boost (<a href="http://www.boost.org">http://www.boost.org</a>), so you need to install at
least the regex library from boost.

   <p>Most GNU/Linux distributions provide this library already in a compiled
form.  If you use your distribution packages, please be sure to install
also the development package of the boost libraries.

   <p>If you experience problems in installing Boost Regex library, or in
compiling source-highlight because of this library, please take a look
at <a href="#Tips-on-installing-Boost-Regex-library">Tips on installing Boost Regex library</a>.

   <p>If you want to use a specific version of the Boost regex library
(because you have many versions of it), you can use the configure option
<code>--with-boost-regex</code> to specify a particular suffix.  For instance,

<pre class="example">     ./configure --with-boost-regex=boost_regex-gcc-1_31
</pre>
   <p>Source-highlight has been developed under GNU/Linux, using gcc (C++),
and bison (yacc) and flex (lex), and ported under Win32 with Cygwin
C/C++compiler, available at <a href="http://www.cygwin.com">http://www.cygwin.com</a>.

   <p>I use the excellent
<a name="index-automake-61"></a><a name="index-autoconf-62"></a><a name="index-libtool-63"></a>GNU Autoconf<a rel="footnote" href="#fn-4" name="fnd-4"><sup>4</sup></a>,
GNU Automake<a rel="footnote" href="#fn-5" name="fnd-5"><sup>5</sup></a> and
GNU Libtool<a rel="footnote" href="#fn-6" name="fnd-6"><sup>6</sup></a>. 
<a name="index-gnulib-64"></a>Since version 2.6 I also started to use Gnulib - The GNU Portability
Library<a rel="footnote" href="#fn-7" name="fnd-7"><sup>7</sup></a>, &ldquo;a central
location for common GNU code, intended to be shared among GNU packages&rdquo;
(for instance, I rely on Gnulib for checking for the presence and
correctness of <code>getopt_long</code> function).

   <p>Finally I used <em>GNU gengetopt</em>
(<a href="http://www.gnu.org/software/gengetopt">http://www.gnu.org/software/gengetopt</a>), for command line parsing.

   <p>I started to use also <em>doublecpp</em>
(<a href="http://doublecpp.sourceforge.net">http://doublecpp.sourceforge.net</a>) that permits achieving dynamic
overloading.

   <p>Actually, apart from the boost regex library, you don't need the other
tools above to build source-highlight (indeed I provide the output
sources generated by the above mentioned tools), unless you want to
develop source-highlight.

   <p>However, if you obtained sources through Git, you need some other tools,
see <a href="#Anonymous-Git-Checkout">Anonymous Git Checkout</a>.

<div class="node">
<a name="Tips-on-installing-Boost-Regex-library"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Patching-from-a-previous-version">Patching from a previous version</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#What-you-need-to-build-source_002dhighlight">What you need to build source-highlight</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Installation">Installation</a>

</div>

<h3 class="section">2.5 Tips on installing Boost Regex library</h3>

<p><a name="index-Boost-regex-65"></a>
If you experience no problem in compiling source-highlight, you can
happily skip this section<a rel="footnote" href="#fn-8" name="fnd-8"><sup>8</sup></a> :-)

   <p>I created this section because many users reported some problems after
installing Boost Regex library from sources; other users had problems in
compiling source-highlight even if this library was already correctly
installed (especially windows users, using cygwin).  I hope this section
sheds some light in installing/using the Boost Regex library.  Please,
note that this section does not explain how to compile the Boost
libraries (the documentation you'll find on <a href="http://www.boost.org">http://www.boost.org</a>
is well done); it explains how to tweak things if you have problems in
compiling source-highlight even after a successful installation of Boost
libraries.

   <p>First of all, if your distribution provides packages for the Boost regex
library, please be sure to install also the development package of the
boost libraries, i.e., those providing also the header files needed to
compile a program using these libraries.  For instance, on my Debian
system I had to install the package <code>libboost-regex-dev</code>, besides
the package <code>libboost-regex</code>.

   <p>If your distribution does not provide these packages then you have to
download the sources of Boost libraries from <a href="http://www.boost.org">http://www.boost.org</a>
and follow the instructions for compilation and installation.  However,
I suggest you specify <samp><span class="file">/usr</span></samp> as prefix for installation, instead of
relying on the default prefix <samp><span class="file">/usr/local</span></samp> (unless
<samp><span class="file">/usr/local/include</span></samp> is already in the inclusion path of your C++
compiler), since this will make things easier when compiling
source-highlight.  I suggest this, since <samp><span class="file">/usr/include</span></samp> is usually
the place where C++ searches for header files during compilation.

   <p>If you successfully compiled and installed the Boost Regex library, or
you installed the package from your distribution, but you STILL
experience problems in compiling source-highlight, then you simply have
to adjust some things as described in the following.

   <p>If the <code>./configure</code> command of source-highlight reports this
error:

<pre class="example">     ERROR! Boost::regex library not installed.
</pre>
   <p class="noindent">then, the compiler cannot find the header files for this library.  In
this case, check that the directory <samp><span class="file">/usr/include/boost</span></samp> actually
exists; if it does not, then probably you'll find a similar directory,
e.g., <samp><span class="file">/usr/include/boost-1_33/boost</span></samp>, depending on the version of
the library you have installed.  Then, all you have to do is to create a
symbolic link as follows:

<pre class="example">     ln -s /usr/include/boost-1_33/boost /usr/include/boost
</pre>
   <p class="noindent"><a name="index-g_t_0040code_007bCXXFLAGS_007d-66"></a>Alternatively, you might run source-highlight's configure as follows:

<pre class="example">     ./configure CXXFLAGS=-I/usr/include/boost-1_33/
</pre>
   <p>If you install (or build) the Boost Regex library in a non standard
path, e.g., somewhere in your home directory, say
<samp><span class="file">/home/myhome/boost-1_33</span></samp>, you'll have to update the
<code>CXXFLAGS</code> variable accordingly on the <code>configure</code> command
line; in this particular case, you might also have to specify the path
of actual library files (<code>CXXFLAGS</code> will only specify the path of
header files).  In particular, you'll have to know where the lib files
are within the boost installation (or build directory); for instance,
if they are in <samp><span class="file">/home/myhome/boost-1_33/stage/lib</span></samp>, while the
header files (i.e., the <samp><span class="file">boost</span></samp> header files directory) are in
<samp><span class="file">/home/myhome/boost-1_33</span></samp>, the complete <code>configure</code> command
should be

   <p><a name="index-g_t_0040code_007bLDFLAGS_007d-67"></a>
<pre class="example">     ./configure CXXFLAGS=-I/home/myhome/boost-1_33 \
                 LDFLAGS=-L/home/myhome/boost-1_33/stage/lib
</pre>
   <p>If then <code>./configure</code> command of source-highlight reports this
other error:

<pre class="example">     ERROR! Boost::regex library is installed, but you
     must specify the suffix with --with-boost-regex at configure
     for instance, --with-boost-regex=boost_regex-gcc-1_31
</pre>
   <p class="noindent">then, there's still another thing to fix: you must find out the exact
names of the files of your installed Boost Regex libraries; you can do
this by using the command:

<pre class="example">     $ ls -l /usr/lib/libboost_regex*
</pre>
   <p class="noindent">that, for instance, on one of my cygwin installation reports:

<pre class="example">     -rwxr-x---+ Nov  9 23:29 /usr/lib/libboost_regex-gcc-mt-s-1_33.a
     -rwxr-x---+ Nov 22 09:22 /usr/lib/libboost_regex-gcc-mt-s.a
     -rwxr-x---+ Nov  9 23:29 /usr/lib/libboost_regex-gcc-mt-s-1_33.so
     -rwxr-x---+ Nov 22 09:22 /usr/lib/libboost_regex-gcc-mt-s.so
</pre>
   <p class="noindent">Now, you have all the information to correctly run the
source-highlight's configure command:

<pre class="example">     ./configure --with-boost-regex=boost_regex-gcc-mt-s-1_33
</pre>
   <p class="noindent">or, if you solved the first problem in the second way<a rel="footnote" href="#fn-9" name="fnd-9"><sup>9</sup></a>,

<pre class="example">     ./configure CXXFLAGS=-I/usr/include/boost-1_33/ \
                 --with-boost-regex=boost_regex-gcc-mt-s-1_33
</pre>
   <p>Of course, you have to modify this command according to the names of
your Boost Regex library installed files.

   <p>These instructions managed to let many users, who were experiencing
problems, to compile source-highlight If you still have problems, please
send me an e-mail.

<div class="node">
<a name="Patching-from-a-previous-version"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Using-source_002dhighlight-with-less">Using source-highlight with less</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Tips-on-installing-Boost-Regex-library">Tips on installing Boost Regex library</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Installation">Installation</a>

</div>

<h3 class="section">2.6 Patching from a previous version</h3>

<p><a name="index-patching-68"></a>
If you downloaded a patch, say
<samp><span class="file">source-highlight-1.3-1.3.1-patch.gz</span></samp> (i.e., the patch to go from version
1.3 to version 1.3.1), cd to the directory with sources from the
previous version (source-highlight-1.3) and type:

<pre class="example">     gunzip -cd ../source-highlight-1.3-1.3.1.patch.gz | patch -p1
</pre>
   <p>and restart the compilation process (if you had already run configure a
simple make should do).

<div class="node">
<a name="Using-source-highlight-with-less"></a>
<a name="Using-source_002dhighlight-with-less"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Using-source_002dhighlight-as-a-CGI">Using source-highlight as a CGI</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Patching-from-a-previous-version">Patching from a previous version</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Installation">Installation</a>

</div>

<h3 class="section">2.7 Using source-highlight with less</h3>

<p><a name="index-src_002dhilite_002dlesspipe_002esh-69"></a>This was suggested by Konstantine Serebriany.   The script
<samp><span class="file">src-hilite-lesspipe.sh</span></samp> will be installed together with
source-highlight.  You can use the following environment variables:

<pre class="example">     export LESSOPEN="| /path/to/src-hilite-lesspipe.sh %s"
     export LESS=' -R '
</pre>
   <p>This way, when you use less to browse a file, if it is a source file
handled by source-highlight, it will be automatically highlighted.

   <p><a name="index-source_002dhighlight_002desc_002esh-70"></a>Xavier-Emmanuel Vincent recently provided an alternative version of
ANSI color scheme, <samp><span class="file">esc256.style</span></samp>: some terminals can handle 256
colors.  Xavier also provided a script which checks how many colors
your terminal can handle, and in case, uses the 256 variant.  The
script is called <samp><span class="file">source-highlight-esc.sh</span></samp> and it will be
installed together with the other binaries.

<div class="node">
<a name="Using-source-highlight-as-a-CGI"></a>
<a name="Using-source_002dhighlight-as-a-CGI"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Building-_002erpm">Building .rpm</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Using-source_002dhighlight-with-less">Using source-highlight with less</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Installation">Installation</a>

</div>

<h3 class="section">2.8 Using source-highlight as a CGI</h3>

<p><a name="index-CGI-71"></a>CGI support was enabled thanks to Robert Wetzel; I haven't tested it
personally.  If you want to use source-highlight as a CGI program, you
have to use the executable source-highlight-cgi.  You can build such
executable by issuing

<pre class="example">     make source-highlight-cgi
</pre>
   <p class="noindent">in the <samp><span class="file">src</span></samp> directory.

<div class="node">
<a name="Building-.rpm"></a>
<a name="Building-_002erpm"></a>
<p><hr>
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Using-source_002dhighlight-as-a-CGI">Using source-highlight as a CGI</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Installation">Installation</a>

</div>

<h3 class="section">2.9 Building .rpm</h3>

<p><a name="index-rpm-72"></a>
Christian W. Zuckschwerdt added support for building an .rpm and an
.rpm.src.  You can issue the following command

<pre class="example">     rpmbuild -tb source-highlight-3.1.7.tar.gz
</pre>
   <p>for building an .rpm with binaries and

<pre class="example">     rpmbuild -ts source-highlight-3.1.7.tar.gz
</pre>
   <p>for building an .rpm.src with sources.

<div class="node">
<a name="Copying"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Simple-Usage">Simple Usage</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Installation">Installation</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">3 Copying Conditions</h2>

<p><a name="index-Copying-conditions-73"></a>
GNU Source-highlight is free software; you are free to use, share and modify it
under the terms of the GNU General Public License that accompanies this software
(see <samp><span class="file">COPYING</span></samp>).

   <p>GNU <samp><span class="command">source-highlight</span></samp> was written and
maintained by Lorenzo Bettini <a href="http://www.lorenzobettini.it">http://www.lorenzobettini.it</a>.

<div class="node">
<a name="Simple-Usage"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Configuration-files">Configuration files</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Copying">Copying</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">4 Simple Usage</h2>

<p><a name="index-sample-74"></a>
Here are some realistic examples of running
<samp><span class="command">source-highlight</span></samp><a rel="footnote" href="#fn-10" name="fnd-10"><sup>10</sup></a>.

   <p>Source-highlight only does a lexical analysis of the source code, so the
program source is assumed to be correct!

   <p>Here's how to run source-highlight (for this example we will use
C/C++ input files, but this is valid also for other source-highlight
input languages):

<pre class="example">     source-highlight --src-lang cpp --out-format html \
         --input <var>&lt;C++ file&gt;</var> \
         --output <var>&lt;html file&gt;</var> \
         --style-file <var>&lt;style file&gt;</var> \
         <var>options</var>
</pre>
   <p>For input files, apart from the <code>-i (--input)</code> option and the
standard input redirection, you can simply specify some files at the
command line and also use regular expressions (for instance
<samp><span class="file">*.java</span></samp>).  In this case the name for the output files will be
formed using the name of the source file with a .&lt;ext&gt; appended, where
&lt;ext&gt; is the extension chosen according to the output format specified
(in this example it would be .html).  The style file
(<a href="#Output-format-style">Output format style</a>)
contains information on how to format specific language parts
(e.g., keywords in blue and boldface, etc.).

   <p>IMPORTANT: you must choose one of the above two invocation modes: either
you use <code>-i (--input)</code>, <code>-o (--output)</code> (possibly replacing
them with standard input/output redirection), or you specify one or many
files without <code>-i (--input)</code>; if you try to mix them you'll get an
error:

<pre class="example">     source-highlight -o main.html main.cpp
     Please, use one of the two syntaxes for invocation:
     source-highlight [OPTIONS]... -i input_file -o output_file
     source-highlight [OPTIONS]... [FILES]...
</pre>
   <p>If <code>STDOUT</code> string is passed as <code>-o (--output)</code> option, then
the output is forced to the standard output anyway.

   <p>If <code>-s (--src-lang)</code> is not specified, the source language is
inferred by the extension of the input file or from the file name itself
(possibly using also lower case versions); this, of course, does not
work with standard input redirection.  For further details, see <a href="#How-the-input-language-is-discovered">How the input language is discovered</a>.

   <p>If <code>-f (--out-format)</code> is not specified, the output will be
produced in HTML.

   <p>If <code>--style-file</code> is not specified, the <samp><span class="file">default.style</span></samp>, which
is included in the distribution, will be used (see <a href="#Output-format-style">Output format style</a>
for further information).

<ul class="menu">
<li><a accesskey="1" href="#HTML-and-XHTML-output">HTML and XHTML output</a>
<li><a accesskey="2" href="#LaTeX-output">LaTeX output</a>
<li><a accesskey="3" href="#Texinfo-output">Texinfo output</a>
<li><a accesskey="4" href="#DocBook-output">DocBook output</a>
<li><a accesskey="5" href="#ANSI-color-escape-sequences">ANSI color escape sequences</a>
<li><a accesskey="6" href="#Odf-output">Odf output</a>
</ul>

<div class="node">
<a name="HTML-and-XHTML-output"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#LaTeX-output">LaTeX output</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Simple-Usage">Simple Usage</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Simple-Usage">Simple Usage</a>

</div>

<h3 class="section">4.1 HTML and XHTML output</h3>

<p><a name="index-HTML-75"></a><a name="index-XHTML-76"></a>
The default output format for HTML and XHTML uses fixed width fonts by
inserting all the formatted output between <code>&lt;tt&gt;</code> and <code>&lt;/tt&gt;</code>. 
Thus, for instance, specification for fixed width and not fixed width
(see <a href="#Output-format-style">Output format style</a>) will have no effect: every character
will have fixed width.  If you don't like this default behavior and
would like to have not fixed fonts by default (as it happens, e.g., with
LaTeX output) you can use the file <samp><span class="file">html_notfixed.outlang</span></samp> with
the command line argument <code>--outlang-def</code>.  For XHTML output, the
corresponding file is <samp><span class="file">xhtml_notfixed.outlang</span></samp>

   <p>Furthermore, the file <samp><span class="file">htmltable.outlang</span></samp> can be used to generate
HTML output enclosed in an HTML table (which will use also a background
color if specified in the style file).   The file
<samp><span class="file">xhtmltable.outlang</span></samp> does the same but for XHTML output.

<div class="node">
<a name="LaTeX-output"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Texinfo-output">Texinfo output</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#HTML-and-XHTML-output">HTML and XHTML output</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Simple-Usage">Simple Usage</a>

</div>

<h3 class="section">4.2 LaTeX output</h3>

<p><a name="index-g_t_0040LaTeX_007b_007d-77"></a>
When using LaTeX output format you can choose between monochromatic
output (by using <code>-f latex</code>) or colored output (by using <code>-f
latexcolor</code>).  When using colored output, you need the
<code>color</code> package (again this should be present in your system). 
Of course, you are free to define your own LaTeX output format,
see <a href="#Output-Language-Definitions">Output Language Definitions</a>.

<div class="node">
<a name="Texinfo-output"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#DocBook-output">DocBook output</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#LaTeX-output">LaTeX output</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Simple-Usage">Simple Usage</a>

</div>

<h3 class="section">4.3 Texinfo output</h3>

<p><a name="index-Texinfo-78"></a>
When using the Texinfo output format, you may want to use a dedicated
style file, <samp><span class="file">texinfo.style</span></samp>, which comes with the source-highlight
distribution, with the option <code>--style-file</code>.  For instance, the
example in <a href="#Examples">Examples</a> is formatted with this style file.

<div class="node">
<a name="DocBook-output"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#ANSI-color-escape-sequences">ANSI color escape sequences</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Texinfo-output">Texinfo output</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Simple-Usage">Simple Usage</a>

</div>

<h3 class="section">4.4 DocBook output</h3>

<p><a name="index-DocBook-79"></a>
DocBook output is generated using the <code>&lt;programlisting&gt;</code> tag.  If
the <code>--doc</code> command line option is given, an <code>&lt;article&gt;</code>
document is generated.

<div class="node">
<a name="ANSI-color-escape-sequences"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Odf-output">Odf output</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#DocBook-output">DocBook output</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Simple-Usage">Simple Usage</a>

</div>

<h3 class="section">4.5 ANSI color escape sequences</h3>

<p><a name="index-ANSI-color-80"></a>
If you're using this output format, for instance together with
<code>less</code> (see <a href="#Using-source_002dhighlight-with-less">Using source-highlight with less</a>), you may want
to use the <samp><span class="file">esc.style</span></samp> (or <samp><span class="file">esc256.style</span></samp> if your terminal
can handle 256 colors), which comes with the source-highlight
distribution, with the option <code>--style-file</code>.  This should result
in a more pleasant coloring output.

<div class="node">
<a name="Odf-output"></a>
<p><hr>
Previous:&nbsp;<a rel="previous" accesskey="p" href="#ANSI-color-escape-sequences">ANSI color escape sequences</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Simple-Usage">Simple Usage</a>

</div>

<h3 class="section">4.6 Odf output</h3>

<p>The ODF language output for GNU source-highlight enables the user to
generate color-highlighted ODF output of source code files. Or to
generate ODF color-highlighted snippets to be used by ODF back-ends
(like asciidoc-odf).  We create an <code>.fodt</code> file, which is a Text
document that newer versions of LibreOffice can open.

<div class="node">
<a name="Configuration-files"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Invoking-source_002dhighlight">Invoking source-highlight</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Simple-Usage">Simple Usage</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">5 Configuration files</h2>

<p><a name="index-configuration-files-81"></a>
During execution, source-highlight needs some files where it finds
directives on how to recognize the source language (if not  specified
explicitly with <code>--src-lang</code> or <code>--lang-def</code>), on which output
format to use (if not specified explicitly with <code>--out-format</code> or
<code>--outlang-def</code>), on how to format specific source elements (e.g.,
keywords, comments, etc.), and source and output language definitions. 
These files will be explained in the next sections.

   <p><a name="index-g_t_0040code_007b_002d_002ddata_002ddir_007d-82"></a>If the directory for such files is not explicitly specified with the
command line option <code>--data-dir</code>, these files are searched for in
the following order:

     <ul>
<li>the current directory;
<li>the installation directory for conf files, see <a href="#Installation">Installation</a>
(please keep in mind that this directory is hard-coded into
source-highlight during compilation). 
<li>if the source-highlight command is specified with an
explicit path name, the installation directory name is
still used, but relative to the explicit path name. 
</ul>

   <p>In particular, the user can set the value also with the environment
variable
<a name="index-g_t_0040code_007bSOURCE_005fHIGHLIGHT_005fDATADIR_007d-83"></a><code>SOURCE_HIGHLIGHT_DATADIR</code> (see also <a href="#The-program-source_002dhighlight_002dsettings">The program source-highlight-settings</a>).

   <p>If you want to be sure about which file is used during the
execution, you can use the command line option <code>--verbose</code>.

<ul class="menu">
<li><a accesskey="1" href="#Output-format-style">Output format style</a>
<li><a accesskey="2" href="#Output-format-style-using-CSS">Output format style using CSS</a>
<li><a accesskey="3" href="#Default-Styles">Default Styles</a>
<li><a accesskey="4" href="#Language-map">Language map</a>
<li><a accesskey="5" href="#Language-definition-files">Language definition files</a>
<li><a accesskey="6" href="#Output-Language-map">Output Language map</a>
<li><a accesskey="7" href="#Output-Language-definition-files">Output Language definition files</a>
<li><a accesskey="8" href="#Developing-your-own-definition-files">Developing your own definition files</a>
</ul>

<div class="node">
<a name="Output-format-style"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Output-format-style-using-CSS">Output format style using CSS</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Configuration-files">Configuration files</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Configuration-files">Configuration files</a>

</div>

<h3 class="section">5.1 Output format style</h3>

<p><a name="index-output-style-84"></a><a name="index-default_002estyle-85"></a>
You must specify your options for syntax highlighting in the file
<samp><span class="file">default.style</span></samp><a rel="footnote" href="#fn-11" name="fnd-11"><sup>11</sup></a>. 
You can specify formatting options for each element defined
by a language definition file (you can get the list of such elements,
<a name="index-g_t_0040code_007b_002d_002dshow_002dlang_002delements_007d-86"></a>by using <code>--show-lang-elements</code>, see <a href="#Listing-Language-Elements">Listing Language Elements</a>).

   <p><a name="index-g_t_0040code_007bbgcolor_007d-87"></a><a name="index-background-color-88"></a>Since version 2.6, you can also specify the background color for the
output document, using the keyword <code>bgcolor</code> (this might be visible
only when the <code>--doc</code> command line option is used).

   <p>If many elements share the same formatting options, you can specify
these elements in the same line, separated by a comma<a rel="footnote" href="#fn-12" name="fnd-12"><sup>12</sup></a>.

   <p>Here's the <samp><span class="file">default.style</span></samp> that comes with this distribution (this
is formatted by using the <samp><span class="file">style.lang</span></samp> that is shown in
<a href="#Tutorials-on-Language-Definitions">Tutorials on Language Definitions</a>):

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <b>bgcolor</b> <tt>"white"</tt>; <i>// the background color for documents</i>
     <i>context</i> <b>gray</b>; <i>// the color for context lines (when specified with line ranges)</i>
     
     <i>keyword</i> <b>blue</b> <b>b</b> ; <i>// for language keywords</i>
     <i>type</i> <b>darkgreen</b> ; <i>// for basic types</i>
     <i>usertype</i> <b>teal</b> ; <i>// for user defined types</i>
     <i>string</i> <b>red</b> <b>f</b> ; <i>// for strings and chars</i>
     <i>regexp</i> <b>orange</b> <b>f</b> ; <i>// for strings and chars</i>
     <i>specialchar</i> <b>pink</b> <b>f</b> ; <i>// for special chars, e.g., \n, \t, \\</i>
     <i>comment</i> <b>brown</b> <b>i</b>, <b>noref</b>; <i>// for comments</i>
     <i>number</i> <b>purple</b> ;       <i>// for literal numbers</i>
     <i>preproc</i> <b>darkblue</b> <b>b</b> ; <i>// for preproc directives (e.g. #include, import)</i>
     <i>symbol</i> <b>darkred</b> ; <i>// for simbols (e.g. &lt;, &gt;, +)</i>
     <i>function</i> <b>black</b> <b>b</b>; <i>// for function calls and declarations</i>
     <i>cbracket</i> <b>red</b>; <i>// for block brackets (e.g. {, })</i>
     <i>todo</i> <b>bg:cyan</b> <b>b</b>;       <i>// for TODO and FIXME</i>
     <i>code</i> <b>bg:brightgreen</b> <b>b</b>; <i>// for code snippets</i>
     
     <i>//Predefined variables and functions (for instance glsl)</i>
     <i>predef_var</i> <b>darkblue</b> ;
     <i>predef_func</i> <b>darkblue</b> <b>b</b> ;
     
     <i>// for OOP</i>
     <i>classname</i> <b>teal</b> ; <i>// for class names, e.g., in Java and C++</i>
     
     <i>// line numbers</i>
     <b>linenum</b> <b>black</b> <b>f</b>;
     
     <i>// Internet related</i>
     <i>url</i> <b>blue</b> <b>u</b>, <b>f</b>;
     
     <i>// other elements for ChangeLog and Log files</i>
     <i>date</i> <b>blue</b> <b>b</b> ;
     <i>time</i>, <i>file</i> <b>darkblue</b> <b>b</b> ;
     <i>ip</i>, <i>name</i> <b>darkgreen</b> ;
     
     <i>// for Prolog, Perl...</i>
     <i>variable</i> <b>darkgreen</b> ;
     
     <i>// explicit for Latex</i>
     <i>italics</i> <b>darkgreen</b> <b>i</b>;
     <i>bold</i> <b>darkgreen</b> <b>b</b>;
     <i>underline</i> <b>darkgreen</b> <b>u</b>;
     <i>fixed</i> <b>green</b> <b>f</b>;
     <i>argument</i> <b>darkgreen</b>;
     <i>optionalargument</i> <b>purple</b>;
     <i>math</i> <b>orange</b>;
     <i>bibtex</i> <b>blue</b>;
     
     <i>// for diffs</i>
     <i>oldfile</i> <b>orange</b>;
     <i>newfile</i> <b>darkgreen</b>;
     <i>difflines</i> <b>blue</b>;
     
     <i>// for css</i>
     <i>selector</i> <b>purple</b>;
     <i>property</i> <b>blue</b>;
     <i>value</i> <b>darkgreen</b> <b>i</b>;
     
     <i>// for oz</i>
     <i>atom</i> <b>orange</b>;
     <i>meta</i> <b>i</b>;
     
     <i>// for file system</i>
     <i>path</i> <b>orange</b>;
     
     <i>// for C (or other language) labels</i>
     <i>label</i> <b>teal</b> <b>b</b>;
     
     <i>// for errors</i>
     <i>error</i> <b>purple</b>;
     <i>warning</i> <b>darkgreen</b>;
</pre>
   <p>This file tries to define a style for most elements defined in the
language definition files that comes with Source-highlight
distribution.

   <p><a name="index-g_t_0040code_007b_002d_002dstyle_002dfile_007d-89"></a>You can specify your own file (it doesn't have to be named
<samp><span class="file">default.style</span></samp>) with the command line option
<code>--style-file</code><a rel="footnote" href="#fn-13" name="fnd-13"><sup>13</sup></a>, see
<a href="#Invoking-source_002dhighlight">Invoking source-highlight</a>.

   <p>You can also specify the color of normal text by adding this line

<pre class="example">     normal darkblue ;
</pre>
   <p><a name="index-color-90"></a><a name="index-background-color-91"></a>As you might see the syntax of this file is quite straightforward: after
the element (or elements, separated by commas) you can specify the
color, and the background color<a rel="footnote" href="#fn-14" name="fnd-14"><sup>14</sup></a> by using
the prefix <code>bg:</code> (for instance, in the <samp><span class="file">default.style</span></samp> above
the background color is specified for the <code>todo</code> element).

   <p>Note that the background color might not be available for all output
formats: it is available for XHTML and LaTeX but not for
HTML<a rel="footnote" href="#fn-15" name="fnd-15"><sup>15</sup></a>.

   <p><a name="index-bold-92"></a><a name="index-italics-93"></a><a name="index-underline-94"></a><a name="index-fixed-95"></a><a name="index-notfixed-96"></a>Then, you can specify further formatting options such as bold, italics,
etc.; these are the keywords that can be used:

<pre class="example">     b = bold
     i = italics
     u = underline
     f = fixed
     nf = not fixed
     noref = no reference information is generated for these elements
</pre>
   <p><a name="index-color-97"></a>Since version 2.2, the color specification is not required.  For
instance, the <samp><span class="file">texinfo.style</span></samp> is as follows (we avoid colors for
Texinfo outputs):

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <i>keyword</i>, <i>type</i> <b>b</b> ;
     <i>variable</i> <b>f</b>, <b>i</b> ;
     <i>string</i> <b>f</b> ;
     <i>regexp</i> <b>f</b> ;
     <i>comment</i> <b>nf</b>, <b>i</b>, <b>noref</b> ;
     <i>preproc</i> <b>b</b> ;
     
     <i>// line numbers</i>
     <b>linenum</b> <b>f</b>;
     
     <i>// Internet related</i>
     <i>url</i> <b>f</b>;
     
     <i>// for diffs</i>
     <i>oldfile</i>, <i>newfile</i> <b>i</b>;
     <i>difflines</i> <b>b</b>;
     
     <i>// for css</i>
     <i>selector</i>, <i>property</i> <b>b</b>;
     <i>value</i> <b>i</b>;
</pre>
   <p>You may also specify more than on of these options separated by commas,
e.g.

<pre class="example">     keyword blue u, b ;
</pre>
   <p class="noindent">Please keep in mind that in this case the order of these specified
options is kept during the generation of the output; for instance,
depending on the specific output format, the sequences <code>u, b</code> and
<code>b, u</code> may lead to different results.  In particular, the style
that comes first is used after the ones that follow.  For instance, in
the case of HTML, the sequence <code>u, b</code> will lead to the following
formatting: <code>&lt;u&gt;&lt;b&gt;...&lt;/b&gt;&lt;/u&gt;</code>.

   <p><a name="index-noref-98"></a>The <code>noref</code> option specifies that for this element reference
information are not generated (see <a href="#Generating-References">Generating References</a>).  For
instance, this is used for the <code>comment</code> element, since we do not
want that elements in a comment are searched for cross-references.

   <p>These are all possible color logical names handled by
source-highlight<a rel="footnote" href="#fn-16" name="fnd-16"><sup>16</sup></a>:

<pre class="example">     black
     red
     darkred
     brown
     yellow
     cyan
     blue
     pink
     purple
     orange
     brightorange
     green
     brightgreen
     darkgreen
     teal
     gray
     darkblue
     white
</pre>
   <p><a name="index-direct-color-scheme-99"></a>You can also use the direct color scheme for the specific output format,
by using double quotes, such as, e.g., <code>"#00FF00"</code> in
HTML<a rel="footnote" href="#fn-17" name="fnd-17"><sup>17</sup></a> or even string colors in double quotes<a rel="footnote" href="#fn-18" name="fnd-18"><sup>18</sup></a>, such as <code>"lightblue"</code>.  Of course, the double quotes will be
discarded during the generation.

   <p>For instance, this is the <samp><span class="file">syslog.style</span></samp> used in the <samp><span class="file">tests</span></samp>
directory.  This uses direct color schemes.

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <i>date</i>, <i>keyword</i> <b>yellow</b> <b>b</b> ;
     <i>time</i> <tt>"#9999FF"</tt> ;
     <i>ip</i> <tt>"lightblue"</tt> <b>b</b> ;
     
     <i>type</i> <b>cyan</b> <b>b</b> ;
     <i>string</i> <tt>"brown"</tt> <b>b</b> ;
     <i>comment</i> <b>teal</b> ;
     <i>number</i> <b>red</b> ;
     <i>preproc</i> <b>cyan</b> ;
     <i>symbol</i> <b>green</b> ;
     <i>function</i> <tt>"#CC66CC"</tt> <b>b</b> ;
     <i>cbracket</i> <b>green</b> <b>b</b> ;
     <i>twonumbers</i> <b>green</b> <b>b</b> ;
     <i>port</i> <b>green</b> <b>b</b> ;
     <i>webmethod</i> <b>teal</b> ;
     
     <i>// foo option</i>
     <i>foo</i> <b>red</b> <b>b</b> ; <i>// foo entry</i>
     
     
</pre>
   <p>Note that, if you use direct color schemes, source-highlight will
perform no transformation, and will output exactly the color scheme you
specified.  For instance, the specification <code>"brown"</code> is different
from <code>brown</code>: the former will be output as it is, while the latter
will be translated in the corresponding color of the output format (for
HTML the visible result is likely to be the same).

   <p>It is up to you to specify a color scheme string that is handled by the
specific output format.  Thus, direct color schemes might not be
portable in different output formats; for instance, <code>"#00FF00"</code> is
valid in HTML but not in LaTeX.

<div class="node">
<a name="Output-format-style-using-CSS"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Default-Styles">Default Styles</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Output-format-style">Output format style</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Configuration-files">Configuration files</a>

</div>

<h3 class="section">5.2 Output format style using CSS</h3>

<p><a name="index-CSS-100"></a>Since version 2.6 you can specify the output format style also using
a limited CSS syntax.  Please, note that this has nothing to do
with output produced by source-highlight using the <code>--css</code> option.

   <p><a name="index-g_t_0040code_007b_002d_002dstyle_002dcss_002dfile_007d-101"></a>By using a CSS file as the style file (i.e., passing it to the
<code>--style-css-file</code> command line option) you will only specify the
output format style using the same syntax of CSS.  This means that you
can use a css syntax for specifying the output format style
independently from the actual output (this is what the output format
style is for).  Thus, you can use a css file as the output format style
also for LaTeX output (just like you would do with a source-highlight
output format style, <a href="#Output-format-style">Output format style</a>).

   <p>This feature is provided basically for code re-use: you can specify the
output format style using a css file, and then re-use the same css file
as the actual style sheet of other HTML pages (or even output files
produced by source-highlight using the <code>--css</code> option).

   <p>Note that this feature is quite primordial, so only a limited subset
of CSS syntax is recognized.  In particular, selectors are always
intended as CSS class selectors, so they must start with a dot. 
<code>/* */</code> comments are handled.  Properties (and their values) not
handled by source-highlight are simply (and silently) discarded).

   <p>This is an example of CSS specification handled correctly by
source-highlight as a style format specification:

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     body {
       <b>background-color:</b> &lt;<i>color</i> <i>specification</i>&gt;;
      }
     
     <b>.selector</b> {
       <b>color:</b> &lt;<i>color</i> <i>specification</i>&gt;;
       <b>background-color:</b> &lt;<i>color</i> <i>specification</i>&gt;;
       <b>font-weight:</b> <i>bold</i>; <i>/* this is a comment */</i>
       <b>font-family:</b> <i>monospace</i>;
       <b>font-style:</b> <i>italic</i>;
       <b>text-decoration:</b> <i>underline</i>;
      }
</pre>
   <p>Finally, this is the <samp><span class="file">default.css</span></samp> that corresponds to
<samp><span class="file">default.style</span></samp> presented in <a href="#Output-format-style">Output format style</a>:

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     body {  <b>background-color:</b> <i>white</i>;  }
     
     <i>/* the color for context lines (when specified with line ranges) */</i>
     <b>.context</b> {  <b>color:</b> <i>gray</i>; }
     
     <b>.keyword</b> { <b>color:</b> <i>blue</i>; <b>font-weight:</b> <i>bold</i>; }
     <b>.type</b> { <b>color:</b> <i>darkgreen</i>; }
     <b>.usertype</b>, <b>.classname</b> { <b>color:</b> <i>teal</i>; }
     <b>.string</b> { <b>color:</b> <i>red</i>; <b>font-family:</b> <i>monospace</i>; }
     <b>.regexp</b> { <b>color:</b> <i>orange</i>; }
     <b>.specialchar</b> { <b>color:</b> <i>pink</i>; <b>font-family:</b> <i>monospace</i>; }
     <b>.comment</b> { <b>color:</b> <i>brown</i>; <b>font-style:</b> <i>italic</i>; }
     <b>.number</b> { <b>color:</b> <i>purple</i>; }
     <b>.preproc</b> { <b>color:</b> <i>darkblue</i>; <b>font-weight:</b> <i>bold</i>; }
     <b>.symbol</b> { <b>color:</b> <i>darkred</i>; }
     <b>.function</b> { <b>color:</b> <i>black</i>; <b>font-weight:</b> <i>bold</i>; }
     <b>.cbracket</b> { <b>color:</b> <i>red</i>; }
     <b>.todo</b> { <b>font-weight:</b> <i>bold</i>; <b>background-color:</b> <i>cyan</i>; }
     
     <i>/* line numbers */</i>
     <b>.linenum</b> { <b>color:</b> <i>black</i>; <b>font-family:</b> <i>monospace</i>; }
     
     <i>/* Internet related */</i>
     <b>.url</b> { <b>color:</b> <i>blue</i>; <b>text-decoration:</b> <i>underline</i>; <b>font-family:</b> <i>monospace</i>; }
     
     <i>/* other elements for ChangeLog and Log files */</i>
     <b>.date</b> { <b>color:</b> <i>blue</i>; <b>font-weight:</b> <i>bold</i>; }
     <b>.time</b>, <b>.file</b> { <b>color:</b> <i>darkblue</i>; <b>font-weight:</b> <i>bold</i>; }
     <b>.ip</b>, <b>.name</b> { <b>color:</b> <i>darkgreen</i>; }
     
     <i>/* for Prolog, Perl */</i>
     <b>.variable</b> { <b>color:</b> <i>darkgreen</i>; }
     <b>.italics</b> { <b>color:</b> <i>darkgreen</i>; <b>font-style:</b> <i>italic</i>; }
     <b>.bold</b> { <b>color:</b> <i>darkgreen</i>; <b>font-weight:</b> <i>bold</i>; }
     
     <i>/* for LaTeX */</i>
     <b>.underline</b> { <b>color:</b> <i>darkgreen</i>; <b>text-decoration:</b> <i>underline</i>; }
     <b>.fixed</b> { <b>color:</b> <i>green</i>; <b>font-family:</b> <i>monospace</i>; }
     <b>.argument</b>, <b>.optionalargument</b> { <b>color:</b> <i>darkgreen</i>; }
     <b>.math</b> { <b>color:</b> <i>orange</i>; }
     <b>.bibtex</b> { <b>color:</b> <i>blue</i>; }
     
     <i>/* for diffs */</i>
     <b>.oldfile</b> { <b>color:</b> <i>orange</i>; }
     <b>.newfile</b> { <b>color:</b> <i>darkgreen</i>; }
     <b>.difflines</b> { <b>color:</b> <i>blue</i>; }
     
     <i>/* for css */</i>
     <b>.selector</b> { <b>color:</b> <i>purple</i>; }
     <b>.property</b> { <b>color:</b> <i>blue</i>; }
     <b>.value</b> { <b>color:</b> <i>darkgreen</i>; <b>font-style:</b> <i>italic</i>; }
     
     <i>/* for Oz */</i>
     <b>.atom</b> { <b>color:</b> <i>orange</i>; }
     <b>.meta</b> { <b>font-style:</b> <i>italic</i>; }
     
</pre>
   <p>If you pass this file to the <code>--style-css-file</code> command line option
and you produce an output file, you will get the same result of using
<samp><span class="file">default.style</span></samp>.

   <p>Source-highlight comes with a lot of CSS files that can be used either
as standard CSS files for HTML documents, or as style files to pass to
<code>--style-css-file</code>.  In the documentation installation directory
(see <a href="#Installation">Installation</a>) you will find the file
<samp><span class="file">style_examples.html</span></samp> which shows many output examples, each one
with a different CSS style.

<div class="node">
<a name="Default-Styles"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Language-map">Language map</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Output-format-style-using-CSS">Output format style using CSS</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Configuration-files">Configuration files</a>

</div>

<h3 class="section">5.3 Default Styles</h3>

<p>This file<a rel="footnote" href="#fn-19" name="fnd-19"><sup>19</sup></a> (the default file is
<samp><span class="file">style.defaults</span></samp>) lists the default style for a language element
whose output style is not specified in the style file; in particular the
following line (comment lines start with <code>#</code>):

<pre class="example">     elem1 = elem2
</pre>
   <p class="noindent">tells that, if the style for an element, say elem1, is not specified in
the style file, then elem1 will have the same style of elem2.

   <p><a name="index-style_002edefaults-102"></a>For instance, this is the <samp><span class="file">style.defaults</span></samp> that comes with
Source-highlight:

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     # defaults for styles
     # the format is:
     # elem1 = elem2
     # meaning that if the style for elem1 is not specified,
     # then it will have the same style as elem2
     
     classname = normal
     usertype = normal
     preproc = keyword
     section = function
     paren = cbracket
     attribute = type
     value = string
     predef_var = type
     predef_func = function
     atom = regexp
     meta = function
     path = regexp
     label = preproc
     error = string
     warning = type
     code = preproc
</pre>
   <p class="noindent">In this case the style for the element <code>preproc</code> will default to
the style of the element <code>keyword</code>.

   <p>This file is useful when you want to create your own style file and you
don't want to specify styles for all the elements that will have the
same output style in your style (e.g., the default style formats
<code>preproc</code> elements differently from keywords, but if in your style
you don't specify a style for it, a <code>preproc</code> element will still be
formatted as a <code>keyword</code>).

<div class="node">
<a name="Language-map"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Language-definition-files">Language definition files</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Default-Styles">Default Styles</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Configuration-files">Configuration files</a>

</div>

<h3 class="section">5.4 Language map</h3>

<p><a name="index-language-map-103"></a>
This configuration file associates a file extension to a specific
language definition file.  You can also use such file extension to
specify the <code>--src-lang</code> option (see <a href="#Simple-Usage">Simple Usage</a>). 
Source-highlight comes with such a file, called <samp><span class="file">lang.map</span></samp>.

   <p>Of course, you can override the settings of this file by writing your
own language map file and specify such file with the command line option
<code>--lang-map</code>).  Moreover, as explained above, if a file
<samp><span class="file">lang.map</span></samp> is present in the current directory, such version will
be used.  The format of such file is quite simple (comment lines start
with <code>#</code>):

<pre class="example">     extension = language definition file
</pre>
   <p>The default language definition file is shown in <a href="#Introduction">Introduction</a>.

<div class="node">
<a name="Language-definition-files"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Output-Language-map">Output Language map</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Language-map">Language map</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Configuration-files">Configuration files</a>

</div>

<h3 class="section">5.5 Language definition files</h3>

<p>These files are crucial for source-highlight since they specify the
source elements that have to be highlighted.   These files also allow to
specify your own language definitions in order to deal with a language
that is not handled by source-highlight<a rel="footnote" href="#fn-20" name="fnd-20"><sup>20</sup></a>.  The syntax for these files is explained in <a href="#Language-Definitions">Language Definitions</a>.

<div class="node">
<a name="Output-Language-map"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Output-Language-definition-files">Output Language definition files</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Language-definition-files">Language definition files</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Configuration-files">Configuration files</a>

</div>

<h3 class="section">5.6 Output Language map</h3>

<p><a name="index-output-language-map-104"></a>
This configuration file associates an output format to a specific output
language definition file.  You can use the name of that output format to
specify the <code>--out-format</code> option (see <a href="#Simple-Usage">Simple Usage</a>). 
Source-highlight comes with such a file, called <samp><span class="file">outlang.map</span></samp>.

   <p>Of course, you can override the settings of this file by
writing your own output language map file and specify such file
with the command line option <code>--outlang-map</code>). 
Moreover, as explained above, if a file <samp><span class="file">outlang.map</span></samp>
is present in the current directory, such version will be used. 
The format of such file is quite simple:

<pre class="example">     output format name = language definition file
</pre>
   <p>The default language definition file is shown in <a href="#Introduction">Introduction</a>.

   <p>In particular, there is a convention for the output format name in the
output language map: the one with <code>-css</code> suffix is the one used
when <code>--css</code> command line option is given

<div class="node">
<a name="Output-Language-definition-files"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Developing-your-own-definition-files">Developing your own definition files</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Output-Language-map">Output Language map</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Configuration-files">Configuration files</a>

</div>

<h3 class="section">5.7 Output Language definition files</h3>

<p>These files are crucial for source-highlight since they specify how the
source elements are highlighted.   These files also allow to specify
your own output format definitions in order to deal with an output
format that is not handled by source-highlight<a rel="footnote" href="#fn-21" name="fnd-21"><sup>21</sup></a>.  The syntax for these files is explained in <a href="#Output-Language-Definitions">Output Language Definitions</a>.

   <p>These files are part of source-highlight distribution, but they can
also be downloaded, independently, from here:

   <p><a href="http://www.gnu.org/software/src-highlite/outlang_files/">http://www.gnu.org/software/src-highlite/outlang_files/</a>

<div class="node">
<a name="Developing-your-own-definition-files"></a>
<p><hr>
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Output-Language-definition-files">Output Language definition files</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Configuration-files">Configuration files</a>

</div>

<h3 class="section">5.8 Developing your own definition files</h3>

<p>I encourage those who write new language definitions or correct/modify
existing language definitions to send them to me so that they can be
added to the source-highlight distribution!

   <p>Since these files require more explanations (that, however, are not
necessary to the standard usage of source-highlight), they are carefully
explained in separate parts: <a href="#Language-Definitions">Language Definitions</a> and <a href="#Output-Language-Definitions">Output Language Definitions</a>.

   <p>These files are part of source-highlight distribution, but they can
also be downloaded, independently, from here:

   <p><a href="http://www.gnu.org/software/src-highlite/lang_files/">http://www.gnu.org/software/src-highlite/lang_files/</a>

<div class="node">
<a name="Invoking-source-highlight"></a>
<a name="Invoking-source_002dhighlight"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Language-Definitions">Language Definitions</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Configuration-files">Configuration files</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">6 Invoking <samp><span class="command">source-highlight</span></samp></h2>

<p><a name="index-invoking-105"></a><a name="index-version-106"></a><a name="index-options-107"></a><a name="index-usage-108"></a><a name="index-help-109"></a><a name="index-getting-help-110"></a>
The format for running the <samp><span class="command">source-highlight</span></samp> program is:

<pre class="example">     source-highlight <var>option</var> ...
</pre>
   <p><code>source-highlight</code> supports the following options, shown by
the output of <code>source-highlight --detailed-help</code>:

<pre class="smallexample">     source-highlight
     
     Highlight the syntax of a source file (e.g. Java) into a specific format (e.g.
     HTML)
     
     Usage:  [OPTIONS]... &lt; input_file &gt; output_file
            source-highlight [OPTIONS]... -i input_file -o output_file
            source-highlight [OPTIONS]... [FILES]...
     
       -h, --help                    Print help and exit
           --detailed-help           Print help, including all details and hidden
                                       options, and exit
       -V, --version                 Print version and exit
       -i, --input=filename          input file. default std input
       -o, --output=filename         output file. default std output (when the third
                                       invocation form is used). If STDOUT is
                                       specified, the output is directed to standard
                                       output
     
     you can simply specify some files at the command line and also use regular
     expressions (for instance *.java).  In this case the name for the output files
     will be formed using the name of the source file with a .&lt;ext&gt; appended, where
     &lt;ext&gt; is the extension chosen according to the output format specified (for
     instance .html).
     
       -s, --src-lang=STRING         source language (use --lang-list to get the
                                       complete list).  If not specified, the source
                                       language will be guessed from the file
                                       extension.
           --lang-list               list all the supported language and associated
                                       language definition file
           --outlang-list            list all the supported output language and
                                       associated language definition file
       -f, --out-format=STRING       output format (use --outlang-list to get the
                                       complete list)  (default=`html')
       -d, --doc                     create an output file that can be used as a
                                       stand alone document (e.g., not to be
                                       included in another one)
           --no-doc                  cancel the --doc option even if it is implied
                                       (e.g., when css is given)
       -c, --css=filename            the external style sheet filename.  Implies
                                       --doc
       -T, --title=STRING            give a title to the output document.  Implies
                                       --doc
       -t, --tab=INT                 specify tab length.  (default=`8')
       -H, --header=filename         file to insert as header
       -F, --footer=filename         file to insert as footer
           --style-file=filename     specify the file containing format options
                                       (default=`default.style')
           --style-css-file=filename specify the file containing format options (in
                                       css syntax)
           --style-defaults=filename specify the file containing defaults for format
                                       options  (default=`style.defaults')
           --outlang-def=filename    output language definition file
           --outlang-map=filename    output language map file
                                       (default=`outlang.map')
           --data-dir=path           directory where language definition files and
                                       language maps are searched for.  If not
                                       specified these files are searched for in the
                                       current directory and in the data dir
                                       installation directory
           --output-dir=path         output directory
           --lang-def=filename       language definition file
           --lang-map=filename       language map file  (default=`lang.map')
           --show-lang-elements=filename
                                     prints the language elements that are defined
                                       in the language definition file
           --infer-lang              force to infer source script language
                                       (overriding given language specification)
     
     Lines:
       -n, --line-number[=padding]   number all output lines, using the specified
                                       padding character  (default=`0')
           --line-number-ref[=prefix]
                                     number all output lines and generate an anchor,
                                       made of the specified prefix + the line
                                       number  (default=`line')
     
     Filtering output:
     
      Mode: linerange
       specifying line ranges
           --line-range=STRING       generate only the lines in the specified
                                       range(s)
       each range can be of the shape:
       	single line (e.g., --line-range=50)
       	full range (e.g., --line-range=2-10)
       	partial range (e.g., --line-range=-30, first 30 lines,
       	--line-range=40- from line 40 to the end
     
           --range-separator=STRING  the optional separator to be printed among
                                       ranges (e.g., "...")
           --range-context=INT       number of (context) lines generated even if not
                                       in range
       The optional --range-context specifies the number of lines that are not in
       	range that will be printed anyway (before and after the lines in range);
       	These lines will be formatted according to the "context" style.
     
     
      Mode: regexrange
       specifying regular expression delimited ranges
           --regex-range=STRING      generate only the lines within the specified
                                       regular expressions
       when a line containing the specified regular expression is found, then
       the lines after this one are actually generated, until another line,
       containing the same regular expression is found (this last line is not
       generated).
       More than one regular expression can be specified.
     
     reference generation:
           --gen-references=STRING   generate references  (possible
                                       values="inline", "postline", "postdoc"
                                       default=`inline')
           --ctags-file=filename     specify the file generated by ctags that will
                                       be used to generate references
                                       (default=`tags')
           --ctags=cmd               how to run the ctags command.  If this option
                                       is not specified, ctags will be executed with
                                       the default value.  If it is specified with
                                       an empty string, ctags will not be executed
                                       at all  (default=`ctags --excmd=n
                                       --tag-relative=yes')
     
     testing:
       -v, --verbose                 verbose mode on
       -q, --quiet                   print no progress information
           --binary-output           write output files in binary mode
       This is useful for testing purposes, since you may want to make
       sure that output files are always generated with a final newline character
       only
           --statistics              print some statistics (i.e., elapsed time)
           --gen-version             put source-highlight version in the generated
                                       file  (default=on)
           --check-lang=filename     only check the correctness of a language
                                       definition file
           --check-outlang=filename  only check the correctness of an output
                                       language definition file
           --failsafe                if no language definition is found for the
                                       input, it is simply copied to the output
       -g, --debug-langdef[=type]    debug a language definition.  In dump mode just
                                       dumps all the steps; in interactive, at each
                                       step, waits for some input (press ENTER to
                                       step)  (possible values="interactive",
                                       "dump" default=`dump')
           --show-regex=filename     show the regular expression automaton
                                       corresponding to a language definition file
</pre>
   <p>Let us explain some options in details (apart from those that should be
clear from the <code>--help</code> output itself, and those already explained
in <a href="#Simple-Usage">Simple Usage</a>).

<!-- Formatting copied from the Texinfo 4.0 manual. -->
     <dl>
<dt><code>--data-dir</code><dd><a name="index-g_t_0040code_007b_002d_002ddata_002ddir_007d-111"></a>Source-highlight, during the execution, will need some files, such as,
e.g., language definition files, output format definition files, etc. 
These files are installed in <code>prefix/share/source-highlight</code> where
<code>prefix</code> is chosen at compilation time (see See <a href="#Installation">Installation</a>). 
Thus, source-highlight should be able to find all the files it needs
independently.  However, if you want to override this setting, e.g.,
because you have your own language definition files, or simply because
you installed a possible source-highlight binary in a different
directory from the one used during the compilation, you can use the
command line option <code>--data-dir</code>.

     <br><dt><code>--doc</code><dt><code>-d</code><dd>If you want a stand alone output document (i.e., an output file that is
not thought to be included in another document), specify this option
(otherwise you just get some text that you can paste into another
document).  If you choose this option and do not provide a
<code>--title</code>, the your source file name will be used as the title.

     <br><dt><code>--no-doc</code><dd>The <code>--doc</code> option above is actually implied by other command line
options (e.g., <code>--css</code>).  If you do not want this (e.g., you want
to include the output in an existing document containing the global
style sheet), you can disable this by using <code>--no-doc</code>.

     <br><dt><code>--css</code><dt><code>-c</code><dd>Specify the style sheet file (e.g., a <samp><span class="file">.css</span></samp> for HTML<a rel="footnote" href="#fn-22" name="fnd-22"><sup>22</sup></a>) for the output document.  Note that source-highlight
will not use this file: it will simply use this file name when
generating the output file, so to specify that the output file uses this
file as the style sheet (e.g., if the generated HTML relies on this file
as the CSS file).

     <br><dt><code>--tab</code><dt><code>-t</code><dd>With this options, tab characters will be converted into specified
number of space characters (tabulation points will be preserved).  This
option is automatically selected when generating line numbers.

     <br><dt><code>--style-file</code><dt><code>--style-css-file</code><dd>Specify the file that source-highlight will use to produce (i.e.,
format) the output (e.g., colors and other styles for each  language
element).  The formats of these files are detailed in <a href="#Output-format-style">Output format style</a> and in <a href="#Output-format-style-using-CSS">Output format style using CSS</a>, respectively.

     <br><dt><code>--style-defaults</code><dd>Specify the file that contains the default styles for elements
whose styles are not found in the style file (see <a href="#Default-Styles">Default Styles</a> for
further details).

     <br><dt><code>--output-dir</code><dd>You can pass to source-highlight more than one input file (see
<a href="#Simple-Usage">Simple Usage</a>).  In this case you cannot specify the output file
name.  In such cases the output files will be automatically generated
into the directory where you invoked the command from; if you want the
output files to be generated into a different directory you can use this
option.

     <br><dt><code>--infer-lang</code><dd><a name="index-language-inference-112"></a><a name="index-g_t_0040code_007b_002d_002dinfer_002dlang_007d-113"></a>Force the inference mechanism for detecting the input language.  This is
detailed in <a href="#How-the-input-language-is-discovered">How the input language is discovered</a>.

     <br><dt><code>--line-number</code><dd>Line numbers will be generated in the output, using the (optional)
specified padding character<a rel="footnote" href="#fn-23" name="fnd-23"><sup>23</sup></a> (the default padding character is <code>0</code>).

     <br><dt><code>--line-number-ref</code><dd>As <code>--line-number</code>, this option numbers all the output lines, and,
additionally, generates an anchor for each line.  The anchor consists of
the specified prefix (default is <code>line</code>) and the line number (e.g.,
<code>line25</code>).  For instance, as prefix, if you deal with many files,
you can use the file name.  Note that some output languages might not
support this feature (e.g., <code>esc</code>, since it makes no sense in such
case).  See <a href="#Anchors-and-References">Anchors and References</a> for defining how to generate an
anchor in a specific output language.

     <p><a name="index-line-ranges-114"></a><a name="index-range-context-115"></a><a name="index-range-separator-116"></a><br><dt><code>--line-range</code><dt><code>--range-context</code><dt><code>--range-separator</code><dd>Since version 2.11, you can specify multiple line ranges: only the lines
in the source that are in these ranges will be output.  For instance, by
specifying

     <pre class="example">          --line-range="-5","10","20-25","50-"
</pre>
     <p>Only the following lines will be output: the first 5 lines, line 10,
lines 20 to 25 and from line 50 to the end of input.  (See also the
examples in <a href="#Line-ranges">Line ranges</a>).

     <p>Together with <code>--line-range</code>, you can also specify
<code>--range-context</code>: this is the number of lines that will be printed
before and after the lines of a range (i.e., the surrounding
&ldquo;context&rdquo;).  These lines will not be highlighted: they will be printed
according to the style <code>context</code>.  For instance, extending the
previous example,

     <pre class="example">          --line-range="-5","10","20-25","50-" --range-context=1
</pre>
     <p>Also the following lines will be output: 6, 9, 11, 19, 26, 49.  (See
also the examples in <a href="#Line-ranges-_0028with-context_0029">Line ranges (with context)</a>).

     <p>Finally, you can specify a range separator line string with
<code>--range-separator</code> that will be printed between ranges (See also
the examples in <a href="#Line-ranges-_0028with-context_0029">Line ranges (with context)</a>).  The separator string
is preformatted automatically, so, e.g., you don't have to escape
special output characters, such as the { } in texinfo output.

     <p><a name="index-regex-ranges-117"></a><br><dt><code>--regex-range</code><dd>
Ranges can be expressed also using regular expressions, with the command
line option <code>--regex-range</code>.  In this case the beginning of the
range will be detected by a line containing (in any point) a string
matching the specified regular expression; the end will be detected by a
line containing a string matching the same regular expression that
started the range.  This feature is very useful when we want to document
some code (e.g., in this very manual) by showing only specific parts,
that are delimited in a ad-hoc way in the source code (e.g., with
specific comment patterns).  You can see some usage examples
in See <a href="#Regex-ranges">Regex ranges</a>.

     <p>The specified strings (this option accepts multiple occurrences) must be
valid regular expressions (thus you must escape special characters
accordingly), otherwise you will get an error.

     <p>Furthermore, <code>--line-range</code> and <code>--regex-range</code> cannot coexist
in the same command line.

     <br><dt><code>--failsafe</code><dd><a name="index-failsafe-118"></a>If no language specification is found, an error will be printed and the
program exits.  With this option, instead, in such situations, the input
is simply formatted in the output format.  This is useful when
<samp><span class="command">source-highlight</span></samp> is used with many input files, and it is also
used in the <samp><span class="file">src-hilite-lesspipe.sh</span></samp> script.  Actually I failed to
find a good reason why one should not always use this option.  So my
suggestion is to always use it when you run source-highlight (and
indeed, in the future, this option might become the default one).  See
also <a href="#Using-source_002dhighlight-with-less">Using source-highlight with less</a>, <a href="#Using-source_002dhighlight-as-a-simple-formatter">Using source-highlight as a simple formatter</a>.

     <p><a name="index-default_002elang-119"></a>When using <code>--failsafe</code>, if no input language can be established,
source-highlight will use the input language definition file
<samp><span class="file">default.lang</span></samp>, which is an empty file.  You might want to
customize such file, though.

     <br><dt><code>--debug-lang</code><br><dt><code>--show-regex</code><dd>Allows to debug a language definition file, <a href="#Debugging">Debugging</a>.

   </dl>

   <p>The other command line options dealing with references are explained in
more details in <a href="#Generating-References">Generating References</a>.

<ul class="menu">
<li><a accesskey="1" href="#How-the-input-language-is-discovered">How the input language is discovered</a>
</ul>

<div class="node">
<a name="How-the-input-language-is-discovered"></a>
<p><hr>
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Invoking-source_002dhighlight">Invoking source-highlight</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Invoking-source_002dhighlight">Invoking source-highlight</a>

</div>

<h3 class="section">6.1 How the input language is discovered</h3>

<p>As already explained, <a href="#Simple-Usage">Simple Usage</a>, source-highlight uses a
language definition file according the language specified with the
option <code>--src-lang</code>, or <code>--lang-def</code>, or by using the input
file extension.

   <p>Since version 2.5, source-highlight can use an inference mechanism to
deduce the input language.  For the moment, it can detect script
languages based on the &ldquo;sha-bang&rdquo; mechanism, i.e., when the first line
of a script contains a line such as, e.g.,

<pre class="example">     #!/bin/sh
</pre>
   <p>It detects script languages specified by using the <code>env</code>
program<a rel="footnote" href="#fn-24" name="fnd-24"><sup>24</sup></a>:

<pre class="example">     #!/usr/bin/env perl
</pre>
   <p>It recognizes the Emacs convention, of declaring the Emacs
major mode using the format <code>-*- lang -*-</code>.

   <p>For instance, a script starting as the following one:

<pre class="example">     #!/bin/bash
     # -*- Tcl -*-
</pre>
   <p class="noindent">will be interpreted as a Tcl script, and not as bash script.

   <p>Finally, it recognizes <code>&lt;?</code> specifications (e.g.,
<code>&lt;?php</code> and <code>&lt;?xml</code>) and <code>&lt;!doctype</code> (in that case,
it infers it is an xml file)<a rel="footnote" href="#fn-25" name="fnd-25"><sup>25</sup></a>.

   <p>This inference mechanism is performed, by default, in case the input
language is neither explicitly specified nor found in the language map
file by using the input file extension or the filename itself, possibly
also the lowercase version (the input file may also have no extension at
all, but, for instance, a <samp><span class="file">ChangeLog</span></samp> input file will be
highlighted using <samp><span class="file">changelog.lang</span></samp>).

   <p><a name="index-g_t_0040code_007b_002d_002dinfer_002dlang_007d-120"></a>Furthermore, this mechanism can be given priority with the command line
option <code>--infer-lang</code>.  For instance, this is used in the script
<samp><span class="file">src-hilite-lesspipe.sh</span></samp> (<a href="#Using-source_002dhighlight-with-less">Using source-highlight with less</a>)
when running source-highlight, in order to avoid the problem of
formatting a Perl script as a Prolog program (since the extension
<samp><span class="file">.pl</span></samp> is associated to Prolog programs in the language map file,
<a href="#Perl">Perl</a>).

<div class="node">
<a name="Language-Definitions"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Output-Language-Definitions">Output Language Definitions</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Invoking-source_002dhighlight">Invoking source-highlight</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">7 Language Definitions</h2>

<p><a name="index-language-definition-121"></a>
Since version 2.0 source-highlight uses a specific syntax
to specify source language elements (e.g., keywords, strings,
comments, etc.).  Before version 2.0, language elements were scanned
through Flex.  This had the drawback of writing a new flex file
to deal with a new language; even worse, a new language could
not be added &ldquo;dynamically&rdquo;: you had to recompile the whole
source-highlight program.

   <p>Instead, now, language elements are specified in a file, loaded
dynamically, through a (hopefully) simple syntax.  Then, these
definitions are used internally to create, on-the-fly, regular
expressions that are used to highlight the elements (see also <a href="#How-source_002dhighlight-works">How source-highlight works</a>).  In particular, we use the regular expressions
provided by the Boost library (see <a href="#Installation">Installation</a>).   Thus, when
writing a language definition file you will surely have to deal with
regular expressions.  Don't be scared: for most of the languages you may
never have to deal with difficult regular expressions, and you can also
specify language keywords (such as, e.g., &ldquo;if&rdquo;, &ldquo;while&rdquo;, etc., see
<a href="#Simple-definitions">Simple definitions</a>); moreover, for defining delimited language
elements you will not have to write a regular expression, but just the
delimiters (see <a href="#Delimited-definitions">Delimited definitions</a>).  However, there might be
some language definitions that may require heavy use of more involved
regular expressions (e.g., Perl, just to mention one).

   <p>Of course, we use the Boost regex library regular expression syntax.  We
refer to Boost documentation for such syntax,
<a href="http://www.boost.org/libs/regex/doc/syntax.html">http://www.boost.org/libs/regex/doc/syntax.html</a>, however, in
<a href="#Notes-on-regular-expressions">Notes on regular expressions</a>, we provide some notes on regular
expressions that might be helpful for those who never dealt with them. 
By default, Boost regex library uses Perl regular expression syntax,
and, at the moment, this is the only syntax supported by
source-highlight.

   <p>Here, we see such syntax in details, by relying on many examples.  This
allows a user to easily modify an existing language definition and
create a new one.  These files have, typically, extension <samp><span class="file">.lang</span></samp>.

   <p>Each definition basically associates a regular expression to a language
element and defines a name for the language element.  Such name will be
used to associate a particular style (e.g., bold face, color, etc.) when
highlighting such elements.  You cannot use names that are the same
of keywords used in the language definition syntax (e.g., <code>start</code>,
as shown later, is a reserved word).

   <p>Comments can be given by using <code>#</code>; the rest of the line is
considered as a comment.

   <p>Source-highlight will scan each line of the input file separately.  So a
regular expression that tries to match new line characters is destined
to fail.  However, the language definition syntax provides means to deal
with multiple lines (see <a href="#Delimited-definitions">Delimited definitions</a> and
<a href="#State_002fEnvironment-Definitions">State/Environment Definitions</a>).

<ul class="menu">
<li><a accesskey="1" href="#Ways-of-specifying-regular-expressions">Ways of specifying regular expressions</a>
<li><a accesskey="2" href="#Simple-definitions">Simple definitions</a>
<li><a accesskey="3" href="#Line-wide-definitions">Line wide definitions</a>
<li><a accesskey="4" href="#Order-of-definitions">Order of definitions</a>
<li><a accesskey="5" href="#Delimited-definitions">Delimited definitions</a>
<li><a accesskey="6" href="#Variable-definitions">Variable definitions</a>
<li><a accesskey="7" href="#Dynamic-Backreferences">Dynamic Backreferences</a>
<li><a accesskey="8" href="#File-inclusion">File inclusion</a>:               Include the contents of another file
<li><a accesskey="9" href="#State_002fEnvironment-Definitions">State/Environment Definitions</a>
<li><a href="#Explicit-subexpressions-with-names">Explicit subexpressions with names</a>
<li><a href="#Redefinitions-and-Substitutions">Redefinitions and Substitutions</a>
<li><a href="#How-source_002dhighlight-works">How source-highlight works</a>
<li><a href="#Notes-on-regular-expressions">Notes on regular expressions</a>
<li><a href="#The-program-check_002dregexp">The program check-regexp</a>
<li><a href="#Listing-Language-Elements">Listing Language Elements</a>
<li><a href="#Concluding-Remarks">Concluding Remarks</a>
<li><a href="#Debugging">Debugging</a>:                    Debug a language definition file
<li><a href="#Tutorials-on-Language-Definitions">Tutorials on Language Definitions</a>
</ul>

<div class="node">
<a name="Ways-of-specifying-regular-expressions"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Simple-definitions">Simple definitions</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Language-Definitions">Language Definitions</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Language-Definitions">Language Definitions</a>

</div>

<h3 class="section">7.1 Ways of specifying regular expressions</h3>

<p>Before getting into details of language definition syntax, it is crucial
to describe the 3 possible ways of specifying a regular expression
string.  These 3 different ways, basically differ in the way they handle
regular expression special characters, such, e.g., parenthesis.  For
this reason, one mechanism can be more powerful than another one, but it
could also require more attention; furthermore, there can be situations
where you're forced to use only one mechanism, since the other ones
cannot accomplish the required goal.

     
<a name="index-g_t_0040code_007b_0022expression_0022_007d-122"></a>
<dl><dt><code>"expression"</code><dd>
If you use double quotes (note, <code>"</code> and not <code>``</code> or
<code>''</code>) to specify a regular expression, then basically all the
characters, but the alternation symbol, i.e., the pipe symbol <code>|</code>,
are considered literally, and thus will be automatically escaped (e.g.,
a dot <code>.</code> is interpreted as the character <code>.</code> not as the
regular expression wild card).  Thus, for instance, if you specify

     <pre class="example">          "my(regular)ex.pre$$ion{*}"
</pre>
     <p class="noindent">source-highlight will automatically transform it into

     <pre class="example">          my\(regular\)ex\.pre\$\$ion\{\*\}
</pre>
     <p>The special character <code>|</code>, unless it is meant to separate two
alternatives (<a href="#Simple-definitions">Simple definitions</a>), must be escaped with the
character <code>\</code>, e.g., <code>\|</code>.  Also the character <code>\</code>,
if it is intended literally, must be escaped, e.g., <code>\\</code>.

     <p><a name="index-g_t_0040code_007b_0027expression_0027_007d-123"></a><br><dt><code>'expression'</code><dd>
If you want to enjoy (almost) the full power of regular expressions, you
need to use single quoted strings (<code>'</code>), instead of double quoted
strings.  This way, you can specify special characters with their
intended meaning.

     <p>However, marked subexpressions are automatically transformed in non
marked subexpressions, i.e., the parts in the expression of the shape
<code>(...)</code> will be transformed into <code>(?:...)</code>  (as explained in
<a href="#Notes-on-regular-expressions">Notes on regular expressions</a>, <code>(?:...)</code>  lexically groups
part of a regular expression, without generating a marked
sub-expression).

     <p>Thus, for instance, if you specify

     <pre class="example">          'my(regular)ex.pre$ion*'
</pre>
     <p class="noindent">source-highlight will automatically transform it into

     <pre class="example">          my(?:regular)ex.pre$ion*
</pre>
     <p>Since marked subexpressions cannot be specified with this syntax, then
<em>backreferences</em> (see <a href="#Notes-on-regular-expressions">Notes on regular expressions</a>) are not
allowed.

     <p><a name="index-g_t_0040code_007b_0060expression_0060_007d-124"></a><br><dt><code>`expression`</code><dd>
<a name="index-marked-subexpressions-125"></a><a name="index-backreference-126"></a><a name="index-backtick-127"></a>This syntax<a rel="footnote" href="#fn-26" name="fnd-26"><sup>26</sup></a> (note the difference, this
one uses the <em>backtick</em> <code>`</code> while the previous one uses
<code>'</code>) for specifying a regular expression was introduced to overcome
the limitations of the other two syntaxes.  With this syntax, the marked
subexpressions are not transformed, and so you can use regular
expressions mechanisms that rely on marked subexpressions, such as
<em>backreferences</em> and <em>conditionals</em> (see <a href="#Notes-on-regular-expressions">Notes on regular expressions</a>).

     <p>This syntax is also crucial for highlighting specific program parts of
some programming languages, such as, e.g., Perl regular expressions
(e.g., in substitution expressions) that can be expressed in many forms,
in particular, separators for the part to be replaced and the part to
replace which can be any non alphanumerical characters<a rel="footnote" href="#fn-27" name="fnd-27"><sup>27</sup></a>,
for instance,

     <pre class="example">          s/foo/bar/g
          s|foo|bar|g
          s#foo#bar#g
          s@foo@bar@g
</pre>
     <p>Using this syntax, and backreferences, we can easily define a single
language element to deal with these expressions (without specifying all
the cases for each possible non alphanumerical character):

     <pre class="example">          regexp = `s([^[:alnum:][:blank:]]).*\1.*\1[ixsmogce]*`
</pre>
     </dl>

   <p>Since version 2.11, in all kinds of regular expression specification, you
can insert newline characters, which will simply be ignored.  Thus,
e.g., the file:

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <i># test_newlines.lang</i>
     <i># test that newlines in expressions are simply discarded</i>
     
     <i>keyword</i> = <tt>"foo</tt>
     <tt>|</tt>
     <tt>lang"</tt>
     
     (<i>keyword</i>,<i>normal</i>,<i>classname</i>) =
       <tt>`(\&lt;struct)</tt>
     <tt>([[:blank:]]+)</tt>
     <tt>([[:alnum:]_]+)`</tt>
     
     <i>preproc</i> = <tt>'^[[:blank:]]*</tt>
     <tt>#([[:blank:]]*</tt>
     <tt>[[:word:]]*)'</tt>
</pre>
   <p class="noindent">and the file:

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <i># test_nonewlines.lang</i>
     <i># test that newlines in expressions are simply discarded</i>
     <i># see the corresponding test_newlines.lang</i>
     
     <i>keyword</i> = <tt>"foo|lang"</tt>
     
     (<i>keyword</i>,<i>normal</i>,<i>classname</i>) = <tt>`(\&lt;struct)([[:blank:]]+)([[:alnum:]_]+)`</tt>
     
     <i>preproc</i> = <tt>'^[[:blank:]]*#([[:blank:]]*[[:word:]]*)'</tt>
</pre>
   <p class="noindent">are equivalent.  However, the former is surely more readable.

   <p>Note however, that space characters are NOT ignored in regular expression
definitions.

<div class="node">
<a name="Simple-definitions"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Line-wide-definitions">Line wide definitions</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Ways-of-specifying-regular-expressions">Ways of specifying regular expressions</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Language-Definitions">Language Definitions</a>

</div>

<h3 class="section">7.2 Simple definitions</h3>

<p><a name="index-simple-language-definition-128"></a>
The simplest way to specify language elements is to list the possible
alternatives.  This is the case, for instance, for keywords.  For
instance, in <samp><span class="file">java.lang</span></samp> you have:

<pre class="example">     keyword = "abstract|assert|break|case|catch|class|const",
               "continue|default|do|else|extends|false|final",
               "finally|for|goto|if|implements|instanceof|interface"
     keyword = "native|new|null|private|protected|public|return",
               "static|strictfp|super|switch|synchronized|throw",
               "throws|true|this|transient|try|volatile|while"
</pre>
   <p>You can separate quoted definitions with commas.  Alternatively, within
a quoted definition, alternatives can be separated with the pipe symbol
<code>|</code>.  The above definition defines the language element
<code>keyword</code>.  Each time an element is found in the source file, it is
highlighted with the style for the element with the same name in the
output format style file (note that all elements shown in the example
are taken from the language definition files that come with
source-highlight and there is a style for each of such elements, see
<a href="#Configuration-files">Configuration files</a>).  If such an element is not specified in the
output format style file, it is simply not highlighted (actually, it is
highlighted with style <code>normal</code>, <a href="#Configuration-files">Configuration files</a>) (so pay
attention to typos :-).

   <p>From the above example you may have noted that language element
definitions are cumulative, so the second <code>keyword</code> definition does
not replace the first one.   (Indeed, in some cases you may want to
actually redefine a language element; this is possible as explained in
<a href="#Redefinitions-and-Substitutions">Redefinitions and Substitutions</a>).

   <p>Note that words specified in double quotes have to match exactly in a
source file, and they must be isolated (not surrounded by anything but
spaces).  Thus for instance <code>class</code> is matched as a keyword, but in
<code>my_class</code> the substring <code>class</code> is not matched as keyword. 
From the point of view of regular expressions a string such as
<code>class</code> in a double quote simple definition is intended as
<code>\&lt;(class)\&gt;</code>.

   <p>Special characters have to be escaped with the character <code>\</code>.  So
for instance if you want to specify the character <code>|</code>, which is
normally used to separate alternatives in double quoted strings, you
have to specify <code>\|</code>.

   <p>As explained in <a href="#Ways-of-specifying-regular-expressions">Ways of specifying regular expressions</a>,
definitions in double quotes are interpreted literally (thus, e.g., a
dot <code>.</code> is interpreted as the character <code>.</code> not as the regular
expression wild card).   If you want to enjoy the full power of regular
expressions to specify a language alternative, you have to use single
quoted strings (<code>'</code>), instead of double quoted strings, or strings
quoted with backticks (<code>`</code>).

   <p>For instance, the following is the definition for a preprocessor
directive in C/C++:

<pre class="example">     preproc = '^[[:blank:]]*#([[:blank:]]*[[:word:]]*)'
</pre>
   <p>Note that the definition <code>'class'</code> is different from
<code>"class"</code>, as explained above.  Thus, for instance <code>'class'</code>
matches also the sub-expression <code>class</code> inside <code>my_class</code>.

   <p>Furthermore, you are not allowed to specify, in the same list, double
quoted strings and single quoted strings: you need to split such list
definitions.  Thus, for instance, the following definition is wrong:

<pre class="example">     preproc = "#define",'^[[:blank:]]*#([[:blank:]]*[[:word:]]*)'
</pre>
   <p>while the following one is correct:

<pre class="example">     preproc = "#define"
     preproc = '^[[:blank:]]*#([[:blank:]]*[[:word:]]*)'
</pre>
   <p><a name="index-nonsensitive-129"></a>Finally, at the end of a list of definitions, one can specify the
keyword <code>nonsensitive</code>; in that case, the specified strings will be
interpreted in a non case sensitive way.  For instance, we use this
feature in Pascal language definition, <samp><span class="file">pascal.lang</span></samp> where keywords
are parsed in a non sensitive way:

<pre class="example">     keyword = "alfa|and|array|begin|case|const|div",
           "do|downto|else|end|false|file|for|function|get|goto|if|in",
           "label|mod|new|not|of|or|pack|packed|page|program",
           "put|procedure|read|readln|record|repeat|reset|rewrite|set",
           "text|then|to|true|type|unpack|until|var|while|with|writeln|write"
       nonsensitive
</pre>
   <div class="node">
<a name="Line-wide-definitions"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Order-of-definitions">Order of definitions</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Simple-definitions">Simple definitions</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Language-Definitions">Language Definitions</a>

</div>

<h3 class="section">7.3 Line wide definitions</h3>

<p><a name="index-lines-130"></a>
It is often useful to define a language element that affects all the
remaining characters up to the end of the line.   For such definitions,
instead of the <code>=</code> you must use the keyword <code>start</code>.   For
instance, the following is the definition of a single line comment in
C++:

<pre class="example">     comment start "//"
</pre>
   <p>This means that when the two characters <code>//</code> are encountered in the
source file, everything from these characters on, up to the end of
the line, will be highlighted according to the style <code>comment</code>.

<div class="node">
<a name="Order-of-definitions"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Delimited-definitions">Delimited definitions</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Line-wide-definitions">Line wide definitions</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Language-Definitions">Language Definitions</a>

</div>

<h3 class="section">7.4 Order of definitions</h3>

<p><a name="index-definition-order-131"></a>
It is important to observe that the order of language definitions is
important since it will be used during regular expression matching (this
will be detailed in <a href="#How-source_002dhighlight-works">How source-highlight works</a>).  You then have to
make sure that, if there are definitions that start with same
characters, the longest expression is specified first in the file.  For
instance if you write

<pre class="example">     symbol = "/"
     comment start "//"
</pre>
   <p>The first expression will always be matched first, and the
second expression will never be matched.  The right order is

<pre class="example">     comment start "//"
     symbol = "/"
</pre>
   <div class="node">
<a name="Delimited-definitions"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Variable-definitions">Variable definitions</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Order-of-definitions">Order of definitions</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Language-Definitions">Language Definitions</a>

</div>

<h3 class="section">7.5 Delimited definitions</h3>

<p><a name="index-delimited-definitions-132"></a>
Many elements are delimited by specific character sequences. 
For instance, strings and multiline comments.  The syntax for
such an element definition is

<pre class="example">     &lt;name&gt; delim &lt;left delimited&gt; &lt;right delimiter&gt; \
             {escape &lt;escape character&gt;} \
             {multiline} {nested}
</pre>
   <p>The <code>escape</code> statement specifies the escape character that may
precede one of the delimiters inside the element.  This is optional.

   <p>For instance, this is the definition of C-like strings:

<pre class="example">     string delim "\"" "\"" escape "\\"
</pre>
   <p>Note that <code>\</code> is a special characters in definitions so it has to
be escaped.  If the <code>escape</code> specification was omitted, the C
string <code>"write \"hello\" string"</code> would have been highlight
incorrectly (it would have been highlighted as the string
<code>"write \"</code>, the normal character sequence <code>hello\</code> and
the string <code>" string"</code>).

   <p>The option <code>multiline</code> specifies that the element can spawn
multiple lines.  For instance, PHP strings are defined as follows:

<pre class="example">     string delim "\"" "\"" escape "\\" multiline
</pre>
   <p>The option <code>nested</code> instructs to count possible multiple
occurrences of delimited characters and to match relative multiple
occurrences (using a stack).  For instance, if we wanted to highlight
C-like multiline comments in a nested way<a rel="footnote" href="#fn-28" name="fnd-28"><sup>28</sup></a>, we could use the following definition:

<pre class="example">     comment delim "/*" "*/" multiline nested
</pre>
   <p>If <code>nested</code> was not used, then the closing <code>*/</code> of the
following nested comment would conclude the comment (and the second
<code>*/</code> would not be highlighted as a comment):

<pre class="example">     /*
        This is a /* nested comment */
     */
</pre>
   <p>Note that, in order for a delimited language element to be nested, its
starting and ending elements must be different; thus, for instance, the
following definition is not correct:

<pre class="example">     string delim "\"" "\"" nested # WRONG!
</pre>
   <p>As said above, definitions are cumulative, and they are also cumulative
even when using different syntactic forms.  Thus, for instance, the
complete definition for C++-style comments are the following (actually,
the definition of C-style comment is more involved, see the file
<samp><span class="file">c_comment.lang</span></samp>):

<pre class="example">     comment start "//"
     comment delim "/*" "*/" multiline
</pre>
   <div class="node">
<a name="Variable-definitions"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Dynamic-Backreferences">Dynamic Backreferences</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Delimited-definitions">Delimited definitions</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Language-Definitions">Language Definitions</a>

</div>

<h3 class="section">7.6 Variable definitions</h3>

<p><a name="index-variables-133"></a>
It is possible to define variables to be re-used in
many parts in a language definition file. 
A variable is defined by using

   <p><code>vardef</code> &lt;name of the variable&gt; <code>=</code> &lt;list of definitions&gt;

   <p>Once defined, a variable can be used by prepending the
symbol <code>$</code> to its name.  For instance,

<pre class="example">     vardef FUNCTION = '(?:[[:alpha:]]|_)[[:word:]]*(?=[[:blank:]]*\()'
     function = $FUNCTION
</pre>
   <p>The capital letters are used only for readability.

   <p>It is also possible to concatenate variables and expressions, and reuse
variables inside further variable definitions:

<pre class="example">     vardef basic_time = '[[:digit:]]{2}:[[:digit:]]{2}:[[:digit:]]{2}'
     vardef time = '\&lt;' + $basic_time + '\&gt;'
</pre>
   <div class="node">
<a name="Dynamic-Backreferences"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#File-inclusion">File inclusion</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Variable-definitions">Variable definitions</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Language-Definitions">Language Definitions</a>

</div>

<h3 class="section">7.7 Dynamic Backreferences</h3>

<p><a name="index-dynamic-backreference-134"></a>
With <em>dynamic backreferences</em> you can refer to a string matched by
the regular expression of the first element of a <code>delim</code>
specification<a rel="footnote" href="#fn-29" name="fnd-29"><sup>29</sup></a>.  I called these
backreferences dynamic in order to distinguish them by the
backreferences of regular expression syntax, <a href="#Ways-of-specifying-regular-expressions">Ways of specifying regular expressions</a>.  This is crucial in cases when the right delimiter
depends on a subexpression matched by the left delimiter; for instance,
Lua comments can be of the shape <code>--[[ comment ]]</code> or <code>--[=[
comment ]=]</code>, but not <code>--[=[ comment ]]</code> neither <code>--[[ comment
]=]</code> (furthermore, they can be nested)<a rel="footnote" href="#fn-30" name="fnd-30"><sup>30</sup></a>.  Thus, the regular expression of
the right element depends on the one of the left element.

   <p>A dynamic backreference is similar to a variable (<a href="#Variable-definitions">Variable definitions</a>),
but there's no declaration, and have the shape of

<pre class="example">     @{number}
</pre>
   <p class="noindent">where <code>number</code> is the number of the marked subexpression in the
left delimiter (source-highlight will actually check that such a marked
subexpression exists in the left delimiter).

   <p>For instance, this is the definition of Lua comments (see also
<samp><span class="file">lua.lang</span></samp>):

<pre class="example">     environment comment delim `--\[(=*)\[` "]" + @{1} + "]"
                 multiline nested begin
       include "url.lang"
       ...
     end
</pre>
   <p class="noindent">Note how the left delimiter can match an optional <code>=</code>, as a
marked subexpression, and the right delimiter refers to that with @{1}.

   <p>Source-highlight will take care of escaping possible special characters
during dynamic backreference substitutions.  For instance, suppose that
you must substitute <code>|</code> for @{1}, because we matched <code>|</code>
with the subexpression <code>[^[:alnum:]]</code> in a delim element like the
following one:

<pre class="example">     comment delim `([^[:alnum:]])` @{1}
</pre>
   <p class="noindent">Since <code>|</code> is a special character in regular expression syntax
source-highlight will actually replace <code>@{1}</code> with <code>\|</code>.

   <p>IMPORTANT: the right delimiter can only refer to subexpressions of its
left delimiter; thus, in case of nested delim element definitions (e.g.,
in states or environment, <a href="#State_002fEnvironment-Definitions">State/Environment Definitions</a>), the left
delimiter acts as a binder and hides possible subexpressions defined in
outer delim elements.

   <p>This is crucial to correctly match nested delimited elements with
backreferences: source-highlight will correctly recognize this nested
(and syntactically correct) Lua comment:

<pre class="example">     --[[
       first level comment
       --[=[
         second level
          --[[
            third level
         ]]
       ]=]
     ]]
</pre>
   <div class="node">
<a name="File-inclusion"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#State_002fEnvironment-Definitions">State/Environment Definitions</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Dynamic-Backreferences">Dynamic Backreferences</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Language-Definitions">Language Definitions</a>

</div>

<h3 class="section">7.8 File inclusion</h3>

<p><a name="index-file-inclusion-135"></a>
It is possible to include other language definition files into another
file.  This is inclusion actually physically includes the contents of
the included file into the current file during parsing, at the exact
point of inclusion (just like the <code>#include</code> in C/C++).   This is
useful for re-using definitions in many files.   For instance, C++
comment definitions are given in a file <samp><span class="file">c_comment.lang</span></samp>, and this
file is included in the Java and C++ definition files.  The same happens
for number and functions.  For instance, the file <samp><span class="file">java.lang</span></samp>
contains the following include instructions:

<pre class="example">     include "c_comment.lang"
     
     include "number.lang"
     
     keywords ...
     
     include "function.lang"
</pre>
   <p>Note that the order of inclusion is crucial since the order of
definition is crucial.  If function definition was included before
keyword definitions, then the sentence <code>if (exp)</code> would be
highlighted as a function invocation (see <a href="#Order-of-definitions">Order of definitions</a> and
<a href="#How-source_002dhighlight-works">How source-highlight works</a>).

<div class="node">
<a name="State%2fEnvironment-Definitions"></a>
<a name="State_002fEnvironment-Definitions"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Explicit-subexpressions-with-names">Explicit subexpressions with names</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#File-inclusion">File inclusion</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Language-Definitions">Language Definitions</a>

</div>

<h3 class="section">7.9 State/Environment Definitions</h3>

<p><a name="index-states-136"></a><a name="index-environments-137"></a>
Sometimes you want some source element to be highlighted only if they
are surrounded by other elements.  Source-highlight language definitions
provides also this feature.

<pre class="example">     state|environment &lt;standard definition&gt; begin
       &lt;other definitions&gt;
     end
</pre>
   <p>This structure is recursive (so other state/environment definitions can
be given within a state/environment).   The meaning of a
state/environment is that the definitions within the <code>begin
... end</code> are matched only if the definitions that define the
state/environment have been matched.  When entering a state/environment,
however, the definitions given outside the state/environment are not
matched.  The difference between <code>state</code> and <code>environment</code> is
that in the latter, normal parts of the source language (i.e., those
that do not match any definition) are highlighted according to the style
of the definition that defines the environment.

   <p>As an example, the following defines the multiline  nested C comment,
and highlights URL and e-mail addresses only when they appear inside a
comment (note that this uses file inclusion):

<pre class="example">     environment comment delim "/*" "*/" multiline nested begin
           include "url.lang"
     end
</pre>
   <p>Note that we used <code>environment</code> because everything else inside a
comment has to be formatted according to the comment style.

   <p>While for programming language definitions states/environments can be
avoided (although they allow to highlight some parts only if inside a
specific environment, e.g., URLs inside comments, or documentation tags
in Javadoc comments), they are pretty important for highlighting files
such as logs and ChangeLog files, since elements have to be highlighted
when they appear in a specific position.   For instance, for ChangeLog
(see <samp><span class="file">changelog.lang</span></samp>), we use a state for highlighting the date,
name, e-mail or URL (taken from <samp><span class="file">url.lang</span></samp>):

<pre class="example">     state date start '[[:digit:]]{2,4}-?[[:digit:]]{2}-?[[:digit:]]{2}' begin
       include "url.lang"
       name = '([[:word:]]|[[:punct:]])+'
     end
</pre>
   <p>Note that definitions that appear inside a state/environment have the
same scope of the expressions that define the environment.  While this
makes sense for <code>start</code> and <code>delim</code> definitions, it may make
less sense for simple definitions (i.e., those that simply lists all
possible expressions): in fact, in this case, such expressions do not
define a scope.  For such definitions, the semantics of
state/environment is that the state/environment starts after matching one
of the alternatives.  And where will it end?   In this case you must
explicitly exit the environment.   For instance, you can say that, when
inside a state/environment, a specific language definition, when
encountered also exits the environment, with the keyword <code>exit</code>
(you can also specify the number of states to exit). 
You can even exit all the environments with <code>exitall</code>.   For
instance, the following definition, highlights a non empty string
following a web method:

<pre class="example">     vardef non_empty = '[^[:blank:]]+'
     
     state webmethod = "OPTIONS|GET|HEAD|POST|PUT|DELETE",
               "TRACE|CONNECT|PROPFIND|MKCOL|COPY|MOVE|LOCK|UNLOCK" begin
       string = $non_empty exit
     end
</pre>
   <p>If you ever need such advanced features, you may want to take a look at
the <samp><span class="file">log.lang</span></samp> definition file that defines highlighting for
several log files (access logs, Apache logs, etc.).  Moreover, there
might be cases, and the above one is one of such cases, explicit
subexpressions with names will be enough (see <a href="#Explicit-subexpressions-with-names">Explicit subexpressions with names</a>).

   <p>We conclude this section with an interesting example: comments in
M4 files can start with the <code>dnl</code> keyword (up to the end of line),
e.g.,

<pre class="example">     dnl @synopsis AC_CTAGS_FLAGS
</pre>
   <p>Now if we want to highlight the <code>dnl</code> as a keyword, and the rest of
line as a comment, we cannot simply rely on an environment, since this
would highlight all the line with the same style.  Moreover, we want
to highlight elements starting with <code>@</code> differently, so we actually
need a state (this would allow us also to highlight urls inside a comment
just like in C++ comments in the example above).  Thus, we need
to simulate an environment with a state, and we do this for M4 as follows
(see the file <samp><span class="file">m4.lang</span></samp>):

<pre class="example">     state keyword start "dnl" begin
       # avoid spaces in front of urls or @[[:alpha:]]+ be captured as prefixes
       comment = '[[:blank:]]+'
       include "url.lang"
       include "html.lang"
       type = '@[[:alpha:]]+'
       # everything else is a comment
       comment = '.+'
     end
</pre>
   <p>Once entered the state, every isolated space character is highlighted as
a comment; then we have rules for URLs and @ elements; then everything
else (<code>.+</code>) is highlighted as a comment.

   <p>One might think that a smarter way would be to have simply the following
definition (after all, why bothering highlighting spaces as comments):

<pre class="example">     state keyword start "dnl" begin
       include "url.lang"
       include "html.lang"
       type = '@[[:alpha:]]+'
       comment = '.+'
     end
</pre>
   <p>Well, with this definition spaces in front of matched URLs or @
elements would be highlighted as normal, being considered as prefixes. 
This is due to how source-highlight searches for matching rules; we refer
to <a href="#How-source_002dhighlight-works">How source-highlight works</a> for further details.

<div class="node">
<a name="Explicit-subexpressions-with-names"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Redefinitions-and-Substitutions">Redefinitions and Substitutions</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#State_002fEnvironment-Definitions">State/Environment Definitions</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Language-Definitions">Language Definitions</a>

</div>

<h3 class="section">7.10 Explicit subexpressions with names</h3>

<p>Often, you need to specify two program elements in the same regular
expressions, because they are tightly related, but you also need to
highlight them differently.

   <p>For instance, you might want to highlight the name of a class (or
interface) in a class (or interface)
definition (e.g., in Java).  Thus, you can rely on the preceding
<code>class</code> keyword which will then be followed by an identifier.

   <p>A definition such as

<pre class="example">     keyword = '(\&lt;(?:class|interface))([[:blank:]]+)([$[:alnum:]]+)'
</pre>
   <p class="noindent">will not produce a good final result, since the name of the class will
be highlighted as a keyword, which is not what you might have wanted:
for instance, the class name should be highlighted as a <code>type</code>.

   <p>Up to version 2.6, the only way to do this was to use state or
environments (<a href="#State_002fEnvironment-Definitions">State/Environment Definitions</a>) but this tended to be
quite difficult to write.

   <p>Since version 2.7, you can specify a regular expression with marked
subexpressions and bind each of them to a specific language element (the
regular expression must be enclosed in <code>`</code>, see <a href="#Ways-of-specifying-regular-expressions">Ways of specifying regular expressions</a>):

<pre class="example">     (elem1,...,elemn) = `(subexp1)(...)(subexpn)`
</pre>
   <p>Now, with this syntax, we can accomplish our previous goal:

<pre class="example">     (keyword,normal,type) =
       `(\&lt;(?:class|interface))([[:blank:]]+)([$[:alnum:]]+)`
</pre>
   <p class="noindent">This way, the <code>class</code> (or <code>interface</code>) will be highlighted as
a keyword, the separating blank characters are formatted as
<code>normal</code>, and the name of the class as a <code>type</code>.

   <p>Note that the number of element names must be equal to the number of
subexpressions in the expression; furthermore, at least in the current
version, the expression can contain only marked subexpressions (no
character outside is allowed) and no nested subexpressions are allowed.

   <p>Thus, the following specifications are NOT correct:

<pre class="example">     (keyword,symbol) = `(...)(...)(...)` # number of elements doesn't match
     (keyword,symbol) = `(...(...)...)(...)` # contains nested subexpressions
     (keyword,symbol) = `...(...)...(...)` # outside characters
</pre>
   <p>This mechanism permits expressing regular expressions for some situation
in a much more compact and probably more readable way.  For instance,
for highlighting ChangeLog parts (the optional <code>*</code> as a symbol, the
optional file name and the element specified in parenthesis as a
<code>file</code> element, and the rest as <code>normal</code>) such as

<pre class="example">       * src/Makefile.am (source_highlight_SOURCES): correctly include
       changelog_scanner.ll
     
       * this is a comment without a file name
</pre>
   <p class="noindent">before version 2.6, we used to use these two language definitions:

<pre class="example">     state symbol start '^(?:[[:blank:]]+)\*[[:blank:]]+' begin
       state file start '[^:]+\:' begin
         normal start '.'
       end
     end
     
     state normal start '^(?:[[:blank:]]+)' begin
       state file start '[^:]+\:' begin
         normal start '.'
       end
     end
</pre>
   <p class="noindent">which can be hard to read after having written them.  Now, we can write
them more easily (see <samp><span class="file">changelog.lang</span></samp>):

<pre class="example">     (normal,symbol,normal,file)=
       `(^[[:blank:]]+)(\*)([[:blank:]]+)((?:[^:]+\:)?)`
     (normal,file)= `(^[[:blank:]]+)((?:[^:]+\:)?)`
</pre>
   <p>Since a language element definition using explicit subexpressions with
names consists of more than one element, and thus of more than one
formatting style, it cannot be used to start an environment (what would
the default element be?); while, as seen above, they can be used to
start a state.

<div class="node">
<a name="Redefinitions-and-Substitutions"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#How-source_002dhighlight-works">How source-highlight works</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Explicit-subexpressions-with-names">Explicit subexpressions with names</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Language-Definitions">Language Definitions</a>

</div>

<h3 class="section">7.11 Redefinitions and Substitutions</h3>

<p>These two features are useful when you want to define
a language by re-using an existing language definition
with some changes.  Typically you <code>include</code> another
language definition file and you redefine/substitute some
elements.

   <p><a name="index-redef-138"></a>When you use <code>redef</code> you erase all the previous
definitions of that language elements with the new one. 
The new language element definition will be placed exactly
in the point of the new definition. 
We use this feature, for instance, when we define the
<code>sml</code> language by re-using the <code>caml</code> one:
they differ only for the keywords<a rel="footnote" href="#fn-31" name="fnd-31"><sup>31</sup></a>.  In fact, the contents of
<samp><span class="file">sml.lang</span></samp> is summarized as follows:

<pre class="example">     include "caml.lang"
     
     redef keyword = "abstraction|abstype|and|andalso..."
     
     redef type = "int|byte|boolean|char|long|float|double|short|void"
</pre>
   <p>Since the new language element definition appears in the
exact point of the redefinition, this means that
such a regular expression will be matched only if all
the previous ones (the ones of the included file) cannot
be matched.  This may lead to unwanted results in some
cases (not in the <code>sml</code> case though). 
In other words the following code

<pre class="example">     keyword = "foo"
     keyword = "bar"
     type = "int"
     redef keyword = "myfoo"
</pre>
   <p class="noindent">is equivalent to the following one

<pre class="example">     type = "int"
     keyword = "myfoo"
</pre>
   <p><a name="index-subst-139"></a>If this is not what you want, you can use <code>subst</code>,
which is similar to <code>redef</code> apart from that it
replaces the previous first definition of that language
element in the exact point of that first definition
(all other possible definitions are simply erased). 
That is to say that the following code

<pre class="example">     keyword = "foo"
     keyword = "bar"
     type = "int"
     subst keyword = "myfoo"
</pre>
   <p class="noindent">is equivalent to the following one

<pre class="example">     keyword = "myfoo"
     type = "int"
</pre>
   <p>It is up to you to decide which one fits best your needs. 
We could use this feature to define <code>javascript</code> in terms
of <code>java</code>, e.g.:

<pre class="example">     include "java.lang"
     
     subst keyword = "abstract|break|case|catch|class|if..."
</pre>
   <p class="noindent">Here using <code>redef</code> would have led to the unwanted behavior that
<code>if (exp)</code> would have been highlighted as a function call, since
the function element definition would have come first (and then
matched first) than the redefinition of <code>if</code> as a keyword. 
Another example is the language definition for C# by reusing the one
for C/C++, <a href="#Highlighting-C_002fC_002b_002b-and-C_0023">Highlighting C/C++ and C#</a>.

<div class="node">
<a name="How-source-highlight-works"></a>
<a name="How-source_002dhighlight-works"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Notes-on-regular-expressions">Notes on regular expressions</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Redefinitions-and-Substitutions">Redefinitions and Substitutions</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Language-Definitions">Language Definitions</a>

</div>

<h3 class="section">7.12 How source-highlight works</h3>

<p>As hinted at the beginning of <a href="#Language-Definitions">Language Definitions</a>,
source-highlight uses the definitions in the language definition file to
internally create, on-the-fly, regular expressions that are used to
highlight the tokens of an input file.  Here we provide some internal
details that are crucial to understand how to write language definition
files correctly<a rel="footnote" href="#fn-32" name="fnd-32"><sup>32</sup></a>.

   <p>First of all, for each element definition an highlighting rule is
created by source-highlight (even if they correspond to the same
language element); thus, each language definition file will correspond
to a list of highlighting rules.  For each line of the input file,
source-highlight will try to match all these rules against the whole
line (more formally, against the part of the line that has not been
highlighted yet).  It will not stop as soon as an highlighting rule
matched, since there might be another rule that matches &ldquo;better&rdquo;. 
Now, everything basically reduces to the semantics of that <em>better
match</em>.

   <p><a name="index-matching-strategy-140"></a>The strategy used by source-highlight is to select the first matching rule

     <ul>
<li>with empty prefix (or prefix containing only space characters, i.e.,
spaces or tabs) or

     <li>with the smallest prefix,

   </ul>

   <p><a name="index-prefix-141"></a>where the <em>prefix</em> of a matched rule is the part of the examined
string that did not match<a rel="footnote" href="#fn-33" name="fnd-33"><sup>33</sup></a>.  Thus, for instance, if we try to match
the simple regular expression <code>=</code> against the string

<pre class="example">     i = 10;
</pre>
   <p><a name="index-suffix-142"></a>then the prefix is <code>i </code>, including the space.  Following the
terminology of regular expression, the remaining part that did not
match, i.e., <code> 10;</code>, is the <em>suffix</em>.  When source-highlight
finds a matching rule, according to the above strategy, it formats the
matched part (and the prefix as <code>normal</code>), and then it starts again
searching for a matching rule on the suffix, until it processed the
whole line.

   <p>Let us explain this strategy a little bit further with an example. 
Consider the following language definition file:

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <i># an example for explaining the strategy of source-highlight</i>
     <i>type</i> = <tt>"int"</tt>
     <i>keyword</i> = <tt>"null"</tt>
     <i>symbol</i> = <tt>"="</tt>
</pre>
   <p class="noindent">and the following line to be highlighted:

<pre class="example">     int i = null
</pre>
   <p>Then source-highlight performs these steps:

     <ol type=1 start=1>

     <li>The first matching rule is the one for <code>type</code>; since it has
an empty prefix, there's no need to look any further: it highlights
<code>int</code> as <code>type</code>; the remaining part to be processed is now
<code> i = null</code>;

     <li>the first matching rule is the one for <code>keyword</code>, with the prefix
<code> i = </code>; since the prefix is not empty (nor it contain only
spaces), we inspect other rules;

     <li>the next matching rule is the one for <code>symbol</code>, with prefix <code>
i </code>, which is smaller than the one for <code>keyword</code>, and since there
are no other matching rules, the one for <code>symbol</code> is better, and we
highlight <code>=</code> as symbol; the remaining part to be processed is now
<code> null</code>;

     <li>the first matching rule is the one for <code>keyword</code>, and, since it has
a prefix with only spaces, we look no further, and we highlight
<code>null</code> as <code>keyword</code>.

        </ol>

   <p>We conclude this section by showing the following language definition,
which summarizes what we said about the highlighting strategy:

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <i>keyword</i> = <tt>"if|class"</tt>
     
     <i>type</i> = <tt>'int'</tt>
     
     <i>comment</i> <b>delim</b> <tt>"/*"</tt> <tt>"*/"</tt>
     
     <i># thus this won't catch "/* */ /" as a regexp,</i>
     <i># since comment elem definition comes first</i>
     <i>regexp</i> = <tt>'/.*/.*/'</tt>
     
     <i># this won't match if ( ) as a function,</i>
     <i># since keyword elem definition comes first</i>
     <i>function</i> = <tt>'([[:alpha:]]|_)[[:word:]]*[[:blank:]]*\(*[[:blank:]]*\)'</tt>
     
     <i># the following order is conceptually wrong,</i>
     <i># since "//" won't be highlighted as a comment, but as two symbols</i>
     <i>symbol</i> = <tt>"/"</tt>
     <i>comment</i> <b>start</b> <tt>"//"</tt>
</pre>
   <div class="node">
<a name="Notes-on-regular-expressions"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#The-program-check_002dregexp">The program check-regexp</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#How-source_002dhighlight-works">How source-highlight works</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Language-Definitions">Language Definitions</a>

</div>

<h3 class="section">7.13 Notes on regular expressions</h3>

<p><a name="index-regular-expressions-143"></a>
Although we refer to Boost documentation for such
syntax<a rel="footnote" href="#fn-34" name="fnd-34"><sup>34</sup></a>,
we want to provide here some explanations of some forms of regular
expressions that might be unknown but that are pretty useful in language
definitions.

   <p><a name="index-non_002dmarking-parenthesis-144"></a>Typically, when you need to group sub-expressions with parenthesis,  but
you don't want the parenthesis to spit out another marked
sub-expression,  you can use a <em>non-marking parenthesis</em>
<code>(?:expression)</code>.  This is not necessary in the language definition
syntax: even though you use standard parenthesis, source-highlight will
transform it into a non-marking parenthesis.

   <p><a name="index-marked-subexpressions-145"></a>Source-highlight translates possible <em>marked subexpressions</em>, i.e.,
those enclosed in <code>(</code> and <code>)</code>, into non-marked subexpressions
(i.e., those explained above).  Since version 2.7, if you specify the
expression inside <code>`</code> the marked subexpressions are left as such
(see also <a href="#Ways-of-specifying-regular-expressions">Ways of specifying regular expressions</a>).  This is useful
for <em>backreferences</em> and <em>conditionals</em>.

   <p><a name="index-backreference-146"></a>An escape character followed by a digit n, where n is in the range 1-9,
is a <em>backreference</em> matches the same string that was matched by
sub-expression n.  For example the expression <code>^(a*).*\1$</code> will
match the string: <code>aaabbaaa</code> but not the string <code>aaabba</code>. 
Backreferences are useful to write compact language elements, such
as in the case of Perl's substitution modifiers; thus

<pre class="example">     regexp = `s([^[:alnum:][:blank:]]).*\1.*\1[ixsmogce]*`
</pre>
   <p>will match all these forms

<pre class="example">     s/foo/bar/g
     s|foo|bar|g
     s#foo#bar#g
     s@foo@bar@g
</pre>
   <p><a name="index-lookahead-asserts-147"></a>A useful regular expression form is the <em>Forward Lookahead Asserts</em>
that come in two forms, one for positive forward lookahead asserts, and
one for negative lookahead asserts:

     <dl>
<dt><code>(?=abc)</code><dd>matches zero characters only if they are followed by the expression
&ldquo;abc&rdquo;. 
<br><dt><code>(?!abc)</code><dd>matches zero characters only if they are not followed by the expression
&ldquo;abc&rdquo;. 
</dl>

   <p>For instance, in the definition of a function (<samp><span class="file">function.lang</span></samp>) we
use the following regular expression:

<pre class="example">     ([[:alpha:]]|_)[[:word:]]*(?=[[:blank:]]*\()
</pre>
   <p class="noindent">Thus after the name of a function we test, with the regular expression
<code>(?=\()</code> whether an open parenthesis <code>(</code> can be matched.  If
it can be matched, however, we leave that part in the input, so that the
parenthesis will not be formatted the same way of a function name (see
also <a href="#How-source_002dhighlight-works">How source-highlight works</a> to understand better this language
element definition).

   <p>Please, be careful when using such regular expression forms: since part
of the input is not actually removed you may end up always scanning the
same input part (thus looping) if you do not write the regular
expressions well.  For instance, consider this language definition

<pre class="example">     state foo = '(?=foo)' begin
       foo = '(?=foo)'
     end
</pre>
   <p class="noindent">and the following input file:

<pre class="example">     hello
     foo
     bar
</pre>
   <p class="noindent">As soon as we match the word <code>foo</code> we leave it in the input and we
enter a state where we try to match the word <code>foo</code> still leaving it
in the input.  As you might have guess this will make source-highlight
loop forever.  Probably one might have wanted to write this
language definition:

<pre class="example">     state foo = '(?=foo)' begin
       foo = 'foo'
     end
</pre>
   <p class="noindent">but a cut-and-paste error had its way ;-)

   <p><a name="index-lookbehind-asserts-148"></a>You can also use <em>Lookbehind Asserts</em>:

     <dl>
<dt><code>(?&lt;=pattern)</code><dd> consumes zero characters, only if pattern could be matched against the
 characters preceding the current position (pattern must be of fixed
 length). 
<br><dt><code>(?&lt;!pattern)</code><dd> consumes zero characters, only if pattern could not be matched against the
 characters preceding the current position (pattern must be of fixed
 length). 
</dl>

   <p><a name="index-conditional-expressions-149"></a>Another advanced regular expression mechanism is the one of
<em>conditional expressions</em>

     <dl>
<dt><code>(?(condition)yes-pattern|no-pattern)</code><dd>attempts to match yes-pattern if the condition is true, otherwise
attempts to match no-pattern. 
<br><dt><code>(?(condition)yes-pattern)</code><dd>attempts to match yes-pattern if the condition is true, otherwise fails. 
</dl>

   <p>Condition may be either a forward lookahead assert, or the
index<a rel="footnote" href="#fn-35" name="fnd-35"><sup>35</sup></a> of a
marked sub-expression (the condition becomes true if the sub-expression
has been matched).  For instance, the following expression<a rel="footnote" href="#fn-36" name="fnd-36"><sup>36</sup></a>,
that we wrote on more lines to try to make it more readable

<pre class="example">     (?:
       (\()
       |(\[)
       |(\{)
     )
     [[:alpha:]]*
     (?:
       (?(1)
         \)
         |(?:(?(2)
           \]
           |(?:\}
     )))))
</pre>
   <p>will match <code>(foo)</code>, <code>[foo]</code> and <code>{foo}</code> but not
<code>(foo]</code>, <code>{foo]</code> or <code>{foo)</code>.

<div class="node">
<a name="The-program-check-regexp"></a>
<a name="The-program-check_002dregexp"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Listing-Language-Elements">Listing Language Elements</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Notes-on-regular-expressions">Notes on regular expressions</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Language-Definitions">Language Definitions</a>

</div>

<h3 class="section">7.14 The program <samp><span class="command">check-regexp</span></samp></h3>

<p><a name="index-g_t_0040command_007bcheck_002dregexp_007d-150"></a>Since version 2.7, the source-highlight package comes with a
small additional program, <samp><span class="command">check-regexp</span></samp>, that permits
testing regular expressions on the command line.

   <p>You simply pass as the first command line argument the regular
expression and then the strings you want to try to match (actually, the
program searches the string for the given regular expression, so it is
not required to match the whole string).  It is crucial, in order to
avoid shell substitutions, to enclose both the expression and the
strings in single quotes.

   <p>The program then prints some information about the (possibly successful
matching).  The <code>what[0]</code> part represents the whole match, and
<code>what[i]</code> part represents the i-th marked subexpression that
matched.  The program also prints possible prefix and suffix.

   <p>Here's an example of output of the program:

<pre class="example">     check-regexp '(a+)(.*)\1' 'aabcdaa' 'babbbacc'
     
     searching      : aabcdaa
     for the regexp : (a+)(.*)\1
     what[0]: aabcdaa
       what[1]: aa
       length: 2
       what[2]: bcd
       length: 3
     total number of matches: 1
     
     searching      : babbbacc
     for the regexp : (a+)(.*)\1
     prefix: b
     what[0]: abbba
       what[1]: a
       length: 1
       what[2]: bbb
       length: 3
     suffix: cc
     total number of matches: 1
</pre>
   <p>And here's the example of matching parenthesis we saw in <a href="#Notes-on-regular-expressions">Notes on regular expressions</a>:

<pre class="smallexample">     check-regexp \
        '(?:(\()|(\[)|(\{))[[:alnum:]]*(?:(?(1)\)|(?:(?(2)\]|(?:\})))))' \
        '{ciao}' '(foo]' '[hithere]'
     
     searching      : {ciao}
     for the regexp : (?:(\()|(\[)|(\{))[[:alnum:]]*(?:(?(1)\)|(?:(?(2)\]|(?:\})))))
     what[0]: {ciao}
       what[3]: {
       length: 1
     total number of matches: 1
     
     searching      : (foo]
     for the regexp : (?:(\()|(\[)|(\{))[[:alnum:]]*(?:(?(1)\)|(?:(?(2)\]|(?:\})))))
     total number of matches: 0
     
     searching      : [hithere]
     for the regexp : (?:(\()|(\[)|(\{))[[:alnum:]]*(?:(?(1)\)|(?:(?(2)\]|(?:\})))))
     what[0]: [hithere]
       what[2]: [
       length: 1
     total number of matches: 1
</pre>
   <div class="node">
<a name="Listing-Language-Elements"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Concluding-Remarks">Concluding Remarks</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#The-program-check_002dregexp">The program check-regexp</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Language-Definitions">Language Definitions</a>

</div>

<h3 class="section">7.15 Listing Language Elements</h3>

<p>In order for language definitions to be really useful they must be
used in proper combination with formatting styles (see <a href="#Output-format-style">Output format style</a>).  However, these different files might not be developed
by the same person, or simply some one may want to customize one of
these.  In order to define good output formatting style files you should
be aware of each language element defined by a language definition file. 
Instead of having to look inside the language definition file itself
(and recursively in each included file) you can use the command line
<a name="index-g_t_0040code_007b_002d_002dshow_002dlang_002delements_007d-151"></a>option <code>--show-lang-elements</code><a rel="footnote" href="#fn-37" name="fnd-37"><sup>37</sup></a>, that
simply prints to the standard output all the language elements that
can be highlighted with a specific language definition file.

   <p>For instance, for <code>cpp.lang</code> you get:

<pre class="example">     cbracket
     classname
     comment
     function
     keyword
     label
     normal
     number
     preproc
     specialchar
     string
     symbol
     todo
     type
     url
     usertype
</pre>
   <p>while for <code>log.lang</code> you get:

<pre class="example">     cbracket
     comment
     date
     function
     ip
     normal
     number
     port
     string
     symbol
     time
     twonumbers
     webmethod
</pre>
   <div class="node">
<a name="Concluding-Remarks"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Debugging">Debugging</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Listing-Language-Elements">Listing Language Elements</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Language-Definitions">Language Definitions</a>

</div>

<h3 class="section">7.16 Concluding Remarks</h3>

<p>By mixing all these features you can unleash your imagination and define
highlighting for complex source languages such as Flex and Bison by
writing few lines of code and re-use existing ones.  For instance, Flex
and Bison have their own syntax and lets you write C/C++ code in
specific parts of the source language, e.g., the code between  the
outmost brackets, in the following example, is C++ code, and should be
highlighted following C++ language definitions (apart from variables
that are prefixed with <code>$</code>):

<pre class="example">     globaltags : options { if (...) { setTags( $1 ); } }
</pre>
   <p>This is easy to do (taken from <samp><span class="file">flex.lang</span></samp>):

<pre class="example">     state cbracket delim "{" "}" multiline nested begin
       variable = '\$.'
       include "cpp.lang"
     end
</pre>
   <p>Note that, since we used <code>nested</code> we can be sure
that the C++ language definitions are not considered
anymore when we matched the last closing <code>}</code>.

<div class="node">
<a name="Debugging"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Tutorials-on-Language-Definitions">Tutorials on Language Definitions</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Concluding-Remarks">Concluding Remarks</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Language-Definitions">Language Definitions</a>

</div>

<h3 class="section">7.17 Debugging</h3>

<p><a name="index-debug-152"></a>
When writing a language definition file, it is quite useful to be able
to debug it (by using complex regular expressions one may experience
unwanted behaviors).  Since version 2.1 the command line option
<code>--debug-lang</code> is available.  When using this option, some
additional information are printed to the standard output.

   <p>Since version 2.5 this option also accepts the a sub specification (see
<a href="#Invoking-source_002dhighlight">Invoking source-highlight</a>).  When using <code>dump</code> (the default)
all the additional information explained below will be dumped without
interaction with the user.  When using <code>interactive</code>, for each
formatted string the program will stop waiting for a command from the
user.  In this very primordial version of interactive debug, the user
will only have to press <code>ENTER</code> to make the program continue until
the next formatted string.  This way, the programmer will have the
chance to step the highlighting of each part of the input file. 
Moreover, when debugging is enabled, no buffering will be performed by
the program, thus each formatted element will be immediately available
in the output.  For instance, you can use the command <samp><span class="command">tail -f</span></samp>
to see the modifications on the output file on-the-fly.

   <p>When using this command line option the additional information produced
has the following format:

<pre class="example">     &lt;.lang filename&gt;:&lt;line number&gt;
     expression: &lt;matched subexpression&gt;
     formatting: &lt;source file string to be formatted&gt;
     entering: &lt;next state's id&gt;
     exiting state, level: &lt;number of states&gt;
</pre>
   <p>The lines starting with <code>entering</code>, <code>exiting</code> and
<code>exitingall</code> are related to entering a new state/environment and
exiting one and all states/environments (<code>current state</code>, if shown,
comes after <code>entering</code> and prints the same state's regular
expression but after the substitution of dynamic backreferences,
<a href="#Dynamic-Backreferences">Dynamic Backreferences</a>).  The first line shows a link to the
<samp><span class="file">.lang</span></samp> definition file and the line number, i.e., and the
sub-expression that matched and the line starting with <code>formatting</code>
shows the source file string that matched with that expression.  If a
line starting with <code>formatting</code> is not preceded by a line with the
link to the sub-expression, it means that no particular regular
expression has matched, and thus the style <code>normal</code> will be used to
format that string.

   <p>Consider the following (simplified) Java source file:

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <tt>01:</tt> <i>/*</i>
     <tt>02:</tt> <i>  This is to demonstrate --debug-lang</i>
     <tt>03:</tt>   <tt>http://www.lorenzobettini.it</tt>
     <tt>04:</tt> <i>*/</i>
     <tt>05:</tt>
     <tt>06:</tt> <b>package</b> hello;
     <tt>07:</tt>
     <tt>08:</tt> <b>public</b> <b>class</b> Hello {
     <tt>09:</tt>         <i>// just some greetings ;-)  /*</i>
     <tt>10:</tt>     <b>int</b> i = 10;
     <tt>11:</tt>     System.out.println(<tt>"Hello World!"</tt>);
     <tt>12:</tt> }
     <tt>13:</tt>
</pre>
   <p>Now you can debug the <samp><span class="file">java.lang</span></samp> file by using the
<code>--debug-lang</code> command line option.  And the output is as follows:

<pre class="example">     c_comment.lang:24
     expression: "/\*"
     formatting "/*" as comment
     entering state: 23
     formatting "  This is to demonstrate --debug-lang" as default
     formatting "  " as default
     url.lang:3
     expression: "(?:(?:&lt;?)[[:word:]]+://[[:word:]\./\-_]+(?:&gt;?))"
     formatting "http://www.lorenzobettini.it" as url
     c_comment.lang:24
     expression: "\*/"
     formatting "*/" as comment
     exiting state, level: 1
     java.lang:1
     expression: "\&lt;(?:import|package)\&gt;"
     formatting "package" as preproc
     formatting " hello" as default
     symbols.lang:1
     expression: "(?:~|!|%|\^|\*|\(|\)|-|\+|=|\[|\]|\\|:|;|,|\.|/|\?|&amp;|&lt;|&gt;|\|)"
     formatting ";" as symbol
     ... omissis ...
     c_comment.lang:13
     expression: "//"
     formatting "//" as comment
     entering state: 12
     formatting " just some greetings ;-)  /*" as default
     c_comment.lang:13
     expression: "\z"
     formatting "" as comment
     exiting state, level: 1
     ... omissis ...
</pre>
   <p>This should provide enough information to understand how the regular
expressions are used and how the states/environments are entered and
exited.  Please note that the sub-expressions that are shown may
differ from the original ones specified in the <samp><span class="file">.lang</span></samp> file.  This
is due to the preprocessing that is performed by Source-highlight. 
Moreover, some sub-expressions are not defined at all in the
<samp><span class="file">.lang</span></samp> file: for instance, this is the case for line wide
definitions, i.e., those that are defined with the keyword <code>start</code>,
<a href="#Line-wide-definitions">Line wide definitions</a>.  The last lines above, showing
<code>expression: "\z"</code>, means that we matched the end of a line.

   <p>Another useful feature in debugging is the option <code>--show-regex</code>
that shows, on the standard output, the regular expression automaton
that source-highlight creates.

   <p>For instance, consider this language definition
(<samp><span class="file">comment-show.lang</span></samp>):

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <b>vardef</b> <i>TODO</i> = <tt>'(TODO|FIXME)([:]?)'</tt>
     
     <b>environment</b> <i>comment</i> <b>delim</b> <tt>"/**"</tt> <tt>"*/"</tt> <b>multiline</b> <b>begin</b>
       <i>type</i> = <tt>'@[[:alpha:]]+'</tt>
       <i>todo</i> = <i>$TODO</i>
     <b>end</b>
     
     <b>state</b> <i>cbracket</i> <b>delim</b> <tt>"{"</tt> <tt>"}"</tt> <b>escape</b> <tt>"\\"</tt> <b>multiline</b> <b>nested</b> <b>begin</b>
       <i>keyword</i> = <tt>"if|then|else|endif"</tt>
     <b>end</b>
     
     <i>string</i> <b>delim</b> <tt>"&lt;"</tt> <tt>"&gt;"</tt>
     
     <i>string2</i> <b>delim</b> <tt>"&lt;&lt;"</tt> <tt>"&gt;&gt;"</tt> <b>multiline</b>
</pre>
   <p class="noindent">If you now execute the following command:

<pre class="example">     source-highlight --show-regex=comment-show.lang
</pre>
   <p class="noindent">you will get, on the standard output, the following output<a rel="footnote" href="#fn-38" name="fnd-38"><sup>38</sup></a>:

<pre class="smallexample">     <!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
     <pre class="example">          STATE 1 default: normal
            rule (comment) "/\*\*" (exit level: 0, next: 2)
              STATE 2 default: comment
                rule (comment) "\*/" (exit level: 1, next: 0)
                rule (type) "(?:\@[[:alpha:]]+)" (exit level: 0, next: 0)
                rule (todo) "(?:(?:TODO|FIXME)(?:[:]?))" (exit level: 0, next: 0)
            rule (cbracket) "\{" (exit level: 0, next: 3)
              STATE 3 default: normal
                rule (cbracket) "\}" (exit level: 1, next: 0)
                rule (cbracket) "\\." (exit level: 0, next: 0)
                rule (cbracket) "\{" (exit level: 0, next: 0, nested)
                rule (keyword) "\&lt;(?:if|then|else|endif)\&gt;" (exit level: 0, next: 0)
            rule (string) "&lt;(?:[^&lt;&gt;])*&gt;" (exit level: 0, next: 0)
            rule (string2) "&lt;&lt;" (exit level: 0, next: 4)
              STATE 4 default: string2
                rule (string2) "&gt;&gt;" (exit level: 1, next: 0)
          
</pre>
   </pre>
   <p class="noindent">This shows the states and highlight rules of the regular expression
automaton that source-highlight creates and will use to format an input
source.

   <p>Each state is associated a unique number in order to identify it;
moreover, the default element of the state is shown (i.e., if none of
the state's rule match, then that part is highlighted with the default
element style). For instance, in the initial state the default style is
normal.  Then for each state it shows the rules for that state. 
For each rule you can see the corresponding element of the rule,
the regular expression for the rule and some other information, that we
explain in the following.

   <p>We can see that if we match a <code>/**</code> (it is shown as a string with
escaped special characters, <code>/\*\*</code>) we enter a new state, in this
case the state 2 (<code>next: 2</code>).  This corresponds to the delimited
element defining a new environment (<a href="#State_002fEnvironment-Definitions">State/Environment Definitions</a>).  The fact that it is actually an environment and not a
state<a rel="footnote" href="#fn-39" name="fnd-39"><sup>39</sup></a> can be seen by the fact
that the default element is the same of the environment itself.  If we
match a <code>*/</code>, i.e., the end of the delimited element, we exit one
level (<code>exit level: 1</code>) meaning that we go back to state 1.  Then
we have the state for <code>cbracket</code>, which is not an environment, in
fact its default state is normal.  The second rule of this state,
<code>\\.</code> represents the <code>escape</code> string of the state definition. 
Since the delimited element is defined as nested, we have a third rule
<code>{</code> which has the <code>nested</code> information; thus, if we match it,
we simply enter a new instance of state 3 itself.

   <p>The <code>string</code> and <code>string2</code> show the difference implied by the
<code>multiline</code> option: since source-highlight handles a line of input
separately, the first delimited definition can be handled with a single
regular expression while the multiline version cannot.

   <p>Note that the states/environments are indented so that it's
easier to understand the outer and the inner states.

   <p>Let us now consider a variation of the previous example:

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <b>vardef</b> <i>TODO</i> = <tt>'(TODO|FIXME)([:]?)'</tt>
     
     <b>environment</b> <i>comment</i> <b>delim</b> <tt>"/**"</tt> <tt>"*/"</tt> <b>multiline</b> <b>nested</b> <b>begin</b>
       <i>type</i> = <tt>'@[[:alpha:]]+'</tt>
       <i>todo</i> = <i>$TODO</i>
     <b>end</b>
     
     <i>regexp</i> = <tt>`([^[:alnum:]]).*(\1)`</tt>
     
     <i>string</i> <b>delim</b> <tt>"&lt;"</tt> <tt>"&gt;"</tt>
     
     <i>string2</i> <b>delim</b> <tt>"&lt;&lt;"</tt> <tt>"&gt;&gt;"</tt> <b>multiline</b>
     
     (<i>paren</i>,<i>normal</i>,<i>paren</i>) = <tt>`(\[)(.*)(\])`</tt>
</pre>
   <p>and let us see the output of <code>--show-regex</code>

<pre class="smallexample">     <!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
     <pre class="example">          STATE 1 default: normal
            rule (comment) "/\*\*" (exit level: 0, next: 2)
              STATE 2 default: comment
                rule (comment) "\*/" (exit level: 1, next: 0)
                rule (comment) "/\*\*" (exit level: 0, next: 0, nested)
                rule (type) "(?:\@[[:alpha:]]+)" (exit level: 0, next: 0)
                rule (todo) "(?:(?:TODO|FIXME)(?:[:]?))" (exit level: 0, next: 0)
            rule (regexp) "(?:([^[:alnum:]]).*(\1))" (exit level: 0, next: 0)
            rule (string) "&lt;(?:[^&lt;&gt;])*&gt;" (exit level: 0, next: 0)
            rule (string2) "&lt;&lt;" (exit level: 0, next: 3)
              STATE 3 default: string2
                rule (string2) "&gt;&gt;" (exit level: 1, next: 0)
            rule (paren normal paren) "(\[)(.*)(\])" (exit level: 0, next: 0)
          
</pre>
   </pre>
   <p>Since in the rule <code>regexp</code> we used the <code>`</code> regular expression
(see <a href="#Ways-of-specifying-regular-expressions">Ways of specifying regular expressions</a>), then, the marked
subexpressions are not translated in order to make backreferences work
correctly.

   <p>The last rule uses explicit subexpressions with names (see <a href="#Explicit-subexpressions-with-names">Explicit subexpressions with names</a>); although that expression is made up of
different elements, the expression is matched as a whole.

<div class="node">
<a name="Tutorials-on-Language-Definitions"></a>
<p><hr>
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Debugging">Debugging</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Language-Definitions">Language Definitions</a>

</div>

<h3 class="section">7.18 Tutorials on Language Definitions</h3>

<p>Now we provide some examples of language definitions.   In the previous
sections we have already provided some code snippets, while here we
provide complete examples of language definitions that are included in
the source-highlight distribution itself.

   <p>In particular we will first show the language definition for the
language definition syntax itself (file <samp><span class="file">langdef.lang</span></samp>).  This will
be used to highlight the examples of language definitions that we will
show in this section (the highlighting will not be visible if you are
viewing this manual with the <code>info</code> command).  Of course, this
example is highlighted itself.

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <i># this is the language definition for the</i>
     <i># language definition syntax itself</i>
     <i>comment</i> <b>start</b> <tt>"#"</tt>
     
     <i>preproc</i> = <tt>"include"</tt>
     
     <i>string</i> <b>delim</b> <tt>"\""</tt> <tt>"\""</tt> <b>escape</b> <tt>"\\"</tt> <b>multiline</b>
     <i>regexp</i> <b>delim</b> <tt>"'"</tt> <tt>"'"</tt> <b>escape</b> <tt>"\\"</tt> <b>multiline</b>
     <i>regexp</i> <b>delim</b> <tt>"`"</tt> <tt>"`"</tt> <b>escape</b> <tt>"\\"</tt> <b>multiline</b>
     
     <i>keyword</i> = <tt>"state|environment|begin|end|delim|escape|start"</tt>,
               <tt>"multiline|nested|vardef|exitall|exit"</tt>,
               <tt>"redef|subst|nonsensitive"</tt>
     
     <i>symbol</i> = <tt>"=|+|,|(|)"</tt>
     
     <b>vardef</b> <i>ID</i> = <tt>'[[:word:]]+'</tt>
     
     <i>variable</i> = <tt>'\$'</tt> + <i>$ID</i>
     
     <i>variable</i> = <i>$ID</i>
     
</pre>
   <p>The style that is used to highlight these examples in Texinfo is
<samp><span class="file">texinfo.style</span></samp> that is shown in <a href="#Output-format-style">Output format style</a>.  The
language definition for the style syntax (file <samp><span class="file">style.lang</span></samp>) is
even simpler:

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <i># this is the language definition for the</i>
     <i># style definition syntax</i>
     <i>comment</i> <b>start</b> <tt>"//"</tt>
     
     <i>string</i> <b>delim</b> <tt>"\""</tt> <tt>"\""</tt> <b>escape</b> <tt>"\\"</tt>
     
     <i>keyword</i> = <tt>"bgcolor|purple|orange|brightorange|brightgreen|darkgreen"</tt>,
               <tt>"green|darkred|red|brown|pink|yellow|cyan"</tt>,
               <tt>"black|teal|gray|darkblue|blue"</tt>,
               <tt>"normal|linenum"</tt>,
               <tt>"noref|nf|f|u|i|b"</tt>
     <i>keyword</i> = <tt>'bg\:'</tt>
     
     <i>symbol</i> = <tt>",|;"</tt>
     
     <i>variable</i> = <tt>'[[:word:]]+'</tt>
     
</pre>
   <p>Note that this definition is pretty simple since the language
definition syntax is simple.  In the next examples we will see how to
use more complex features to highlight more complex language syntaxes.

<ul class="menu">
<li><a accesskey="1" href="#Highlighting-C_002fC_002b_002b-and-C_0023">Highlighting C/C++ and C#</a>
<li><a accesskey="2" href="#Highlighting-Diff-files">Highlighting Diff files</a>
<li><a accesskey="3" href="#Pseudo-semantic-analysis">Pseudo semantic analysis</a>
</ul>

<div class="node">
<a name="Highlighting-C%2fC++-and-C%23"></a>
<a name="Highlighting-C_002fC_002b_002b-and-C_0023"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Highlighting-Diff-files">Highlighting Diff files</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Tutorials-on-Language-Definitions">Tutorials on Language Definitions</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Tutorials-on-Language-Definitions">Tutorials on Language Definitions</a>

</div>

<h4 class="subsection">7.18.1 Highlighting C/C++ and C#</h4>

<p>This is the language definition for C, included in the file
<samp><span class="file">c.lang</span></samp>:

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <i># definitions for C</i>
     <b>include</b> <tt>"c_comment.lang"</tt>
     
     <i>label</i> = <tt>'^[[:blank:]]*[[:alnum:]]+:[[:blank:]]*\z'</tt>
     
     (<i>keyword</i>,<i>normal</i>,<i>classname</i>) =
       <tt>`(\&lt;struct)([[:blank:]]+)([[:alnum:]_]+)`</tt>
     
     <b>state</b> <i>preproc</i> <b>start</b> <tt>'^[[:blank:]]*#(?:[[:blank:]]*include)'</tt> <b>begin</b>
             <i>string</i> <b>delim</b> <tt>"&lt;"</tt> <tt>"&gt;"</tt>
             <i>string</i> <b>delim</b> <tt>"\""</tt> <tt>"\""</tt> <b>escape</b> <tt>"\\"</tt>
             <b>include</b> <tt>"c_comment.lang"</tt>
     <b>end</b>
     
     <i>preproc</i> = <tt>'^[[:blank:]]*#([[:blank:]]*[[:word:]]*)'</tt>
     
     <b>include</b> <tt>"number.lang"</tt>
     
     <b>include</b> <tt>"c_string.lang"</tt>
     
     <i>keyword</i> = <tt>"__asm|__cdecl|__declspec|__export|__far16"</tt>,
       <tt>"__fastcall|__fortran|__import"</tt>,
       <tt>"__pascal|__rtti|__stdcall|_asm|_cdecl"</tt>,
       <tt>"__except|_export|_far16|_fastcall"</tt>,
       <tt>"__finally|_fortran|_import|_pascal|_stdcall|__thread|__try|asm|auto"</tt>,
       <tt>"break|case|catch|cdecl|const|continue|default"</tt>,
       <tt>"do|else|enum|extern|for|goto"</tt>,
       <tt>"if|pascal"</tt>,
       <tt>"register|return|sizeof|static"</tt>,
       <tt>"struct|switch"</tt>,
       <tt>"typedef|union"</tt>,
       <tt>"volatile|while"</tt>
     
     <i>type</i> = <tt>"bool|char|double|float|int|long"</tt>,
       <tt>"short|signed|unsigned|void|wchar_t"</tt>
     
     <b>include</b> <tt>"symbols.lang"</tt>
     
     <i>cbracket</i> = <tt>"{|}"</tt>
     
     <b>include</b> <tt>"function.lang"</tt>
     
     <b>include</b> <tt>"clike_vardeclaration.lang"</tt>
     
</pre>
   <p class="noindent">Note that this makes use of lots of <code>include</code>s since these parts
are reused in other language definitions (e.g., Java has lots of parts
that are in common with C/C++ so we wrote these parts in separate
files).  In particular the comments definitions:

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <i># c_comment.lang</i>
     
     <i># comments with documentation tags</i>
     <b>environment</b> <i>comment</i> <b>start</b> <tt>"///"</tt> <b>begin</b>
       <b>include</b> <tt>"url.lang"</tt>
       <b>include</b> <tt>"html_simple.lang"</tt>
       <i>type</i> = <tt>'@[[:alpha:]]+'</tt>
       <b>include</b> <tt>"todo.lang"</tt>
     <b>end</b>
     
     <i>comment</i> <b>start</b> <tt>"//"</tt>
     
     <i># comments with documentation tags</i>
     <b>environment</b> <i>comment</i> <b>delim</b> <tt>"/**"</tt> <tt>"*/"</tt> <b>multiline</b> <b>begin</b>
       <b>include</b> <tt>"url.lang"</tt>
       <b>include</b> <tt>"html_simple.lang"</tt>
       <i>type</i> = <tt>'@[[:alpha:]]+'</tt>
       <b>include</b> <tt>"todo.lang"</tt>
     <b>end</b>
     
     <i># standard comments</i>
     <b>environment</b> <i>comment</i> <b>delim</b> <tt>"/*"</tt> <tt>"*/"</tt> <b>multiline</b> <b>begin</b>
       <b>include</b> <tt>"url.lang"</tt>
       <b>include</b> <tt>"todo.lang"</tt>
     <b>end</b>
</pre>
   <p class="noindent">Here we have the definitions for line-wide comments (<code>//</code>) and
for multi line comments where we highlight also URL addresses and
e-mail addresses (defined in the file <samp><span class="file">url.lang</span></samp> not shown here). 
Moreover, for comments that are used in automatic documentation
generation tools (such as Doxygen or Javadoc), i.e., those that start
with <code>/**</code> or <code>///</code>) we also highlight the complete HTML
syntax (defined in the file <samp><span class="file">html.lang</span></samp> not shown here).

   <p>Going back to <samp><span class="file">c.lang</span></samp> we see that we use subexpressions with names
(see <a href="#Explicit-subexpressions-with-names">Explicit subexpressions with names</a>) for highlighting the
struct name (when preceded by <code>struct</code>, highlighted as a keyword).

   <p>For preprocessor directives <code>#include</code> we use a state definition
since in this case the file included with the <code>&lt;file&gt;</code> syntax must
be formatted as strings (and only in this context the <code>&lt;&gt;</code> must be
considered as strings, anywhere else they are operators).  Since a state
erases definitions defined outside the state we must include
<samp><span class="file">c_comment.lang</span></samp> again in order to highlight comments also in this
context<a rel="footnote" href="#fn-40" name="fnd-40"><sup>40</sup></a>.  Then we
have a definition of <code>preproc</code> that catches all the other
preprocessor directives.

   <p>The included file <samp><span class="file">number.lang</span></samp> defines the regular expression that
catches number constants (not shown here), then we include the file
<samp><span class="file">c_string.lang</span></samp> that define strings (again shared by Java):

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <b>vardef</b> <i>SPECIALCHAR</i> = <tt>'\\.'</tt>
     
     <b>environment</b> <i>string</i> <b>delim</b> <tt>"\""</tt> <tt>"\""</tt> <b>begin</b>
       <i>specialchar</i> = <i>$SPECIALCHAR</i>
     <b>end</b>
     
     <b>environment</b> <i>string</i> <b>delim</b> <tt>"'"</tt> <tt>"'"</tt> <b>begin</b>
       <i>specialchar</i> = <i>$SPECIALCHAR</i>
     <b>end</b>
     
</pre>
   <p class="noindent">inside a string we want to highlight in a different way the special
characters (such as, e.g., <code>\n</code>, <code>\t</code>, etc.)  and in general
escaped characters, matched by the regular expression `<code>\\.</code>'.

   <p>The included file <samp><span class="file">symbols.lang</span></samp> defines all the symbols (shared
also by other languages):

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <i>symbol</i> = <tt>"~"</tt>,<tt>"!"</tt>,<tt>"%"</tt>,<tt>"^"</tt>,<tt>"*"</tt>,<tt>"("</tt>,<tt>")"</tt>,<tt>"-"</tt>,<tt>"+"</tt>,<tt>"="</tt>,<tt>"["</tt>,
             <tt>"]"</tt>,<tt>"\\"</tt>,<tt>":"</tt>,<tt>";"</tt>,<tt>","</tt>,<tt>"."</tt>,<tt>"/"</tt>,<tt>"?"</tt>,<tt>"&amp;"</tt>,<tt>"&lt;"</tt>,<tt>"&gt;"</tt>,<tt>"\|"</tt>
</pre>
   <p class="noindent">This has nothing interesting but the fact that it shows that
the character <code>\</code> and <code>|</code> have to be escaped.

   <p>The included file <samp><span class="file">function.lang</span></samp> defines the regular expression to
match a function definition or invocation:

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <b>vardef</b> <i>FUNCTION</i> = <tt>'([[:alpha:]]|_)[[:word:]]*(?=[[:blank:]]*\()'</tt>
     <i>function</i> = <i>$FUNCTION</i>
</pre>
   <p class="noindent">that shows an example of forward lookahead assert for the opening
parenthesis (see <a href="#Notes-on-regular-expressions">Notes on regular expressions</a>).  As noted in
<a href="#File-inclusion">File inclusion</a>, it is crucial that this file is included after the
keyword definition.

   <p>Finally, <samp><span class="file">c.lang</span></samp> includes the file
<samp><span class="file">clike_vardeclaration.lang</span></samp>:

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     (<i>usertype</i>,<i>usertype</i>,<i>normal</i>) =
     <tt>`([[:alpha:]_](?:[^[:punct:][:space:]]|[_])*)</tt>
     <tt>((?:&lt;.*&gt;)?)</tt>
     <tt>(\s+(?=[*&amp;]*[[:alpha:]_][^[:punct:][:space:]]*\s*[[:punct:]\[\]]+))`</tt>
     
</pre>
   <p>This definition, using subexpressions with names (see <a href="#Explicit-subexpressions-with-names">Explicit subexpressions with names</a>), tries<a rel="footnote" href="#fn-41" name="fnd-41"><sup>41</sup></a> to match
user types (e.g., struct names) in function parameter and variable
declarations.  It basically tries to match a type identifier, then a
possible template specification<a rel="footnote" href="#fn-42" name="fnd-42"><sup>42</sup></a> and then we have a complete lookahead assert
(<a href="#Notes-on-regular-expressions">Notes on regular expressions</a>) that tries to match the variable
identifier, possibly with <code>&amp;</code> and <code>*</code> reference and pointer
specification, followed by an assignment <code>=</code> or a <code>;</code>, more
generally a <code>[:punct:]</code> or <code>[]</code> (for array specifications). 
This should catch the user types in the correct contexts, as in the
following (where we intentionally highlighted <code>usertype</code> in
italics):

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <i>Integer</i> i = 10;
     <i>Boolean</i> b;
     <i>String</i> args[];
     <b>const</b> <i>MyType</i> args[];
     <b>const</b> <i>My_Type</i> args[];
     <i>List&lt;Integer&gt;</i> mylist;
     <i>List&lt;List&lt;Integer&gt; &gt;</i> mylist;
     myspace::<i>InputStream</i> iStream ;
     <i>MyType</i> *t;
     <i>MyType</i> **t;
     <b>const</b> <i>MyType</i> &amp;t;
     <b>if</b> (argc &gt; 0) { }
     <i>__mytype</i> _i;
     <b>typedef</b> <i>_mytype</i> __i;
     
</pre>
   <p>Note that since for the third group we use a lookahead assert, what is
matched is not actually formatted but it is put back in the input stream
so that it can be formatted using other rules (e.g., <code>symbol</code> for
<code>*</code> and <code>=</code>).

   <p>Since, at least syntactically, C++ is an extension of C, the language
definition for C++, included in the file <samp><span class="file">cpp.lang</span></samp>, relies on
<samp><span class="file">c.lang</span></samp><a rel="footnote" href="#fn-43" name="fnd-43"><sup>43</sup></a>:

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <i># definitions for C++</i>
     <i># most of it is shared with c.lang</i>
     
     (<i>keyword</i>,<i>normal</i>,<i>classname</i>) =
       <tt>`(\&lt;(?:class|struct|typename))([[:blank:]]+)([[:alnum:]_]+)`</tt>
     
     <i>keyword</i> = <tt>"class|const_cast|delete"</tt>,
       <tt>"dynamic_cast|explicit|false|friend"</tt>,
       <tt>"inline|mutable|namespace|new|operator|private|protected"</tt>,
       <tt>"public|reinterpret_cast|static_cast"</tt>,
       <tt>"template|this|throw|true"</tt>,
       <tt>"try|typeid|typename"</tt>,
       <tt>"using|virtual"</tt>
     
     <b>include</b> <tt>"c.lang"</tt>
     
</pre>
   <p>In particular, it extends the set of keywords.  Moreover, note that we
use subexpressions with names (see <a href="#Explicit-subexpressions-with-names">Explicit subexpressions with names</a>) for highlighting the class (or struct) name (when preceded by
<code>class</code>, <code>struct</code> or <code>typename</code>, highlighted as a
keyword).  A similar rule was also present in <samp><span class="file">c.lang</span></samp>, but it
concerned only <code>struct</code>.

   <p>Now that we wrote the language definition for C/C++, writing the one
for C# is straightforward, since we only need to add the keyword
<code>using</code> as a preprocessor element, and redefine  (or better,
&ldquo;substitute&rdquo;, <a href="#Redefinitions-and-Substitutions">Redefinitions and Substitutions</a>) the keywords
and types:

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <i># definitions for C-sharp</i>
     <i># by S. HEMMI, updated by L. Bettini.</i>
     <i>preproc</i> = <tt>"using"</tt>
     
     <i>number</i> =
     <tt>'\&lt;[+-]?((0x[[:xdigit:]]+)|(([[:digit:]]*\.)?</tt>
     <tt>[[:digit:]]+([eE][+-]?[[:digit:]]+)?))([FfDdMmUulL]+)?\&gt;'</tt>
     
     <b>include</b> <tt>"cpp.lang"</tt>
     
     <b>subst</b> <i>keyword</i> = <tt>"abstract|event|new|struct"</tt>,
      <tt>"as|explicit|null|switch"</tt>,
      <tt>"base|extern|this"</tt>,
      <tt>"false|operator|throw"</tt>,
      <tt>"break|finally|out|true"</tt>,
      <tt>"fixed|override|try"</tt>,
      <tt>"case|params|typeof"</tt>,
      <tt>"catch|for|private"</tt>,
      <tt>"foreach|protected"</tt>,
      <tt>"checked|goto|public|unchecked"</tt>,
      <tt>"class|if|readonly|unsafe"</tt>,
      <tt>"const|implicit|ref"</tt>,
      <tt>"continue|in|return"</tt>,
      <tt>"virtual"</tt>,
      <tt>"default|interface|sealed|volatile"</tt>,
      <tt>"delegate|internal"</tt>,
      <tt>"do|is|sizeof|while"</tt>,
      <tt>"lock|stackalloc"</tt>,
      <tt>"else|static"</tt>,
      <tt>"enum|namespace"</tt>,
      <tt>"get|partial|set"</tt>,
      <tt>"value|where|yield"</tt>
     
     <b>subst</b> <i>type</i> = <tt>"bool|byte|sbyte|char|decimal|double"</tt>,
      <tt>"float|int|uint|long|ulong|object"</tt>,
      <tt>"short|ushort|string|void"</tt>
     
</pre>
   <div class="node">
<a name="Highlighting-Diff-files"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Pseudo-semantic-analysis">Pseudo semantic analysis</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Highlighting-C_002fC_002b_002b-and-C_0023">Highlighting C/C++ and C#</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Tutorials-on-Language-Definitions">Tutorials on Language Definitions</a>

</div>

<h4 class="subsection">7.18.2 Highlighting Diff files</h4>

<p>Now we want to highlight files that are generated by <code>diff</code>
(typically used to create patches).  This program can generate outputs
in three different formats (at least at best of my knowledge).

   <p>With the option <code>-u|--unified</code> the differences among files
are shown in the same context, for instance (the examples of the
diff files shown here are manually modified so that they can
fit in the page width):

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     diff -ruP source-highlight-2.1.1/source-highlight.spec ...
     <i>--- source-highlight-2.1.1/source-highlight.spec ...</i>
     <i>+++ source-highlight-2.1.2/source-highlight.spec ...</i>
     <b>@@ -6,8 +6,8 @@</b>
     
      Summary:   syntax highlighting for source documents
      Name:      source-highlight
     <i>-Version:   2.1.1</i>
     <i>-Release:   2.1.1</i>
     <i>+Version:   2.1.2</i>
     <i>+Release:   2.1.2</i>
      License:   GPL
      Group:     Utilities/Console
      Source:    ftp://ftp.gnu.org/gnu/source-highlight/%{name}-%{version}.tar.gz
     
</pre>
   <p>With the option <code>-c--context</code> the differences are shown into
two different parts:

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     diff -rc2P source-highlight-2.1.1/source-highlight.spec ...
     <i>*** source-highlight-2.1.1/source-highlight.spec ...</i>
     <i>--- source-highlight-2.1.2/source-highlight.spec ...</i>
     <i>***************</i>
     <i>*** 7,12 ****</i>
       Summary:   syntax highlighting for source documents
       Name:      source-highlight
     <i>! Version:   2.1.1</i>
     <i>! Release:   2.1.1</i>
       License:   GPL
       Group:     Utilities/Console
     <i>--- 7,12 ----</i>
       Summary:   syntax highlighting for source documents
       Name:      source-highlight
     <i>! Version:   2.1.2</i>
     <i>! Release:   2.1.2</i>
       License:   GPL
       Group:     Utilities/Console
     diff -rc2P source-highlight-2.1.1/src/latex.outlang ...
     <i>*** source-highlight-2.1.1/src/latex.outlang ...</i>
     <i>--- source-highlight-2.1.2/src/latex.outlang ...</i>
     <i>***************</i>
     <i>*** 35,37 ****</i>
     <i>--- 35,38 ----</i>
       "--" "-\\/-"
       "---" "-\\/-\\/-"
     <i>+ "\"" "\"{}" # avoids problems with some inputenc</i>
       end
     
</pre>
   <p>Without options it generates only the essential difference
information without any addition context lines:

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     diff -rP source-highlight-2.1.1/source-highlight.spec ...
     <b>9,10c9,10</b>
     <i>&lt; Version:   2.1.1</i>
     <i>&lt; Release:   2.1.1</i>
     ---
     <i>&gt; Version:   2.1.2</i>
     <i>&gt; Release:   2.1.2</i>
</pre>
   <p>Summarizing, we would like to be able to handle all these three
different syntaxes; note that the first format and the second format
have something conflicting: the first one uses the <code>---</code> to
indicate the new version of a file while the second format uses it to
indicate the old version of a file.  Since we want to highlight
differently the old parts and the new parts (this is not visible in the
Texinfo highlighting due to the lack of enhanced formatting features,
but it is visible for instance in HTML output where we use two
different colors), this behavior adds some difficulties.  Of course, we
could define three different language definitions, one for each diff
output format.  However, we prefer to handle them all in the same
file!

   <p>This is the language definition for diff files:

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <i># language definition for files created with 'diff'</i>
     
     <i># diff created with -u option</i>
     <b>state</b> <i>oldfile</i> = <tt>'(?=^[-]{3})'</tt> <b>begin</b>
       <i>oldfile</i> <b>start</b> <tt>'^[-]{3}'</tt>
       <i>oldfile</i> <b>start</b> <tt>'^[-]'</tt>
       <i>newfile</i> <b>start</b> <tt>'^[+]'</tt>
       <i>difflines</i> <b>start</b> <tt>'^@@'</tt>
     <b>end</b>
     
     <i># diff created with -c option</i>
     <b>state</b> <i>oldfile</i> = <tt>'(?=^[*]{3})'</tt> <b>begin</b>
       <b>environment</b> <i>oldfile</i> = <tt>'^[*]{3}[[:blank:]]+[[:digit:]]'</tt> <b>begin</b>
         <i>normal</i> <b>start</b> <tt>'^[[:space:]]'</tt>
         <i>newfile</i> = <tt>'(?=^[-]{3})'</tt> <b>exit</b>
       <b>end</b>
       <i>oldfile</i> <b>start</b> <tt>'^[*]{3}'</tt>
     
       <b>environment</b> <i>newfile</i> = <tt>'^[-]{3}[[:blank:]]+[[:digit:]]'</tt> <b>begin</b>
         <i>normal</i> <b>start</b> <tt>'^[[:space:]]'</tt>
         <i>newfile</i> = <tt>'(?=^[*]{3})'</tt> <b>exit</b>
         <i>normal</i> <b>start</b> <tt>'^diff'</tt> <b>exit</b>
       <b>end</b>
       <i>newfile</i> <b>start</b> <tt>'^[-]{3}'</tt>
     <b>end</b>
     
     <i># otherwise, created without options</i>
     <b>state</b> <i>difflines</i> = <tt>'(?=^[[:digit:]])'</tt> <b>begin</b>
       <i>difflines</i> <b>start</b> <tt>'^[[:digit:]]'</tt>
       <i>oldfile</i> <b>start</b> <tt>'^[&lt;]'</tt>
       <i>newfile</i> <b>start</b> <tt>'^[&gt;]'</tt>
     <b>end</b>
     
</pre>
   <p>Since we can safely assume that when we process a diff file it contains
only information created with the same diff command line switch, we
define three different states that correspond to the three diff output
formats.  Note that these states are entered with a simple definition;
as noted in <a href="#State_002fEnvironment-Definitions">State/Environment Definitions</a>, this means that no
automatic exit means are provided, and since no explicit exit condition
is specified, this means that once one of this state is entered it will
never be exited.  This is consistent with our goal.  Of course, the
expression that makes us enter a state must be defined correctly, and in
particular we first search for an initial <code>---</code> sequence since this
is used as the first difference specification by the <code>-u|--unified</code>
option, so this is a distinguishing feature to be used to
infer which diff format file we are processing.

   <p>Another interesting thing, is that we use the forward lookahead assert
for the opening parenthesis (see <a href="#Notes-on-regular-expressions">Notes on regular expressions</a>),
since we only want to see which file format we are processing.  Once we
entered the right state we can define the regular expressions for the
elements of the specific diff file format.

   <p>For the files created with the option <code>-c|--context</code> we define two
inner environments, one for the new file part and one for the old file
part (these are delimited by a <code>---</code> or <code>***</code> and line number
information).  Note that these are environments, so anything that is
not matched by any expression is formatted according to the style of the
element that defines the environment.  Thus, we provide an expression
for text that must be formatted as normal.  For diff files this
corresponds to a line that start with a space or with <code>diff</code> (take
a look at the examples above).  In particular the latter case can take
place only during the new file part.  In both environments we must
define the exit conditions.  In both cases these correspond to the
beginning of the complementary part; also in this case we use forward
lookahead assertions, since we use it only to exit the environment.  The
outer definitions for <code>oldfile</code> and <code>newfile</code> are used to
match the lines with source file information information.

   <p>The third state, corresponding to the normal diff output format, should
be straightforward by now.

<div class="node">
<a name="Pseudo-semantic-analysis"></a>
<p><hr>
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Highlighting-Diff-files">Highlighting Diff files</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Tutorials-on-Language-Definitions">Tutorials on Language Definitions</a>

</div>

<h4 class="subsection">7.18.3 Pseudo semantic analysis</h4>

<p>Source-highlight, by means of regular expressions can only perform
lexical analysis of the input source.  In particular, it is based on the
assumption that the input source is syntactically correct with respect
to the input language.  However, by using the language definition syntax
and by writing the right regular expression it is  possible to simulate
some sort of semantic analysis of the input source.

   <p>For instance, consider the following C (or C++) source file:

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <i>// test special #if 0 treatment</i>
     
     <b>int</b> main() {
     <b>#if</b> 0 <i>// equivalent to a comment</i>
       <b>int</b> i = 10;
       printf(<tt>"this should never be executed</tt>\n<tt>"</tt>);
       <b>return</b> 1;
     <b>#else</b>
       printf(<tt>"Hello world!</tt>\n<tt>"</tt>);
       <b>return</b> 0;
     <b>#endif</b>
     
       printf(<tt>"never reach here!</tt>\n<tt>"</tt>);
     }
     
</pre>
   <p class="noindent">It is easy to verify that the code between <code>#if 0</code> and
<code>#else</code> will be never executed (indeed it will not even
be compiled).  Thus, we might want to format it as a comment.

   <p>We then write another language definition file, based on the file
<samp><span class="file">cpp.lang</span></samp>:

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <b>environment</b> <i>comment</i> <b>start</b> <tt>'^[[:blank:]]*#if[[:blank:]]+0'</tt> <b>begin</b>
       <i>comment</i> <b>start</b> <tt>'^[[:blank:]]*#(else|endif)'</tt> <b>exit</b>
     <b>end</b>
     
     <b>include</b> <tt>"cpp.lang"</tt>
     
</pre>
   <p class="noindent">We intentionally included an error in this first version:
we used the <code>start</code> element to start the environment,
but such element has the scope of a single line, thus,
it does not have the desired behavior:

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <i>// test special #if 0 treatment</i>
     
     <b>int</b> main() {
     <i>#if 0 // equivalent to a comment</i>
       <b>int</b> i = 10;
       printf(<tt>"this should never be executed</tt>\n<tt>"</tt>);
       <b>return</b> 1;
     <b>#else</b>
       printf(<tt>"Hello world!</tt>\n<tt>"</tt>);
       <b>return</b> 0;
     <b>#endif</b>
     
       printf(<tt>"never reach here!</tt>\n<tt>"</tt>);
     }
     
</pre>
   <p>A better solution is the following one:

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <b>environment</b> <i>comment</i> = <tt>'^[[:blank:]]*#[[:blank:]]*if[[:blank:]]+0'</tt> <b>begin</b>
       <i>comment</i> <b>start</b> <tt>'^[[:blank:]]*#[[:blank:]]*(else|endif)'</tt> <b>exit</b>
     <b>end</b>
     
     <b>include</b> <tt>"cpp.lang"</tt>
     
</pre>
   <p class="noindent">here we enter the <code>comment</code> environment by not using a delimited
element, but simply the regular expression to match <code>#ifdef 0</code>. 
Then we exit the environment either when we match an <code>#else</code> or a
<code>#endif</code>.  This seems to work:

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <i>// test special #if 0 treatment</i>
     
     <b>int</b> main() {
     <i>#if 0 // equivalent to a comment</i>
     <i>  int i = 10;</i>
     <i>  printf("this should never be executed\n");</i>
     <i>  return 1;</i>
     <i>#else</i>
       printf(<tt>"Hello world!</tt>\n<tt>"</tt>);
       <b>return</b> 0;
     <b>#endif</b>
     
       printf(<tt>"never reach here!</tt>\n<tt>"</tt>);
     }
     
</pre>
   <p>However, it does not work if we consider nested <code>#if...#else</code>; for
instance consider the following code, formatted with the previous
language definition:

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <i>// test special #if 0 treatment</i>
     
     <b>int</b> main() {
     <i>#if 0 // equivalent to a comment</i>
     <i>  int i = 10;</i>
     <i>  printf("this should never be executed\n");</i>
     <i>#  ifdef FOO</i>
     <i>  printf("foo\n");</i>
     <i>#     ifndef BAR</i>
     <i>  printf("no bar\n");</i>
     <i>#     else</i>
     <b>#     endif</b>
     <b>#  else</b>
       printf(<tt>"no foo</tt>\n<tt>"</tt>);
     <b>#  endif</b> <i>// FOO</i>
       <b>return</b> 1;
     <b>#else</b>
       printf(<tt>"Hello world!</tt>\n<tt>"</tt>);
       <b>return</b> 0;
     <b>#endif</b>
     
       printf(<tt>"never reach here!</tt>\n<tt>"</tt>);
     }
     
</pre>
   <p class="noindent">The problem is that the previous language definition does not consider
nested <code>#if</code> and thus, the first time it matches a <code>#else</code> or
an <code>#endif</code> it exits the <code>comment</code> environment.

   <p>We must then take into account possible nested occurrences.  This can be
done by using a delimited element with the <code>nested</code> option
(<a href="#Delimited-definitions">Delimited definitions</a>):

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <i># treat the preprocess statement</i>
     <i>#  #if 0</i>
     <i>#    ...</i>
     <i>#  #else</i>
     <i># as a comment</i>
     
     <b>environment</b> <i>comment</i> = <tt>'^[[:blank:]]*#[[:blank:]]*if[[:blank:]]+0'</tt> <b>begin</b>
       <i>comment</i> <b>start</b> <tt>'^[[:blank:]]*#[[:blank:]]*else'</tt> <b>exit</b>
       <i>comment</i> <b>delim</b> <tt>'^[[:blank:]]*#[[:blank:]]*if'</tt>
                     <tt>'^[[:blank:]]*#[[:blank:]]*endif'</tt> <b>multiline</b> <b>nested</b>
     
     <b>end</b>
     
     <b>include</b> <tt>"cpp.lang"</tt>
     
     
</pre>
   <p class="noindent">This time the right block of code is correctly formatted as a comment:

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <i>// test special #if 0 treatment</i>
     
     <b>int</b> main() {
     <i>#if 0 // equivalent to a comment</i>
     <i>  int i = 10;</i>
     <i>  printf("this should never be executed\n");</i>
     <i>#  ifdef FOO</i>
     <i>  printf("foo\n");</i>
     <i>#     ifndef BAR</i>
     <i>  printf("no bar\n");</i>
     <i>#     else</i>
     <i>#     endif</i>
     <i>#  else</i>
     <i>  printf("no foo\n");</i>
     <i>#  endif // FOO</i>
     <i>  return 1;</i>
     <i>#else</i>
       printf(<tt>"Hello world!</tt>\n<tt>"</tt>);
       <b>return</b> 0;
     <b>#endif</b>
     
       printf(<tt>"never reach here!</tt>\n<tt>"</tt>);
     }
     
</pre>
   <p>Note that it is crucial to exit the environment even when we match an
<code>#else</code> (not only an <code>#endif</code>, since, this way, we can match
again another <code>#ifdef 0</code>; consider, for instance, the following
code:

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <i>// test special #if 0 treatment</i>
     
     <b>int</b> main() {
     <i>#if 0 // equivalent to a comment</i>
     <i>  int i = 10;</i>
     <i>  printf("this should never be executed\n");</i>
     <i>  return 1;</i>
     <i>#else</i>
       printf(<tt>"Hello world!</tt>\n<tt>"</tt>);
     <i>#   if 0 // another one</i>
     <i>  return 1;</i>
     <i>#   else</i>
       <b>return</b> 0;
     <b>#   endif</b>
     <b>#endif</b>
     
       printf(<tt>"never reach here!</tt>\n<tt>"</tt>);
     }
     
</pre>
   <div class="node">
<a name="Output-Language-Definitions"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Generating-References">Generating References</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Language-Definitions">Language Definitions</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">8 Output Language Definitions</h2>

<p><a name="index-output-language-definition-153"></a>
Since version 2.1 source-highlight uses a specific syntax to specify
output formats (e.g., how to format in HTML, LaTeX, etc.).  Before
version 2.1, in order to add a new output format, many C++ classes had
to be written.  This had the drawback that a new output format could not
be added &ldquo;dynamically&rdquo;: you had to recompile the whole
source-highlight program.

   <p>Instead, now, an output format is specified in a file, loaded
dynamically, through a (hopefully) simple syntax.  Then, these
definitions are used internally to create, on-the-fly,  text formatters.

   <p>Here, we see such syntax in details, by relying on many examples.  This
allows a user to easily modify an existing output format definition and
create a new one.  These files have, typically, extension
<samp><span class="file">.outlang</span></samp>.

   <p>Each definition basically associates a text style (such as, e.g., bold,
italics, colors, etc.)  to the representation of that style into the
output format (such as, e.g., <code>&lt;b&gt;$text&lt;/b&gt;</code> in HTML).  The
representation is given in <code>"</code> and you can use the classic escape
character <code>\</code> to use the <code>"</code> inside the definition.  If you
want to specify the ASCII code for a character you can do so by
specifying the numeric code in hexadecimal notation preceded by
<code>\x</code>, for an example, see <a href="#Style-template">Style template</a>.

   <p>If no definition is given for a specific style, e.g., bold, then when
that style is requested during formatting, the text will be formatted as
it is, i.e., the style without the definition is simply ignored.

   <p>Comments can be given by using <code>#</code>; the rest of the line is
considered as a comment.

   <p>Files can be included in the same way as for language definitions,
<a href="#File-inclusion">File inclusion</a>.

   <p>In any case, if a definition for a style is given more than once, the
last definition replaces all the others.

<ul class="menu">
<li><a accesskey="1" href="#File-extension">File extension</a>:               Specify the output file extension
<li><a accesskey="2" href="#Text-styles">Text styles</a>:                  Bold, Italics, Underline, etc. 
<li><a accesskey="3" href="#Colors">Colors</a>:                       Style and definitions for colors
<li><a accesskey="4" href="#Anchors-and-References">Anchors and References</a>
<li><a accesskey="5" href="#One-style">One style</a>
<li><a accesskey="6" href="#Style-template">Style template</a>
<li><a accesskey="7" href="#Line-prefix">Line prefix</a>
<li><a accesskey="8" href="#String-translation">String translation</a>
<li><a accesskey="9" href="#Document-template">Document template</a>
<li><a href="#Generating-HTML-output">Generating HTML output</a>
</ul>

<div class="node">
<a name="File-extension"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Text-styles">Text styles</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Output-Language-Definitions">Output Language Definitions</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Output-Language-Definitions">Output Language Definitions</a>

</div>

<h3 class="section">8.1 File extension</h3>

<p>With the line:

<pre class="example">     extension "&lt;file extension&gt;"
</pre>
   <p class="noindent">you define the default file extension (without the <code>.</code>) used to
generate files formatted according to this output format.  This is used
when no output file name is specified; if the file extension is not
included in the <code>.outlang</code> is not defined, and no output file name
is specified, an error will occur.

   <p>For instance, this is used in <samp><span class="file">html_common.outlang</span></samp>:

<pre class="example">     extension "html"
</pre>
   <div class="node">
<a name="Text-styles"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Colors">Colors</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#File-extension">File extension</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Output-Language-Definitions">Output Language Definitions</a>

</div>

<h3 class="section">8.2 Text styles</h3>

<p><a name="index-bold-154"></a><a name="index-italics-155"></a><a name="index-underline-156"></a><a name="index-fixed-157"></a><a name="index-notfixed-158"></a>
These are the text styles that one can define:

<pre class="example">     bold
     italics
     underline
     notfixed
     fixed
</pre>
   <p class="noindent">These, of course, correspond to the ones used to specify the output
format style, <a href="#Output-format-style">Output format style</a>.

   <p>These definitions, for instance, are from the HTML format definition:

<pre class="example">     bold "&lt;b&gt;$text&lt;/b&gt;"
     italics "&lt;i&gt;$text&lt;/i&gt;"
     underline "&lt;u&gt;$text&lt;/u&gt;"
</pre>
   <p><a name="index-g_t_0024text-159"></a>Inside a definition you use the special variable <code>$text</code> to specify
where the actual text to be formatted has to be inserted.  For instance,
the definition of <code>bold</code> above says that if you need to format the
keyword <code>class</code> in bold in HTML, the following text will be
generated: <code>&lt;b&gt;class&lt;/b&gt;</code>.  This variable is used also when mixing
more than one styles recursively, in particular if you want to format in
bold and italics (i.e, first bold and then italics, or, in other words,
the sequence <code>i, b</code> is used in the the output format style file, see
<a href="#Output-format-style">Output format style</a>), then first the text
<code>class</code> is substituted for <code>$text</code> into <code>&lt;b&gt;$text&lt;/b&gt;</code>
and then the text <code>&lt;b&gt;class&lt;/b&gt;</code> will be substituted for
<code>$text</code> into <code>&lt;i&gt;$text&lt;/i&gt;</code>, thus obtaining
<code>&lt;i&gt;&lt;b&gt;class&lt;/b&gt;&lt;/i&gt;</code>.

<div class="node">
<a name="Colors"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Anchors-and-References">Anchors and References</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Text-styles">Text styles</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Output-Language-Definitions">Output Language Definitions</a>

</div>

<h3 class="section">8.3 Colors</h3>

<p><a name="index-colors-160"></a><a name="index-g_t_0024style-161"></a>
The definition for using colors during formatting requires
the definition for the <code>color</code> style

<pre class="example">     color "..."
</pre>
   <p><a name="index-background-color-162"></a>and for the <code>bgcolor</code> style<a rel="footnote" href="#fn-44" name="fnd-44"><sup>44</sup></a>:

<pre class="example">     bgcolor "..."
</pre>
   <p>This definition concerns only the background color for a specific
highlighted element, i.e., the color specified in the style file with
the prefix <code>bg:</code> (see <a href="#Output-format-style">Output format style</a>) or the property
<code>background-color</code> specified in a CSS file passed to
<code>--style-css-file</code> (see <a href="#Output-format-style-using-CSS">Output format style using CSS</a>). 
Thus it should not be confused with the background color of the entire
output (i.e., the one specified using <code>bgcolor</code> in a style file or
the property <code>background-color</code> of the <code>body</code> selector in a
CSS).  The background color for the entire document is explained in
<a href="#Document-template">Document template</a>.

   <p>Note that the background color might not be available for all output
formats.   For instance, for HTML we only have:

<pre class="example">     color "&lt;font color=\"$style\"&gt;$text&lt;/font&gt;"
</pre>
   <p class="noindent">while for XHTML we have:

<pre class="example">     color "&lt;span style=\"color: $style\"&gt;$text&lt;/span&gt;"
     bgcolor "&lt;span style=\"background-color: $style\"&gt;$text&lt;/span&gt;"
</pre>
   <p>Apart from the variable <code>$text</code> that we already saw, we
have also the variable <code>$style</code>, that will be replaced
with the actual color.

   <p>Source-highlight recognizes a number of color constants,
see <a href="#Output-format-style">Output format style</a>.

   <p>You then must associate a color constant to the color definition in the
output format, through the <code>colormap</code> definition:

<pre class="example">     colormap
     "color constant" "color representation"
     "color constant" "color representation"
     ...
     default "default color representation"
     end
</pre>
   <p>The <code>default</code> row (note the absence of <code>"</code>) defines the
color to be used in case a color constant is used during formatting, but
it is not defined in the output format.

   <p>For instance, for HTML we have:

<pre class="example">     colormap
     "green" "#33CC00"
     "red" "#FF0000"
     "darkred" "#990000"
     "blue" "#0000FF"
     "brown" "#9A1900"
     "pink" "#CC33CC"
     "yellow" "#FFCC00"
     "cyan" "#66FFFF"
     "purple" "#993399"
     "orange" "#FF6600"
     "brightorange" "#FF9900"
     "brightgreen" "#33FF33"
     "darkgreen" "#009900"
     "black" "#000000"
     "teal" "#008080"
     "gray" "#808080"
     "darkblue" "#000080"
     default "#000000"
     end
</pre>
   <p>If your output format does not handle colors you can simply avoid the
definitions of <code>color</code> and <code>colormap</code> and Source-highlight
will simply ignore colors.

   <p>The color is applied after applying the other styles,
e.g., bold, italics, etc.

   <p>Thus, by continuing the example of the previous section, suppose you defined
the following output style for keywords:

<pre class="example">     keyword blue i, b;
</pre>
   <p class="noindent">then the <code>class</code> text will be replaced to <code>$text</code> variable and
the value <code>#0000FF</code> to <code>$style</code> inside the color definition
<code>&lt;font color="$style"&gt;$text&lt;/font&gt;</code> obtaining <code>&lt;font
color="#0000FF"&gt;class&lt;/font&gt;</code> which will then be replaced to
<code>$text</code> in <code>&lt;b&gt;$text&lt;/b&gt;</code> and so on for italics, finally
obtaining

   <p><code>&lt;i&gt;&lt;b&gt;&lt;font color="#0000FF"&gt;class&lt;/font&gt;&lt;/b&gt;&lt;/i&gt;</code>.

<div class="node">
<a name="Anchors-and-References"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#One-style">One style</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Colors">Colors</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Output-Language-Definitions">Output Language Definitions</a>

</div>

<h3 class="section">8.4 Anchors and References</h3>

<p><a name="index-g_t_0024linenum-163"></a>
When using the command line option <code>--line-number-ref</code>
(<a href="#Invoking-source_002dhighlight">Invoking source-highlight</a>) an anchor is generated in the output
file for each line numbering.  The style of the anchor is defined by the
definition <code>anchor</code>.  If this is not defined, the option
<code>--line-number-ref</code> has no effect.  The <code>$linenum</code> variable will
be replaced with the line number, and the <code>$text</code> variable
with the actual text.

   <p>For instance, for HTML we have

<pre class="example">     anchor "&lt;a name=\"$linenum\"&gt;$text&lt;/a&gt;"
</pre>
   <p><a name="index-g_t_0024infile-164"></a><a name="index-g_t_0024infilename-165"></a><a name="index-g_t_0024outfile-166"></a>Since version 2.2 source-highlight can also generate references to
several elements (e.g., variables, class definitions, etc.),
<a href="#Generating-References">Generating References</a>.  Also in this case the definition
<code>anchor</code> is used; furthermore, the definition of <code>reference</code>
is required.   In the definition of <code>anchor</code> and <code>reference</code>,
apart from the variable <code>$linenum</code>, we also have the variables
<code>$infile</code> (the name of the original input file) and
<code>$infilename</code> (the name of the original input file without the
path) and in the definition of <code>reference</code> we also have the
variable <code>$outfile</code> (the name of the file where the anchor is). 
One can decide how to define an anchor and a reference by using these
two variables.  For instance, for HTML we have

<pre class="example">     reference "&lt;a href=\"$outfile#$linenum\"&gt;$text&lt;/a&gt;"
</pre>
   <p class="noindent">Note, that in this case we use the <code>$outfile</code> since we actually
generate a link to another (or possibly the same) output file.

   <p>On the contrary, for LaTeX, since we do not generate a &ldquo;clickable&rdquo;
reference, we refer to the original input file (we use both
<code>$infilename</code> and <code>$linenum</code> in both definitions of <code>anchor</code>
and <code>reference</code>):

<pre class="example">     anchor "\label{$infilename:$linenum}$text"
     reference "{\hfill $text $\rightarrow$ $infile:$linenum, \
                page~\pageref{$infilename:$linenum}}"
</pre>
   <p class="noindent">In particular, we use <code>$infilename</code> for generating the
<code>\label</code> and not <code>$infile</code> because the path symbol would
&ldquo;disturb&rdquo; LaTeX (while we use the complete file path in the textual
information of the reference).

   <p>This will generate a right aligned reference.  Note that it is assumed
that when generating references in LaTeX one uses
<code>--gen-references=postline</code> or <code>--gen-references=postdoc</code> and
not <code>--gen-references=inline</code> (<a href="#Generating-References">Generating References</a>), since
it makes no sense to generate an inline reference (or at least I would
not know how to generate a nice looking one :-).

   <p>Furthermore, for Texinfo:

<pre class="example">     anchor "@anchor{$infilename:$linenum}$text"
     reference "@flushright
     @xref{$infilename:$linenum,$text,$text $infile:$linenum}.
     @end flushright"
</pre>
   <p class="noindent">Note that using both <code>$infilename</code> (and not <code>$infile</code> for
the same reasons) and <code>$linenum</code> also in the definition of
<code>anchor</code> somehow ensures that there are no duplicate anchors; this
is done for LaTeX and Texinfo but not for HTML because it is assumed
that the generated <samp><span class="file">.tex</span></samp> and <samp><span class="file">.texinfo</span></samp> file is included
directly in a master file, as it is done in this manual (while, for
instance, it is assumed that a separate HTML file is generated for each
source and kept separate).  If this is not your case you can change the
definitions of <code>anchor</code> and <code>reference</code> as you see fit.  Some
examples of outputs with references in Texinfo are shown in
<a href="#Examples">Examples</a>.

   <p><a name="index-inline_005freference-167"></a><a name="index-postline_005freference-168"></a><a name="index-postdoc_005freference-169"></a>Indeed, one can use three more definitions for <code>reference</code> that
corresponds to the three arguments that can be passed to
<code>--gen-references</code> command line option (<a href="#Generating-References">Generating References</a>): <code>inline_reference</code>, <code>postline_reference</code> and
<code>postdoc_reference</code>.  If one of this not defined, then the same
definition of <code>reference</code> is used.  Having the possibility of
specifying different definitions is useful for instance in the case of
HTML: the same style for an inline reference is pretty ugly when used
also for a postline or postdoc reference:

<pre class="smallexample">     postline_reference "&lt;a href=\"$outfile#$linenum\"&gt;$text -&gt; $infile:$linenum&lt;/a&gt;"
     postdoc_reference "&lt;a href=\"$outfile#$linenum\"&gt;$text -&gt; $infile:$linenum&lt;/a&gt;"
     reference "&lt;a href=\"$outfile#$linenum\"&gt;$text&lt;/a&gt;"
</pre>
   <div class="node">
<a name="One-style"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Style-template">Style template</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Anchors-and-References">Anchors and References</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Output-Language-Definitions">Output Language Definitions</a>

</div>

<h3 class="section">8.5 One style</h3>

<p><a name="index-one-style-170"></a>
If the output format you are defining does not have a specific style
for bold, italics, ... and for colors you can simply use the definition
<code>onestyle</code>, where you can use both <code>$style</code> and <code>$text</code>. 
This will be used for any style (indeed any other definition such as
bold, italics, color will be ignored).  Indeed, in this case, it is
assumed that the style of each source element is defined in a file with
its own syntax, i.e., not with a syntax defined by Source-highlight. 
(This is the case, for instance, of HTML using CSS style sheets.) 
Moreover, since the output format style is not used, during formatting
the variable <code>$style</code> will be replaced with the name of the element
to highlight (e.g., <code>keyword</code>, <code>comment</code>, etc.).

   <p>For instance, for HTML CSS, we simply have:

<pre class="example">     onestyle "&lt;span class=\"$style\"&gt;$text&lt;/span&gt;"
</pre>
   <p class="noindent">In fact, HTML CSS relies on style definitions provided in a separate
file (the <samp><span class="file">.css</span></samp> file indeed).  Thus, when formatting a
<code>keyword</code>, e.g., <code>abstract</code>, we will obtain:

<pre class="example">     &lt;span class="keyword"&gt;abstract&lt;/span&gt;
</pre>
   <p class="noindent">Of course, the style for <code>keyword</code> must be defined in the
<samp><span class="file">.css</span></samp> file.

<div class="node">
<a name="Style-template"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Line-prefix">Line prefix</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#One-style">One style</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Output-Language-Definitions">Output Language Definitions</a>

</div>

<h3 class="section">8.6 Style template</h3>

<p><a name="index-style-template-171"></a><a name="index-style-separator-172"></a>
Some output formats are based on a unique template that where the other
styles are composed; during composition the styles can be separated with
a specific separator:

<pre class="example">     styletemplate "..."
     styleseparator "..."
</pre>
   <p>This is used, for instance, for the ANSI color escape sequence
output format (<samp><span class="file">esc.outlang</span></samp>):

<pre class="example">     styletemplate "\x1b[$stylem$text\x1b[m"
     styleseparator ";"
     
     bold "01$style"
     underline "04$style"
     italics "$style"
     color "$style"
</pre>
   <p class="noindent">Note that, since more than one style can be mixed into the style
template, <code>bold</code>, <code>underline</code>, ... explicitly use the variable
<code>$style</code>.

<div class="node">
<a name="Line-prefix"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#String-translation">String translation</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Style-template">Style template</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Output-Language-Definitions">Output Language Definitions</a>

</div>

<h3 class="section">8.7 Line prefix</h3>

<p>This feature allows you to generate a string as the prefix of each
generated line that corresponds to an input line (i.e., this prefix is
not generated for other generated output elements, e.g., the lines in
the header, footer, etc.).

   <p>We use this feature in the LaTeX output (<a href="#LaTeX-output">LaTeX output</a>):

<pre class="example">     lineprefix "\mbox{}"
</pre>
   <p class="noindent">This way each line in the LaTeX output is prefixed with
<code>\mbox{}</code><a rel="footnote" href="#fn-45" name="fnd-45"><sup>45</sup></a>.

   <p>Another interesting example that uses <code>lineprefix</code> is the javadoc
output, see <a href="#Generating-HTML-output">Generating HTML output</a>.

<div class="node">
<a name="String-translation"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Document-template">Document template</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Line-prefix">Line prefix</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Output-Language-Definitions">Output Language Definitions</a>

</div>

<h3 class="section">8.8 String translation</h3>

<p>Some character sequences that are in the source file may have a
special meaning in an output format, so they need some preprocessing
(e.g., escaping them).  You can specify the translation table with:

<pre class="example">     translations
     "original sequence" "transformed sequence"
     'regex' "transformed sequence"
     ...
     end
</pre>
   <p class="noindent">The difference between <code>"original sequence"</code> and
<code>'regex'</code><a rel="footnote" href="#fn-46" name="fnd-46"><sup>46</sup></a> is that with the former
you specify a character sequence that will be matched literally, apart
from special characters such as <code>\</code> (which, if needed to be
inserted, must be escaped), <code>\n</code> (new line) and <code>\t</code> (tab
character).  Instead, with the latter, you can specify a regular
expression (this is basically the same difference between <code>"</code> and
<code>'</code> in language definitions, see <a href="#Simple-definitions">Simple definitions</a>).

   <p>For instance, for HTML, we have the following translation table:

<pre class="example">     translations
     "&amp;" "&amp;amp;"
     "&lt;" "&amp;lt;"
     "&gt;" "&amp;gt;"
     end
</pre>
   <p>For LaTeX, the translation table is a little bit bigger; here we
show only a little part, that shows how to escape special characters
(such as <code>\</code>), to translate a new line character and tab
character:

<pre class="example">     translations
     "&lt;" "$&lt;$"
     "&gt;" "$&gt;$"
     "&amp;" "\\&amp;"
     "\\" "\\textbackslash{}"
     "\n" " \\\\\n"
     " " "\\ "
     "\t" "\\ \\ \\ \\ \\ \\ \\ \\ "
     end
</pre>
   <p class="noindent">Note that, since a new character must be translated in LaTeX with
<code>\\</code>, we have to escape two <code>\</code> (i.e., <code>\\\\</code>) and then
we want to actually insert a new line in the output file <code>\n</code>.

   <p>For HTML with not fixed font by default, <samp><span class="file">html_notfixed.outlang</span></samp>
(see <a href="#HTML-and-XHTML-output">HTML and XHTML output</a>), we need two translate two space sequence
(i.e., two adjacent spaces, since in HTML more adjacent spaces are
rendered as only one space<a rel="footnote" href="#fn-47" name="fnd-47"><sup>47</sup></a>, while we want them as they are), and we also
need to translate a space starting a new line in the source (thus we
use the regular expression <code>^ </code>, enclosed in <code>'</code>); thus we
have:

<pre class="example">     translations
     "\n" "&lt;br&gt;\n"
     "  " "&amp;nbsp; "
     '^ ' "&amp;nbsp;" # a space at the beginning of a line
     "\t" "&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; "
     end
</pre>
   <div class="node">
<a name="Document-template"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Generating-HTML-output">Generating HTML output</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#String-translation">String translation</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Output-Language-Definitions">Output Language Definitions</a>

</div>

<h3 class="section">8.9 Document template</h3>

<p>You can define the beginning and the end of an output file, with

   <p><a name="index-doctemplate-173"></a>
<pre class="example">     doctemplate
     "...beginning..."
     "...end..."
     end
</pre>
   <p><a name="index-nodoctemplate-174"></a>
<pre class="example">     nodoctemplate
     "...beginning..."
     "...end..."
     end
</pre>
   <p>The first one is used when the <code>--doc</code> command line option is
specified, while the second one is used in the other case<a rel="footnote" href="#fn-48" name="fnd-48"><sup>48</sup></a>.

   <p>For instance, for HTML we have

<pre class="example">     nodoctemplate
     "&lt;!-- Generator: $additional --&gt;
     $header&lt;pre&gt;&lt;tt&gt;"
     "&lt;/tt&gt;&lt;/pre&gt;$footer
     "
     end
</pre>
   <p class="noindent">Note that in the end part there is an explicit new line.

   <p>In the definition of the <code>doctemplate</code> and <code>nodoctemplate</code> the
following variables can be used and will be replaced during the output
generation:

     <dl>
<dt><code>$title</code><dd>the value of the title for the output file (e.g., the one passed with
the <code>--title</code> command line option;
<br><dt><code>$header</code><dd>the contents of the file specified with the command line option
<code>--header</code>;
<br><dt><code>$footer</code><dd>the contents of the file specified with the command line option
<code>--footer</code>;
<br><dt><code>$css</code><dd>the value passed with the command line option <code>--css</code>;
<br><dt><code>$additional</code><dd>other additional information.  Source-highlight replaces this with its
name and its version. 
<br><dt><code>$docbgcolor<a rel="footnote" href="#fn-49" name="fnd-49"><sup>49</sup></a></code><dd>the background color for the output document.  Source-highlight replaces
this with the value specified in the <code>bgcolor</code> of the <samp><span class="file">.style</span></samp>
file (see <a href="#Output-format-style">Output format style</a>) or in the <code>body</code> selector of
the CSS file passed with <code>--style-css-file</code> (see <a href="#Output-format-style-using-CSS">Output format style using CSS</a>). 
</dl>

   <p>For instance, for an HTML document with css, (file
<samp><span class="file">htmlcss.outlang</span></samp>) we have:

<pre class="example">     doctemplate
     "&lt;!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\"
         \"http://www.w3.org/TR/REC-html40/strict.dtd\"&gt;
     &lt;html&gt;
     &lt;head&gt;
     &lt;meta http-equiv=\"Content-Type\"
     content=\"text/html; charset=iso-8859-1\"&gt;
     &lt;meta name=\"GENERATOR\" content=\"$additional\"&gt;
     &lt;title&gt;$title&lt;/title&gt;
     &lt;link rel=\"stylesheet\" href=\"$css\" type=\"text/css\"&gt;
     &lt;/head&gt;
     &lt;body&gt;
     $header&lt;pre&gt;&lt;tt&gt;"
     "&lt;/tt&gt;&lt;/pre&gt;
     $footer&lt;/body&gt;
     &lt;/html&gt;
     "
     end
</pre>
   <p>For an HTML document with header and footer, (file
<samp><span class="file">html.outlang</span></samp>) we have (note the use of <code>$docbgcolor</code>):

<pre class="example">     doctemplate
     "&lt;!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\"&gt;
     &lt;html&gt;
     &lt;head&gt;
     &lt;meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"&gt;
     &lt;meta name=\"GENERATOR\" content=\"$additional\"&gt;
     &lt;title&gt;$title&lt;/title&gt;
     &lt;/head&gt;
     &lt;body bgcolor=\"$docbgcolor\"&gt;
     $header&lt;pre&gt;&lt;tt&gt;"
     "&lt;/tt&gt;&lt;/pre&gt;
     $footer&lt;/body&gt;
     &lt;/html&gt;
     "
     end
</pre>
   <p>And for an HTML table output (file <samp><span class="file">htmltable.outlang</span></samp>):

<pre class="example">     doctemplate
     "&lt;table  BGCOLOR=\"$docbgcolor\" NOSAVE &gt;
     &lt;tr NOSAVE&gt;
     &lt;td NOSAVE&gt;
     &lt;pre&gt;&lt;tt&gt;"
     "&lt;/tt&gt;&lt;/pre&gt;
     &lt;/td&gt;
     &lt;/tr&gt;
     &lt;/table&gt;
     "
     end
</pre>
   <div class="node">
<a name="Generating-HTML-output"></a>
<p><hr>
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Document-template">Document template</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Output-Language-Definitions">Output Language Definitions</a>

</div>

<h3 class="section">8.10 Generating HTML output</h3>

<p>As a complete example we show the file <samp><span class="file">html_common.outlang</span></samp> which
contains the common definitions for the various HTML output formats
(<samp><span class="file">html.outlang</span></samp>, <samp><span class="file">htmltable.outlang</span></samp>, etc.):

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <b>include</b> <tt>"html_ref.outlang"</tt>
     
     <b>extension</b> <tt>"html"</tt>
     
     <b>bold</b> <tt>"&lt;b&gt;$text&lt;/b&gt;"</tt>
     <b>italics</b> <tt>"&lt;i&gt;$text&lt;/i&gt;"</tt>
     <b>underline</b> <tt>"&lt;u&gt;$text&lt;/u&gt;"</tt>
     <b>color</b> <tt>"&lt;font color=\"$style\"&gt;$text&lt;/font&gt;"</tt>
     
     <b>colormap</b>
     <tt>"green"</tt> <tt>"#33CC00"</tt>
     <tt>"red"</tt> <tt>"#FF0000"</tt>
     <tt>"darkred"</tt> <tt>"#990000"</tt>
     <tt>"blue"</tt> <tt>"#0000FF"</tt>
     <tt>"brown"</tt> <tt>"#9A1900"</tt>
     <tt>"pink"</tt> <tt>"#CC33CC"</tt>
     <tt>"yellow"</tt> <tt>"#FFCC00"</tt>
     <tt>"cyan"</tt> <tt>"#66FFFF"</tt>
     <tt>"purple"</tt> <tt>"#993399"</tt>
     <tt>"orange"</tt> <tt>"#FF6600"</tt>
     <tt>"brightorange"</tt> <tt>"#FF9900"</tt>
     <tt>"brightgreen"</tt> <tt>"#33FF33"</tt>
     <tt>"darkgreen"</tt> <tt>"#009900"</tt>
     <tt>"black"</tt> <tt>"#000000"</tt>
     <tt>"teal"</tt> <tt>"#008080"</tt>
     <tt>"gray"</tt> <tt>"#808080"</tt>
     <tt>"darkblue"</tt> <tt>"#000080"</tt>
     <tt>"white"</tt> <tt>"#FFFFFF"</tt>
     <b>default</b> <tt>"#000000"</tt>
     <b>end</b>
     
     <b>translations</b>
     <tt>"&amp;"</tt> <tt>"&amp;amp;"</tt>
     <tt>"&lt;"</tt> <tt>"&amp;lt;"</tt>
     <tt>"&gt;"</tt> <tt>"&amp;gt;"</tt>
     <b>end</b>
     
</pre>
   <p>Moreover, this file is also used for generating javadoc output:

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <b>include</b> <tt>"html_common.outlang"</tt>
     
     <b>doctemplate</b>
     <tt>" * &lt;!-- Generated by Source-highlight --&gt;</tt>
     <tt> * &lt;pre&gt;&lt;tt&gt;</tt>
     <tt>"</tt>
     <tt>" * &lt;/tt&gt;&lt;/pre&gt;</tt>
     <tt>"</tt>
     <b>end</b>
     
     <b>nodoctemplate</b>
     <tt>" * &lt;!-- Generated by Source-highlight --&gt;</tt>
     <tt> * &lt;pre&gt;&lt;tt&gt;</tt>
     <tt>"</tt>
     <tt>" * &lt;/tt&gt;&lt;/pre&gt;</tt>
     <tt>"</tt>
     <b>end</b>
     
     <b>lineprefix</b> <tt>" * "</tt>
     
     <b>translations</b>
     <tt>"*/"</tt> <tt>"&amp;#42;/"</tt> <i># this avoids the */ to be interpreted as</i>
     <i># the end of a comment inside a javadoc comment</i>
     <b>end</b>
     
</pre>
   <p>The javadoc output format is useful to format code snippets that have to
be included inside a javadoc comment of another Java
file<a rel="footnote" href="#fn-50" name="fnd-50"><sup>50</sup></a>.  Apart from being formatted nicely in the
generated HTML documentation, this also releases the programmer from
escaping specific characters in the code snippet (i.e., <code>&amp;</code>,
<code>&lt;</code> and <code>&gt;</code>).  Note also that it also avoids the sequence
<code>*/</code> to be interpreted as the closing of the (javadoc) comment. 
For instance, if you write this code:

<pre class="example">     /**
      * This is an example of usage
      *
      * &lt;pre&gt;&lt;tt&gt;
      * System.out.println("*/");
      * &lt;/tt&gt;&lt;/pre&gt;
      */
</pre>
   <p class="noindent">The resulting Java code contains a syntax error.  If you use
source-highlight to format the code to insert in a javadoc comment you
will avoid these problems.

   <p>An example of a javadoc generated HTML page containing a code snippet
formatted with source-highlight can be found in the file
<samp><span class="file">SimpleClass-doc.html</span></samp> in the documentation directory.

<div class="node">
<a name="Generating-References"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Examples">Examples</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Output-Language-Definitions">Output Language Definitions</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">9 Generating References</h2>

<p><a name="index-reference-175"></a><a name="index-anchor-176"></a><a name="index-ctags-177"></a>
Since version 2.2 Source-highlight also produces references to fields,
variables, etc.  In order to do this it relies on the program
<em>Exuberant Ctags</em>, by Darren Hiebert, available at
<a href="http://ctags.sourceforge.net">http://ctags.sourceforge.net</a>.  Thus, you must install this program
if you want Source-highlight to provide this feature.

   <p>The <code>ctags</code> program generates an index (or &ldquo;tag&rdquo;) file for a
variety of language objects found in file(s).  This allows these items
to be quickly and easily located by a text editor or other utility (as
in this case for Source-highlight).  A &ldquo;tag&rdquo; signifies a language
object for which an index entry is available (or, alternatively, the
index entry created for that object)<a rel="footnote" href="#fn-51" name="fnd-51"><sup>51</sup></a>.

   <p>This means that Source-highlight is able to generate references for a
specific source language if and only if <code>ctags</code> handles such
language.  We refer to the command line options of <code>ctags</code>:
<code>--list-maps</code> and <code>--list-languages</code> to find out the
associations of file extensions and supported languages.

   <p>Reference generation is enable by using the command line option
<code>--gen-references</code> (<a href="#Invoking-source_002dhighlight">Invoking source-highlight</a>).  This option
takes an argument that rules how references will be generated:

     <dl>
<dt><code>inline</code><dd>a reference pointer will be generated exactly in the same place of the
specific element.  This is useful in output formats that naturally
supports links, such as HTML, while it is useless for output formats
that do not support inline links, such as LaTeX. 
<br><dt><code>postline</code><dd>if a line of the input source contains elements for which we found
references, the list of references will be generated right after the
line (see the examples, <a href="#Examples">Examples</a>). 
<br><dt><code>postdoc</code><dd>All the references will be generated after the whole input file has been
generated. 
</dl>

   <p>There is an exception: when an element has more than one reference
(because a variable is defined in many sources or because a method is
overloaded) then if <code>inline</code> is specified, the generation switches
to <code>postline</code> for that occurrence.

   <p>When <code>--gen-references</code> is specified, Source-highlight first
invokes <code>ctags</code>.  The use can customize this call by using the
command line option <code>--ctags</code> (<a href="#Invoking-source_002dhighlight">Invoking source-highlight</a>). 
In particular, if one does not want <code>ctags</code> to be invoked by
Source-highlight (e.g., because the tags file has already been
generated) then <code>--ctags</code> must be passed an empty string,
<code>""</code>.  In this case or when the specified <code>ctags</code> command line
generates an alternative output tag file (the default generated file is
<samp><span class="file">tags</span></samp>), one must specify the exact tag file with the command line
option <code>--ctags-file</code>.

   <p>Once the tag file is generated, Source-highlight relies on the library
<samp><span class="file">readtags</span></samp> provided by the <code>ctags</code> distribution, and included
in the Source-highlight sources.

   <p>Note that if a program element is formatted according to a style that
has the option <code>noref</code> (see <a href="#Output-format-style">Output format style</a>) then this
element is not considered a tag, and no reference is generated.  This is
the case, for instance, for a <code>comment</code> element: each string that
is generated with the <code>comment</code> style, since this is declared with
the option <code>noref</code>, it is not considered a tag (see <a href="#Examples">Examples</a>).

<div class="node">
<a name="Examples"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Problems">Problems</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Generating-References">Generating References</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">10 Examples</h2>

<p>Here we provide some examples of sources formatted with
Source-highlight using the <code>-f texinfo</code>
command line option.  Please keep in mind that the highlighting
will not be visible in the Info file, but only in the
printed manual and in the HTML output (well, at least line
numbers are visible everywhere :-).

<ul class="menu">
<li><a accesskey="1" href="#Simple-example">Simple example</a>
<li><a accesskey="2" href="#References">References</a>
<li><a accesskey="3" href="#Line-ranges">Line ranges</a>
<li><a accesskey="4" href="#Line-ranges-_0028with-context_0029">Line ranges (with context)</a>
<li><a accesskey="5" href="#Regex-ranges">Regex ranges</a>
</ul>

<div class="node">
<a name="Simple-example"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#References">References</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Examples">Examples</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Examples">Examples</a>

</div>

<h3 class="section">10.1 Simple example</h3>

<p>The first example is produced by using the command:

<pre class="example">     source-highlight -f texinfo -i test.java -o test.java.texinfo -n
</pre>
   <p>and here's the result

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <tt>01:</tt> <i>/*</i>
     <tt>02:</tt> <i>  This is a classical Hello program</i>
     <tt>03:</tt> <i>  to test source-highlight with Java programs.</i>
     <tt>04:</tt>   
     <tt>05:</tt> <i>  to have an html translation type</i>
     <tt>06:</tt>
     <tt>07:</tt> <i>        source-highlight -s java -f html --input Hello.java --output Hello.html</i>
     <tt>08:</tt> <i>        source-highlight -s java -f html &lt; Hello.java &gt; Hello.html</i>
     <tt>09:</tt>
     <tt>10:</tt> <i>  or type source-highlight --help for the list of options</i>
     <tt>11:</tt>
     <tt>12:</tt> <i>  written by</i>
     <tt>13:</tt> <i>  Lorenzo Bettini</i>
     <tt>14:</tt>   <tt>http://www.lorenzobettini.it</tt>
     <tt>15:</tt>   <tt>http://www.gnu.org/software/src-highlite</tt>
     <tt>16:</tt> <i>*/</i>
     <tt>17:</tt>
     <tt>18:</tt> <b>package</b> hello;
     <tt>19:</tt>
     <tt>20:</tt> <b>import</b> java.io.* ;
     <tt>21:</tt>
     <tt>22:</tt> <i>/**</i>
     <tt>23:</tt> <i> * </i><b>&lt;p&gt;</b>
     <tt>24:</tt> <i> * A simple Hello World class, used to demonstrate some</i>
     <tt>25:</tt> <i> * features of Java source highlighting.</i>
     <tt>26:</tt> <i> * </i><b>&lt;/p&gt;</b>
     <tt>27:</tt> <i> * </i>TODO:<i> nothing, just to show an highlighted </i>TODO<i> or </i>FIXME
     <tt>28:</tt> <i> *</i>
     <tt>29:</tt> <i> * </i><b>@author</b><i> Lorenzo Bettini</i>
     <tt>30:</tt> <i> * </i><b>@version</b><i> 2.0</i>
     <tt>31:</tt> <i> */</i> <i>/// class</i>
     <tt>32:</tt> <b>public</b> <b>class</b> Hello {
     <tt>33:</tt>     <b>int</b> foo = 1998 ;
     <tt>34:</tt>     <b>int</b> hex_foo = 0xCAFEBABE;
     <tt>35:</tt>     <b>boolean</b> b = <b>false</b>;
     <tt>36:</tt>     Integer i = <b>null</b> ;
     <tt>37:</tt>     <b>char</b> c = <tt>'</tt>\'<tt>'</tt>, d = <tt>'n'</tt>, e = <tt>'</tt>\\<tt>'</tt> ;
     <tt>38:</tt>     String xml = <tt>"&lt;tag attr=</tt>\"<tt>value</tt>\"<tt>&gt;&amp;auml;&lt;/tag&gt;"</tt>, foo2 = <tt>"</tt>\\<tt>"</tt> ;
     <tt>39:</tt>
     <tt>40:</tt>     <i>/* mymethod */</i>
     <tt>41:</tt>     <b>public</b> <b>void</b> mymethod(<b>int</b> i) {
     <tt>42:</tt>         <i>// just a foo method</i>
     <tt>43:</tt>     }
     <tt>44:</tt>     <i>/* mymethod */</i>
     <tt>45:</tt>
     <tt>46:</tt>     <i>/* main */</i>
     <tt>47:</tt>     <b>public</b> <b>static</b> <b>void</b> main( String args[] ) {
     <tt>48:</tt>         <i>// just some greetings ;-)  /*</i>
     <tt>49:</tt>         System.out.println( <tt>"Hello from java2html :-)"</tt> ) ;
     <tt>50:</tt>         System.out.println( <tt>"</tt>\t<tt>by Lorenzo Bettini"</tt> ) ;
     <tt>51:</tt>         System.out.println( <tt>"</tt>\t<tt>http://www.lorenzobettini.it"</tt> ) ;
     <tt>52:</tt>         <b>if</b> (argc &gt; 0)
     <tt>53:</tt>             String param = argc[0];
     <tt>54:</tt>         <i>//System.out.println( "bye bye... :-D" ) ; // see you soon</i>
     <tt>55:</tt>     }
     <tt>56:</tt>     <i>/* main */</i>
     <tt>57:</tt> }
     <tt>58:</tt> <i>/// class</i>
     <tt>59:</tt>
     <tt>60:</tt> <i>// end of file test.java</i>
</pre>
   <div class="node">
<a name="References"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Line-ranges">Line ranges</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Simple-example">Simple example</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Examples">Examples</a>

</div>

<h3 class="section">10.2 References</h3>

<p>This example shows the use of <code>--gen-references</code>
functionality.  In particular, the following output is generated with
the command:

<pre class="example">     source-highlight -f texinfo -i test.h -o test_ref.h.texinfo -n \
          --gen-references=postline
</pre>
   <p>and here's the result (note how the comment line containing the string
<code>mysum</code> does not contain references, since it is a <code>comment</code>
element, and this element has the option <code>noref</code> in the
<samp><span class="file">texinfo.style</span></samp>, see <a href="#Output-format-style">Output format style</a>.  The same holds for
the <code>_TEXTGEN_H</code> comment in the last comment line).

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <tt>01:</tt> <i>/**</i>
     <tt>02:</tt> <i>** Copyright (C) 1999-2007 Lorenzo Bettini</i>
     <tt>03:</tt> <i>**  </i>
     <tt>04:</tt>   <tt>http://www.lorenzobettini.it</tt>
     <tt>05:</tt>   
     <tt>06:</tt> <i>  r2 = r2 XOR (1&lt;&lt;10);</i>
     <tt>07:</tt> <i>  cout &lt;&lt; "hello world" &lt;&lt; endl;</i>
     <tt>08:</tt> <i>**  </i>
     <tt>09:</tt> <i>*/</i>
     <tt>10:</tt>
     <tt>11:</tt> <i>// this file also contains the definition of mysum as a #define</i>
     <tt>12:</tt>
     <tt>13:</tt> <i>// textgenerator.h : Text Generator class &amp;&amp;</i>
     <tt>14:</tt>
     <tt>15:</tt> <b>#ifndef</b> _TEXTGEN_H
     <div align="right"><i>See <a href="#test_002eh_003a16">_TEXTGEN_H</a>.</i>
     </div>
     <tt>16:</tt> <b>#define</b> <a name="test_002eh_003a16"></a>_TEXTGEN_H
     <tt>17:</tt>
     <tt>18:</tt> <b>#define</b> <a name="test_002eh_003a18"></a>foo(x) (x + 1)
     <tt>19:</tt>
     <tt>20:</tt> <b>#define</b> <a name="test_002eh_003a20"></a>mysum myfunbody
     <tt>21:</tt>
     <tt>22:</tt> <b>#include</b> <tt>&lt;iostream.h&gt;</tt> <i>// for cerr</i>
     <tt>23:</tt>
     <tt>24:</tt> <b>#include</b> <tt>"genfun.h"</tt> <i>/* for generating functions */</i>
     <tt>25:</tt>
     <tt>26:</tt> <b>class</b> <a name="test_002eh_003a26"></a>TextGenerator {
     <tt>27:</tt>   <b>public</b> :
     <tt>28:</tt>     <b>virtual</b> <b>void</b> <a name="test_002eh_003a28"></a>generate( <b>const</b> <b>char</b> *s ) <b>const</b> { (*sout) &lt;&lt; s ; }
     <tt>29:</tt>     <b>virtual</b> <b>void</b> <a name="test_002eh_003a29"></a>generate( <b>const</b> <b>char</b> *s, <b>int</b> start, <b>int</b> end ) <b>const</b>
     <tt>30:</tt>       {
     <tt>31:</tt>         <b>for</b> ( <b>int</b> i = start ; i &lt;= end ; ++i )
     <tt>32:</tt>           (*sout) &lt;&lt; s[i] ;
     <tt>33:</tt>         <b>return</b> a&lt;p-&gt;b ? a : 3;
     <tt>34:</tt>       }
     <tt>35:</tt>     <b>virtual</b> <b>void</b> <a name="test_002eh_003a35"></a>generateln( <b>const</b> <b>char</b> *s ) <b>const</b>
     <tt>36:</tt>         {
     <tt>37:</tt>             generate( s ) ;
     <div align="right"><i>See <a href="#test_002eh_003a28">generate</a>.</i>
     </div>

     <div align="right"><i>See <a href="#test_002eh_003a29">generate</a>.</i>
     </div>
     <tt>38:</tt>             (*sout) &lt;&lt; endl ;
     <tt>39:</tt>         }
     <tt>40:</tt>     <b>virtual</b> <b>void</b> <a name="test_002eh_003a40"></a>generateEntire( <b>const</b> <b>char</b> *s ) <b>const</b>
     <tt>41:</tt>         {
     <tt>42:</tt>             startTextGeneration() ;
     <div align="right"><i>See <a href="#test_002eh_003a46">startTextGeneration</a>.</i>
     </div>

     <div align="right"><i>See <a href="#test_002eh_003a70">startTextGeneration</a>.</i>
     </div>
     <tt>43:</tt>             generate(s) ;
     <div align="right"><i>See <a href="#test_002eh_003a28">generate</a>.</i>
     </div>

     <div align="right"><i>See <a href="#test_002eh_003a29">generate</a>.</i>
     </div>
     <tt>44:</tt>             endTextGeneration() ;
     <div align="right"><i>See <a href="#test_002eh_003a47">endTextGeneration</a>.</i>
     </div>

     <div align="right"><i>See <a href="#test_002eh_003a76">endTextGeneration</a>.</i>
     </div>
     <tt>45:</tt>         }
     <tt>46:</tt>     <b>virtual</b> <b>void</b> <a name="test_002eh_003a46"></a>startTextGeneration() <b>const</b> {}
     <tt>47:</tt>     <b>virtual</b> <b>void</b> <a name="test_002eh_003a47"></a>endTextGeneration() <b>const</b> {}
     <tt>48:</tt>     <b>virtual</b> <b>void</b> <a name="test_002eh_003a48"></a>beginText( <b>const</b> <b>char</b> *s ) <b>const</b>
     <tt>49:</tt>         {
     <tt>50:</tt>             startTextGeneration() ;
     <div align="right"><i>See <a href="#test_002eh_003a46">startTextGeneration</a>.</i>
     </div>

     <div align="right"><i>See <a href="#test_002eh_003a70">startTextGeneration</a>.</i>
     </div>
     <tt>51:</tt>             <b>if</b> ( s )
     <tt>52:</tt>                 generate( s ) ;
     <div align="right"><i>See <a href="#test_002eh_003a28">generate</a>.</i>
     </div>

     <div align="right"><i>See <a href="#test_002eh_003a29">generate</a>.</i>
     </div>
     <tt>53:</tt>         }
     <tt>54:</tt>     <b>virtual</b> <b>void</b> <a name="test_002eh_003a54"></a>endText( <b>const</b> <b>char</b> *s ) <b>const</b>
     <tt>55:</tt>         {
     <tt>56:</tt>             <b>if</b> ( s )
     <tt>57:</tt>                 generate( s ) ;
     <div align="right"><i>See <a href="#test_002eh_003a28">generate</a>.</i>
     </div>

     <div align="right"><i>See <a href="#test_002eh_003a29">generate</a>.</i>
     </div>
     <tt>58:</tt>             endTextGeneration() ;
     <div align="right"><i>See <a href="#test_002eh_003a47">endTextGeneration</a>.</i>
     </div>

     <div align="right"><i>See <a href="#test_002eh_003a76">endTextGeneration</a>.</i>
     </div>
     <tt>59:</tt>         }
     <tt>60:</tt> } ;
     <tt>61:</tt>
     <tt>62:</tt> <i>// Decorator</i>
     <tt>63:</tt> <b>class</b> <a name="test_002eh_003a63"></a>TextDecorator : <b>public</b> TextGenerator {
     <div align="right"><i>See <a href="#test_002eh_003a26">TextGenerator</a>.</i>
     </div>
     <tt>64:</tt>   <b>protected</b> :
     <tt>65:</tt>     TextGenerator *<a name="test_002eh_003a65"></a>decorated ;
     <div align="right"><i>See <a href="#test_002eh_003a26">TextGenerator</a>.</i>
     </div>
     <tt>66:</tt>
     <tt>67:</tt>   <b>public</b> :
     <tt>68:</tt>     <a name="test_002eh_003a68"></a>TextDecorator( TextGenerator *t ) : decorated( t ) {}
     <div align="right"><i>See <a href="#test_002eh_003a26">TextGenerator</a>.</i>
     </div>

     <div align="right"><i>See <a href="#test_002eh_003a65">decorated</a>.</i>
     </div>
     <tt>69:</tt>
     <tt>70:</tt>     <b>virtual</b> <b>void</b> <a name="test_002eh_003a70"></a>startTextGeneration() <b>const</b>
     <tt>71:</tt>     {
     <tt>72:</tt>         startDecorate() ;
     <tt>73:</tt>         <b>if</b> ( decorated )
     <div align="right"><i>See <a href="#test_002eh_003a65">decorated</a>.</i>
     </div>
     <tt>74:</tt>             decorated-&gt;startTextGeneration() ;
     <div align="right"><i>See <a href="#test_002eh_003a46">startTextGeneration</a>.</i>
     </div>

     <div align="right"><i>See <a href="#test_002eh_003a65">decorated</a>.</i>
     </div>

     <div align="right"><i>See <a href="#test_002eh_003a70">startTextGeneration</a>.</i>
     </div>
     <tt>75:</tt>     }
     <tt>76:</tt>     <b>virtual</b> <b>void</b> <a name="test_002eh_003a76"></a>endTextGeneration() <b>const</b>
     <tt>77:</tt>     {
     <tt>78:</tt>         <b>if</b> ( decorated )
     <div align="right"><i>See <a href="#test_002eh_003a65">decorated</a>.</i>
     </div>
     <tt>79:</tt>             decorated-&gt;endTextGeneration() ;
     <div align="right"><i>See <a href="#test_002eh_003a47">endTextGeneration</a>.</i>
     </div>

     <div align="right"><i>See <a href="#test_002eh_003a65">decorated</a>.</i>
     </div>

     <div align="right"><i>See <a href="#test_002eh_003a76">endTextGeneration</a>.</i>
     </div>
     <tt>80:</tt>         endDecorate() ;
     <tt>81:</tt>         mysum;
     <div align="right"><i>See <a href="#test_002eh_003a20">mysum</a>.</i>
     </div>
     <tt>82:</tt>     }
     <tt>83:</tt>
     <tt>84:</tt>     <i>// pure virtual functions</i>
     <tt>85:</tt>     <b>virtual</b> <b>void</b> startDecorate() <b>const</b> = 0 ;
     <tt>86:</tt>     <b>virtual</b> <b>void</b> endDecorate() <b>const</b> = 0 ;
     <tt>87:</tt> } ;
     <tt>88:</tt>
     <tt>89:</tt> <b>#endif</b> <i>// _TEXTGEN_H</i>
     <tt>90:</tt>
</pre>
   <div class="node">
<a name="Line-ranges"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Line-ranges-_0028with-context_0029">Line ranges (with context)</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#References">References</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Examples">Examples</a>

</div>

<h3 class="section">10.3 Line ranges</h3>

<p><a name="index-line-ranges-178"></a>This is an example that uses <code>--line-range</code> command line
option on the input file shown in See <a href="#Simple-example">Simple example</a>:

<pre class="example">     source-highlight -f texinfo -i test.java -n \
          --line-range="12-18","29-34"
</pre>
   <p>This generates the following output

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <tt>12:</tt> <i>  written by</i>
     <tt>13:</tt> <i>  Lorenzo Bettini</i>
     <tt>14:</tt>   <tt>http://www.lorenzobettini.it</tt>
     <tt>15:</tt>   <tt>http://www.gnu.org/software/src-highlite</tt>
     <tt>16:</tt> <i>*/</i>
     <tt>17:</tt>
     <tt>18:</tt> <b>package</b> hello;
     <tt>29:</tt> <i> * </i><b>@author</b><i> Lorenzo Bettini</i>
     <tt>30:</tt> <i> * </i><b>@version</b><i> 2.0</i>
     <tt>31:</tt> <i> */</i> <i>/// class</i>
     <tt>32:</tt> <b>public</b> <b>class</b> Hello {
     <tt>33:</tt>     <b>int</b> foo = 1998 ;
     <tt>34:</tt>     <b>int</b> hex_foo = 0xCAFEBABE;
     
</pre>
   <p>Note that, although the specified line ranges span comment environments,
the highlighting is respected: the starting of the comment is not
printed, but the remaining parts of the comment are correctly
highlighted as comment.

<div class="node">
<a name="Line-ranges-(with-context)"></a>
<a name="Line-ranges-_0028with-context_0029"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Regex-ranges">Regex ranges</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Line-ranges">Line ranges</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Examples">Examples</a>

</div>

<h3 class="section">10.4 Line ranges (with context)</h3>

<p><a name="index-line-ranges-179"></a><a name="index-range-context-180"></a><a name="index-range-separator-181"></a>This is an example that uses the command line option <code>--line-range</code>
together with the <code>--range-context</code> and <code>--range-separator</code>:

<pre class="example">     source-highlight -f texinfo -i test.java -n \
          --line-range="12-18","29-34" \
          --range-context=2 \
          --range-separator="{... not in range ...}"
</pre>
   <p>This generates the following output

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     {... not in range ...}
     <tt>10:</tt>   or type source-highlight --help for the list of options
     <tt>11:</tt>
     <tt>12:</tt> <i>  written by</i>
     <tt>13:</tt> <i>  Lorenzo Bettini</i>
     <tt>14:</tt>   <tt>http://www.lorenzobettini.it</tt>
     <tt>15:</tt>   <tt>http://www.gnu.org/software/src-highlite</tt>
     <tt>16:</tt> <i>*/</i>
     <tt>17:</tt>
     <tt>18:</tt> <b>package</b> hello;
     <tt>19:</tt>
     <tt>20:</tt> import java.io.* ;
     {... not in range ...}
     <tt>27:</tt>  * TODO: nothing, just to show an highlighted TODO or FIXME
     <tt>28:</tt>  *
     <tt>29:</tt> <i> * </i><b>@author</b><i> Lorenzo Bettini</i>
     <tt>30:</tt> <i> * </i><b>@version</b><i> 2.0</i>
     <tt>31:</tt> <i> */</i> <i>/// class</i>
     <tt>32:</tt> <b>public</b> <b>class</b> Hello {
     <tt>33:</tt>     <b>int</b> foo = 1998 ;
     <tt>34:</tt>     <b>int</b> hex_foo = 0xCAFEBABE;
     <tt>35:</tt>     boolean b = false;
     <tt>36:</tt>     Integer i = null ;
     {... not in range ...}
     
</pre>
   <p>Note the two additional 2 lines before and after the ranges (compare it
with the output in <a href="#Line-ranges">Line ranges</a>).  Note that the (elements of the)
context lines are not highlighted.  Moreover, the range separator line
<code>"{... not in range ...}"</code> is printed between ranges (the
separator string is preformatted automatically, so, e.g., you don't have
to escape special output characters, such as the { } in texinfo
output).

<div class="node">
<a name="Regex-ranges"></a>
<p><hr>
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Line-ranges-_0028with-context_0029">Line ranges (with context)</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Examples">Examples</a>

</div>

<h3 class="section">10.5 Regex ranges</h3>

<p><a name="index-regex-ranges-182"></a>Ranges can be expressed also using regular expressions, with the command
line option <code>--regex-range</code>.  In this case the beginning of the
range will be detected by a line containing (in any point) a string
matching the specified regular expression; the end will be detected by a
line containing a string matching the same regular expression that
started the range.  This feature is very useful when we want to document
some code (e.g., in this very manual) by showing only specific parts,
that are delimited in a ad-hoc way in the source code (e.g., with
specific comment patterns).

   <p>For instance, the following output was produced, starting from the
source file shown in See <a href="#Simple-example">Simple example</a>, by specifying:

<pre class="example">     --regex-range="/// [[:alpha:]]+"
</pre>
   <p class="noindent">Note that the lines containing <code>/// class</code>, which determine the
range, are not shown in the output:

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <tt>32:</tt> <b>public</b> <b>class</b> Hello {
     <tt>33:</tt>     <b>int</b> foo = 1998 ;
     <tt>34:</tt>     <b>int</b> hex_foo = 0xCAFEBABE;
     <tt>35:</tt>     <b>boolean</b> b = <b>false</b>;
     <tt>36:</tt>     Integer i = <b>null</b> ;
     <tt>37:</tt>     <b>char</b> c = <tt>'</tt>\'<tt>'</tt>, d = <tt>'n'</tt>, e = <tt>'</tt>\\<tt>'</tt> ;
     <tt>38:</tt>     String xml = <tt>"&lt;tag attr=</tt>\"<tt>value</tt>\"<tt>&gt;&amp;auml;&lt;/tag&gt;"</tt>, foo2 = <tt>"</tt>\\<tt>"</tt> ;
     <tt>39:</tt>
     <tt>40:</tt>     <i>/* mymethod */</i>
     <tt>41:</tt>     <b>public</b> <b>void</b> mymethod(<b>int</b> i) {
     <tt>42:</tt>         <i>// just a foo method</i>
     <tt>43:</tt>     }
     <tt>44:</tt>     <i>/* mymethod */</i>
     <tt>45:</tt>
     <tt>46:</tt>     <i>/* main */</i>
     <tt>47:</tt>     <b>public</b> <b>static</b> <b>void</b> main( String args[] ) {
     <tt>48:</tt>         <i>// just some greetings ;-)  /*</i>
     <tt>49:</tt>         System.out.println( <tt>"Hello from java2html :-)"</tt> ) ;
     <tt>50:</tt>         System.out.println( <tt>"</tt>\t<tt>by Lorenzo Bettini"</tt> ) ;
     <tt>51:</tt>         System.out.println( <tt>"</tt>\t<tt>http://www.lorenzobettini.it"</tt> ) ;
     <tt>52:</tt>         <b>if</b> (argc &gt; 0)
     <tt>53:</tt>             String param = argc[0];
     <tt>54:</tt>         <i>//System.out.println( "bye bye... :-D" ) ; // see you soon</i>
     <tt>55:</tt>     }
     <tt>56:</tt>     <i>/* main */</i>
     <tt>57:</tt> }
     
</pre>
   <p>Furthermore, the line numbers are consistent with the lines of the
original file.

   <p>If we want to output only what is included between <code>/* main */</code>, we
specify (note that we must escape the special regular expression
character <code>*</code>):

<pre class="example">     --regex-range="/\* main \*/"
</pre>
   <p class="noindent">and we get:

<!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <tt>47:</tt>     <b>public</b> <b>static</b> <b>void</b> main( String args[] ) {
     <tt>48:</tt>         <i>// just some greetings ;-)  /*</i>
     <tt>49:</tt>         System.out.println( <tt>"Hello from java2html :-)"</tt> ) ;
     <tt>50:</tt>         System.out.println( <tt>"</tt>\t<tt>by Lorenzo Bettini"</tt> ) ;
     <tt>51:</tt>         System.out.println( <tt>"</tt>\t<tt>http://www.lorenzobettini.it"</tt> ) ;
     <tt>52:</tt>         <b>if</b> (argc &gt; 0)
     <tt>53:</tt>             String param = argc[0];
     <tt>54:</tt>         <i>//System.out.println( "bye bye... :-D" ) ; // see you soon</i>
     <tt>55:</tt>     }
     
</pre>
   <p>If we want to show only the methods, which in the source file
are delimited by comment lines containing the method's name, we can specify:

<pre class="example">     --regex-range="/\* [[:alpha:]]+ \*/"
</pre>
   <!-- Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite -->
<pre class="example">     <tt>41:</tt>     <b>public</b> <b>void</b> mymethod(<b>int</b> i) {
     <tt>42:</tt>         <i>// just a foo method</i>
     <tt>43:</tt>     }
     <tt>47:</tt>     <b>public</b> <b>static</b> <b>void</b> main( String args[] ) {
     <tt>48:</tt>         <i>// just some greetings ;-)  /*</i>
     <tt>49:</tt>         System.out.println( <tt>"Hello from java2html :-)"</tt> ) ;
     <tt>50:</tt>         System.out.println( <tt>"</tt>\t<tt>by Lorenzo Bettini"</tt> ) ;
     <tt>51:</tt>         System.out.println( <tt>"</tt>\t<tt>http://www.lorenzobettini.it"</tt> ) ;
     <tt>52:</tt>         <b>if</b> (argc &gt; 0)
     <tt>53:</tt>             String param = argc[0];
     <tt>54:</tt>         <i>//System.out.println( "bye bye... :-D" ) ; // see you soon</i>
     <tt>55:</tt>     }
     
</pre>
   <p>In this case, we might have also specified:

<pre class="example">     --regex-range="/\* main \*/","/\* mymethod \*/"
</pre>
   <p class="noindent">since <code>--regex-range</code> accepts multiple regular expressions.

   <p>IMPORTANT: the order of regular expression specification is crucial,
since they are tested in the same order they are specified at the
command line.

<div class="node">
<a name="Problems"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Mailing-Lists">Mailing Lists</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Examples">Examples</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">11 Reporting Bugs</h2>

<p><a name="index-bugs-183"></a><a name="index-problems-184"></a>
If you find a bug in <samp><span class="command">source-highlight</span></samp>, please send electronic
mail to

   <p><code>bug-source-highlight at gnu dot org</code>

   <p>Include the version
number, which you can find by running &lsquo;<samp><span class="samp">source-highlight&nbsp;--version</span></samp>&rsquo;<!-- /@w -->.  Also include in your message the output that the program
produced and the output you expected.

   <p>Even better, please file a bug report at Savannah site:

   <p><a href="https://savannah.gnu.org/bugs/?group=src-highlite">https://savannah.gnu.org/bugs/?group=src-highlite</a>

   <p>If you have other questions, comments or suggestions about
<samp><span class="command">source-highlight</span></samp>, contact the author via electronic mail
(find the address at <a href="http://www.lorenzobettini.it">http://www.lorenzobettini.it</a>).  The author will try to help
you out, although he may not have time to fix your problems.

<div class="node">
<a name="Mailing-Lists"></a>
<p><hr>
Next:&nbsp;<a rel="next" accesskey="n" href="#Concept-Index">Concept Index</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Problems">Problems</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">12 Mailing Lists</h2>

<p><a name="index-mailing-list-185"></a>
The following mailing lists are available:

   <p><code>help-source-highlight at gnu dot org</code>

   <p>for generic discussions about the program and for asking for help about
it (open mailing list),
<a href="http://mail.gnu.org/mailman/listinfo/help-source-highlight">http://mail.gnu.org/mailman/listinfo/help-source-highlight</a>

   <p><code>info-source-highlight at gnu dot org</code>

   <p>for receiving information about new releases and features (read-only
mailing list),
<a href="http://mail.gnu.org/mailman/listinfo/info-source-highlight">http://mail.gnu.org/mailman/listinfo/info-source-highlight</a>.

   <p>If you want to subscribe to a mailing list just go to the URL and follow
the instructions, or send me an e-mail and I'll subscribe you.

   <p>I'll describe new features in new releases also in my blog, at
this URL:

   <p><a href="http://tronprog.blogspot.com/search/label/source-highlight">http://tronprog.blogspot.com/search/label/source-highlight</a>

<div class="node">
<a name="Concept-Index"></a>
<p><hr>
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Mailing-Lists">Mailing Lists</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="unnumbered">Concept Index</h2>

<p><a name="index-tail-recursion-186"></a>

<ul class="index-cp" compact>
<li><a href="#index-g_t_0040code_007b_0022expression_0022_007d-122"><code>"expression"</code></a>: <a href="#Ways-of-specifying-regular-expressions">Ways of specifying regular expressions</a></li>
<li><a href="#index-g_t_0024infile-164">$infile</a>: <a href="#Anchors-and-References">Anchors and References</a></li>
<li><a href="#index-g_t_0024infilename-165">$infilename</a>: <a href="#Anchors-and-References">Anchors and References</a></li>
<li><a href="#index-g_t_0024linenum-163">$linenum</a>: <a href="#Anchors-and-References">Anchors and References</a></li>
<li><a href="#index-g_t_0024outfile-166">$outfile</a>: <a href="#Anchors-and-References">Anchors and References</a></li>
<li><a href="#index-g_t_0024style-161">$style</a>: <a href="#Colors">Colors</a></li>
<li><a href="#index-g_t_0024text-159">$text</a>: <a href="#Text-styles">Text styles</a></li>
<li><a href="#index-g_t_0040code_007b_0027expression_0027_007d-123"><code>'expression'</code></a>: <a href="#Ways-of-specifying-regular-expressions">Ways of specifying regular expressions</a></li>
<li><a href="#index-g_t_0040code_007b_002d_002ddata_002ddir_007d-111"><code>--data-dir</code></a>: <a href="#Invoking-source_002dhighlight">Invoking source-highlight</a></li>
<li><a href="#index-g_t_0040code_007b_002d_002ddata_002ddir_007d-82"><code>--data-dir</code></a>: <a href="#Configuration-files">Configuration files</a></li>
<li><a href="#index-g_t_0040code_007b_002d_002ddata_002ddir_007d-6"><code>--data-dir</code></a>: <a href="#The-program-source_002dhighlight_002dsettings">The program source-highlight-settings</a></li>
<li><a href="#index-g_t_0040code_007b_002d_002dinfer_002dlang_007d-120"><code>--infer-lang</code></a>: <a href="#How-the-input-language-is-discovered">How the input language is discovered</a></li>
<li><a href="#index-g_t_0040code_007b_002d_002dinfer_002dlang_007d-113"><code>--infer-lang</code></a>: <a href="#Invoking-source_002dhighlight">Invoking source-highlight</a></li>
<li><a href="#index-g_t_0040code_007b_002d_002dinfer_002dlang_007d-10"><code>--infer-lang</code></a>: <a href="#Perl">Perl</a></li>
<li><a href="#index-g_t_0040code_007b_002d_002dshow_002dlang_002delements_007d-151"><code>--show-lang-elements</code></a>: <a href="#Listing-Language-Elements">Listing Language Elements</a></li>
<li><a href="#index-g_t_0040code_007b_002d_002dshow_002dlang_002delements_007d-86"><code>--show-lang-elements</code></a>: <a href="#Output-format-style">Output format style</a></li>
<li><a href="#index-g_t_0040code_007b_002d_002dstyle_002dcss_002dfile_007d-101"><code>--style-css-file</code></a>: <a href="#Output-format-style-using-CSS">Output format style using CSS</a></li>
<li><a href="#index-g_t_0040code_007b_002d_002dstyle_002dfile_007d-89"><code>--style-file</code></a>: <a href="#Output-format-style">Output format style</a></li>
<li><a href="#index-g_t_0040code_007b_002d_002dwith_002ddoxygen_007d-43"><code>--with-doxygen</code></a>: <a href="#Installation">Installation</a></li>
<li><a href="#index-g_t_0040code_007b_0060expression_0060_007d-124"><code>`expression`</code></a>: <a href="#Ways-of-specifying-regular-expressions">Ways of specifying regular expressions</a></li>
<li><a href="#index-anchor-176">anchor</a>: <a href="#Generating-References">Generating References</a></li>
<li><a href="#index-ANSI-color-80">ANSI color</a>: <a href="#ANSI-color-escape-sequences">ANSI color escape sequences</a></li>
<li><a href="#index-Apache-25">Apache</a>: <a href="#Related-Software-and-Links">Related Software and Links</a></li>
<li><a href="#index-autoconf-62">autoconf</a>: <a href="#What-you-need-to-build-source_002dhighlight">What you need to build source-highlight</a></li>
<li><a href="#index-autoconf-55">autoconf</a>: <a href="#Anonymous-Git-Checkout">Anonymous Git Checkout</a></li>
<li><a href="#index-automake-61">automake</a>: <a href="#What-you-need-to-build-source_002dhighlight">What you need to build source-highlight</a></li>
<li><a href="#index-automake-54">automake</a>: <a href="#Anonymous-Git-Checkout">Anonymous Git Checkout</a></li>
<li><a href="#index-background-color-162">background color</a>: <a href="#Colors">Colors</a></li>
<li><a href="#index-background-color-88">background color</a>: <a href="#Output-format-style">Output format style</a></li>
<li><a href="#index-backreference-146">backreference</a>: <a href="#Notes-on-regular-expressions">Notes on regular expressions</a></li>
<li><a href="#index-backreference-126">backreference</a>: <a href="#Ways-of-specifying-regular-expressions">Ways of specifying regular expressions</a></li>
<li><a href="#index-backtick-127">backtick</a>: <a href="#Ways-of-specifying-regular-expressions">Ways of specifying regular expressions</a></li>
<li><a href="#index-bash-completion-41">bash completion</a>: <a href="#Installation">Installation</a></li>
<li><a href="#index-g_t_0040code_007bbgcolor_007d-87"><code>bgcolor</code></a>: <a href="#Output-format-style">Output format style</a></li>
<li><a href="#index-bold-154">bold</a>: <a href="#Text-styles">Text styles</a></li>
<li><a href="#index-bold-92">bold</a>: <a href="#Output-format-style">Output format style</a></li>
<li><a href="#index-boost-60">boost</a>: <a href="#What-you-need-to-build-source_002dhighlight">What you need to build source-highlight</a></li>
<li><a href="#index-boost-49">boost</a>: <a href="#Building-with-qmake">Building with qmake</a></li>
<li><a href="#index-Boost-regex-65">Boost regex</a>: <a href="#Tips-on-installing-Boost-Regex-library">Tips on installing Boost Regex library</a></li>
<li><a href="#index-bugs-183">bugs</a>: <a href="#Problems">Problems</a></li>
<li><a href="#index-building-requirements-59">building requirements</a>: <a href="#What-you-need-to-build-source_002dhighlight">What you need to build source-highlight</a></li>
<li><a href="#index-CGI-71">CGI</a>: <a href="#Using-source_002dhighlight-as-a-CGI">Using source-highlight as a CGI</a></li>
<li><a href="#index-g_t_0040command_007bcheck_002dregexp_007d-150"><samp><span class="command">check-regexp</span></samp></a>: <a href="#The-program-check_002dregexp">The program check-regexp</a></li>
<li><a href="#index-code2blog-24">code2blog</a>: <a href="#Related-Software-and-Links">Related Software and Links</a></li>
<li><a href="#index-color-90">color</a>: <a href="#Output-format-style">Output format style</a></li>
<li><a href="#index-colors-160">colors</a>: <a href="#Colors">Colors</a></li>
<li><a href="#index-compilation-38">compilation</a>: <a href="#Installation">Installation</a></li>
<li><a href="#index-compilation-requirements-58">compilation requirements</a>: <a href="#What-you-need-to-build-source_002dhighlight">What you need to build source-highlight</a></li>
<li><a href="#index-conditional-expressions-149">conditional expressions</a>: <a href="#Notes-on-regular-expressions">Notes on regular expressions</a></li>
<li><a href="#index-configuration-files-81">configuration files</a>: <a href="#Configuration-files">Configuration files</a></li>
<li><a href="#index-Copying-conditions-73">Copying conditions</a>: <a href="#Copying">Copying</a></li>
<li><a href="#index-cpp2html-46">cpp2html</a>: <a href="#Installation">Installation</a></li>
<li><a href="#index-CSS-100">CSS</a>: <a href="#Output-format-style-using-CSS">Output format style using CSS</a></li>
<li><a href="#index-ctags-177">ctags</a>: <a href="#Generating-References">Generating References</a></li>
<li><a href="#index-g_t_0040code_007bCXXFLAGS_007d-66"><code>CXXFLAGS</code></a>: <a href="#Tips-on-installing-Boost-Regex-library">Tips on installing Boost Regex library</a></li>
<li><a href="#index-debug-152">debug</a>: <a href="#Debugging">Debugging</a></li>
<li><a href="#index-default_002elang-119">default.lang</a>: <a href="#Invoking-source_002dhighlight">Invoking source-highlight</a></li>
<li><a href="#index-default_002elang-13">default.lang</a>: <a href="#Using-source_002dhighlight-as-a-simple-formatter">Using source-highlight as a simple formatter</a></li>
<li><a href="#index-default_002estyle-85">default.style</a>: <a href="#Output-format-style">Output format style</a></li>
<li><a href="#index-definition-order-131">definition order</a>: <a href="#Order-of-definitions">Order of definitions</a></li>
<li><a href="#index-delimited-definitions-132">delimited definitions</a>: <a href="#Delimited-definitions">Delimited definitions</a></li>
<li><a href="#index-direct-color-scheme-99">direct color scheme</a>: <a href="#Output-format-style">Output format style</a></li>
<li><a href="#index-directories-40">directories</a>: <a href="#Installation">Installation</a></li>
<li><a href="#index-DocBook-79">DocBook</a>: <a href="#DocBook-output">DocBook output</a></li>
<li><a href="#index-doctemplate-173">doctemplate</a>: <a href="#Document-template">Document template</a></li>
<li><a href="#index-download-52">download</a>: <a href="#Download">Download</a></li>
<li><a href="#index-doxygen-44">doxygen</a>: <a href="#Installation">Installation</a></li>
<li><a href="#index-dynamic-backreference-134">dynamic backreference</a>: <a href="#Dynamic-Backreferences">Dynamic Backreferences</a></li>
<li><a href="#index-environments-137">environments</a>: <a href="#State_002fEnvironment-Definitions">State/Environment Definitions</a></li>
<li><a href="#index-failsafe-118">failsafe</a>: <a href="#Invoking-source_002dhighlight">Invoking source-highlight</a></li>
<li><a href="#index-failsafe-12">failsafe</a>: <a href="#Using-source_002dhighlight-as-a-simple-formatter">Using source-highlight as a simple formatter</a></li>
<li><a href="#index-features-2">features</a>: <a href="#Introduction">Introduction</a></li>
<li><a href="#index-file-inclusion-135">file inclusion</a>: <a href="#File-inclusion">File inclusion</a></li>
<li><a href="#index-Firefox-27">Firefox</a>: <a href="#Related-Software-and-Links">Related Software and Links</a></li>
<li><a href="#index-fixed-157">fixed</a>: <a href="#Text-styles">Text styles</a></li>
<li><a href="#index-fixed-95">fixed</a>: <a href="#Output-format-style">Output format style</a></li>
<li><a href="#index-Fortran-8">Fortran</a>: <a href="#Fortran">Fortran</a></li>
<li><a href="#index-getting-help-110">getting help</a>: <a href="#Invoking-source_002dhighlight">Invoking source-highlight</a></li>
<li><a href="#index-Git-53">Git</a>: <a href="#Anonymous-Git-Checkout">Anonymous Git Checkout</a></li>
<li><a href="#index-gnulib-64">gnulib</a>: <a href="#What-you-need-to-build-source_002dhighlight">What you need to build source-highlight</a></li>
<li><a href="#index-help-109">help</a>: <a href="#Invoking-source_002dhighlight">Invoking source-highlight</a></li>
<li><a href="#index-HTML-75">HTML</a>: <a href="#HTML-and-XHTML-output">HTML and XHTML output</a></li>
<li><a href="#index-Ikiwiki-29">Ikiwiki</a>: <a href="#Related-Software-and-Links">Related Software and Links</a></li>
<li><a href="#index-inline_005freference-167">inline_reference</a>: <a href="#Anchors-and-References">Anchors and References</a></li>
<li><a href="#index-installation-37">installation</a>: <a href="#Installation">Installation</a></li>
<li><a href="#index-introduction-1">introduction</a>: <a href="#Introduction">Introduction</a></li>
<li><a href="#index-invoking-105">invoking</a>: <a href="#Invoking-source_002dhighlight">Invoking source-highlight</a></li>
<li><a href="#index-italics-155">italics</a>: <a href="#Text-styles">Text styles</a></li>
<li><a href="#index-italics-93">italics</a>: <a href="#Output-format-style">Output format style</a></li>
<li><a href="#index-java2html-45">java2html</a>: <a href="#Installation">Installation</a></li>
<li><a href="#index-java2html-22">java2html</a>: <a href="#Related-Software-and-Links">Related Software and Links</a></li>
<li><a href="#index-KDE-19">KDE</a>: <a href="#Related-Software-and-Links">Related Software and Links</a></li>
<li><a href="#index-Ksrc2highlight-20">Ksrc2highlight</a>: <a href="#Related-Software-and-Links">Related Software and Links</a></li>
<li><a href="#index-language-definition-121">language definition</a>: <a href="#Language-Definitions">Language Definitions</a></li>
<li><a href="#index-language-inference-112">language inference</a>: <a href="#Invoking-source_002dhighlight">Invoking source-highlight</a></li>
<li><a href="#index-language-map-103">language map</a>: <a href="#Language-map">Language map</a></li>
<li><a href="#index-g_t_0040LaTeX_007b_007d-77">LaTeX</a>: <a href="#LaTeX-output">LaTeX output</a></li>
<li><a href="#index-g_t_0040code_007bLDFLAGS_007d-67"><code>LDFLAGS</code></a>: <a href="#Tips-on-installing-Boost-Regex-library">Tips on installing Boost Regex library</a></li>
<li><a href="#index-library-42">library</a>: <a href="#Installation">Installation</a></li>
<li><a href="#index-library-3">library</a>: <a href="#Introduction">Introduction</a></li>
<li><a href="#index-libtool-63">libtool</a>: <a href="#What-you-need-to-build-source_002dhighlight">What you need to build source-highlight</a></li>
<li><a href="#index-libtool-56">libtool</a>: <a href="#Anonymous-Git-Checkout">Anonymous Git Checkout</a></li>
<li><a href="#index-line-ranges-179">line ranges</a>: <a href="#Line-ranges-_0028with-context_0029">Line ranges (with context)</a></li>
<li><a href="#index-line-ranges-178">line ranges</a>: <a href="#Line-ranges">Line ranges</a></li>
<li><a href="#index-line-ranges-114">line ranges</a>: <a href="#Invoking-source_002dhighlight">Invoking source-highlight</a></li>
<li><a href="#index-lines-130">lines</a>: <a href="#Line-wide-definitions">Line wide definitions</a></li>
<li><a href="#index-lookahead-asserts-147">lookahead asserts</a>: <a href="#Notes-on-regular-expressions">Notes on regular expressions</a></li>
<li><a href="#index-lookbehind-asserts-148">lookbehind asserts</a>: <a href="#Notes-on-regular-expressions">Notes on regular expressions</a></li>
<li><a href="#index-mailing-list-185">mailing list</a>: <a href="#Mailing-Lists">Mailing Lists</a></li>
<li><a href="#index-marked-subexpressions-145">marked subexpressions</a>: <a href="#Notes-on-regular-expressions">Notes on regular expressions</a></li>
<li><a href="#index-marked-subexpressions-125">marked subexpressions</a>: <a href="#Ways-of-specifying-regular-expressions">Ways of specifying regular expressions</a></li>
<li><a href="#index-matching-strategy-140">matching strategy</a>: <a href="#How-source_002dhighlight-works">How source-highlight works</a></li>
<li><a href="#index-MinGW-50">MinGW</a>: <a href="#Building-with-qmake">Building with qmake</a></li>
<li><a href="#index-MSVC-48">MSVC</a>: <a href="#Building-with-qmake">Building with qmake</a></li>
<li><a href="#index-msys-51">msys</a>: <a href="#Building-with-qmake">Building with qmake</a></li>
<li><a href="#index-nodoctemplate-174">nodoctemplate</a>: <a href="#Document-template">Document template</a></li>
<li><a href="#index-nohilite_002elang-11">nohilite.lang</a>: <a href="#Using-source_002dhighlight-as-a-simple-formatter">Using source-highlight as a simple formatter</a></li>
<li><a href="#index-non_002dmarking-parenthesis-144">non-marking parenthesis</a>: <a href="#Notes-on-regular-expressions">Notes on regular expressions</a></li>
<li><a href="#index-nonsensitive-129">nonsensitive</a>: <a href="#Simple-definitions">Simple definitions</a></li>
<li><a href="#index-noref-98">noref</a>: <a href="#Output-format-style">Output format style</a></li>
<li><a href="#index-notfixed-158">notfixed</a>: <a href="#Text-styles">Text styles</a></li>
<li><a href="#index-notfixed-96">notfixed</a>: <a href="#Output-format-style">Output format style</a></li>
<li><a href="#index-one-style-170">one style</a>: <a href="#One-style">One style</a></li>
<li><a href="#index-options-107">options</a>: <a href="#Invoking-source_002dhighlight">Invoking source-highlight</a></li>
<li><a href="#index-output-language-definition-153">output language definition</a>: <a href="#Output-Language-Definitions">Output Language Definitions</a></li>
<li><a href="#index-output-language-map-104">output language map</a>: <a href="#Output-Language-map">Output Language map</a></li>
<li><a href="#index-output-style-84">output style</a>: <a href="#Output-format-style">Output format style</a></li>
<li><a href="#index-Pastebin-36">Pastebin</a>: <a href="#Related-Software-and-Links">Related Software and Links</a></li>
<li><a href="#index-patching-68">patching</a>: <a href="#Patching-from-a-previous-version">Patching from a previous version</a></li>
<li><a href="#index-Perl-35">Perl</a>: <a href="#Related-Software-and-Links">Related Software and Links</a></li>
<li><a href="#index-Perl-9">Perl</a>: <a href="#Perl">Perl</a></li>
<li><a href="#index-Php-31">Php</a>: <a href="#Related-Software-and-Links">Related Software and Links</a></li>
<li><a href="#index-postdoc_005freference-169">postdoc_reference</a>: <a href="#Anchors-and-References">Anchors and References</a></li>
<li><a href="#index-postline_005freference-168">postline_reference</a>: <a href="#Anchors-and-References">Anchors and References</a></li>
<li><a href="#index-prefix-141">prefix</a>: <a href="#How-source_002dhighlight-works">How source-highlight works</a></li>
<li><a href="#index-problems-184">problems</a>: <a href="#Problems">Problems</a></li>
<li><a href="#index-PyQt-34">PyQt</a>: <a href="#Related-Software-and-Links">Related Software and Links</a></li>
<li><a href="#index-Python-33">Python</a>: <a href="#Related-Software-and-Links">Related Software and Links</a></li>
<li><a href="#index-qmake-47">qmake</a>: <a href="#Building-with-qmake">Building with qmake</a></li>
<li><a href="#index-QSource_002dHighlight-16">QSource-Highlight</a>: <a href="#Related-Software-and-Links">Related Software and Links</a></li>
<li><a href="#index-Qt-15">Qt</a>: <a href="#Related-Software-and-Links">Related Software and Links</a></li>
<li><a href="#index-range-context-180">range context</a>: <a href="#Line-ranges-_0028with-context_0029">Line ranges (with context)</a></li>
<li><a href="#index-range-context-115">range context</a>: <a href="#Invoking-source_002dhighlight">Invoking source-highlight</a></li>
<li><a href="#index-range-separator-181">range separator</a>: <a href="#Line-ranges-_0028with-context_0029">Line ranges (with context)</a></li>
<li><a href="#index-range-separator-116">range separator</a>: <a href="#Invoking-source_002dhighlight">Invoking source-highlight</a></li>
<li><a href="#index-RapidWeaver-26">RapidWeaver</a>: <a href="#Related-Software-and-Links">Related Software and Links</a></li>
<li><a href="#index-redef-138">redef</a>: <a href="#Redefinitions-and-Substitutions">Redefinitions and Substitutions</a></li>
<li><a href="#index-reference-175">reference</a>: <a href="#Generating-References">Generating References</a></li>
<li><a href="#index-regex-ranges-182">regex ranges</a>: <a href="#Regex-ranges">Regex ranges</a></li>
<li><a href="#index-regex-ranges-117">regex ranges</a>: <a href="#Invoking-source_002dhighlight">Invoking source-highlight</a></li>
<li><a href="#index-regular-expressions-143">regular expressions</a>: <a href="#Notes-on-regular-expressions">Notes on regular expressions</a></li>
<li><a href="#index-rpm-72">rpm</a>: <a href="#Building-_002erpm">Building .rpm</a></li>
<li><a href="#index-sample-74">sample</a>: <a href="#Simple-Usage">Simple Usage</a></li>
<li><a href="#index-shadow-build-57">shadow build</a>: <a href="#Anonymous-Git-Checkout">Anonymous Git Checkout</a></li>
<li><a href="#index-shadow-build-39">shadow build</a>: <a href="#Installation">Installation</a></li>
<li><a href="#index-SHJS-23">SHJS</a>: <a href="#Related-Software-and-Links">Related Software and Links</a></li>
<li><a href="#index-simple-language-definition-128">simple language definition</a>: <a href="#Simple-definitions">Simple definitions</a></li>
<li><a href="#index-SIP-32">SIP</a>: <a href="#Related-Software-and-Links">Related Software and Links</a></li>
<li><a href="#index-source_002dhighlight_002desc_002esh-70">source-highlight-esc.sh</a>: <a href="#Using-source_002dhighlight-with-less">Using source-highlight with less</a></li>
<li><a href="#index-Source_002dHighlight_002dQt-14">Source-Highlight-Qt</a>: <a href="#Related-Software-and-Links">Related Software and Links</a></li>
<li><a href="#index-source_002dhighlight_002dsettings-4">source-highlight-settings</a>: <a href="#The-program-source_002dhighlight_002dsettings">The program source-highlight-settings</a></li>
<li><a href="#index-source_002dhighlight_002econf-5">source-highlight.conf</a>: <a href="#The-program-source_002dhighlight_002dsettings">The program source-highlight-settings</a></li>
<li><a href="#index-g_t_0040code_007bSOURCE_005fHIGHLIGHT_005fDATADIR_007d-83"><code>SOURCE_HIGHLIGHT_DATADIR</code></a>: <a href="#Configuration-files">Configuration files</a></li>
<li><a href="#index-g_t_0040code_007bSOURCE_005fHIGHLIGHT_005fDATADIR_007d-7"><code>SOURCE_HIGHLIGHT_DATADIR</code></a>: <a href="#The-program-source_002dhighlight_002dsettings">The program source-highlight-settings</a></li>
<li><a href="#index-SourceHighlightIDE-18">SourceHighlightIDE</a>: <a href="#Related-Software-and-Links">Related Software and Links</a></li>
<li><a href="#index-src_002dhilite_002dlesspipe_002esh-69">src-hilite-lesspipe.sh</a>: <a href="#Using-source_002dhighlight-with-less">Using source-highlight with less</a></li>
<li><a href="#index-states-136">states</a>: <a href="#State_002fEnvironment-Definitions">State/Environment Definitions</a></li>
<li><a href="#index-style-separator-172">style separator</a>: <a href="#Style-template">Style template</a></li>
<li><a href="#index-style-template-171">style template</a>: <a href="#Style-template">Style template</a></li>
<li><a href="#index-style_002edefaults-102">style.defaults</a>: <a href="#Default-Styles">Default Styles</a></li>
<li><a href="#index-subst-139">subst</a>: <a href="#Redefinitions-and-Substitutions">Redefinitions and Substitutions</a></li>
<li><a href="#index-suffix-142">suffix</a>: <a href="#How-source_002dhighlight-works">How source-highlight works</a></li>
<li><a href="#index-tail-recursion-186">tail recursion</a>: <a href="#Concept-Index">Concept Index</a></li>
<li><a href="#index-Texinfo-78">Texinfo</a>: <a href="#Texinfo-output">Texinfo output</a></li>
<li><a href="#index-underline-156">underline</a>: <a href="#Text-styles">Text styles</a></li>
<li><a href="#index-underline-94">underline</a>: <a href="#Output-format-style">Output format style</a></li>
<li><a href="#index-usage-108">usage</a>: <a href="#Invoking-source_002dhighlight">Invoking source-highlight</a></li>
<li><a href="#index-variables-133">variables</a>: <a href="#Variable-definitions">Variable definitions</a></li>
<li><a href="#index-version-106">version</a>: <a href="#Invoking-source_002dhighlight">Invoking source-highlight</a></li>
<li><a href="#index-Wiki-28">Wiki</a>: <a href="#Related-Software-and-Links">Related Software and Links</a></li>
<li><a href="#index-XHTML-76">XHTML</a>: <a href="#HTML-and-XHTML-output">HTML and XHTML output</a></li>
   </ul>
<div class="shortcontents">
<h2>Short Contents</h2>
<ul>
<li><a href="#toc_Top">GNU Source-highlight</a></li>
<li><a href="#toc_Introduction">1 Introduction</a></li>
<li><a href="#toc_Installation">2 Installation</a></li>
<li><a href="#toc_Copying">3 Copying Conditions</a></li>
<li><a href="#toc_Simple-Usage">4 Simple Usage</a></li>
<li><a href="#toc_Configuration-files">5 Configuration files</a></li>
<li><a href="#toc_Invoking-source_002dhighlight">6 Invoking <samp><span class="command">source-highlight</span></samp></a></li>
<li><a href="#toc_Language-Definitions">7 Language Definitions</a></li>
<li><a href="#toc_Output-Language-Definitions">8 Output Language Definitions</a></li>
<li><a href="#toc_Generating-References">9 Generating References</a></li>
<li><a href="#toc_Examples">10 Examples</a></li>
<li><a href="#toc_Problems">11 Reporting Bugs</a></li>
<li><a href="#toc_Mailing-Lists">12 Mailing Lists</a></li>
<li><a href="#toc_Concept-Index">Concept Index</a></li>
</ul>
</div>

   <div class="footnote">
<hr>
<a name="texinfo-footnotes-in-document"></a><h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1" href="#fnd-1">1</a>]</small> Up to version 2.9, there were also the suffixes
<code>-doc</code> and <code>-css-doc</code>, but this mechanism was quite confusing
and complex; hopefully, this new one should be better.</p>

   <p class="footnote"><small>[<a name="fn-2" href="#fnd-2">2</a>]</small> Although this might
have been achieved with previous version, it is an official supported
feature since version 2.5.</p>

   <p class="footnote"><small>[<a name="fn-3" href="#fnd-3">3</a>]</small> Since version 3.1.2 of Source-highlight the
CVS repository was dismissed in favor of Git
(<a href="http://git-scm.com/">http://git-scm.com/</a>).</p>

   <p class="footnote"><small>[<a name="fn-4" href="#fnd-4">4</a>]</small> <a href="http://www.gnu.org/software/autoconf">http://www.gnu.org/software/autoconf</a></p>

   <p class="footnote"><small>[<a name="fn-5" href="#fnd-5">5</a>]</small> <a href="http://www.gnu.org/software/automake">http://www.gnu.org/software/automake</a></p>

   <p class="footnote"><small>[<a name="fn-6" href="#fnd-6">6</a>]</small> <a href="http://www.gnu.org/software/libtool">http://www.gnu.org/software/libtool</a></p>

   <p class="footnote"><small>[<a name="fn-7" href="#fnd-7">7</a>]</small> <a href="http://www.gnu.org/software/gnulib">http://www.gnu.org/software/gnulib</a></p>

   <p class="footnote"><small>[<a name="fn-8" href="#fnd-8">8</a>]</small> Since version 2.11, the <code>configure</code> script should be able
to correctly find the boost regex library if it is in the compiler
default path.</p>

   <p class="footnote"><small>[<a name="fn-9" href="#fnd-9">9</a>]</small> Command
lines that are too long are split into multiple indented lines separated
by a <code>\</code>.  Of course these commands are to be given in one line
only, anyway.</p>

   <p class="footnote"><small>[<a name="fn-10" href="#fnd-10">10</a>]</small> Command lines that are too long are
split into multiple indented lines separated by a <code>\</code>.  Of course
these commands are to be given in one line only, anyway.</p>

   <p class="footnote"><small>[<a name="fn-11" href="#fnd-11">11</a>]</small> Before version 2.1, this file was called
<samp><span class="file">tags.j2h</span></samp> which used to be a very obscure name.  I hope this name
convention is a better one :-).</p>

   <p class="footnote"><small>[<a name="fn-12" href="#fnd-12">12</a>]</small> Since
version 2.6.</p>

   <p class="footnote"><small>[<a name="fn-13" href="#fnd-13">13</a>]</small> Before version 2.1, this command line
option was called <code>--tags-file</code> which used to be a very obscure
name.  I hope this name convention is a better one :-).</p>

   <p class="footnote"><small>[<a name="fn-14" href="#fnd-14">14</a>]</small> Since version 2.6.</p>

   <p class="footnote"><small>[<a name="fn-15" href="#fnd-15">15</a>]</small> Of course, if you use HTML and an external CSS file you
will achieve the same result.</p>

   <p class="footnote"><small>[<a name="fn-16" href="#fnd-16">16</a>]</small> You can see these colors in HTML in the file
<samp><span class="file">colors.html</span></samp>.</p>

   <p class="footnote"><small>[<a name="fn-17" href="#fnd-17">17</a>]</small> Note that, since version 2.2, you must use double
quotes.</p>

   <p class="footnote"><small>[<a name="fn-18" href="#fnd-18">18</a>]</small> Since version
2.6.</p>

   <p class="footnote"><small>[<a name="fn-19" href="#fnd-19">19</a>]</small> Since version 2.9.</p>

   <p class="footnote"><small>[<a name="fn-20" href="#fnd-20">20</a>]</small> This is the main
difference introduced in version 2.0 with respect the previous
version.</p>

   <p class="footnote"><small>[<a name="fn-21" href="#fnd-21">21</a>]</small> This is the main
difference introduced in version 2.1 with respect the the previous
version.</p>

   <p class="footnote"><small>[<a name="fn-22" href="#fnd-22">22</a>]</small> As
explained before, originally Source-highlight was thought mainly for
generating HTML output, this is why the term <em>css</em> is used for
style sheets.</p>

   <p class="footnote"><small>[<a name="fn-23" href="#fnd-23">23</a>]</small> Padding character can be specified
since version 2.8.</p>

   <p class="footnote"><small>[<a name="fn-24" href="#fnd-24">24</a>]</small> Since version 2.7.</p>

   <p class="footnote"><small>[<a name="fn-25" href="#fnd-25">25</a>]</small> Since version 3.1.2.</p>

   <p class="footnote"><small>[<a name="fn-26" href="#fnd-26">26</a>]</small> Since version 2.7.</p>

   <p class="footnote"><small>[<a name="fn-27" href="#fnd-27">27</a>]</small> This
issue concerning Perl regular expression syntax was raised by Elias
Pipping, and this also pushed me to deal with this more powerful syntax
that permits using backreferences, for instance.  Although we're still
far from highlighting Perl syntax completely (<a href="#Perl">Perl</a>), I definitely
must thank Elias for his precious information about this matter :-)</p>

   <p class="footnote"><small>[<a name="fn-28" href="#fnd-28">28</a>]</small> As Ed Kelly correctly
pointed out, C-style comments are NOT nested; it's a big shame I've been
using C++ and Java for years and have always thought they were nested
:-)... Thus, in previous versions of source-highlight distributions,
C-style comments were (uncorrectly) defined as nested.  Thank you Ed,
for your feedback!</p>

   <p class="footnote"><small>[<a name="fn-29" href="#fnd-29">29</a>]</small> Since version 2.8</p>

   <p class="footnote"><small>[<a name="fn-30" href="#fnd-30">30</a>]</small> I'm grateful to Jurgen
Hotzel for rising this issue about Lua comments; this led me to
introduce dynamic backreferences.</p>

   <p class="footnote"><small>[<a name="fn-31" href="#fnd-31">31</a>]</small> At least, to the best
of my knowledge :-)</p>

   <p class="footnote"><small>[<a name="fn-32" href="#fnd-32">32</a>]</small> The strategy used by source-highlight for
matching regular expressions changed since version 2.11 (and in version
2.10 the strategy used was not completely conceptually correct and
it had a lot of overhead).</p>

   <p class="footnote"><small>[<a name="fn-33" href="#fnd-33">33</a>]</small> according to the terminology of
regular expressions.</p>

   <p class="footnote"><small>[<a name="fn-34" href="#fnd-34">34</a>]</small> <a href="http://www.boost.org/libs/regex/doc/syntax.html">http://www.boost.org/libs/regex/doc/syntax.html</a></p>

   <p class="footnote"><small>[<a name="fn-35" href="#fnd-35">35</a>]</small> the index only, without the escape character.</p>

   <p class="footnote"><small>[<a name="fn-36" href="#fnd-36">36</a>]</small> This
expression was provided by John Maddock, the author of the Boost regex
library, as a solution of a problem I posted on the boost list,

   <p><a href="http://thread.gmane.org/gmane.comp.lib.boost.devel/158237/focus=158276">http://thread.gmane.org/gmane.comp.lib.boost.devel/158237/focus=158276</a></p>

   <p class="footnote"><small>[<a name="fn-37" href="#fnd-37">37</a>]</small> Since version 2.4.</p>

   <p class="footnote"><small>[<a name="fn-38" href="#fnd-38">38</a>]</small> Up
to version 2.9 the output of <code>--show-regex</code> was a little bit more
complex to read; hopefully this output is better.</p>

   <p class="footnote"><small>[<a name="fn-39" href="#fnd-39">39</a>]</small> Please note that this concept of state is different
from the concept of &ldquo;state&rdquo; of an automaton.</p>

   <p class="footnote"><small>[<a name="fn-40" href="#fnd-40">40</a>]</small> As a future extension we might think of providing a
way, in the language definition syntax, to define a state/environment
that extends the outer contexts instead of overriding them.</p>

   <p class="footnote"><small>[<a name="fn-41" href="#fnd-41">41</a>]</small> This was not tested
extensively and might not catch all the correct situations.</p>

   <p class="footnote"><small>[<a name="fn-42" href="#fnd-42">42</a>]</small> OK, there are no templates in
C, and they are only in C++, but we think it should no harm when
highlighting C files.</p>

   <p class="footnote"><small>[<a name="fn-43" href="#fnd-43">43</a>]</small> Before version 2.9, there was only
<samp><span class="file">cpp.lang</span></samp> which was used both for C and C++; however, this way, if
you had a C program where you were using a C++ keyword as a variable
name&mdash;which of course is correct in C&mdash;that variable was actually
highlighted as a keyword and this was not correct.</p>

   <p class="footnote"><small>[<a name="fn-44" href="#fnd-44">44</a>]</small> Since version 2.6.</p>

   <p class="footnote"><small>[<a name="fn-45" href="#fnd-45">45</a>]</small> This is a sort of trick to insert spaces at
the beginning of a line without using a tabular environment; without the
leading <code>\mbox{}</code> these spaces would be ignored.  This is the
only way I found to achieve this, if you have suggestions, please let me
know!</p>

   <p class="footnote"><small>[<a name="fn-46" href="#fnd-46">46</a>]</small> Since version 2.4.</p>

   <p class="footnote"><small>[<a name="fn-47" href="#fnd-47">47</a>]</small> Unless they are inside a
<code>&lt;tt&gt;...&lt;/tt&gt;</code>.</p>

   <p class="footnote"><small>[<a name="fn-48" href="#fnd-48">48</a>]</small> Up
to version 2.9, there was only <code>doctemplate</code> and for <code>--doc</code>
there was a separate <code>.outlang</code> file; I think the present solution
is better and reduces the number of files.</p>

   <p class="footnote"><small>[<a name="fn-49" href="#fnd-49">49</a>]</small> Since version 2.6.</p>

   <p class="footnote"><small>[<a name="fn-50" href="#fnd-50">50</a>]</small> Although I haven't tested it, I think this will work also
for Doxygen comments.</p>

   <p class="footnote"><small>[<a name="fn-51" href="#fnd-51">51</a>]</small> This description is taken
from the ctags man page</p>

   <hr></div>

</body></html>