-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathox-twbs.el
3228 lines (2869 loc) · 126 KB
/
ox-twbs.el
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
;;; ox-twbs.el --- Bootstrap compatible HTML Back-End for Org
;; Copyright (C) 2011-2014 Free Software Foundation, Inc.
;; Copyright (C) 2016 Brandon van Beekum
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Jambunathan K <kjambunathan at gmail dot com>
;; Brandon van Beekum <marsmining at gmail dot com>
;; URL: https://github.com/marsmining/ox-twbs
;; Keywords: org, html, publish, twitter, bootstrap
;; Version: 1.1.4
;; This file is not part of GNU Emacs.
;;; Commentary:
;; This library implements an HTML back-end for exporting org-mode
;; docs as HTML compatible with Twitter Bootstrap. Use the function
;; `org-twbs-export-to-html` to export an org file. For publishing
;; use the function `org-twbs-publish-to-html`.
;;; License:
;; This program 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.
;;
;; This program 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; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Code:
;;; Dependencies
(require 'ox-publish)
(require 'format-spec)
(eval-when-compile (require 'cl) (require 'table nil 'noerror))
;;; 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))
(declare-function mm-url-decode-entities "mm-url" ())
;;; Define Back-End
(org-export-define-backend 'twbs
'((bold . org-twbs-bold)
(center-block . org-twbs-center-block)
(clock . org-twbs-clock)
(code . org-twbs-code)
(drawer . org-twbs-drawer)
(dynamic-block . org-twbs-dynamic-block)
(entity . org-twbs-entity)
(example-block . org-twbs-example-block)
(export-block . org-twbs-export-block)
(export-snippet . org-twbs-export-snippet)
(fixed-width . org-twbs-fixed-width)
(footnote-definition . org-twbs-footnote-definition)
(footnote-reference . org-twbs-footnote-reference)
(headline . org-twbs-headline)
(horizontal-rule . org-twbs-horizontal-rule)
(inline-src-block . org-twbs-inline-src-block)
(inlinetask . org-twbs-inlinetask)
(inner-template . org-twbs-inner-template)
(italic . org-twbs-italic)
(item . org-twbs-item)
(keyword . org-twbs-keyword)
(latex-environment . org-twbs-latex-environment)
(latex-fragment . org-twbs-latex-fragment)
(line-break . org-twbs-line-break)
(link . org-twbs-link)
(paragraph . org-twbs-paragraph)
(plain-list . org-twbs-plain-list)
(plain-text . org-twbs-plain-text)
(planning . org-twbs-planning)
(property-drawer . org-twbs-property-drawer)
(quote-block . org-twbs-quote-block)
(quote-section . org-twbs-quote-section)
(radio-target . org-twbs-radio-target)
(section . org-twbs-section)
(special-block . org-twbs-special-block)
(src-block . org-twbs-src-block)
(statistics-cookie . org-twbs-statistics-cookie)
(strike-through . org-twbs-strike-through)
(subscript . org-twbs-subscript)
(superscript . org-twbs-superscript)
(table . org-twbs-table)
(table-cell . org-twbs-table-cell)
(table-row . org-twbs-table-row)
(target . org-twbs-target)
(template . org-twbs-template)
(timestamp . org-twbs-timestamp)
(underline . org-twbs-underline)
(verbatim . org-twbs-verbatim)
(verse-block . org-twbs-verse-block))
:filters-alist '((:filter-final-output . org-twbs-final-function))
:menu-entry
'(?w "Export to TWBS HTML"
((?H "As HTML buffer" org-twbs-export-as-html)
(?h "As HTML file" org-twbs-export-to-html)
(?o "As HTML file and open"
(lambda (a s v b)
(if a (org-twbs-export-to-html t s v b)
(org-open-file (org-twbs-export-to-html nil s v b)))))))
:options-alist
'((:html-extension nil nil org-twbs-extension)
(:html-link-org-files-as-html nil nil org-twbs-link-org-files-as-html)
(:html-container "HTML_CONTAINER" nil org-twbs-container-element)
(:html-link-use-abs-url nil "html-link-use-abs-url" org-twbs-link-use-abs-url)
(:html-link-home "HTML_LINK_HOME" nil org-twbs-link-home)
(:html-link-up "HTML_LINK_UP" nil org-twbs-link-up)
(:html-mathjax "HTML_MATHJAX" nil "" space)
(:html-mathjax-options nil nil org-twbs-mathjax-options)
(:html-mathjax-template nil nil org-twbs-mathjax-template)
(:html-postamble nil "html-postamble" org-twbs-postamble)
(:html-preamble nil "html-preamble" org-twbs-preamble)
(:html-head "HTML_HEAD" nil org-twbs-head newline)
(:html-head-extra "HTML_HEAD_EXTRA" nil org-twbs-head-extra newline)
(:html-head-include-default-style nil "html-style" org-twbs-head-include-default-style)
(:html-head-include-scripts nil "html-scripts" org-twbs-head-include-scripts)
(:html-table-attributes nil nil org-twbs-table-default-attributes)
(:html-table-row-tags nil nil org-twbs-table-row-tags)
(:html-inline-images nil nil org-twbs-inline-images)
(:html-inline-image-rules nil nil org-twbs-inline-image-rules)
;; Redefine regular options.
(:creator "CREATOR" nil org-twbs-creator-string)
(:with-latex nil "tex" org-twbs-with-latex)
(:with-toc nil nil 2)
(:with-creator nil nil t)
(:section-numbers nil nil t)
;; Extra Options
(:gid nil "gid" nil)
(:with-headline-numbers nil "whn" t)
(:with-toc-todo-keywords nil "toc-todo" nil)
(:with-toc-tags nil "toc-tag" nil)
;; Retrieve LaTeX header for fragments.
(:latex-header "LATEX_HEADER" nil nil newline)))
;;; Internal Variables
(defvar org-twbs-format-table-no-css)
(defvar htmlize-buffer-places) ; from htmlize.el
(defvar org-twbs--pre/postamble-class ""
"CSS class used for pre/postamble")
(defconst org-twbs-special-string-regexps
'(("\\\\-" . "­") ; shy
("---\\([^-]\\)" . "—\\1") ; mdash
("--\\([^-]\\)" . "–\\1") ; ndash
("\\.\\.\\." . "…")) ; hellip
"Regular expressions for special string conversion.")
(defconst org-twbs-scripts
"<script>
$(function() {
'use strict';
$('.bs-docs-sidebar li').first().addClass('active');
$(document.body).scrollspy({target: '.bs-docs-sidebar'});
$('.bs-docs-sidebar').affix();
});
</script>"
"Basic JavaScript that is needed by HTML files produced by Org mode.")
(defconst org-twbs-style-default
"<style>
/* org mode styles on top of twbs */
html {
position: relative;
min-height: 100%;
}
body {
font-size: 18px;
margin-bottom: 105px;
}
footer {
position: absolute;
bottom: 0;
width: 100%;
height: 101px;
background-color: #f5f5f5;
}
footer > div {
padding: 10px;
}
footer p {
margin: 0 0 5px;
text-align: center;
font-size: 16px;
}
#table-of-contents {
margin-top: 20px;
margin-bottom: 20px;
}
blockquote p {
font-size: 18px;
}
pre {
font-size: 16px;
}
.footpara {
display: inline-block;
}
figcaption {
font-size: 16px;
color: #666;
font-style: italic;
padding-bottom: 15px;
}
/* from twbs docs */
.bs-docs-sidebar.affix {
position: static;
}
@media (min-width: 768px) {
.bs-docs-sidebar {
padding-left: 20px;
}
}
/* All levels of nav */
.bs-docs-sidebar .nav > li > a {
display: block;
padding: 4px 20px;
font-size: 14px;
font-weight: 500;
color: #999;
}
.bs-docs-sidebar .nav > li > a:hover,
.bs-docs-sidebar .nav > li > a:focus {
padding-left: 19px;
color: #A1283B;
text-decoration: none;
background-color: transparent;
border-left: 1px solid #A1283B;
}
.bs-docs-sidebar .nav > .active > a,
.bs-docs-sidebar .nav > .active:hover > a,
.bs-docs-sidebar .nav > .active:focus > a {
padding-left: 18px;
font-weight: bold;
color: #A1283B;
background-color: transparent;
border-left: 2px solid #A1283B;
}
/* Nav: second level (shown on .active) */
.bs-docs-sidebar .nav .nav {
display: none; /* Hide by default, but at >768px, show it */
padding-bottom: 10px;
}
.bs-docs-sidebar .nav .nav > li > a {
padding-top: 1px;
padding-bottom: 1px;
padding-left: 30px;
font-size: 12px;
font-weight: normal;
}
.bs-docs-sidebar .nav .nav > li > a:hover,
.bs-docs-sidebar .nav .nav > li > a:focus {
padding-left: 29px;
}
.bs-docs-sidebar .nav .nav > .active > a,
.bs-docs-sidebar .nav .nav > .active:hover > a,
.bs-docs-sidebar .nav .nav > .active:focus > a {
padding-left: 28px;
font-weight: 500;
}
/* Nav: third level (shown on .active) */
.bs-docs-sidebar .nav .nav .nav {
padding-bottom: 10px;
}
.bs-docs-sidebar .nav .nav .nav > li > a {
padding-top: 1px;
padding-bottom: 1px;
padding-left: 40px;
font-size: 12px;
font-weight: normal;
}
.bs-docs-sidebar .nav .nav .nav > li > a:hover,
.bs-docs-sidebar .nav .nav .nav > li > a:focus {
padding-left: 39px;
}
.bs-docs-sidebar .nav .nav .nav > .active > a,
.bs-docs-sidebar .nav .nav .nav > .active:hover > a,
.bs-docs-sidebar .nav .nav .nav > .active:focus > a {
padding-left: 38px;
font-weight: 500;
}
/* Show and affix the side nav when space allows it */
@media (min-width: 992px) {
.bs-docs-sidebar .nav > .active > ul {
display: block;
}
/* Widen the fixed sidebar */
.bs-docs-sidebar.affix,
.bs-docs-sidebar.affix-bottom {
width: 213px;
}
.bs-docs-sidebar.affix {
position: fixed; /* Undo the static from mobile first approach */
top: 20px;
}
.bs-docs-sidebar.affix-bottom {
position: absolute; /* Undo the static from mobile first approach */
}
.bs-docs-sidebar.affix .bs-docs-sidenav,.bs-docs-sidebar.affix-bottom .bs-docs-sidenav {
margin-top: 0;
margin-bottom: 0
}
}
@media (min-width: 1200px) {
/* Widen the fixed sidebar again */
.bs-docs-sidebar.affix-bottom,
.bs-docs-sidebar.affix {
width: 263px;
}
}
</style>"
"The default style specification for exported HTML files.
You can use `org-twbs-head' and `org-twbs-head-extra' to add to
this style. If you don't want to include this default style,
customize `org-twbs-head-include-default-style'.")
;;; User Configuration Variables
(defgroup org-export-twbs nil
"Options for exporting Org mode files to HTML compatible with Twitter's Bootstrap."
:tag "Org Export TWBS"
:group 'org-export)
;;;; Bold, etc.
(defcustom org-twbs-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-twbs
:version "24.4"
:package-version '(Org . "8.0")
:type '(alist :key-type (symbol :tag "Markup type")
:value-type (string :tag "Format string"))
:options '(bold code italic strike-through underline verbatim))
(defcustom org-twbs-indent nil
"Non-nil means to indent the generated HTML.
Warning: non-nil may break indentation of source code blocks."
:group 'org-export-twbs
:version "24.4"
:package-version '(Org . "8.0")
:type 'boolean)
(defcustom org-twbs-use-unicode-chars nil
"Non-nil means to use unicode characters instead of HTML entities."
:group 'org-export-twbs
:version "24.4"
:package-version '(Org . "8.0")
:type 'boolean)
;;;; Drawers
(defcustom org-twbs-format-drawer-function
(lambda (name contents) contents)
"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:
The default value simply returns the value of CONTENTS."
:group 'org-export-twbs
:version "24.4"
:package-version '(Org . "8.0")
:type 'function)
;;;; Footnotes
(defcustom org-twbs-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-twbs
:type 'string)
(defcustom org-twbs-footnote-format "<sup>%s</sup>"
"The format for the footnote reference.
%s will be replaced by the footnote reference itself."
:group 'org-export-twbs
:type 'string)
(defcustom org-twbs-footnote-separator "<sup>, </sup>"
"Text used to separate footnotes."
:group 'org-export-twbs
:type 'string)
;;;; Headline
(defcustom org-twbs-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-twbs
:type 'integer)
(defcustom org-twbs-format-headline-function 'ignore
"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-twbs
:version "24.4"
:package-version '(Org . "8.0")
:type 'function)
;;;; HTML-specific
(defcustom org-twbs-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-twbs
:version "24.4"
:package-version '(Org . "8.0")
:type 'boolean)
;;;; Inlinetasks
(defcustom org-twbs-format-inlinetask-function 'ignore
"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-twbs
:version "24.4"
:package-version '(Org . "8.0")
:type 'function)
;;;; LaTeX
(defcustom org-twbs-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-twbs
: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-twbs-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-twbs
:type 'boolean)
;;;; Links :: Inline images
(defcustom org-twbs-inline-images t
"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."
:group 'org-export-twbs
:version "24.4"
:package-version '(Org . "8.1")
:type 'boolean)
(defcustom org-twbs-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."
:group 'org-export-twbs
:version "24.4"
:package-version '(Org . "8.0")
:type '(alist :key-type (string :tag "Type")
:value-type (regexp :tag "Path")))
;;;; Plain Text
(defcustom org-twbs-protect-char-alist
'(("&" . "&")
("<" . "<")
(">" . ">"))
"Alist of characters to be converted by `org-twbs-protect'."
:group 'org-export-twbs
:type '(repeat (cons (string :tag "Character")
(string :tag "HTML equivalent"))))
;;;; Src Block
(defcustom org-twbs-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-twbs-htmlize-generate-css] to extract class definitions."
:group 'org-export-twbs
:type '(choice (const css) (const inline-css)))
(defcustom org-twbs-htmlize-font-prefix "org-"
"The prefix for CSS class names for htmlize font specifications."
:group 'org-export-twbs
:type 'string)
;;;; Table
(defcustom org-twbs-table-default-attributes
'(:class "table table-striped table-bordered table-hover table-condensed")
"Default attributes and values which will be used in table tags.
This is a plist where attributes are symbols, starting with
colons, and values are strings."
:group 'org-export-twbs
:version "24.4"
:package-version '(Org . "8.0")
:type '(plist :key-type (symbol :tag "Property")
:value-type (string :tag "Value")))
(defcustom org-twbs-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-twbs-table-use-header-tags-for-first-column'.
See also the variable `org-twbs-table-align-individual-fields'."
:group 'org-export-twbs
:type '(cons (string :tag "Opening tag") (string :tag "Closing tag")))
(defcustom org-twbs-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-twbs-table-align-individual-fields'."
:group 'org-export-twbs
:type '(cons (string :tag "Opening tag") (string :tag "Closing tag")))
(defcustom org-twbs-table-row-tags '("<tr>" . "</tr>")
"The opening and ending tags for table rows.
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, these variables will be dynamically bound so that
you can reuse them:
`row-number': row number (0 is the first row)
`rowgroup-number': group number of current row
`start-rowgroup-p': non-nil means the row starts a group
`end-rowgroup-p': non-nil means the row ends a group
`top-row-p': non-nil means this is the top row
`bottom-row-p': non-nil means this is the bottom row
For example:
\(setq org-twbs-table-row-tags
(cons '(cond (top-row-p \"<tr class=\\\"tr-top\\\">\")
(bottom-row-p \"<tr class=\\\"tr-bottom\\\">\")
(t (if (= (mod row-number 2) 1)
\"<tr class=\\\"tr-odd\\\">\"
\"<tr class=\\\"tr-even\\\">\")))
\"</tr>\"))
will use the \"tr-top\" and \"tr-bottom\" classes for the top row
and the bottom row, and otherwise alternate between \"tr-odd\" and
\"tr-even\" for odd and even rows."
:group 'org-export-twbs
:type '(cons
(choice :tag "Opening tag"
(string :tag "Specify")
(sexp))
(choice :tag "Closing tag"
(string :tag "Specify")
(sexp))))
(defcustom org-twbs-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-twbs
:type 'boolean)
(defcustom org-twbs-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-twbs
:type 'boolean)
(defcustom org-twbs-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-twbs
:type 'boolean)
;;;; Tags
(defcustom org-twbs-tag-class "badge"
"Class name for tags."
:group 'org-export-twbs
:type 'string)
(defcustom org-twbs-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-twbs
:type 'string)
;;;; Template :: Generic
(defcustom org-twbs-extension "html"
"The extension for exported HTML files."
:group 'org-export-twbs
:type 'string)
(defcustom org-twbs-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-twbs-container-element "div"
"HTML element to use for wrapping top level sections.
Can be set with the in-buffer HTML_CONTAINER property or for
publishing, with :html-container."
:group 'org-export-twbs
:version "24.4"
:package-version '(Org . "8.0")
:type 'string)
(defcustom org-twbs-divs
'((preamble "div" "preamble")
(content "div" "content" "container")
(postamble "footer" "postamble"))
"Alist of the three 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-twbs
: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"))))
(defcustom org-twbs-metadata-timestamp-format "%Y-%m-%d %a %H:%M"
"Format used for timestamps in preamble, postamble and metadata.
See `format-time-string' for more information on its components."
:group 'org-export-twbs
:version "24.4"
:package-version '(Org . "8.0")
:type 'string)
;;;; Template :: Mathjax
(defcustom org-twbs-mathjax-options
'((path "https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_SVG")
(scale "100")
(dscale "100")
(align "center")
(indent "2em")
(messages "none"))
"Options for MathJax setup.
path The path where to find MathJax
scale Scaling for the HTML-CSS backend, omit percentage symbol
dscale Scaling for displayed math, omit percentage symbol
align How to align display math: left, center, or right
indent If align is not center, how far from the left/right side?
messages Should display messages in corner?
You can also customize this for each buffer, using something like
#+HTML_MATHJAX: scale:110 dscale:190 align:left messages:none"
:group 'org-export-twbs
:type '(list :greedy t
(list :tag "path (the path from where to load MathJax.js)"
(const :format " " path) (string))
(list :tag "scale (scaling for math)"
(const :format " " scale) (string))
(list :tag "dscale (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 "messages (show pocessing messages in corner)"
(const :format " " messages)
(choice (const "none")
(const "simple")))))
(defcustom org-twbs-mathjax-template
"
<script type=\"text/x-mathjax-config\">
MathJax.Hub.Config({
displayAlign: \"%ALIGN\",
displayIndent: \"%INDENT\",
messageStyle: \"%MESSAGES\",
\"HTML-CSS\": {
scale: %SCALE,
styles: {
\".MathJax_Display\": {
\"font-size\": \"%DSCALE%\"
}
}
},
\"SVG\": {
scale: %SCALE,
styles: {
\".MathJax_SVG_Display\": {
\"font-size\": \"%DSCALE%\",
\"margin-left\": \"-2.281em\"
}
}
}
});
</script>
<script src=\"%PATH\"></script>"
"The MathJax setup for HTML files."
:group 'org-export-twbs
:type 'string)
;;;; Template :: Postamble
(defcustom org-twbs-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-twbs-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-twbs
: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-twbs-postamble-format
'(("en" "<p class=\"author\">Author: %a (%e)</p>
<p class=\"date\">Date: %d</p>
<p class=\"creator\">%c</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. See `org-export-default-language'.
The second element of each list is a format string to format the
postamble 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.
%c will be replaced by `org-twbs-creator-string'.
%v will be replaced by `org-twbs-validation-link'.
%T will be replaced by the export time.
%C will be replaced by the last modification time.
If you need to use a \"%\" character, you need to escape it
like that: \"%%\"."
:group 'org-export-twbs
:type '(repeat
(list (string :tag "Language")
(string :tag "Format string"))))
(defcustom org-twbs-validation-link
"<a href=\"http://validator.w3.org/check?uri=referer\">Validate</a>"
"Link to HTML validation service."
:group 'org-export-twbs
:type 'string)
(defcustom org-twbs-creator-string
(format "<a href=\"http://www.gnu.org/software/emacs/\">Emacs</a> %s (<a href=\"http://orgmode.org\">Org-mode</a> %s)"
emacs-version
(if (fboundp 'org-version) (org-version) "unknown version"))
"Information about the creator of the HTML document.
This option can also be set on with the CREATOR keyword."
:group 'org-export-twbs
:version "24.4"
:package-version '(Org . "8.0")
:type '(string :tag "Creator string"))
;;;; Template :: Preamble
(defcustom org-twbs-preamble t
"Non-nil means insert a preamble in HTML export.
When t, insert a string as defined by the formatting string in
`org-twbs-preamble-format'. When set to a string, use this
formatting string instead (see `org-twbs-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-twbs
: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-twbs-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. See `org-export-default-language'.
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.
%c will be replaced by `org-twbs-creator-string'.
%v will be replaced by `org-twbs-validation-link'.
%T will be replaced by the export time.
%C will be replaced by the last modification time.
If you need to use a \"%\" character, you need to escape it
like that: \"%%\".
See the default value of `org-twbs-postamble-format' for an
example."
:group 'org-export-twbs
:type '(repeat
(list (string :tag "Language")
(string :tag "Format string"))))
(defcustom org-twbs-link-up ""
"Where should the \"UP\" link of exported HTML pages lead?"
:group 'org-export-twbs
:type '(string :tag "File or URL"))
(defcustom org-twbs-link-home ""
"Where should the \"HOME\" link of exported HTML pages lead?"
:group 'org-export-twbs
:type '(string :tag "File or URL"))
(defcustom org-twbs-link-use-abs-url nil
"Should we prepend relative links with HTML_LINK_HOME?"
:group 'org-export-twbs
:version "24.4"
:package-version '(Org . "8.1")
:type 'boolean)
(defcustom org-twbs-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-twbs-link-up' and
`org-twbs-link-home' are empty, the entire snippet will be
ignored."
:group 'org-export-twbs
:type 'string)
;;;; Template :: Scripts
(define-obsolete-variable-alias
'org-twbs-style-include-scripts 'org-twbs-head-include-scripts "24.4")
(defcustom org-twbs-head-include-scripts t
"Non-nil means include the JavaScript snippets in exported HTML files.
The actual script is defined in `org-twbs-scripts' and should