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
| | ;;; ox-html.el --- HTML Back-End for Org Export Engine
;; Copyright (C) 2011-2013 Free Software Foundation, Inc.
;; Author: Jambunathan K <kjambunathan at gmail dot com>
;; Keywords: outlines, hypermedia, calendar, wp
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This library implements a HTML back-end for Org generic exporter.
;; To test it, run:
;;
;; M-x org-export-as-html
;;
;; in an Org mode buffer. See ox.el for more details on how this
;; exporter works.
;;; Code:
;;; Dependencies
(require 'ox)
(require 'ox-publish)
(require 'format-spec)
(eval-when-compile (require 'cl) (require 'table))
\f
;;; Function Declarations
(declare-function org-id-find-id-file "org-id" (id))
(declare-function htmlize-region "ext:htmlize" (beg end))
(declare-function org-pop-to-buffer-same-window
"org-compat" (&optional buffer-or-name norecord label))
;;; Define Back-End
(org-export-define-backend html
((bold . org-html-bold)
(center-block . org-html-center-block)
(clock . org-html-clock)
(code . org-html-code)
(drawer . org-html-drawer)
(dynamic-block . org-html-dynamic-block)
(entity . org-html-entity)
(example-block . org-html-example-block)
(export-block . org-html-export-block)
(export-snippet . org-html-export-snippet)
(fixed-width . org-html-fixed-width)
(footnote-definition . org-html-footnote-definition)
(footnote-reference . org-html-footnote-reference)
(headline . org-html-headline)
(horizontal-rule . org-html-horizontal-rule)
(inline-src-block . org-html-inline-src-block)
(inlinetask . org-html-inlinetask)
(inner-template . org-html-inner-template)
(italic . org-html-italic)
(item . org-html-item)
(keyword . org-html-keyword)
(latex-environment . org-html-latex-environment)
(latex-fragment . org-html-latex-fragment)
(line-break . org-html-line-break)
(link . org-html-link)
(paragraph . org-html-paragraph)
(plain-list . org-html-plain-list)
(plain-text . org-html-plain-text)
(planning . org-html-planning)
(property-drawer . org-html-property-drawer)
(quote-block . org-html-quote-block)
(quote-section . org-html-quote-section)
(radio-target . org-html-radio-target)
(section . org-html-section)
(special-block . org-html-special-block)
(src-block . org-html-src-block)
(statistics-cookie . org-html-statistics-cookie)
(strike-through . org-html-strike-through)
(subscript . org-html-subscript)
(superscript . org-html-superscript)
(table . org-html-table)
(table-cell . org-html-table-cell)
(table-row . org-html-table-row)
(target . org-html-target)
(template . org-html-template)
(timestamp . org-html-timestamp)
(underline . org-html-underline)
(verbatim . org-html-verbatim)
(verse-block . org-html-verse-block))
:export-block "HTML"
:filters-alist ((:filter-options . org-html-infojs-install-script)
(:filter-final-output . org-html-final-function))
:menu-entry
(?h "Export to HTML"
((?H "As HTML buffer" org-html-export-as-html)
(?h "As HTML file" org-html-export-to-html)
(?o "As HTML file and open"
(lambda (a s v b)
(if a (org-html-export-to-html t s v b)
(org-open-file (org-html-export-to-html nil s v b)))))))
:options-alist
((:html-extension nil nil org-html-extension)
(:html-doctype "HTML_DOCTYPE" nil org-html-doctype)
(:html-container "HTML_CONTAINER" nil org-html-container-element)
(:html-link-home "HTML_LINK_HOME" nil org-html-link-home)
(:html-link-up "HTML_LINK_UP" nil org-html-link-up)
(:html-mathjax "HTML_MATHJAX" nil "" space)
(:html-postamble nil "html-postamble" org-html-postamble)
(:html-preamble nil "html-preamble" org-html-preamble)
(:html-head "HTML_HEAD" nil org-html-head newline)
(:html-head-extra "HTML_HEAD_EXTRA" nil org-html-head-extra newline)
(:html-head-include-default-style "HTML_INCLUDE_STYLE" nil org-html-head-include-default-style newline)
(:html-head-include-scripts "HTML_INCLUDE_SCRIPTS" nil org-html-head-include-scripts newline)
(:html-table-tag nil nil org-html-table-tag)
;; Redefine regular options.
(:creator "CREATOR" nil org-html-creator-string)
(:with-latex nil "tex" org-html-with-latex)
;; Leave room for "ox-infojs.el" extension.
(:infojs-opt "INFOJS_OPT" nil nil)))
\f
;;; Internal Variables
(defvar org-html-format-table-no-css)
(defvar htmlize-buffer-places) ; from htmlize.el
(defconst org-html-special-string-regexps
'(("\\\\-" . "­") ; shy
("---\\([^-]\\)" . "—\\1") ; mdash
("--\\([^-]\\)" . "–\\1") ; ndash
("\\.\\.\\." . "…")) ; hellip
"Regular expressions for special string conversion.")
(defconst org-html-scripts
"<script type=\"text/javascript\">
/*
@licstart The following is the entire license notice for the
JavaScript code in this tag.
Copyright (C) 2012 Free Software Foundation, Inc.
The JavaScript code in this tag is free software: you can
redistribute it and/or modify it under the terms of the GNU
General Public License (GNU GPL) as published by the Free Software
Foundation, either version 3 of the License, or (at your option)
any later version. The code is distributed WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
As additional permission under GNU GPL version 3 section 7, you
may distribute non-source (e.g., minimized or compacted) forms of
that code without the copy of the GNU GPL normally required by
section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.
@licend The above is the entire license notice
for the JavaScript code in this tag.
*/
<!--/*--><![CDATA[/*><!--*/
function CodeHighlightOn(elem, id)
{
var target = document.getElementById(id);
if(null != target) {
elem.cacheClassElem = elem.className;
elem.cacheClassTarget = target.className;
target.className = \"code-highlighted\";
elem.className = \"code-highlighted\";
}
}
function CodeHighlightOff(elem, id)
{
var target = document.getElementById(id);
if(elem.cacheClassElem)
elem.className = elem.cacheClassElem;
if(elem.cacheClassTarget)
target.className = elem.cacheClassTarget;
}
/*]]>*///-->
</script>"
"Basic JavaScript that is needed by HTML files produced by Org mode.")
(defconst org-html-style-default
"<style type=\"text/css\">
<!--/*--><![CDATA[/*><!--*/
.title { text-align: center; }
.todo { font-family: monospace; color: red; }
.done { color: green; }
.tag { background-color: #eee; font-family: monospace;
padding: 2px; font-size: 80%; font-weight: normal; }
.timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; }
.right { margin-left: auto; margin-right: 0px; text-align: right; }
.left { margin-left: 0px; margin-right: auto; text-align: left; }
.center { margin-left: auto; margin-right: auto; text-align: center; }
.underline { text-decoration: underline; }
#content { margin: 3em; }
#postamble p, a { font-size: 90%; margin: .2em; }
p.verse { margin-left: 3%; }
pre {
border: 1px solid #ccc;
box-shadow: 3px 3px 3px #eee;
padding: 8pt;
font-family: monospace;
overflow: auto;
margin: 1.2em;
}
pre.src {
position: relative;
overflow: visible;
padding-top: 1.2em;
}
pre.src:before {
display: none;
position: absolute;
background-color: white;
top: -10px;
right: 10px;
padding: 3px;
border: 1px solid black;
}
pre.src:hover:before { display: inline;}
pre.src-sh:before { content: 'sh'; }
pre.src-bash:before { content: 'sh'; }
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
pre.src-R:before { content: 'R'; }
pre.src-perl:before { content: 'Perl'; }
pre.src-java:before { content: 'Java'; }
pre.src-sql:before { content: 'SQL'; }
table { border-collapse:collapse; }
td, th { vertical-align:top; }
th.right { text-align: center; }
th.left { text-align: center; }
th.center { text-align: center; }
td.right { text-align: right; }
td.left { text-align: left; }
td.center { text-align: center; }
dt { font-weight: bold; }
.figure { padding: 1em; }
.figure p { text-align: center; }
.inlinetask {
padding: 10px;
border: 2px solid gray;
margin: 10px;
background: #ffffcc;
}
#org-div-home-and-up
{ text-align: right; font-size: 70%; white-space: nowrap; }
textarea { overflow-x:auto; }
.linenr { font-size:smaller }
.code-highlighted { background-color:#ffff00; }
.org-info-js_info-navigation { border-style:none; }
#org-info-js_console-label
{ font-size:10px; font-weight:bold; white-space:nowrap; }
.org-info-js_search-highlight
{ background-color:#ffff00; color:#000000; font-weight:bold; }
/*]]>*/-->
</style>"
"The default style specification for exported HTML files.
You can use `org-html-head' and `org-html-head-extra' to add to
this style. If you don't want to include this default style,
customize `org-html-head-include-default-style'.")
\f
;;; User Configuration Variables
(defgroup org-export-html nil
"Options for exporting Org mode files to HTML."
:tag "Org Export HTML"
:group 'org-export)
;;;; Handle infojs
(defvar org-html-infojs-opts-table
'((path PATH "http://orgmode.org/org-info.js")
(view VIEW "info")
(toc TOC :with-toc)
(ftoc FIXED_TOC "0")
(tdepth TOC_DEPTH "max")
(sdepth SECTION_DEPTH "max")
(mouse MOUSE_HINT "underline")
(buttons VIEW_BUTTONS "0")
(ltoc LOCAL_TOC "1")
(up LINK_UP :html-link-up)
(home LINK_HOME :html-link-home))
"JavaScript options, long form for script, default values.")
(defcustom org-html-use-infojs 'when-configured
"Non-nil when Sebastian Rose's Java Script org-info.js should be active.
This option can be nil or t to never or always use the script.
It can also be the symbol `when-configured', meaning that the
script will be linked into the export file if and only if there
is a \"#+INFOJS_OPT:\" line in the buffer. See also the variable
`org-html-infojs-options'."
:group 'org-export-html
:version "24.4"
:package-version '(Org . "8.0")
:type '(choice
(const :tag "Never" nil)
(const :tag "When configured in buffer" when-configured)
(const :tag "Always" t)))
(defcustom org-html-infojs-options
(mapcar (lambda (x) (cons (car x) (nth 2 x))) org-html-infojs-opts-table)
"Options settings for the INFOJS JavaScript.
Each of the options must have an entry in `org-html-infojs-opts-table'.
The value can either be a string that will be passed to the script, or
a property. This property is then assumed to be a property that is defined
by the Export/Publishing setup of Org.
The `sdepth' and `tdepth' parameters can also be set to \"max\", which
means to use the maximum value consistent with other options."
:group 'org-export-html
:version "24.4"
:package-version '(Org . "8.0")
:type
`(set :greedy t :inline t
,@(mapcar
(lambda (x)
(list 'cons (list 'const (car x))
'(choice
(symbol :tag "Publishing/Export property")
(string :tag "Value"))))
org-html-infojs-opts-table)))
(defcustom org-html-infojs-template
"<script type=\"text/javascript\" src=\"%SCRIPT_PATH\">
/**
*
* @source: %SCRIPT_PATH
*
* @licstart The following is the entire license notice for the
* JavaScript code in %SCRIPT_PATH.
*
* Copyright (C) 2012-2013 Sebastian Rose
*
*
* The JavaScript code in this tag is free software: you can
* redistribute it and/or modify it under the terms of the GNU
* General Public License (GNU GPL) as published by the Free Software
* Foundation, either version 3 of the License, or (at your option)
* any later version. The code is distributed WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
*
* As additional permission under GNU GPL version 3 section 7, you
* may distribute non-source (e.g., minimized or compacted) forms of
* that code without the copy of the GNU GPL normally required by
* section 4, provided you include this license notice and a URL
* through which recipients can access the Corresponding Source.
*
* @licend The above is the entire license notice
* for the JavaScript code in %SCRIPT_PATH.
*
*/
</script>
<script type=\"text/javascript\">
/*
@licstart The following is the entire license notice for the
JavaScript code in this tag.
Copyright (C) 2012-2013 Free Software Foundation, Inc.
The JavaScript code in this tag is free software: you can
redistribute it and/or modify it under the terms of the GNU
General Public License (GNU GPL) as published by the Free Software
Foundation, either version 3 of the License, or (at your option)
any later version. The code is distributed WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
As additional permission under GNU GPL version 3 section 7, you
may distribute non-source (e.g., minimized or compacted) forms of
that code without the copy of the GNU GPL normally required by
section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.
@licend The above is the entire license notice
for the JavaScript code in this tag.
*/
<!--/*--><![CDATA[/*><!--*/
%MANAGER_OPTIONS
org_html_manager.setup(); // activate after the parameters are set
/*]]>*///-->
</script>"
"The template for the export style additions when org-info.js is used.
Option settings will replace the %MANAGER-OPTIONS cookie."
:group 'org-export-html
:version "24.4"
:package-version '(Org . "8.0")
:type 'string)
(defun org-html-infojs-install-script (exp-plist backend)
"Install script in export options when appropriate.
EXP-PLIST is a plist containing export options. BACKEND is the
export back-end currently used."
(unless (or (memq 'body-only (plist-get exp-plist :export-options))
(not org-html-use-infojs)
(and (eq org-html-use-infojs 'when-configured)
(or (not (plist-get exp-plist :infojs-opt))
(string-match "\\<view:nil\\>"
(plist-get exp-plist :infojs-opt)))))
(let* ((template org-html-infojs-template)
(ptoc (plist-get exp-plist :with-toc))
(hlevels (plist-get exp-plist :headline-levels))
(sdepth hlevels)
(tdepth (if (integerp ptoc) (min ptoc hlevels) hlevels))
(options (plist-get exp-plist :infojs-opt))
(table org-html-infojs-opts-table)
style)
(dolist (entry table)
(let* ((opt (car entry))
(var (nth 1 entry))
;; Compute default values for script option OPT from
;; `org-html-infojs-options' variable.
(default
(let ((default (cdr (assq opt org-html-infojs-options))))
(if (and (symbolp default) (not (memq default '(t nil))))
(plist-get exp-plist default)
default)))
;; Value set through INFOJS_OPT keyword has precedence
;; over the default one.
(val (if (and options
(string-match (format "\\<%s:\\(\\S-+\\)" opt)
options))
(match-string 1 options)
default)))
(case opt
(path (setq template
(replace-regexp-in-string
"%SCRIPT_PATH" val template t t)))
(sdepth (when (integerp (read val))
(setq sdepth (min (read val) sdepth))))
(tdepth (when (integerp (read val))
(setq tdepth (min (read val) tdepth))))
(otherwise (setq val
(cond
((or (eq val t) (equal val "t")) "1")
((or (eq val nil) (equal val "nil")) "0")
((stringp val) val)
(t (format "%s" val))))
(push (cons var val) style)))))
;; Now we set the depth of the *generated* TOC to SDEPTH,
;; because the toc will actually determine the splitting. How
;; much of the toc will actually be displayed is governed by the
;; TDEPTH option.
(setq exp-plist (plist-put exp-plist :with-toc sdepth))
;; The table of contents should not show more sections than we
;; generate.
(setq tdepth (min tdepth sdepth))
(push (cons "TOC_DEPTH" tdepth) style)
;; Build style string.
(setq style (mapconcat
(lambda (x) (format "org_html_manager.set(\"%s\", \"%s\");"
(car x)
(cdr x)))
style "\n"))
(when (and style (> (length style) 0))
(and (string-match "%MANAGER_OPTIONS" template)
(setq style (replace-match style t t template))
(setq exp-plist
(plist-put
exp-plist :html-head-extra
(concat (or (plist-get exp-plist :html-head-extra) "")
"\n"
style)))))
;; This script absolutely needs the table of contents, so we
;; change that setting.
(unless (plist-get exp-plist :with-toc)
(setq exp-plist (plist-put exp-plist :with-toc t)))
;; Return the modified property list.
exp-plist)))
;;;; Bold, etc.
(defcustom org-html-text-markup-alist
'((bold . "<b>%s</b>")
(code . "<code>%s</code>")
(italic . "<i>%s</i>")
(strike-through . "<del>%s</del>")
(underline . "<span class=\"underline\">%s</span>")
(verbatim . "<code>%s</code>"))
"Alist of HTML expressions to convert text markup.
The key must be a symbol among `bold', `code', `italic',
`strike-through', `underline' and `verbatim'. The value is
a formatting string to wrap fontified text with.
If no association can be found for a given markup, text will be
returned as-is."
:group 'org-export-html
:type '(alist :key-type (symbol :tag "Markup type")
:value-type (string :tag "Format string"))
:options '(bold code italic strike-through underline verbatim))
(defcustom org-html-pretty-output nil
"Enable this to generate pretty HTML."
:group 'org-export-html
:version "24.4"
:package-version '(Org . "8.0")
:type 'boolean)
;;;; Drawers
(defcustom org-html-format-drawer-function nil
"Function called to format a drawer in HTML code.
The function must accept two parameters:
NAME the drawer name, like \"LOGBOOK\"
CONTENTS the contents of the drawer.
The function should return the string to be exported.
For example, the variable could be set to the following function
in order to mimic default behaviour:
\(defun org-html-format-drawer-default \(name contents\)
\"Format a drawer element for HTML export.\"
contents\)"
:group 'org-export-html
:type 'function)
;;;; Footnotes
(defcustom org-html-footnotes-section "<div id=\"footnotes\">
<h2 class=\"footnotes\">%s: </h2>
<div id=\"text-footnotes\">
%s
</div>
</div>"
"Format for the footnotes section.
Should contain a two instances of %s. The first will be replaced with the
language-specific word for \"Footnotes\", the second one will be replaced
by the footnotes themselves."
:group 'org-export-html
:type 'string)
(defcustom org-html-footnote-format "<sup>%s</sup>"
"The format for the footnote reference.
%s will be replaced by the footnote reference itself."
:group 'org-export-html
:type 'string)
(defcustom org-html-footnote-separator "<sup>, </sup>"
"Text used to separate footnotes."
:group 'org-export-html
:type 'string)
;;;; Headline
(defcustom org-html-toplevel-hlevel 2
"The <H> level for level 1 headings in HTML export.
This is also important for the classes that will be wrapped around headlines
and outline structure. If this variable is 1, the top-level headlines will
be <h1>, and the corresponding classes will be outline-1, section-number-1,
and outline-text-1. If this is 2, all of these will get a 2 instead.
The default for this variable is 2, because we use <h1> for formatting the
document title."
:group 'org-export-html
:type 'integer)
(defcustom org-html-format-headline-function nil
"Function to format headline text.
This function will be called with 5 arguments:
TODO the todo keyword (string or nil).
TODO-TYPE the type of todo (symbol: `todo', `done', nil)
PRIORITY the priority of the headline (integer or nil)
TEXT the main headline text (string).
TAGS the tags (string or nil).
The function result will be used in the section format string."
:group 'org-export-html
:type 'function)
;;;; HTML-specific
(defcustom org-html-allow-name-attribute-in-anchors t
"When nil, do not set \"name\" attribute in anchors.
By default, anchors are formatted with both \"id\" and \"name\"
attributes, when appropriate."
:group 'org-export-html
:version "24.4"
:package-version '(Org . "8.0")
:type 'boolean)
;;;; Inlinetasks
(defcustom org-html-format-inlinetask-function nil
"Function called to format an inlinetask in HTML code.
The function must accept six parameters:
TODO the todo keyword, as a string
TODO-TYPE the todo type, a symbol among `todo', `done' and nil.
PRIORITY the inlinetask priority, as a string
NAME the inlinetask name, as a string.
TAGS the inlinetask tags, as a list of strings.
CONTENTS the contents of the inlinetask, as a string.
The function should return the string to be exported."
:group 'org-export-html
:type 'function)
;;;; LaTeX
(defcustom org-html-with-latex org-export-with-latex
"Non-nil means process LaTeX math snippets.
When set, the exporter will process LaTeX environments and
fragments.
This option can also be set with the +OPTIONS line,
e.g. \"tex:mathjax\". Allowed values are:
nil Ignore math snippets.
`verbatim' Keep everything in verbatim
`dvipng' Process the LaTeX fragments to images. This will also
include processing of non-math environments.
`imagemagick' Convert the LaTeX fragments to pdf files and use
imagemagick to convert pdf files to png files.
`mathjax' Do MathJax preprocessing and arrange for MathJax.js to
be loaded.
t Synonym for `mathjax'."
:group 'org-export-html
:version "24.4"
:package-version '(Org . "8.0")
:type '(choice
(const :tag "Do not process math in any way" nil)
(const :tag "Use dvipng to make images" dvipng)
(const :tag "Use imagemagick to make images" imagemagick)
(const :tag "Use MathJax to display math" mathjax)
(const :tag "Leave math verbatim" verbatim)))
;;;; Links :: Generic
(defcustom org-html-link-org-files-as-html t
"Non-nil means make file links to `file.org' point to `file.html'.
When `org-mode' is exporting an `org-mode' file to HTML, links to
non-html files are directly put into a href tag in HTML.
However, links to other Org-mode files (recognized by the
extension `.org.) should become links to the corresponding html
file, assuming that the linked `org-mode' file will also be
converted to HTML.
When nil, the links still point to the plain `.org' file."
:group 'org-export-html
:type 'boolean)
;;;; Links :: Inline images
(defcustom org-html-inline-images 'maybe
"Non-nil means inline images into exported HTML pages.
This is done using an <img> tag. When nil, an anchor with href is used to
link to the image. If this option is `maybe', then images in links with
an empty description will be inlined, while images with a description will
be linked only."
:group 'org-export-html
:type '(choice (const :tag "Never" nil)
(const :tag "Always" t)
(const :tag "When there is no description" maybe)))
(defcustom org-html-inline-image-rules
'(("file" . "\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
("http" . "\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
("https" . "\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'"))
"Rules characterizing image files that can be inlined into HTML.
A rule consists in an association whose key is the type of link
to consider, and value is a regexp that will be matched against
link's path.
Note that, by default, the image extension *actually* allowed
depend on the way the HTML file is processed. When used with
pdflatex, pdf, jpg and png images are OK. When processing
through dvi to Postscript, only ps and eps are allowed. The
default we use here encompasses both."
:group 'org-export-html
:version "24.4"
:package-version '(Org . "8.0")
:type '(alist :key-type (string :tag "Type")
:value-type (regexp :tag "Path")))
;;;; Plain Text
(defcustom org-html-protect-char-alist
'(("&" . "&")
("<" . "<")
(">" . ">"))
"Alist of characters to be converted by `org-html-protect'."
:group 'org-export-html
:type '(repeat (cons (string :tag "Character")
(string :tag "HTML equivalent"))))
;;;; Src Block
(defcustom org-html-htmlize-output-type 'inline-css
"Output type to be used by htmlize when formatting code snippets.
Choices are `css', to export the CSS selectors only, or `inline-css', to
export the CSS attribute values inline in the HTML. We use as default
`inline-css', in order to make the resulting HTML self-containing.
However, this will fail when using Emacs in batch mode for export, because
then no rich font definitions are in place. It will also not be good if
people with different Emacs setup contribute HTML files to a website,
because the fonts will represent the individual setups. In these cases,
it is much better to let Org/Htmlize assign classes only, and to use
a style file to define the look of these classes.
To get a start for your css file, start Emacs session and make sure that
all the faces you are interested in are defined, for example by loading files
in all modes you want. Then, use the command
\\[org-html-htmlize-generate-css] to extract class definitions."
:group 'org-export-html
:type '(choice (const css) (const inline-css)))
(defcustom org-html-htmlize-font-prefix "org-"
"The prefix for CSS class names for htmlize font specifications."
:group 'org-export-html
:type 'string)
;;;; Table
(defcustom org-html-table-tag
"<table border=\"2\" cellspacing=\"0\" cellpadding=\"6\" rules=\"groups\" frame=\"hsides\">"
"The HTML tag that is used to start a table.
This must be a <table> tag, but you may change the options like
borders and spacing."
:group 'org-export-html
:type 'string)
(defcustom org-html-table-header-tags '("<th scope=\"%s\"%s>" . "</th>")
"The opening tag for table header fields.
This is customizable so that alignment options can be specified.
The first %s will be filled with the scope of the field, either row or col.
The second %s will be replaced by a style entry to align the field.
See also the variable `org-html-table-use-header-tags-for-first-column'.
See also the variable `org-html-table-align-individual-fields'."
:group 'org-export-html
:type '(cons (string :tag "Opening tag") (string :tag "Closing tag")))
(defcustom org-html-table-data-tags '("<td%s>" . "</td>")
"The opening tag for table data fields.
This is customizable so that alignment options can be specified.
The first %s will be filled with the scope of the field, either row or col.
The second %s will be replaced by a style entry to align the field.
See also the variable `org-html-table-align-individual-fields'."
:group 'org-export-html
:type '(cons (string :tag "Opening tag") (string :tag "Closing tag")))
(defcustom org-html-table-row-tags '("<tr>" . "</tr>")
"The opening tag for table data fields.
This is customizable so that alignment options can be specified.
Instead of strings, these can be Lisp forms that will be evaluated
for each row in order to construct the table row tags. During evaluation,
the variable `head' will be true when this is a header line, nil when this
is a body line. And the variable `nline' will contain the line number,
starting from 1 in the first header line. For example
(setq org-html-table-row-tags
(cons '(if head
\"<tr>\"
(if (= (mod nline 2) 1)
\"<tr class=\\\"tr-odd\\\">\"
\"<tr class=\\\"tr-even\\\">\"))
\"</tr>\"))
will give even lines the class \"tr-even\" and odd lines the class \"tr-odd\"."
:group 'org-export-html
:type '(cons
(choice :tag "Opening tag"
(string :tag "Specify")
(sexp))
(choice :tag "Closing tag"
(string :tag "Specify")
(sexp))))
(defcustom org-html-table-align-individual-fields t
"Non-nil means attach style attributes for alignment to each table field.
When nil, alignment will only be specified in the column tags, but this
is ignored by some browsers (like Firefox, Safari). Opera does it right
though."
:group 'org-export-html
:type 'boolean)
(defcustom org-html-table-use-header-tags-for-first-column nil
"Non-nil means format column one in tables with header tags.
When nil, also column one will use data tags."
:group 'org-export-html
:type 'boolean)
(defcustom org-html-table-caption-above t
"When non-nil, place caption string at the beginning of the table.
Otherwise, place it near the end."
:group 'org-export-html
:type 'boolean)
;;;; Tags
(defcustom org-html-tag-class-prefix ""
"Prefix to class names for TODO keywords.
Each tag gets a class given by the tag itself, with this prefix.
The default prefix is empty because it is nice to just use the keyword
as a class name. But if you get into conflicts with other, existing
CSS classes, then this prefix can be very useful."
:group 'org-export-html
:type 'string)
;;;; Template :: Generic
(defcustom org-html-extension "html"
"The extension for exported HTML files."
:group 'org-export-html
:type 'string)
(defcustom org-html-xml-declaration
'(("html" . "<?xml version=\"1.0\" encoding=\"%s\"?>")
("php" . "<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>"))
"The extension for exported HTML files.
%s will be replaced with the charset of the exported file.
This may be a string, or an alist with export extensions
and corresponding declarations."
:group 'org-export-html
:type '(choice
(string :tag "Single declaration")
(repeat :tag "Dependent on extension"
(cons (string :tag "Extension")
(string :tag "Declaration")))))
(defcustom org-html-coding-system 'utf-8
"Coding system for HTML export.
Use utf-8 as the default value."
:group 'org-export-html
:version "24.4"
:package-version '(Org . "8.0")
:type 'coding-system)
(defcustom org-html-doctype
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"
"Document type definition to use for exported HTML files.
Can be set with the in-buffer HTML_DOCTYPE property or for
publishing, with :html-doctype."
:group 'org-export-html
:version "24.4"
:package-version '(Org . "8.0")
:type 'string)
(defcustom org-html-container-element "div"
"Container class to use for wrapping top level sections.
Can be set with the in-buffer HTML_CONTAINER property or for
publishing, with :html-container.
Note that changing the default will prevent you from using
org-info.js for your website."
:group 'org-export-html
:version "24.4"
:package-version '(Org . "8.0")
:type 'string)
(defcustom org-html-divs
'((preamble "div" "preamble")
(content "div" "content")
(postamble "div" "postamble"))
"Alist of the threed section elements for HTML export.
The car of each entry is one of 'preamble, 'content or 'postamble.
The cdrs of each entry are the ELEMENT_TYPE and ID for each
section of the exported document.
Note that changing the default will prevent you from using
org-info.js for your website."
:group 'org-export-html
:version "24.4"
:package-version '(Org . "8.0")
:type '(list :greedy t
(list :tag "Preamble"
(const :format "" preamble)
(string :tag "element") (string :tag " id"))
(list :tag "Content"
(const :format "" content)
(string :tag "element") (string :tag " id"))
(list :tag "Postamble" (const :format "" postamble)
(string :tag " id") (string :tag "element"))))
;;;; Template :: Mathjax
(defcustom org-html-mathjax-options
'((path "http://orgmode.org/mathjax/MathJax.js")
(scale "100")
(align "center")
(indent "2em")
(mathml nil))
"Options for MathJax setup.
path The path where to find MathJax
scale Scaling for the HTML-CSS backend, usually between 100 and 133
align How to align display math: left, center, or right
indent If align is not center, how far from the left/right side?
mathml Should a MathML player be used if available?
This is faster and reduces bandwidth use, but currently
sometimes has lower spacing quality. Therefore, the default is
nil. When browsers get better, this switch can be flipped.
You can also customize this for each buffer, using something like
#+MATHJAX: scale:\"133\" align:\"right\" mathml:t path:\"/MathJax/\""
:group 'org-export-html
:type '(list :greedy t
(list :tag "path (the path from where to load MathJax.js)"
(const :format " " path) (string))
(list :tag "scale (scaling for the displayed math)"
(const :format " " scale) (string))
(list :tag "align (alignment of displayed equations)"
(const :format " " align) (string))
(list :tag "indent (indentation with left or right alignment)"
(const :format " " indent) (string))
(list :tag "mathml (should MathML display be used is possible)"
(const :format " " mathml) (boolean))))
(defcustom org-html-mathjax-template
"<script type=\"text/javascript\" src=\"%PATH\">
<!--/*--><![CDATA[/*><!--*/
MathJax.Hub.Config({
// Only one of the two following lines, depending on user settings
// First allows browser-native MathML display, second forces HTML/CSS
:MMLYES: config: [\"MMLorHTML.js\"], jax: [\"input/TeX\"],
:MMLNO: jax: [\"input/TeX\", \"output/HTML-CSS\"],
extensions: [\"tex2jax.js\",\"TeX/AMSmath.js\",\"TeX/AMSsymbols.js\",
\"TeX/noUndefined.js\"],
tex2jax: {
inlineMath: [ [\"\\\\(\",\"\\\\)\"] ],
displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"], [\"\\\\begin{displaymath}\",\"\\\\end{displaymath}\"] ],
skipTags: [\"script\",\"noscript\",\"style\",\"textarea\",\"pre\",\"code\"],
ignoreClass: \"tex2jax_ignore\",
processEscapes: false,
processEnvironments: true,
preview: \"TeX\"
},
showProcessingMessages: true,
displayAlign: \"%ALIGN\",
displayIndent: \"%INDENT\",
\"HTML-CSS\": {
scale: %SCALE,
availableFonts: [\"STIX\",\"TeX\"],
preferredFont: \"TeX\",
webFont: \"TeX\",
imageFont: \"TeX\",
showMathMenu: true,
},
MMLorHTML: {
prefer: {
MSIE: \"MML\",
Firefox: \"MML\",
Opera: \"HTML\",
other: \"HTML\"
}
}
});
/*]]>*///-->
</script>"
"The MathJax setup for XHTML files."
:group 'org-export-html
:type 'string)
;;;; Template :: Postamble
(defcustom org-html-postamble 'auto
"Non-nil means insert a postamble in HTML export.
When set to 'auto, check against the
`org-export-with-author/email/creator/date' variables to set the
content of the postamble. When set to a string, use this string
as the postamble. When t, insert a string as defined by the
formatting string in `org-html-postamble-format'.
When set to a function, apply this function and insert the
returned string. The function takes the property list of export
options as its only argument.
Setting :html-postamble in publishing projects will take
precedence over this variable."
:group 'org-export-html
:type '(choice (const :tag "No postamble" nil)
(const :tag "Auto postamble" 'auto)
(const :tag "Default formatting string" t)
(string :tag "Custom formatting string")
(function :tag "Function (must return a string)")))
(defcustom org-html-postamble-format
'(("en" "<p class=\"author\">Author: %a (%e)</p>
<p class=\"date\">Date: %d</p>
<p class=\"creator\">Generated by %c</p>
<p class=\"xhtml-validation\">%v</p>"))
"Alist of languages and format strings for the HTML postamble.
The first element of each list is the language code, as used for
the #+LANGUAGE keyword.
The second element of each list is a format string to format the
postamble itself. This format string can contain these elements:
%a stands for the author's name.
%e stands for the author's email.
%d stands for the date.
%c will be replaced by information about Org/Emacs versions.
%v will be replaced by `org-html-validation-link'.
If you need to use a \"%\" character, you need to escape it
like that: \"%%\"."
:group 'org-export-html
:type '(alist :key-type (string :tag "Language")
:value-type (string :tag "Format string")))
(defcustom org-html-validation-link
"<a href=\"http://validator.w3.org/check?uri=referer\">Validate XHTML 1.0</a>"
"Link to HTML validation service."
:group 'org-export-html
:type 'string)
(defcustom org-html-creator-string
(format "Generated by <a href=\"http://orgmode.org\">Org</a> mode %s in <a href=\"http://www.gnu.org/software/emacs/\">Emacs</a> %s."
(if (fboundp 'org-version) (org-version) "(Unknown)")
emacs-version)
"String to insert at the end of the HTML document."
:group 'org-export-html
:type '(string :tag "Creator string"))
;;;; Template :: Preamble
(defcustom org-html-preamble t
"Non-nil means insert a preamble in HTML export.
When t, insert a string as defined by the formatting string in
`org-html-preamble-format'. When set to a string, use this
formatting string instead (see `org-html-postamble-format' for an
example of such a formatting string).
When set to a function, apply this function and insert the
returned string. The function takes the property list of export
options as its only argument.
Setting :html-preamble in publishing projects will take
precedence over this variable."
:group 'org-export-html
:type '(choice (const :tag "No preamble" nil)
(const :tag "Default preamble" t)
(string :tag "Custom formatting string")
(function :tag "Function (must return a string)")))
(defcustom org-html-preamble-format '(("en" ""))
"Alist of languages and format strings for the HTML preamble.
The first element of each list is the language code, as used for
the #+LANGUAGE keyword.
The second element of each list is a format string to format the
preamble itself. This format string can contain these elements:
%t stands for the title.
%a stands for the author's name.
%e stands for the author's email.
%d stands for the date.
If you need to use a \"%\" character, you need to escape it
like that: \"%%\".
See the default value of `org-html-postamble-format' for an
example."
:group 'org-export-html
:type '(alist :key-type (string :tag "Language")
:value-type (string :tag "Format string")))
(defcustom org-html-link-up ""
"Where should the \"UP\" link of exported HTML pages lead?"
:group 'org-export-html
:type '(string :tag "File or URL"))
(defcustom org-html-link-home ""
"Where should the \"HOME\" link of exported HTML pages lead?"
:group 'org-export-html
:type '(string :tag "File or URL"))
(defcustom org-html-home/up-format
"<div id=\"org-div-home-and-up\">
<a accesskey=\"h\" href=\"%s\"> UP </a>
|
<a accesskey=\"H\" href=\"%s\"> HOME </a>
</div>"
"Snippet used to insert the HOME and UP links.
This is a format string, the first %s will receive the UP link,
the second the HOME link. If both `org-html-link-up' and
`org-html-link-home' are empty, the entire snippet will be
ignored."
:group 'org-export-html
:type 'string)
;;;; Template :: Scripts
(define-obsolete-variable-alias
'org-html-style-include-scripts 'org-html-head-include-scripts "24.4")
(defcustom org-html-head-include-scripts t
"Non-nil means include the JavaScript snippets in exported HTML files.
The actual script is defined in `org-html-scripts' and should
not be modified."
:group 'org-export-html
:version "24.4"
:package-version '(Org . "8.0")
:type 'boolean)
;;;; Template :: Styles
(define-obsolete-variable-alias
'org-html-style-include-default 'org-html-head-include-default-style "24.4")
(defcustom org-html-head-include-default-style t
"Non-nil means include the default style in exported HTML files.
The actual style is defined in `org-html-style-default' and
should not be modified. Use `org-html-head' to use your own
style information."
:group 'org-export-html
:version "24.4"
:package-version '(Org . "8.0")
:type 'boolean)
;;;###autoload
(put 'org-html-head-include-default-style 'safe-local-variable 'booleanp)
(define-obsolete-variable-alias 'org-html-style 'org-html-head "24.4")
(defcustom org-html-head ""
"Org-wide head definitions for exported HTML files.
This variable can contain the full HTML structure to provide a
style, including the surrounding HTML tags. You can consider
including definitions for the following classes: title, todo,
done, timestamp, timestamp-kwd, tag, target.
For example, a valid value would be:
<style type=\"text/css\">
<![CDATA[
p { font-weight: normal; color: gray; }
h1 { color: black; }
.title { text-align: center; }
.todo, .timestamp-kwd { color: red; }
.done { color: green; }
]]>
</style>
If you want to refer to an external style, use something like
<link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\" />
As the value of this option simply gets inserted into the HTML
<head> header, you can use it to add any arbitrary text to the
header.
You can set this on a per-file basis using #+HTML_HEAD:,
or for publication projects using the :html-head property."
:group 'org-export-html
:version "24.4"
:package-version '(Org . "8.0")
:type 'string)
;;;###autoload
(put 'org-html-head 'safe-local-variable 'stringp)
(defcustom org-html-head-extra ""
"More head information to add in the HTML output.
You can set this on a per-file basis using #+HTML_HEAD_EXTRA:,
or for publication projects using the :html-head-extra property."
:group 'org-export-html
:version "24.4"
:package-version '(Org . "8.0")
:type 'string)
;;;###autoload
(put 'org-html-head-extra 'safe-local-variable 'stringp)
;;;; Todos
(defcustom org-html-todo-kwd-class-prefix ""
"Prefix to class names for TODO keywords.
Each TODO keyword gets a class given by the keyword itself, with this prefix.
The default prefix is empty because it is nice to just use the keyword
as a class name. But if you get into conflicts with other, existing
CSS classes, then this prefix can be very useful."
:group 'org-export-html
:type 'string)
\f
;;; Internal Functions
(defun org-html-format-inline-image (src &optional
caption label attr standalone-p)
"Format an inline image from SRC.
CAPTION, LABEL and ATTR are optional arguments providing the
caption, the label and the attribute of the image.
When STANDALONE-P is t, wrap the <img.../> into a <div>...</div>."
(let* ((id (if (not label) ""
(format " id=\"%s\"" (org-export-solidify-link-text label))))
(attr (concat attr
(cond
((string-match "\\<alt=" (or attr "")) "")
((string-match "^ltxpng/" src)
(format " alt=\"%s\""
(org-html-encode-plain-text
(org-find-text-property-in-string
'org-latex-src src))))
(t (format " alt=\"%s\""
(file-name-nondirectory src)))))))
(cond
(standalone-p
(let ((img (format "<img src=\"%s\" %s/>" src attr)))
(format "\n<div%s class=\"figure\">%s%s\n</div>"
id (format "\n<p>%s</p>" img)
(when (and caption (not (string= caption "")))
(format "\n<p>%s</p>" caption)))))
(t (format "<img src=\"%s\" %s/>" src (concat attr id))))))
(defun org-html--textarea-block (element)
"Transcode ELEMENT into a textarea block.
ELEMENT is either a src block or an example block."
(let* ((code (car (org-export-unravel-code element)))
(attr (org-export-read-attribute :attr_html element)))
(format "<p>\n<textarea cols=\"%s\" rows=\"%s\">\n%s</textarea>\n</p>"
(or (plist-get attr :width) 80)
(or (plist-get attr :height) (org-count-lines code))
code)))
;;;; Bibliography
(defun org-html-bibliography ()
"Find bibliography, cut it out and return it."
(catch 'exit
(let (beg end (cnt 1) bib)
(save-excursion
(goto-char (point-min))
(when (re-search-forward
"^[ \t]*<div \\(id\\|class\\)=\"bibliography\"" nil t)
(setq beg (match-beginning 0))
(while (re-search-forward "</?div\\>" nil t)
(setq cnt (+ cnt (if (string= (match-string 0) "<div") +1 -1)))
(when (= cnt 0)
(and (looking-at ">") (forward-char 1))
(setq bib (buffer-substring beg (point)))
(delete-region beg (point))
(throw 'exit bib))))
nil))))
;;;; Table
(defun org-html-splice-attributes (tag attributes)
"Return a HTML TAG edited wrt ATTRIBUTES."
(if (not attributes)
tag
(let (oldatt newatt)
(setq oldatt (org-extract-attributes-from-string tag)
tag (pop oldatt)
newatt (cdr (org-extract-attributes-from-string attributes)))
(while newatt
(setq oldatt (plist-put oldatt (pop newatt) (pop newatt))))
(if (string-match ">" tag)
(setq tag
(replace-match (concat (org-attributes-to-string oldatt) ">")
t t tag)))
tag)))
(defun org-export-splice-style (style extra)
"Return STYLE updated wrt EXTRA."
(if (and (stringp extra)
(string-match "\\S-" extra)
(string-match "</style>" style))
(concat (substring style 0 (match-beginning 0))
"\n" extra "\n"
(substring style (match-beginning 0)))
style))
(defun org-html-htmlize-region-for-paste (beg end)
"Convert the region between BEG and END to HTML, using htmlize.el.
This is much like `htmlize-region-for-paste', only that it uses
the settings define in the org-... variables."
(let* ((htmlize-output-type org-html-htmlize-output-type)
(htmlize-css-name-prefix org-html-htmlize-font-prefix)
(htmlbuf (htmlize-region beg end)))
(unwind-protect
(with-current-buffer htmlbuf
(buffer-substring (plist-get htmlize-buffer-places 'content-start)
(plist-get htmlize-buffer-places 'content-end)))
(kill-buffer htmlbuf))))
;;;###autoload
(defun org-html-htmlize-generate-css ()
"Create the CSS for all font definitions in the current Emacs session.
Use this to create face definitions in your CSS style file that can then
be used by code snippets transformed by htmlize.
This command just produces a buffer that contains class definitions for all
faces used in the current Emacs session. You can copy and paste the ones you
need into your CSS file.
If you then set `org-html-htmlize-output-type' to `css', calls
to the function `org-html-htmlize-region-for-paste' will
produce code that uses these same face definitions."
(interactive)
(require 'htmlize)
(and (get-buffer "*html*") (kill-buffer "*html*"))
(with-temp-buffer
(let ((fl (face-list))
(htmlize-css-name-prefix "org-")
(htmlize-output-type 'css)
f i)
(while (setq f (pop fl)
i (and f (face-attribute f :inherit)))
(when (and (symbolp f) (or (not i) (not (listp i))))
(insert (org-add-props (copy-sequence "1") nil 'face f))))
(htmlize-region (point-min) (point-max))))
(org-pop-to-buffer-same-window "*html*")
(goto-char (point-min))
(if (re-search-forward "<style" nil t)
(delete-region (point-min) (match-beginning 0)))
(if (re-search-forward "</style>" nil t)
(delete-region (1+ (match-end 0)) (point-max)))
(beginning-of-line 1)
(if (looking-at " +") (replace-match ""))
(goto-char (point-min)))
(defun org-html--make-string (n string)
"Build a string by concatenating N times STRING."
(let (out) (dotimes (i n out) (setq out (concat string out)))))
(defun org-html-fix-class-name (kwd) ; audit callers of this function
"Turn todo keyword KWD into a valid class name.
Replaces invalid characters with \"_\"."
(save-match-data
(while (string-match "[^a-zA-Z0-9_]" kwd)
(setq kwd (replace-match "_" t t kwd))))
kwd)
(defun org-html-format-footnote-reference (n def refcnt)
"Format footnote reference N with definition DEF into HTML."
(let ((extra (if (= refcnt 1) "" (format ".%d" refcnt))))
(format org-html-footnote-format
(let* ((id (format "fnr.%s%s" n extra))
(href (format " href=\"#fn.%s\"" n))
(attributes (concat " class=\"footref\"" href)))
(org-html--anchor id n attributes)))))
(defun org-html-format-footnotes-section (section-name definitions)
"Format footnotes section SECTION-NAME."
(if (not definitions) ""
(format org-html-footnotes-section section-name definitions)))
(defun org-html-format-footnote-definition (fn)
"Format the footnote definition FN."
(let ((n (car fn)) (def (cdr fn)))
(format
"%s %s\n"
(format org-html-footnote-format
(let* ((id (format "fn.%s" n))
(href (format " href=\"#fnr.%s\"" n))
(attributes (concat " class=\"footnum\"" href)))
(org-html--anchor id n attributes)))
def)))
(defun org-html-footnote-section (info)
"Format the footnote section.
INFO is a plist used as a communication channel."
(let* ((fn-alist (org-export-collect-footnote-definitions
(plist-get info :parse-tree) info))
(fn-alist
(loop for (n type raw) in fn-alist collect
(cons n (if (eq (org-element-type raw) 'org-data)
(org-trim (org-export-data raw info))
(format "<p>%s</p>"
(org-trim (org-export-data raw info))))))))
(when fn-alist
(org-html-format-footnotes-section
(org-html--translate "Footnotes" info)
(format
"\n%s\n"
(mapconcat 'org-html-format-footnote-definition fn-alist "\n"))))))
\f
;;; Template
(defun org-html--build-meta-info (info)
"Return meta tags for exported document.
INFO is a plist used as a communication channel."
(let* ((title (org-export-data (plist-get info :title) info))
(author (and (plist-get info :with-author)
(let ((auth (plist-get info :author)))
(and auth (org-export-data auth info)))))
(date (and (plist-get info :with-date)
(let ((date (plist-get info :date)))
(and date (org-export-data date info)))))
(description (plist-get info :description))
(keywords (plist-get info :keywords)))
(concat
(format "<title>%s</title>\n" title)
(format
"<meta http-equiv=\"Content-Type\" content=\"text/html;charset=%s\"/>\n"
(or (and org-html-coding-system
(fboundp 'coding-system-get)
(coding-system-get org-html-coding-system 'mime-charset))
"iso-8859-1"))
(format "<meta name=\"title\" content=\"%s\"/>\n" title)
(format "<meta name=\"generator\" content=\"Org-mode\"/>\n")
(and date (format "<meta name=\"generated\" content=\"%s\"/>\n" date))
(and author (format "<meta name=\"author\" content=\"%s\"/>\n" author))
(and description
(format "<meta name=\"description\" content=\"%s\"/>\n" description))
(and keywords
(format "<meta name=\"keywords\" content=\"%s\"/>\n" keywords)))))
(defun org-html--build-head (info)
"Return information for the <head>..</head> of the HTML output.
INFO is a plist used as a communication channel."
(org-element-normalize-string
(concat
(when (plist-get info :html-head-include-default-style)
(org-element-normalize-string org-html-style-default))
(org-element-normalize-string (plist-get info :html-head))
(org-element-normalize-string (plist-get info :html-head-extra))
(when (and (plist-get info :html-htmlized-css-url)
(eq org-html-htmlize-output-type 'css))
(format "<link rel=\"stylesheet\" href=\"%s\" type=\"text/css\" />\n"
(plist-get info :html-htmlized-css-url)))
(when (plist-get info :html-head-include-scripts) org-html-scripts))))
(defun org-html--build-mathjax-config (info)
"Insert the user setup into the mathjax template.
INFO is a plist used as a communication channel."
(when (and (memq (plist-get info :with-latex) '(mathjax t))
(org-element-map (plist-get info :parse-tree)
'(latex-fragment latex-environment) 'identity info t))
(let ((template org-html-mathjax-template)
(options org-html-mathjax-options)
(in-buffer (or (plist-get info :html-mathjax) ""))
name val (yes " ") (no "// ") x)
(mapc
(lambda (e)
(setq name (car e) val (nth 1 e))
(if (string-match (concat "\\<" (symbol-name name) ":") in-buffer)
(setq val (car (read-from-string
(substring in-buffer (match-end 0))))))
(if (not (stringp val)) (setq val (format "%s" val)))
(if (string-match (concat "%" (upcase (symbol-name name))) template)
(setq template (replace-match val t t template))))
options)
(setq val (nth 1 (assq 'mathml options)))
(if (string-match (concat "\\<mathml:") in-buffer)
(setq val (car (read-from-string
(substring in-buffer (match-end 0))))))
;; Exchange prefixes depending on mathml setting.
(if (not val) (setq x yes yes no no x))
;; Replace cookies to turn on or off the config/jax lines.
(if (string-match ":MMLYES:" template)
(setq template (replace-match yes t t template)))
(if (string-match ":MMLNO:" template)
(setq template (replace-match no t t template)))
;; Return the modified template.
(org-element-normalize-string template))))
(defun org-html--build-preamble (info)
"Return document preamble as a string, or nil.
INFO is a plist used as a communication channel."
(let ((preamble (plist-get info :html-preamble)))
(when preamble
(let ((preamble-contents
(if (functionp preamble) (funcall preamble info)
(let ((title (org-export-data (plist-get info :title) info))
(date (if (not (plist-get info :with-date)) ""
(org-export-data (plist-get info :date) info)))
(author (if (not (plist-get info :with-author)) ""
(org-export-data (plist-get info :author) info)))
(email (if (not (plist-get info :with-email)) ""
(plist-get info :email))))
(if (stringp preamble)
(format-spec preamble
`((?t . ,title) (?a . ,author)
(?d . ,date) (?e . ,email)))
(format-spec
(or (cadr (assoc (plist-get info :language)
org-html-preamble-format))
(cadr (assoc "en" org-html-preamble-format)))
`((?t . ,title) (?a . ,author)
(?d . ,date) (?e . ,email))))))))
(when (org-string-nw-p preamble-contents)
(concat (format "<%s id=\"%s\">\n"
(nth 1 (assq 'preamble org-html-divs))
(nth 2 (assq 'preamble org-html-divs)))
(org-element-normalize-string preamble-contents)
(format "</%s>\n" (nth 1 (assq 'preamble org-html-divs)))))))))
(defun org-html--build-postamble (info)
"Return document postamble as a string, or nil.
INFO is a plist used as a communication channel."
(let ((postamble (plist-get info :html-postamble)))
(when postamble
(let ((postamble-contents
(if (functionp postamble) (funcall postamble info)
(let ((date (if (not (plist-get info :with-date)) ""
(org-export-data (plist-get info :date) info)))
(author (let ((author (plist-get info :author)))
(and author (org-export-data author info))))
(email (mapconcat
(lambda (e)
(format "<a href=\"mailto:%s\">%s</a>" e e))
(split-string (plist-get info :email) ",+ *")
", "))
(html-validation-link (or org-html-validation-link ""))
(creator-info (plist-get info :creator)))
(cond ((stringp postamble)
(format-spec postamble
`((?a . ,author) (?e . ,email)
(?d . ,date) (?c . ,creator-info)
(?v . ,html-validation-link))))
((eq postamble 'auto)
(concat
(when (plist-get info :time-stamp-file)
(format "<p class=\"date\">%s: %s</p>\n"
(org-html--translate "Date" info)
date))
(when (and (plist-get info :with-author) author)
(format "<p class=\"author\">%s : %s</p>\n"
(org-html--translate "Author" info)
author))
(when (and (plist-get info :with-email) email)
(format "<p class=\"email\">%s </p>\n" email))
(when (plist-get info :with-creator)
(format "<p class=\"creator\">%s</p>\n"
creator-info))
html-validation-link "\n"))
(t (format-spec
(or (cadr (assoc (plist-get info :language)
org-html-postamble-format))
(cadr (assoc "en" org-html-postamble-format)))
`((?a . ,author) (?e . ,email)
(?d . ,date) (?c . ,creator-info)
(?v . ,html-validation-link)))))))))
(when (org-string-nw-p postamble-contents)
(concat
(format "<%s id=\"%s\">\n"
(nth 1 (assq 'postamble org-html-divs))
(nth 2 (assq 'postamble org-html-divs)))
(org-element-normalize-string postamble-contents)
(format "</%s>\n" (nth 1 (assq 'postamble org-html-divs)))))))))
(defun org-html-inner-template (contents info)
"Return body of document string after HTML conversion.
CONTENTS is the transcoded contents string. INFO is a plist
holding export options."
(concat
;; Table of contents.
(let ((depth (plist-get info :with-toc)))
(when depth (org-html-toc depth info)))
;; Document contents.
contents
;; Footnotes section.
(org-html-footnote-section info)
;; Bibliography.
(org-html-bibliography)))
(defun org-html-template (contents info)
"Return complete document string after HTML conversion.
CONTENTS is the transcoded contents string. INFO is a plist
holding export options."
(concat
(format
(or (and (stringp org-html-xml-declaration)
org-html-xml-declaration)
(cdr (assoc (plist-get info :html-extension)
org-html-xml-declaration))
(cdr (assoc "html" org-html-xml-declaration))
"")
(or (and org-html-coding-system
(fboundp 'coding-system-get)
(coding-system-get org-html-coding-system 'mime-charset))
"iso-8859-1"))
"\n"
(plist-get info :html-doctype)
"\n"
(format "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\">\n"
(plist-get info :language) (plist-get info :language))
"<head>\n"
(org-html--build-meta-info info)
(org-html--build-head info)
(org-html--build-mathjax-config info)
"</head>\n"
"<body>\n"
(let ((link-up (org-trim (plist-get info :html-link-up)))
(link-home (org-trim (plist-get info :html-link-home))))
(unless (and (string= link-up "") (string= link-up ""))
(format org-html-home/up-format
(or link-up link-home)
(or link-home link-up))))
;; Preamble.
(org-html--build-preamble info)
;; Document contents.
(format "<%s id=\"%s\">\n"
(nth 1 (assq 'content org-html-divs))
(nth 2 (assq 'content org-html-divs)))
;; Document title.
(let ((title (plist-get info :title)))
(format "<h1 class=\"title\">%s</h1>\n" (org-export-data (or title "") info)))
contents
(format "</%s>\n"
(nth 1 (assq 'content org-html-divs)))
;; Postamble.
(org-html--build-postamble info)
;; Closing document.
"</body>\n</html>"))
(defun org-html--translate (s info)
"Translate string S according to specified language.
INFO is a plist used as a communication channel."
(org-export-translate s :html info))
;;;; Anchor
(defun org-html--anchor (&optional id desc attributes)
"Format a HTML anchor."
(let* ((name (and org-html-allow-name-attribute-in-anchors id))
(attributes (concat (and id (format " id=\"%s\"" id))
(and name (format " name=\"%s\"" name))
attributes)))
(format "<a%s>%s</a>" attributes (or desc ""))))
;;;; Todo
(defun org-html--todo (todo)
"Format TODO keywords into HTML."
(when todo
(format "<span class=\"%s %s%s\">%s</span>"
(if (member todo org-done-keywords) "done" "todo")
org-html-todo-kwd-class-prefix (org-html-fix-class-name todo)
todo)))
;;;; Tags
(defun org-html--tags (tags)
"Format TAGS into HTML."
(when tags
(format "<span class=\"tag\">%s</span>"
(mapconcat
(lambda (tag)
(format "<span class=\"%s\">%s</span>"
(concat org-html-tag-class-prefix
(org-html-fix-class-name tag))
tag))
tags " "))))
;;;; Headline
(defun* org-html-format-headline
(todo todo-type priority text tags
&key level section-number headline-label &allow-other-keys)
"Format a headline in HTML."
(let ((section-number
(when section-number
(format "<span class=\"section-number-%d\">%s</span> "
level section-number)))
(todo (org-html--todo todo))
(tags (org-html--tags tags)))
(concat section-number todo (and todo " ") text
(and tags "   ") tags)))
;;;; Src Code
(defun org-html-fontify-code (code lang)
"Color CODE with htmlize library.
CODE is a string representing the source code to colorize. LANG
is the language used for CODE, as a string, or nil."
(when code
(cond
;; Case 1: No lang. Possibly an example block.
((not lang)
;; Simple transcoding.
(org-html-encode-plain-text code))
;; Case 2: No htmlize or an inferior version of htmlize
((not (and (require 'htmlize nil t) (fboundp 'htmlize-region-for-paste)))
;; Emit a warning.
(message "Cannot fontify src block (htmlize.el >= 1.34 required)")
;; Simple transcoding.
(org-html-encode-plain-text code))
(t
;; Map language
(setq lang (or (assoc-default lang org-src-lang-modes) lang))
(let* ((lang-mode (and lang (intern (format "%s-mode" lang)))))
(cond
;; Case 1: Language is not associated with any Emacs mode
((not (functionp lang-mode))
;; Simple transcoding.
(org-html-encode-plain-text code))
;; Case 2: Default. Fontify code.
(t
;; htmlize
(setq code (with-temp-buffer
;; Switch to language-specific mode.
(funcall lang-mode)
(insert code)
;; Fontify buffer.
(font-lock-fontify-buffer)
;; Remove formatting on newline characters.
(save-excursion
(let ((beg (point-min))
(end (point-max)))
(goto-char beg)
(while (progn (end-of-line) (< (point) end))
(put-text-property (point) (1+ (point)) 'face nil)
(forward-char 1))))
(org-src-mode)
(set-buffer-modified-p nil)
;; Htmlize region.
(org-html-htmlize-region-for-paste
(point-min) (point-max))))
;; Strip any enclosing <pre></pre> tags.
(let* ((beg (and (string-match "\\`<pre[^>]*>\n*" code) (match-end 0)))
(end (and beg (string-match "</pre>\\'" code))))
(if (and beg end) (substring code beg end) code)))))))))
(defun org-html-do-format-code
(code &optional lang refs retain-labels num-start)
"Format CODE string as source code.
Optional arguments LANG, REFS, RETAIN-LABELS and NUM-START are,
respectively, the language of the source code, as a string, an
alist between line numbers and references (as returned by
`org-export-unravel-code'), a boolean specifying if labels should
appear in the source code, and the number associated to the first
line of code."
(let* ((code-lines (org-split-string code "\n"))
(code-length (length code-lines))
(num-fmt
(and num-start
(format "%%%ds: "
(length (number-to-string (+ code-length num-start))))))
(code (org-html-fontify-code code lang)))
(org-export-format-code
code
(lambda (loc line-num ref)
(setq loc
(concat
;; Add line number, if needed.
(when num-start
(format "<span class=\"linenr\">%s</span>"
(format num-fmt line-num)))
;; Transcoded src line.
loc
;; Add label, if needed.
(when (and ref retain-labels) (format " (%s)" ref))))
;; Mark transcoded line as an anchor, if needed.
(if (not ref) loc
(format "<span id=\"coderef-%s\" class=\"coderef-off\">%s</span>"
ref loc)))
num-start refs)))
(defun org-html-format-code (element info)
"Format contents of ELEMENT as source code.
ELEMENT is either an example block or a src block. INFO is
a plist used as a communication channel."
(let* ((lang (org-element-property :language element))
;; Extract code and references.
(code-info (org-export-unravel-code element))
(code (car code-info))
(refs (cdr code-info))
;; Does the src block contain labels?
(retain-labels (org-element-property :retain-labels element))
;; Does it have line numbers?
(num-start (case (org-element-property :number-lines element)
(continued (org-export-get-loc element info))
(new 0))))
(org-html-do-format-code code lang refs retain-labels num-start)))
\f
;;; Tables of Contents
(defun org-html-toc (depth info)
"Build a table of contents.
DEPTH is an integer specifying the depth of the table. INFO is a
plist used as a communication channel. Return the table of
contents as a string, or nil if it is empty."
(let ((toc-entries
(mapcar (lambda (headline)
(cons (org-html--format-toc-headline headline info)
(org-export-get-relative-level headline info)))
(org-export-collect-headlines info depth))))
(when toc-entries
(concat "<div id=\"table-of-contents\">\n"
(format "<h%d>%s</h%d>\n"
org-html-toplevel-hlevel
(org-html--translate "Table of Contents" info)
org-html-toplevel-hlevel)
"<div id=\"text-table-of-contents\">"
(org-html--toc-text toc-entries)
"</div>\n"
"</div>\n"))))
(defun org-html--toc-text (toc-entries)
"Return innards of a table of contents, as a string.
TOC-ENTRIES is an alist where key is an entry title, as a string,
and value is its relative level, as an integer."
(let* ((prev-level (1- (cdar toc-entries)))
(start-level prev-level))
(concat
(mapconcat
(lambda (entry)
(let ((headline (car entry))
(level (cdr entry)))
(concat
(let* ((cnt (- level prev-level))
(times (if (> cnt 0) (1- cnt) (- cnt)))
rtn)
(setq prev-level level)
(concat
(org-html--make-string
times (cond ((> cnt 0) "\n<ul>\n<li>")
((< cnt 0) "</li>\n</ul>\n")))
(if (> cnt 0) "\n<ul>\n<li>" "</li>\n<li>")))
headline)))
toc-entries "")
(org-html--make-string (- prev-level start-level) "</li>\n</ul>\n"))))
(defun org-html--format-toc-headline (headline info)
"Return an appropriate table of contents entry for HEADLINE.
INFO is a plist used as a communication channel."
(let* ((headline-number (org-export-get-headline-number headline info))
(section-number
(and (not (org-export-low-level-p headline info))
(org-export-numbered-headline-p headline info)
(concat (mapconcat 'number-to-string headline-number ".") ". ")))
(tags (and (eq (plist-get info :with-tags) t)
(org-export-get-tags headline info))))
(format "<a href=\"#%s\">%s</a>"
;; Label.
(org-export-solidify-link-text
(or (org-element-property :CUSTOM_ID headline)
(concat "sec-" (mapconcat 'number-to-string
headline-number "-"))))
;; Body.
(concat section-number
(org-export-data-with-translations
(org-export-get-alt-title headline info)
;; Ignore any footnote-reference, link,
;; radio-target and target in table of contents.
(append
'((footnote-reference . ignore)
(link . (lambda (link desc i) desc))
(radio-target . (lambda (radio desc i) desc))
(target . ignore))
(org-export-backend-translate-table 'html))
info)
(and tags "   ") (org-html--tags tags)))))
(defun org-html-list-of-listings (info)
"Build a list of listings.
INFO is a plist used as a communication channel. Return the list
of listings as a string, or nil if it is empty."
(let ((lol-entries (org-export-collect-listings info)))
(when lol-entries
(concat "<div id=\"list-of-listings\">\n"
(format "<h%d>%s</h%d>\n"
org-html-toplevel-hlevel
(org-html--translate "List of Listings" info)
org-html-toplevel-hlevel)
"<div id=\"text-list-of-listings\">\n<ul>\n"
(let ((count 0)
(initial-fmt (org-html--translate "Listing %d:" info)))
(mapconcat
(lambda (entry)
(let ((label (org-element-property :name entry))
(title (org-trim
(org-export-data
(or (org-export-get-caption entry t)
(org-export-get-caption entry))
info))))
(concat
"<li>"
(if (not label)
(concat (format initial-fmt (incf count)) " " title)
(format "<a href=\"#%s\">%s %s</a>"
(org-export-solidify-link-text label)
(format initial-fmt (incf count))
title))
"</li>")))
lol-entries "\n"))
"\n</ul>\n</div>\n</div>"))))
(defun org-html-list-of-tables (info)
"Build a list of tables.
INFO is a plist used as a communication channel. Return the list
of tables as a string, or nil if it is empty."
(let ((lol-entries (org-export-collect-tables info)))
(when lol-entries
(concat "<div id=\"list-of-tables\">\n"
(format "<h%d>%s</h%d>\n"
org-html-toplevel-hlevel
(org-html--translate "List of Tables" info)
org-html-toplevel-hlevel)
"<div id=\"text-list-of-tables\">\n<ul>\n"
(let ((count 0)
(initial-fmt (org-html--translate "Table %d:" info)))
(mapconcat
(lambda (entry)
(let ((label (org-element-property :name entry))
(title (org-trim
(org-export-data
(or (org-export-get-caption entry t)
(org-export-get-caption entry))
info))))
(concat
"<li>"
(if (not label)
(concat (format initial-fmt (incf count)) " " title)
(format "<a href=\"#%s\">%s %s</a>"
(org-export-solidify-link-text label)
(format initial-fmt (incf count))
title))
"</li>")))
lol-entries "\n"))
"\n</ul>\n</div>\n</div>"))))
\f
;;; Transcode Functions
;;;; Bold
(defun org-html-bold (bold contents info)
"Transcode BOLD from Org to HTML.
CONTENTS is the text with bold markup. INFO is a plist holding
contextual information."
(format (or (cdr (assq 'bold org-html-text-markup-alist)) "%s")
contents))
;;;; Center Block
(defun org-html-center-block (center-block contents info)
"Transcode a CENTER-BLOCK element from Org to HTML.
CONTENTS holds the contents of the block. INFO is a plist
holding contextual information."
(format "<div class=\"center\">\n%s</div>" contents))
;;;; Clock
(defun org-html-clock (clock contents info)
"Transcode a CLOCK element from Org to HTML.
CONTENTS is nil. INFO is a plist used as a communication
channel."
(format "<p>
<span class=\"timestamp-wrapper\">
<span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>%s
</span>
</p>"
org-clock-string
(org-translate-time
(org-element-property :raw-value
(org-element-property :value clock)))
(let ((time (org-element-property :duration clock)))
(and time (format " <span class=\"timestamp\">(%s)</span>" time)))))
;;;; Code
(defun org-html-code (code contents info)
"Transcode CODE from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual
information."
(format (or (cdr (assq 'code org-html-text-markup-alist)) "%s")
(org-html-plain-text (org-element-property :value code) info)))
;;;; Drawer
(defun org-html-drawer (drawer contents info)
"Transcode a DRAWER element from Org to HTML.
CONTENTS holds the contents of the block. INFO is a plist
holding contextual information."
(if (functionp org-html-format-drawer-function)
(funcall org-html-format-drawer-function
(org-element-property :drawer-name drawer)
contents)
;; If there's no user defined function: simply
;; display contents of the drawer.
contents))
;;;; Dynamic Block
(defun org-html-dynamic-block (dynamic-block contents info)
"Transcode a DYNAMIC-BLOCK element from Org to HTML.
CONTENTS holds the contents of the block. INFO is a plist
holding contextual information. See `org-export-data'."
contents)
;;;; Entity
(defun org-html-entity (entity contents info)
"Transcode an ENTITY object from Org to HTML.
CONTENTS are the definition itself. INFO is a plist holding
contextual information."
(org-element-property :html entity))
;;;; Example Block
(defun org-html-example-block (example-block contents info)
"Transcode a EXAMPLE-BLOCK element from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual
information."
(if (org-export-read-attribute :attr_html example-block :textarea)
(org-html--textarea-block example-block)
(format "<pre class=\"example\">\n%s</pre>"
(org-html-format-code example-block info))))
;;;; Export Snippet
(defun org-html-export-snippet (export-snippet contents info)
"Transcode a EXPORT-SNIPPET object from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual
information."
(if (eq (org-export-snippet-backend export-snippet) 'html)
(org-element-property :value export-snippet)
(if (< 0 (org-element-property :post-blank export-snippet)) " ")))
;;;; Export Block
(defun org-html-export-block (export-block contents info)
"Transcode a EXPORT-BLOCK element from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual information."
(when (string= (org-element-property :type export-block) "HTML")
(org-remove-indentation (org-element-property :value export-block))))
;;;; Fixed Width
(defun org-html-fixed-width (fixed-width contents info)
"Transcode a FIXED-WIDTH element from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual information."
(format "<pre class=\"example\">\n%s</pre>"
(org-html-do-format-code
(org-remove-indentation
(org-element-property :value fixed-width)))))
;;;; Footnote Reference
(defun org-html-footnote-reference (footnote-reference contents info)
"Transcode a FOOTNOTE-REFERENCE element from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual information."
(concat
;; Insert separator between two footnotes in a row.
(let ((prev (org-export-get-previous-element footnote-reference info)))
(when (eq (org-element-type prev) 'footnote-reference)
org-html-footnote-separator))
(cond
((not (org-export-footnote-first-reference-p footnote-reference info))
(org-html-format-footnote-reference
(org-export-get-footnote-number footnote-reference info)
"IGNORED" 100))
;; Inline definitions are secondary strings.
((eq (org-element-property :type footnote-reference) 'inline)
(org-html-format-footnote-reference
(org-export-get-footnote-number footnote-reference info)
"IGNORED" 1))
;; Non-inline footnotes definitions are full Org data.
(t (org-html-format-footnote-reference
(org-export-get-footnote-number footnote-reference info)
"IGNORED" 1)))))
;;;; Headline
(defun org-html-format-headline--wrap
(headline info &optional format-function &rest extra-keys)
"Transcode a HEADLINE element from Org to HTML.
CONTENTS holds the contents of the headline. INFO is a plist
holding contextual information."
(let* ((level (+ (org-export-get-relative-level headline info)
(1- org-html-toplevel-hlevel)))
(headline-number (org-export-get-headline-number headline info))
(section-number (and (not (org-export-low-level-p headline info))
(org-export-numbered-headline-p headline info)
(mapconcat 'number-to-string
headline-number ".")))
(todo (and (plist-get info :with-todo-keywords)
(let ((todo (org-element-property :todo-keyword headline)))
(and todo (org-export-data todo info)))))
(todo-type (and todo (org-element-property :todo-type headline)))
(priority (and (plist-get info :with-priority)
(org-element-property :priority headline)))
(text (org-export-data (org-element-property :title headline) info))
(tags (and (plist-get info :with-tags)
(org-export-get-tags headline info)))
(headline-label (or (org-element-property :CUSTOM_ID headline)
(concat "sec-" (mapconcat 'number-to-string
headline-number "-"))))
(format-function (cond
((functionp format-function) format-function)
((functionp org-html-format-headline-function)
(function*
(lambda (todo todo-type priority text tags
&allow-other-keys)
(funcall org-html-format-headline-function
todo todo-type priority text tags))))
(t 'org-html-format-headline))))
(apply format-function
todo todo-type priority text tags
:headline-label headline-label :level level
:section-number section-number extra-keys)))
(defun org-html-headline (headline contents info)
"Transcode a HEADLINE element from Org to HTML.
CONTENTS holds the contents of the headline. INFO is a plist
holding contextual information."
;; Empty contents?
(setq contents (or contents ""))
(let* ((numberedp (org-export-numbered-headline-p headline info))
(level (org-export-get-relative-level headline info))
(text (org-export-data (org-element-property :title headline) info))
(todo (and (plist-get info :with-todo-keywords)
(let ((todo (org-element-property :todo-keyword headline)))
(and todo (org-export-data todo info)))))
(todo-type (and todo (org-element-property :todo-type headline)))
(tags (and (plist-get info :with-tags)
(org-export-get-tags headline info)))
(priority (and (plist-get info :with-priority)
(org-element-property :priority headline)))
(section-number (and (org-export-numbered-headline-p headline info)
(mapconcat 'number-to-string
(org-export-get-headline-number
headline info) ".")))
;; Create the headline text.
(full-text (org-html-format-headline--wrap headline info)))
(cond
;; Case 1: This is a footnote section: ignore it.
((org-element-property :footnote-section-p headline) nil)
;; Case 2. This is a deep sub-tree: export it as a list item.
;; Also export as items headlines for which no section
;; format has been found.
((org-export-low-level-p headline info)
;; Build the real contents of the sub-tree.
(let* ((type (if numberedp 'ordered 'unordered))
(itemized-body (org-html-format-list-item
contents type nil nil full-text)))
(concat
(and (org-export-first-sibling-p headline info)
(org-html-begin-plain-list type))
itemized-body
(and (org-export-last-sibling-p headline info)
(org-html-end-plain-list type)))))
;; Case 3. Standard headline. Export it as a section.
(t
(let* ((section-number (mapconcat 'number-to-string
(org-export-get-headline-number
headline info) "-"))
(ids (remove 'nil
(list (org-element-property :CUSTOM_ID headline)
(concat "sec-" section-number)
(org-element-property :ID headline))))
(preferred-id (car ids))
(extra-ids (cdr ids))
(extra-class (org-element-property :HTML_CONTAINER_CLASS headline))
(level1 (+ level (1- org-html-toplevel-hlevel)))
(first-content (car (org-element-contents headline))))
(format "<%s id=\"%s\" class=\"%s\">%s%s</%s>\n"
(if (= 1 (org-export-get-relative-level headline info))
(plist-get info :html-container)
"div")
(format "outline-container-%s"
(or (org-element-property :CUSTOM_ID headline)
section-number))
(concat (format "outline-%d" level1) (and extra-class " ")
extra-class)
(format "\n<h%d id=\"%s\">%s%s</h%d>\n"
level1
preferred-id
(mapconcat
(lambda (x)
(let ((id (org-export-solidify-link-text
(if (org-uuidgen-p x) (concat "ID-" x)
x))))
(org-html--anchor id)))
extra-ids "")
full-text
level1)
;; When there is no section, pretend there is an empty
;; one to get the correct <div class="outline- ...>
;; which is needed by `org-info.js'.
(if (not (eq (org-element-type first-content) 'section))
(concat (org-html-section first-content "" info)
contents)
contents)
(if (= 1 (org-export-get-relative-level headline info))
(plist-get info :html-container)
"div")))))))
;;;; Horizontal Rule
(defun org-html-horizontal-rule (horizontal-rule contents info)
"Transcode an HORIZONTAL-RULE object from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual information."
"<hr/>")
;;;; Inline Src Block
(defun org-html-inline-src-block (inline-src-block contents info)
"Transcode an INLINE-SRC-BLOCK element from Org to HTML.
CONTENTS holds the contents of the item. INFO is a plist holding
contextual information."
(let* ((org-lang (org-element-property :language inline-src-block))
(code (org-element-property :value inline-src-block)))
(error "Cannot export inline src block")))
;;;; Inlinetask
(defun org-html-format-section (text class &optional id)
"Format a section with TEXT into a HTML div with CLASS and ID."
(let ((extra (concat (when id (format " id=\"%s\"" id)))))
(concat (format "<div class=\"%s\"%s>\n" class extra) text "</div>\n")))
(defun org-html-inlinetask (inlinetask contents info)
"Transcode an INLINETASK element from Org to HTML.
CONTENTS holds the contents of the block. INFO is a plist
holding contextual information."
(cond
;; If `org-html-format-inlinetask-function' is provided, call it
;; with appropriate arguments.
((functionp org-html-format-inlinetask-function)
(let ((format-function
(function*
(lambda (todo todo-type priority text tags
&key contents &allow-other-keys)
(funcall org-html-format-inlinetask-function
todo todo-type priority text tags contents)))))
(org-html-format-headline--wrap
inlinetask info format-function :contents contents)))
;; Otherwise, use a default template.
(t (format "<div class=\"inlinetask\">\n<b>%s</b><br/>\n%s</div>"
(org-html-format-headline--wrap inlinetask info)
contents))))
;;;; Italic
(defun org-html-italic (italic contents info)
"Transcode ITALIC from Org to HTML.
CONTENTS is the text with italic markup. INFO is a plist holding
contextual information."
(format (or (cdr (assq 'italic org-html-text-markup-alist)) "%s") contents))
;;;; Item
(defun org-html-checkbox (checkbox)
"Format CHECKBOX into HTML."
(case checkbox (on "<code>[X]</code>")
(off "<code>[ ]</code>")
(trans "<code>[-]</code>")
(t "")))
(defun org-html-format-list-item (contents type checkbox
&optional term-counter-id
headline)
"Format a list item into HTML."
(let ((checkbox (concat (org-html-checkbox checkbox) (and checkbox " "))))
(concat
(case type
(ordered
(let* ((counter term-counter-id)
(extra (if counter (format " value=\"%s\"" counter) "")))
(concat
(format "<li%s>" extra)
(when headline (concat headline "<br/>")))))
(unordered
(let* ((id term-counter-id)
(extra (if id (format " id=\"%s\"" id) "")))
(concat
(format "<li%s>" extra)
(when headline (concat headline "<br/>")))))
(descriptive
(let* ((term term-counter-id))
(setq term (or term "(no term)"))
;; Check-boxes in descriptive lists are associated to tag.
(concat (format "<dt> %s </dt>"
(concat checkbox term))
"<dd>"))))
(unless (eq type 'descriptive) checkbox)
contents
(case type
(ordered "</li>")
(unordered "</li>")
(descriptive "</dd>")))))
(defun org-html-item (item contents info)
"Transcode an ITEM element from Org to HTML.
CONTENTS holds the contents of the item. INFO is a plist holding
contextual information."
(let* ((plain-list (org-export-get-parent item))
(type (org-element-property :type plain-list))
(counter (org-element-property :counter item))
(checkbox (org-element-property :checkbox item))
(tag (let ((tag (org-element-property :tag item)))
(and tag (org-export-data tag info)))))
(org-html-format-list-item
contents type checkbox (or tag counter))))
;;;; Keyword
(defun org-html-keyword (keyword contents info)
"Transcode a KEYWORD element from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual information."
(let ((key (org-element-property :key keyword))
(value (org-element-property :value keyword)))
(cond
((string= key "HTML") value)
;; Invisible targets.
((string= key "TARGET") nil)
((string= key "TOC")
(let ((value (downcase value)))
(cond
((string-match "\\<headlines\\>" value)
(let ((depth (or (and (string-match "[0-9]+" value)
(string-to-number (match-string 0 value)))
(plist-get info :with-toc))))
(org-html-toc depth info)))
((string= "listings" value) (org-html-list-of-listings info))
((string= "tables" value) (org-html-list-of-tables info))))))))
;;;; Latex Environment
(defun org-html-format-latex (latex-frag processing-type)
"Format the LaTeX fragment LATEX-FRAG into HTML."
(let ((cache-relpath "") (cache-dir "") bfn)
(unless (eq processing-type 'mathjax)
(setq bfn (buffer-file-name)
cache-relpath
(concat "ltxpng/"
(file-name-sans-extension
(file-name-nondirectory bfn)))
cache-dir (file-name-directory bfn)))
(with-temp-buffer
(insert latex-frag)
(org-format-latex cache-relpath cache-dir nil "Creating LaTeX Image..."
nil nil processing-type)
(buffer-string))))
(defun org-html-latex-environment (latex-environment contents info)
"Transcode a LATEX-ENVIRONMENT element from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual information."
(let ((processing-type (plist-get info :with-latex))
(latex-frag (org-remove-indentation
(org-element-property :value latex-environment)))
(caption (org-export-data
(org-export-get-caption latex-environment) info))
(attr nil) ; FIXME
(label (org-element-property :name latex-environment)))
(cond
((memq processing-type '(t mathjax))
(org-html-format-latex latex-frag 'mathjax))
((eq processing-type 'dvipng)
(let* ((formula-link (org-html-format-latex
latex-frag processing-type)))
(when (and formula-link
(string-match "file:\\([^]]*\\)" formula-link))
(org-html-format-inline-image
(match-string 1 formula-link) caption label attr t))))
(t latex-frag))))
;;;; Latex Fragment
(defun org-html-latex-fragment (latex-fragment contents info)
"Transcode a LATEX-FRAGMENT object from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual information."
(let ((latex-frag (org-element-property :value latex-fragment))
(processing-type (plist-get info :with-latex)))
(case processing-type
((t mathjax)
(org-html-format-latex latex-frag 'mathjax))
(dvipng
(let* ((formula-link (org-html-format-latex
latex-frag processing-type)))
(when (and formula-link
(string-match "file:\\([^]]*\\)" formula-link))
(org-html-format-inline-image
(match-string 1 formula-link)))))
(t latex-frag))))
;;;; Line Break
(defun org-html-line-break (line-break contents info)
"Transcode a LINE-BREAK object from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual information."
"<br/>\n")
;;;; Link
(defun org-html-link--inline-image (link desc info)
"Return HTML code for an inline image.
LINK is the link pointing to the inline image. INFO is a plist
used as a communication channel."
(let* ((type (org-element-property :type link))
(raw-path (org-element-property :path link))
(path (cond ((member type '("http" "https"))
(concat type ":" raw-path))
((file-name-absolute-p raw-path)
(expand-file-name raw-path))
(t raw-path)))
(parent (org-export-get-parent-element link))
(caption (org-export-data (org-export-get-caption parent) info))
(label (org-element-property :name parent))
(attr (mapconcat #'identity (org-element-property :attr_html parent) " ")))
;; Return proper string, depending on DISPOSITION.
(org-html-format-inline-image
path caption label attr (org-html-standalone-image-p link info))))
(defvar org-html-standalone-image-predicate)
(defun org-html-standalone-image-p (element info &optional predicate)
"Test if ELEMENT is a standalone image for the purpose HTML export.
INFO is a plist holding contextual information.
Return non-nil, if ELEMENT is of type paragraph and it's sole
content, save for whitespaces, is a link that qualifies as an
inline image.
Return non-nil, if ELEMENT is of type link and it's containing
paragraph has no other content save for leading and trailing
whitespaces.
Return nil, otherwise.
Bind `org-html-standalone-image-predicate' to constrain
paragraph further. For example, to check for only captioned
standalone images, do the following.
\(setq org-html-standalone-image-predicate
\(lambda \(paragraph\)
\(org-element-property :caption paragraph\)\)\)"
(let ((paragraph (case (org-element-type element)
(paragraph element)
(link (and (org-export-inline-image-p
element org-html-inline-image-rules)
(org-export-get-parent element)))
(t nil))))
(when (eq (org-element-type paragraph) 'paragraph)
(when (or (not (and (boundp 'org-html-standalone-image-predicate)
(functionp org-html-standalone-image-predicate)))
(funcall org-html-standalone-image-predicate paragraph))
(let ((contents (org-element-contents paragraph)))
(loop for x in contents
with inline-image-count = 0
always (cond
((eq (org-element-type x) 'plain-text)
(not (org-string-nw-p x)))
((eq (org-element-type x) 'link)
(when (org-export-inline-image-p
x org-html-inline-image-rules)
(= (incf inline-image-count) 1)))
(t nil))))))))
(defun org-html-link (link desc info)
"Transcode a LINK object from Org to HTML.
DESC is the description part of the link, or the empty string.
INFO is a plist holding contextual information. See
`org-export-data'."
(let* ((--link-org-files-as-html-maybe
(function
(lambda (raw-path info)
"Treat links to `file.org' as links to `file.html', if needed.
See `org-html-link-org-files-as-html'."
(cond
((and org-html-link-org-files-as-html
(string= ".org"
(downcase (file-name-extension raw-path "."))))
(concat (file-name-sans-extension raw-path) "."
(plist-get info :html-extension)))
(t raw-path)))))
(type (org-element-property :type link))
(raw-path (org-element-property :path link))
;; Ensure DESC really exists, or set it to nil.
(desc (and (not (string= desc "")) desc))
(path
(cond
((member type '("http" "https" "ftp" "mailto"))
(concat type ":" raw-path))
((string= type "file")
;; Treat links to ".org" files as ".html", if needed.
(setq raw-path
(funcall --link-org-files-as-html-maybe raw-path info))
;; If file path is absolute, prepend it with protocol
;; component - "file://".
(when (file-name-absolute-p raw-path)
(setq raw-path
(concat "file://" (expand-file-name raw-path))))
;; Add search option, if any. A search option can be
;; relative to a custom-id or a headline title. Any other
;; option is ignored.
(let ((option (org-element-property :search-option link)))
(cond ((not option) raw-path)
((eq (aref option 0) ?#) (concat raw-path option))
;; External fuzzy link: try to resolve it if path
;; belongs to current project, if any.
((eq (aref option 0) ?*)
(concat
raw-path
(let ((numbers
(org-publish-resolve-external-fuzzy-link
(org-element-property :path link) option)))
(and numbers (concat "#sec-"
(mapconcat 'number-to-string
numbers "-")))))))))
(t raw-path)))
attributes protocol)
;; Extract attributes from parent's paragraph. HACK: Only do this
;; for the first link in parent. This is needed as long as
;; attributes cannot be set on a per link basis.
(and (setq attributes
(let ((parent (org-export-get-parent-element link)))
(if (not (eq (org-element-map parent 'link 'identity info t)
link))
""
(mapconcat
'identity
(let ((att (org-element-property :attr_html parent)))
(unless (and desc att
(string-match (regexp-quote (car att)) desc))
att))
" "))))
(unless (string= attributes "")
(setq attributes (concat " " attributes))))
(cond
;; Image file.
((and (or (eq t org-html-inline-images)
(and org-html-inline-images (not desc)))
(org-export-inline-image-p link org-html-inline-image-rules))
(org-html-link--inline-image link desc info))
;; Radio target: Transcode target's contents and use them as
;; link's description.
((string= type "radio")
(let ((destination (org-export-resolve-radio-link link info)))
(when destination
(format "<a href=\"#%s\"%s>%s</a>"
(org-export-solidify-link-text path)
attributes
(org-export-data (org-element-contents destination) info)))))
;; Links pointing to a headline: Find destination and build
;; appropriate referencing command.
((member type '("custom-id" "fuzzy" "id"))
(let ((destination (if (string= type "fuzzy")
(org-export-resolve-fuzzy-link link info)
(org-export-resolve-id-link link info))))
(case (org-element-type destination)
;; ID link points to an external file.
(plain-text
(let ((fragment (concat "ID-" path))
;; Treat links to ".org" files as ".html", if needed.
(path (funcall --link-org-files-as-html-maybe
destination info)))
(format "<a href=\"%s#%s\"%s>%s</a>"
path fragment attributes (or desc destination))))
;; Fuzzy link points nowhere.
((nil)
(format "<i>%s</i>"
(or desc
(org-export-data
(org-element-property :raw-link link) info))))
;; Fuzzy link points to an invisible target.
(keyword nil)
;; Link points to a headline.
(headline
(let ((href
;; What href to use?
(cond
;; Case 1: Headline is linked via it's CUSTOM_ID
;; property. Use CUSTOM_ID.
((string= type "custom-id")
(org-element-property :CUSTOM_ID destination))
;; Case 2: Headline is linked via it's ID property
;; or through other means. Use the default href.
((member type '("id" "fuzzy"))
(format "sec-%s"
(mapconcat 'number-to-string
(org-export-get-headline-number
destination info) "-")))
(t (error "Shouldn't reach here"))))
;; What description to use?
(desc
;; Case 1: Headline is numbered and LINK has no
;; description or LINK's description matches
;; headline's title. Display section number.
(if (and (org-export-numbered-headline-p destination info)
(or (not desc)
(string= desc (org-element-property
:raw-value destination))))
(mapconcat 'number-to-string
(org-export-get-headline-number
destination info) ".")
;; Case 2: Either the headline is un-numbered or
;; LINK has a custom description. Display LINK's
;; description or headline's title.
(or desc (org-export-data (org-element-property
:title destination) info)))))
(format "<a href=\"#%s\"%s>%s</a>"
(org-export-solidify-link-text href) attributes desc)))
;; Fuzzy link points to a target. Do as above.
(t
(let ((path (org-export-solidify-link-text path)) number)
(unless desc
(setq number (cond
((org-html-standalone-image-p destination info)
(org-export-get-ordinal
(assoc 'link (org-element-contents destination))
info 'link 'org-html-standalone-image-p))
(t (org-export-get-ordinal destination info))))
(setq desc (when number
(if (atom number) (number-to-string number)
(mapconcat 'number-to-string number ".")))))
(format "<a href=\"#%s\"%s>%s</a>"
path attributes (or desc "No description for this link")))))))
;; Coderef: replace link with the reference name or the
;; equivalent line number.
((string= type "coderef")
(let ((fragment (concat "coderef-" path)))
(format "<a href=\"#%s\"%s%s>%s</a>"
fragment
(org-trim
(format (concat "class=\"coderef\""
" onmouseover=\"CodeHighlightOn(this, '%s');\""
" onmouseout=\"CodeHighlightOff(this, '%s');\"")
fragment fragment))
attributes
(format (org-export-get-coderef-format path desc)
(org-export-resolve-coderef path info)))))
;; Link type is handled by a special function.
((functionp (setq protocol (nth 2 (assoc type org-link-protocols))))
(funcall protocol (org-link-unescape path) desc 'html))
;; External link with a description part.
((and path desc) (format "<a href=\"%s\"%s>%s</a>" path attributes desc))
;; External link without a description part.
(path (format "<a href=\"%s\"%s>%s</a>" path attributes path))
;; No path, only description. Try to do something useful.
(t (format "<i>%s</i>" desc)))))
;;;; Paragraph
(defun org-html-paragraph (paragraph contents info)
"Transcode a PARAGRAPH element from Org to HTML.
CONTENTS is the contents of the paragraph, as a string. INFO is
the plist used as a communication channel."
(let* ((parent (org-export-get-parent paragraph))
(parent-type (org-element-type parent))
(style '((footnote-definition
" style=\"display:inline;\" class=\"footnote\""
"<br/>")))
(extra (or (cadr (assoc parent-type style)) ""))
(after (or (nth 1 (cdr (assoc parent-type style))) "")))
(cond
((and (eq (org-element-type parent) 'item)
(= (org-element-property :begin paragraph)
(org-element-property :contents-begin parent)))
;; leading paragraph in a list item have no tags
contents)
((org-html-standalone-image-p paragraph info)
;; standalone image
contents)
(t (format "<p%s>\n%s</p>%s" extra contents after)))))
;;;; Plain List
;; FIXME Maybe arg1 is not needed because <li value="20"> already sets
;; the correct value for the item counter
(defun org-html-begin-plain-list (type &optional arg1)
"Insert the beginning of the HTML list depending on TYPE.
When ARG1 is a string, use it as the start parameter for ordered
lists."
(case type
(ordered
(format "<ol class=\"org-ol\"%s>"
(if arg1 (format " start=\"%d\"" arg1) "")))
(unordered "<ul class=\"org-ul\">")
(descriptive "<dl class=\"org-dl\">")))
(defun org-html-end-plain-list (type)
"Insert the end of the HTML list depending on TYPE."
(case type
(ordered "</ol>")
(unordered "</ul>")
(descriptive "</dl>")))
(defun org-html-plain-list (plain-list contents info)
"Transcode a PLAIN-LIST element from Org to HTML.
CONTENTS is the contents of the list. INFO is a plist holding
contextual information."
(let* (arg1 ;; (assoc :counter (org-element-map plain-list 'item
(type (org-element-property :type plain-list)))
(format "%s\n%s%s"
(org-html-begin-plain-list type)
contents (org-html-end-plain-list type))))
;;;; Plain Text
(defun org-html-convert-special-strings (string)
"Convert special characters in STRING to HTML."
(let ((all org-html-special-string-regexps)
e a re rpl start)
(while (setq a (pop all))
(setq re (car a) rpl (cdr a) start 0)
(while (string-match re string start)
(setq string (replace-match rpl t nil string))))
string))
(defun org-html-encode-plain-text (text)
"Convert plain text characters from TEXT to HTML equivalent.
Possible conversions are set in `org-html-protect-char-alist'."
(mapc
(lambda (pair)
(setq text (replace-regexp-in-string (car pair) (cdr pair) text t t)))
org-html-protect-char-alist)
text)
(defun org-html-plain-text (text info)
"Transcode a TEXT string from Org to HTML.
TEXT is the string to transcode. INFO is a plist holding
contextual information."
(let ((output text))
;; Protect following characters: <, >, &.
(setq output (org-html-encode-plain-text output))
;; Handle smart quotes. Be sure to provide original string since
;; OUTPUT may have been modified.
(when (plist-get info :with-smart-quotes)
(setq output (org-export-activate-smart-quotes output :html info text)))
;; Handle special strings.
(when (plist-get info :with-special-strings)
(setq output (org-html-convert-special-strings output)))
;; Handle break preservation if required.
(when (plist-get info :preserve-breaks)
(setq output
(replace-regexp-in-string
"\\(\\\\\\\\\\)?[ \t]*\n" "<br/>\n" output)))
;; Return value.
output))
;; Planning
(defun org-html-planning (planning contents info)
"Transcode a PLANNING element from Org to HTML.
CONTENTS is nil. INFO is a plist used as a communication
channel."
(let ((span-fmt "<span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>"))
(format
"<p><span class=\"timestamp-wrapper\">%s</span></p>"
(mapconcat
'identity
(delq nil
(list
(let ((closed (org-element-property :closed planning)))
(when closed
(format span-fmt org-closed-string
(org-translate-time
(org-element-property :raw-value closed)))))
(let ((deadline (org-element-property :deadline planning)))
(when deadline
(format span-fmt org-deadline-string
(org-translate-time
(org-element-property :raw-value deadline)))))
(let ((scheduled (org-element-property :scheduled planning)))
(when scheduled
(format span-fmt org-scheduled-string
(org-translate-time
(org-element-property :raw-value scheduled)))))))
" "))))
;;;; Property Drawer
(defun org-html-property-drawer (property-drawer contents info)
"Transcode a PROPERTY-DRAWER element from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual
information."
;; The property drawer isn't exported but we want separating blank
;; lines nonetheless.
"")
;;;; Quote Block
(defun org-html-quote-block (quote-block contents info)
"Transcode a QUOTE-BLOCK element from Org to HTML.
CONTENTS holds the contents of the block. INFO is a plist
holding contextual information."
(format "<blockquote>\n%s</blockquote>" contents))
;;;; Quote Section
(defun org-html-quote-section (quote-section contents info)
"Transcode a QUOTE-SECTION element from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual information."
(let ((value (org-remove-indentation
(org-element-property :value quote-section))))
(when value (format "<pre>\n%s</pre>" value))))
;;;; Section
(defun org-html-section (section contents info)
"Transcode a SECTION element from Org to HTML.
CONTENTS holds the contents of the section. INFO is a plist
holding contextual information."
(let ((parent (org-export-get-parent-headline section)))
;; Before first headline: no container, just return CONTENTS.
(if (not parent) contents
;; Get div's class and id references.
(let* ((class-num (+ (org-export-get-relative-level parent info)
(1- org-html-toplevel-hlevel)))
(section-number
(mapconcat
'number-to-string
(org-export-get-headline-number parent info) "-")))
;; Build return value.
(format "<div class=\"outline-text-%d\" id=\"text-%s\">\n%s</div>"
class-num
(or (org-element-property :CUSTOM_ID parent) section-number)
contents)))))
;;;; Radio Target
(defun org-html-radio-target (radio-target text info)
"Transcode a RADIO-TARGET object from Org to HTML.
TEXT is the text of the target. INFO is a plist holding
contextual information."
(let ((id (org-export-solidify-link-text
(org-element-property :value radio-target))))
(org-html--anchor id text)))
;;;; Special Block
(defun org-html-special-block (special-block contents info)
"Transcode a SPECIAL-BLOCK element from Org to HTML.
CONTENTS holds the contents of the block. INFO is a plist
holding contextual information."
(format "<div class=\"%s\">\n%s\n</div>"
(downcase (org-element-property :type special-block))
contents))
;;;; Src Block
(defun org-html-src-block (src-block contents info)
"Transcode a SRC-BLOCK element from Org to HTML.
CONTENTS holds the contents of the item. INFO is a plist holding
contextual information."
(if (org-export-read-attribute :attr_html src-block :textarea)
(org-html--textarea-block src-block)
(let ((lang (org-element-property :language src-block))
(caption (org-export-get-caption src-block))
(code (org-html-format-code src-block info))
(label (let ((lbl (org-element-property :name src-block)))
(if (not lbl) ""
(format " id=\"%s\""
(org-export-solidify-link-text lbl))))))
(if (not lang) (format "<pre class=\"example\"%s>\n%s</pre>" label code)
(format
"<div class=\"org-src-container\">\n%s%s\n</div>"
(if (not caption) ""
(format "<label class=\"org-src-name\">%s</label>"
(org-export-data caption info)))
(format "\n<pre class=\"src src-%s\"%s>%s</pre>" lang label code))))))
;;;; Statistics Cookie
(defun org-html-statistics-cookie (statistics-cookie contents info)
"Transcode a STATISTICS-COOKIE object from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual information."
(let ((cookie-value (org-element-property :value statistics-cookie)))
(format "<code>%s</code>" cookie-value)))
;;;; Strike-Through
(defun org-html-strike-through (strike-through contents info)
"Transcode STRIKE-THROUGH from Org to HTML.
CONTENTS is the text with strike-through markup. INFO is a plist
holding contextual information."
(format (or (cdr (assq 'strike-through org-html-text-markup-alist)) "%s")
contents))
;;;; Subscript
(defun org-html-subscript (subscript contents info)
"Transcode a SUBSCRIPT object from Org to HTML.
CONTENTS is the contents of the object. INFO is a plist holding
contextual information."
(format "<sub>%s</sub>" contents))
;;;; Superscript
(defun org-html-superscript (superscript contents info)
"Transcode a SUPERSCRIPT object from Org to HTML.
CONTENTS is the contents of the object. INFO is a plist holding
contextual information."
(format "<sup>%s</sup>" contents))
;;;; Tabel Cell
(defun org-html-table-cell (table-cell contents info)
"Transcode a TABLE-CELL element from Org to HTML.
CONTENTS is nil. INFO is a plist used as a communication
channel."
(let* ((table-row (org-export-get-parent table-cell))
(table (org-export-get-parent-table table-cell))
(cell-attrs
(if (not org-html-table-align-individual-fields) ""
(format (if (and (boundp 'org-html-format-table-no-css)
org-html-format-table-no-css)
" align=\"%s\"" " class=\"%s\"")
(org-export-table-cell-alignment table-cell info)))))
(when (or (not contents) (string= "" (org-trim contents)))
(setq contents " "))
(cond
((and (org-export-table-has-header-p table info)
(= 1 (org-export-table-row-group table-row info)))
(concat "\n" (format (car org-html-table-header-tags) "col" cell-attrs)
contents (cdr org-html-table-header-tags)))
((and org-html-table-use-header-tags-for-first-column
(zerop (cdr (org-export-table-cell-address table-cell info))))
(concat "\n" (format (car org-html-table-header-tags) "row" cell-attrs)
contents (cdr org-html-table-header-tags)))
(t (concat "\n" (format (car org-html-table-data-tags) cell-attrs)
contents (cdr org-html-table-data-tags))))))
;;;; Table Row
(defun org-html-table-row (table-row contents info)
"Transcode a TABLE-ROW element from Org to HTML.
CONTENTS is the contents of the row. INFO is a plist used as a
communication channel."
;; Rules are ignored since table separators are deduced from
;; borders of the current row.
(when (eq (org-element-property :type table-row) 'standard)
(let* ((first-rowgroup-p (= 1 (org-export-table-row-group table-row info)))
(rowgroup-tags
(cond
;; Case 1: Row belongs to second or subsequent rowgroups.
((not (= 1 (org-export-table-row-group table-row info)))
'("<tbody>" . "\n</tbody>"))
;; Case 2: Row is from first rowgroup. Table has >=1 rowgroups.
((org-export-table-has-header-p
(org-export-get-parent-table table-row) info)
'("<thead>" . "\n</thead>"))
;; Case 2: Row is from first and only row group.
(t '("<tbody>" . "\n</tbody>")))))
(concat
;; Begin a rowgroup?
(when (org-export-table-row-starts-rowgroup-p table-row info)
(car rowgroup-tags))
;; Actual table row
(concat "\n" (eval (car org-html-table-row-tags))
contents
"\n"
(eval (cdr org-html-table-row-tags)))
;; End a rowgroup?
(when (org-export-table-row-ends-rowgroup-p table-row info)
(cdr rowgroup-tags))))))
;;;; Table
(defun org-html-table-first-row-data-cells (table info)
"Transcode the first row of TABLE.
INFO is a plist used as a communication channel."
(let ((table-row
(org-element-map table 'table-row
(lambda (row)
(unless (eq (org-element-property :type row) 'rule) row))
info 'first-match))
(special-column-p (org-export-table-has-special-column-p table)))
(if (not special-column-p) (org-element-contents table-row)
(cdr (org-element-contents table-row)))))
(defun org-html-table--table.el-table (table info)
"Format table.el tables into HTML.
INFO is a plist used as a communication channel."
(when (eq (org-element-property :type table) 'table.el)
(require 'table)
(let ((outbuf (with-current-buffer
(get-buffer-create "*org-export-table*")
(erase-buffer) (current-buffer))))
(with-temp-buffer
(insert (org-element-property :value table))
(goto-char 1)
(re-search-forward "^[ \t]*|[^|]" nil t)
(table-generate-source 'html outbuf))
(with-current-buffer outbuf
(prog1 (org-trim (buffer-string))
(kill-buffer) )))))
(defun org-html-table (table contents info)
"Transcode a TABLE element from Org to HTML.
CONTENTS is the contents of the table. INFO is a plist holding
contextual information."
(case (org-element-property :type table)
;; Case 1: table.el table. Convert it using appropriate tools.
(table.el (org-html-table--table.el-table table info))
;; Case 2: Standard table.
(t
(let* ((label (org-element-property :name table))
(caption (org-export-get-caption table))
(attributes (mapconcat #'identity
(org-element-property :attr_html table)
" "))
(alignspec
(if (and (boundp 'org-html-format-table-no-css)
org-html-format-table-no-css)
"align=\"%s\"" "class=\"%s\""))
(table-column-specs
(function
(lambda (table info)
(mapconcat
(lambda (table-cell)
(let ((alignment (org-export-table-cell-alignment
table-cell info)))
(concat
;; Begin a colgroup?
(when (org-export-table-cell-starts-colgroup-p
table-cell info)
"\n<colgroup>")
;; Add a column. Also specify it's alignment.
(format "\n<col %s/>" (format alignspec alignment))
;; End a colgroup?
(when (org-export-table-cell-ends-colgroup-p
table-cell info)
"\n</colgroup>"))))
(org-html-table-first-row-data-cells table info) "\n"))))
(table-attributes
(let ((table-tag (plist-get info :html-table-tag)))
(concat
(and (string-match "<table\\(.*\\)>" table-tag)
(match-string 1 table-tag))
(and label (format " id=\"%s\""
(org-export-solidify-link-text label)))
(unless (string= attributes "")
(concat " " attributes))))))
;; Remove last blank line.
(setq contents (substring contents 0 -1))
(format "<table%s>\n%s\n%s\n%s\n</table>"
table-attributes
(if (not caption) ""
(format "<caption>%s</caption>"
(org-export-data caption info)))
(funcall table-column-specs table info)
contents)))))
;;;; Target
(defun org-html-target (target contents info)
"Transcode a TARGET object from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual
information."
(let ((id (org-export-solidify-link-text
(org-element-property :value target))))
(org-html--anchor id)))
;;;; Timestamp
(defun org-html-timestamp (timestamp contents info)
"Transcode a TIMESTAMP object from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual
information."
(let ((value (org-html-plain-text
(org-timestamp-translate timestamp) info)))
(format "<span class=\"timestamp-wrapper\"><span class=\"timestamp\">%s</span></span>"
(replace-regexp-in-string "--" "–" value))))
;;;; Underline
(defun org-html-underline (underline contents info)
"Transcode UNDERLINE from Org to HTML.
CONTENTS is the text with underline markup. INFO is a plist
holding contextual information."
(format (or (cdr (assq 'underline org-html-text-markup-alist)) "%s")
contents))
;;;; Verbatim
(defun org-html-verbatim (verbatim contents info)
"Transcode VERBATIM from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual
information."
(format (or (cdr (assq 'verbatim org-html-text-markup-alist)) "%s")
(org-html-plain-text (org-element-property :value verbatim) info)))
;;;; Verse Block
(defun org-html-verse-block (verse-block contents info)
"Transcode a VERSE-BLOCK element from Org to HTML.
CONTENTS is verse block contents. INFO is a plist holding
contextual information."
;; Replace each newline character with line break. Also replace
;; each blank line with a line break.
(setq contents (replace-regexp-in-string
"^ *\\\\\\\\$" "<br/>\n"
(replace-regexp-in-string
"\\(\\\\\\\\\\)?[ \t]*\n" " <br/>\n" contents)))
;; Replace each white space at beginning of a line with a
;; non-breaking space.
(while (string-match "^[ \t]+" contents)
(let* ((num-ws (length (match-string 0 contents)))
(ws (let (out) (dotimes (i num-ws out)
(setq out (concat out " "))))))
(setq contents (replace-match ws nil t contents))))
(format "<p class=\"verse\">\n%s</p>" contents))
\f
;;; Filter Functions
(defun org-html-final-function (contents backend info)
"Filter to prettify the HTML output.
Prettifying happens if `org-html-pretty-output' is t."
(if (not org-html-pretty-output) contents
(with-temp-buffer
(html-mode)
(insert contents)
(indent-region (point-min) (point-max))
(buffer-substring-no-properties (point-min) (point-max)))))
\f
;;; End-user functions
;;;###autoload
(defun org-html-export-as-html
(&optional async subtreep visible-only body-only ext-plist)
"Export current buffer to an HTML buffer.
If narrowing is active in the current buffer, only export its
narrowed part.
If a region is active, export that region.
A non-nil optional argument ASYNC means the process should happen
asynchronously. The resulting buffer should be accessible
through the `org-export-stack' interface.
When optional argument SUBTREEP is non-nil, export the sub-tree
at point, extracting information from the headline properties
first.
When optional argument VISIBLE-ONLY is non-nil, don't export
contents of hidden elements.
When optional argument BODY-ONLY is non-nil, only write code
between \"<body>\" and \"</body>\" tags.
EXT-PLIST, when provided, is a property list with external
parameters overriding Org default settings, but still inferior to
file-local settings.
Export is done in a buffer named \"*Org HTML Export*\", which
will be displayed when `org-export-show-temporary-export-buffer'
is non-nil."
(interactive)
(if async
(org-export-async-start
(lambda (output)
(with-current-buffer (get-buffer-create "*Org HTML Export*")
(erase-buffer)
(insert output)
(goto-char (point-min))
(set-auto-mode t)
(org-export-add-to-stack (current-buffer) 'html)))
`(org-export-as 'html ,subtreep ,visible-only ,body-only ',ext-plist))
(let ((outbuf (org-export-to-buffer
'html "*Org HTML Export*"
subtreep visible-only body-only ext-plist)))
;; Set major mode.
(with-current-buffer outbuf (set-auto-mode t))
(when org-export-show-temporary-export-buffer
(switch-to-buffer-other-window outbuf)))))
;;;###autoload
(defun org-html-export-to-html
(&optional async subtreep visible-only body-only ext-plist)
"Export current buffer to a HTML file.
If narrowing is active in the current buffer, only export its
narrowed part.
If a region is active, export that region.
A non-nil optional argument ASYNC means the process should happen
asynchronously. The resulting file should be accessible through
the `org-export-stack' interface.
When optional argument SUBTREEP is non-nil, export the sub-tree
at point, extracting information from the headline properties
first.
When optional argument VISIBLE-ONLY is non-nil, don't export
contents of hidden elements.
When optional argument BODY-ONLY is non-nil, only write code
between \"<body>\" and \"</body>\" tags.
EXT-PLIST, when provided, is a property list with external
parameters overriding Org default settings, but still inferior to
file-local settings.
Return output file's name."
(interactive)
(let* ((extension (concat "." org-html-extension))
(file (org-export-output-file-name extension subtreep))
(org-export-coding-system org-html-coding-system))
(if async
(org-export-async-start
(lambda (f) (org-export-add-to-stack f 'html))
(let ((org-export-coding-system org-html-coding-system))
`(expand-file-name
(org-export-to-file
'html ,file ,subtreep ,visible-only ,body-only ',ext-plist))))
(let ((org-export-coding-system org-html-coding-system))
(org-export-to-file
'html file subtreep visible-only body-only ext-plist)))))
;;;###autoload
(defun org-html-publish-to-html (plist filename pub-dir)
"Publish an org file to HTML.
FILENAME is the filename of the Org file to be published. PLIST
is the property list for the given project. PUB-DIR is the
publishing directory.
Return output file name."
(org-publish-org-to 'html filename ".html" plist pub-dir))
\f
;;; FIXME
;;;; org-format-table-html
;;;; org-format-org-table-html
;;;; org-format-table-table-html
;;;; org-table-number-fraction
;;;; org-table-number-regexp
;;;; org-html-table-caption-above
;;;; org-html-inline-image-extensions
;;;; org-export-preferred-target-alist
;;;; class for anchors
;;;; org-export-with-section-numbers, body-only
;;;; org-export-mark-todo-in-toc
;;;; org-html-format-org-link
;;;; (caption (and caption (org-xml-encode-org-text caption)))
;;;; alt = (file-name-nondirectory path)
(provide 'ox-html)
;; Local variables:
;; generated-autoload-file: "org-loaddefs.el"
;; End:
;;; ox-html.el ends here
|