-
Notifications
You must be signed in to change notification settings - Fork 4
/
ox-context.el
4413 lines (4024 loc) · 175 KB
/
ox-context.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-context --- Org exporter for ConTeXt -*- lexical-binding: t; -*-
;; Copyright (C) 2021 Jason Ross
;; Author: Jason Ross <jasonross1024 at gmail dot com>
;; Keywords: org, ConTeXt
;; Version: 0.1
;; URL: https://github.com/Jason-S-Ross/ox-context
;; Package-Requires: ((emacs "26") (org "9"))
;; This 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 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.
;; TODO Set indentation level for content
;; This can be done by putting content into a temporary buffer, setting
;; (context-mode), and calling (indent-region (point-min) (point-max)).
;; However, this needs to ignore code blocks, so it must be done carefully.
;;
;;; Commentary:
;; This library implements a ConTeXt back-end for Org generic exporter.
;; * Export Commands
;; - `org-context-export-as-context' :: Export as ConTeXt to a temporary
;; buffer. Do not create a file.
;; - `org-context-export-to-context' :: Export as ConTeXt to a file with
;; a ~.mkiv~ extension. For ~myfile.org~, exports as ~myfile.mkiv~,
;; overwriting without warning.
;; - `org-context-export-to-pdf' :: Export as a ConTeXt file and convert it
;; to pdf.
;;
;; * Document-level Keywords
;; The following buffer keywords are added:
;; - ~CONTEXT_HEADER~ :: Adds literal ConTeXt to the document preamble
;; before custom command definitions.
;; - ~CONTEXT_HEADER_EXTRA~ :: Adds literal ConTeXt to the document preamble
;; after custom command definitions.
;; - ~CONTEXT_PRESET~ :: Specifies the document preset to use from
;; `org-context-presets-alist'. See `org-context-preset'.
;; Presets are the primary method used by `ox-context' to specify document
;; structure.
;; - ~DATE~ :: Sets the `metadata:date' ConTeXt document metadata variable. Can
;; be any valid ConTeXt command. If blank, ~\currentdate~ is used.
;; - ~DESCRIPTION~ :: Sets the `metadata:description' ConTeXt document metadata value.
;; - ~KEYWORDS~ :: Sets the `metadata:keywords' ConTeXt document metadata value.
;; - ~LANGUAGE~ :: Sets the `metadata:language' ConTeXt document metatdata value. Adds
;; `\language[%s]' to the preamble.
;; - ~SUBJECT~ :: Sets the `metadata:subject' ConTeXt document metadata value.
;; - ~SUBTITLE~ :: Sets the `metadata:subtitle' ConTeXt document metadata value.
;; - ~TABLE_LOCATION~ :: Specifies ~location~ key for the float wrapping the table.
;; See `org-context-table-location'.
;; - ~TABLE_HEAD~ :: Specifies the ~header~ key for the ~\startxtable~ command.
;; ~repeat~ is supported; see ConTeXt documentation for other values
;; (none known as of this writing).
;; See `org-context-table-head'.
;; - ~TABLE_FOOT~ :: Specifies the ~footer~ key for the ~\startxtable~ command.
;; ~repeat~ is supported; see ConTeXt documentation for other values
;; (none known as of this writing).
;; See `org-context-table-foot'.
;; - ~TABLE_OPTION~ :: Specifies the ~option~ key for the ~\startxtable~ command.
;; As of this writing, the values ~stretch~, ~width~, and ~tight~ are supported.
;; See `org-context-table-option'.
;; - ~TABLE_SPLIT~ :: If "yes", tables are split across pages.
;; See `org-context-table-split'.
;; - ~TABLE_STYLE~ :: Specifies a named ConTeXt table style to pass to the
;; ~\startxtable~ command, defined with the ~\setupxtable~ command.
;; See `org-context-table-style'.
;; - ~TABLE_FLOAT~ :: Specifies a list of arguments to pass to the
;; ~startplacetable~ command, overriding any arguments determined
;; automatically by other options.
;; See `org-context-table-float'.
;;
;;
;; * Options
;; The following additional items are handled from the OPTIONS keyword:
;; - ~syntax~ :: If ~vim~, use the ~t-vim~ ConTeXt module for syntax
;; highlighting. Otherwise, don't highlight source code.
;; - ~numeq~ :: if non-nil, equations are numbered.
;; * In-text Keywords
;; The following additional keywords are supported to add content in text:
;; - ~ATTR_CONTEXT~ :: Adds a plist of context-dependent configuration options
;; for the following element.
;; - ~INDEX~ :: Adds a term to the default ConTeXt index.
;; - ~CINDEX~ :: Adds an `OrgConcept' keyword. Added for compatibility
;; with ~texinfo~ concept keywords.
;; - ~FINDEX~ :: Adds an `OrgFunction' keyword. Added for compatibility
;; with ~texinfo~ function keywords.
;; - ~KINDEX~ :: Adds an `OrgKeystroke' keyword. Added for compatibility
;; with ~texinfo~ keystroke keywords.
;; - ~PINDEX~ :: Adds an `OrgProgram' keyword. Added for compatibility
;; with ~texinfo~ program keywords.
;; - ~TINDEX~ :: Adds an `OrgDataType' keyword. Added for compatibility
;; with ~texinfo~ data-type keywords.
;; - ~VINDEX~ :: Adds an `OrgVariable' keyword. Added for compatibility
;; with ~texinfo~ variable keywords.
;; - ~CONTEXT~ :: Adds raw ConTeXt at this point.
;; - ~TOC~ :: Adds a table of contents or index at this point. Supports the
;; following values:
;; - ~tables~ :: Adds a list of tables.
;; - ~figures~ :: Adds a list of figures.
;; - ~equations~ :: Adds a list of equations.
;; - ~references~ :: Adds a bibliography.
;; - ~definitions~ :: Places the default index.
;; - ~headlines~ :: Places a table of contents. Additional options are supported:
;; - /depth/ :: An integer in the command will limit the toc to this depth.
;; - ~local~ :: If present, limits the scope of the toc to this section.
;; - ~listings~ :: Adds a list of code listings.
;; - ~verses~ :: Adds a list of verse blocks.
;; - ~quotes~ :: Adds a list of quote blocks.
;; - ~examples~ :: Adds a list of example blocks.
;; - ~cp~ :: Adds an index of concepts defined with the ~CINDEX~ keyword.
;; - ~fn~ :: Adds an index of functions defined with the ~FINDEX~ keyword.
;; - ~ky~ :: Adds an index of keystrokes defined with the ~KINDEX~ keyword.
;; - ~pg~ :: Adds an index of programs defined with the ~PINDEX~ keyword.
;; - ~tp~ :: Adds an index of data types defined with the ~TINDEX~ keyword.
;; - ~vr~ :: Adds an index of variables defined with the ~VINDEX keyword.
;; * Additional Inline Configuration of Elements
;; The following elements support additional inline configuration through
;; the ~ATTR_CONTEXT~ keyword.
;; ** Inline images
;; Inline images support configuration for the following keys:
;; - `:float' :: One of the following values:
;; - ~wrap~ :: Places the image in the text, flowing text around it.
;; - ~sideways~ :: Places the image rotated 90 degrees.
;; - ~multicolumn~ :: Places the image to fit in the column instead of the page.
;; - `:width' :: A ConTeXt expression for the desired image width.
;; Otherwise, uses `org-context-image-default-width'.
;; - `:height' :: A ConTeXt expression for the desired image height.
;; Otherwise, uses `org-context-image-default-height'.
;; - `:placement' :: Options to pass to the ~\startplacefigure~ command
;; for the ~location~ key.
;; ** Tables
;; *** Global Options
;; Tables support configuration for the following keys:
;; - `:location' :: Overrides the ~TABLE_LOCATION~ keyword for this table.
;; - `:header' :: Overrides the ~TABLE_HEAD~ keyword for this table.
;; - `:footer' :: Overrides the ~TABLE_FOOT~ keyword for this table.
;; - `:option' :: Overrides the ~TABLE_OPTION~ keyword for this table.
;; - `:split' :: Overrides the ~TABLE_SPLIT~ keyword for this table.
;; - `:table-style' :: Overrides the ~TABLE_STYLE~ keyword for this table.
;; - `:float-style' :: Overrides the ~TABLE_FLOAT~ keyword for this table.
;;
;;
;; *** Content Options
;; Table cells at various positions can be styled with additional keys.
;; Values passed to these keys will be provided as arguments to
;; the ~\startxcell~ macro.
;; The locations of cells to style are specified by the following keys:
;; - `:n' :: "North"; the top row of cells.
;; Defaults to `org-context-table-toprow-style'.
;; - `:e' :: "East"; the right-most column of cells.
;; Defaults to `org-context-table-rightcol-style'.
;; - `:w' :: "West"; the left-most column of cells.
;; Defaults to `org-context-table-leftcol-style'.
;; - `:s' :: "South"; the bottom row of cells.
;; Defaults to `org-context-table-bottomrow-style'.
;; - `:nw' :: "North-West"; the cell in the upper-left corner.
;; Defaults to `org-context-table-topleft-style'.
;; - `:ne' :: "North-East"; the cell in the upper-right.
;; Defaults to `org-context-table-topright-style'.
;; - `:sw' :: "South-West"; the cell in the lower-left.
;; Defaults to `org-context-table-bottomleft-style'.
;; - `:se' :: "South-East"; the cell in the lower-right.
;; Defaults to `org-context-table-bottomright-style'.
;; - `:cgs' :: "Column Group Start"; the cells in the column before a
;; column group boundary.
;; Defaults to `org-context-table-colgroup-start-style'.
;; - `:cge' :: "Column Group End"; the cells in the column after a
;; column group boundary.
;; Defaults to `org-context-table-colgroup-end-style'.
;; - `:rgs' :: "Row Group Start"; the row before a row group boundary.
;; Defaults to `org-context-table-rowgroup-start-style'.
;; - `:rge' :: "Row Group End"; the row after a row group boundary.
;; Defaults to `org-context-table-rowgroup-end-style'.
;; - `:h' :: "Header"; the cells in the header. Defaults to
;; `org-context-table-header-style'.
;; - `:f' :: "Footer"; the cells in the footer. Defaults to
;; `org-context-table-footer-style'.
;; NOTE: If this key is present, tables will attempt to use footers.
;; - `:b' :: "Body"; the cells in the body. Defaults to
;; `org-context-table-body-style'.
;; - `:ht' :: "Header Top"; the cells in the first row of header rows.
;; Defaults to `org-context-table-header-top-style'
;; - `:hm' :: "Header Mid"; the cells in header rows not in the top or bottom.
;; Defaults to `org-context-table-header-mid-style'.
;; - `:hb' :: "Header Bottom"; the cells in the last row of the header rows.
;; Defaults to `org-context-table-header-bottom-style'.
;; - `:ft' :: "Footer Top"; the cells in the last row of footer rows.
;; Defaults to `org-context-table-footer-top-style'.
;; - `:fm' :: "Footer Mid"; the cells in the footer rows not in the top or bottom.
;; Defaults to `org-context-table-footer-mid-style'.
;;
;;
;;
;;; Code:
;;; Dependencies
(require 'cl-lib)
(require 'ox)
(require 'ox-org)
(require 'seq)
(require 'subr-x)
(require 'context)
(require 'texinfmt) ;; Needed for texinfo-part-of-para-regexp
;;; Define Back-end
(org-export-define-backend 'context
'((bold . org-context-bold)
(center-block . org-context-center-block)
(clock . org-context-clock)
(code . org-context-code)
(drawer . org-context-drawer)
(dynamic-block . org-context-dynamic-block)
(entity . org-context-entity)
(example-block . org-context-example-block)
(export-block . org-context-export-block)
(export-snippet . org-context-export-snippet)
(fixed-width . org-context-fixed-width)
(footnote-reference . org-context-footnote-reference)
(headline . org-context-headline)
(horizontal-rule . org-context-horizontal-rule)
(inline-src-block . org-context-inline-src-block)
(inlinetask . org-context-inlinetask)
(inner-template . org-context-inner-template)
(italic . org-context-italic)
(item . org-context-item)
(keyword . org-context-keyword)
(latex-environment . org-context-latex-environment)
(latex-fragment . org-context-latex-fragment)
(line-break . org-context-line-break)
(link . org-context-link)
(node-property . org-context-node-property)
(paragraph . org-context-paragraph)
(plain-list . org-context-plain-list)
(plain-text . org-context-plain-text)
(planning . org-context-planning)
(property-drawer . org-context-property-drawer)
(quote-block . org-context-quote-block)
(radio-target . org-context-radio-target)
(section . org-context-section)
(special-block . org-context-special-block)
(src-block . org-context-src-block)
(statistics-cookie . org-context-statistics-cookie)
(strike-through . org-context-strike-through)
(subscript . org-context-subscript)
(superscript . org-context-superscript)
(table . org-context-table)
(table-cell . org-context-table-cell)
(table-row . org-context-table-row)
(target . org-context-target)
(template . org-context-template)
(timestamp . org-context-timestamp)
(underline . org-context-underline)
(verbatim . org-context-verbatim)
(verse-block . org-context-verse-block)
;;;; Pseudo objects and elements.
(latex-math-block . org-context-math-block))
:menu-entry
'(?C "Export to ConTeXt"
((?c "As ConTeXt file" org-context-export-to-context)
(?C "As ConTeXt buffer" org-context-export-as-context)
(?p "As PDF file" org-context-export-to-pdf)
(?o "As PDF file and open"
(lambda (a s v b)
(if a (org-context-export-to-pdf t s v b)
(org-open-file (org-context-export-to-pdf s v b)))))))
:filters-alist '((:filter-options . org-context-math-block-options-filter)
(:filter-paragraph . org-context-clean-invalid-line-breaks)
(:filter-parse-tree org-context-math-block-tree-filter
org-context-texinfo-tree-filter)
(:filter-verse-block . org-context-clean-invalid-line-breaks))
:options-alist '((:context-block-source-environment nil nil org-context-block-source-environment)
(:context-blockquote-environment nil nil org-context-blockquote-environment)
(:context-bullet-off-command nil nil org-context-bullet-off-command)
(:context-bullet-on-command nil nil org-context-bullet-on-command)
(:context-bullet-trans-command nil nil org-context-bullet-trans-command)
(:context-clock-command nil nil org-context-clock-command)
(:context-description-command nil nil org-context-description-command)
(:context-drawer-command nil nil org-context-drawer-command)
(:context-enumerate-blockquote-empty-environment nil nil org-context-enumerate-blockquote-empty-environment)
(:context-enumerate-blockquote-environment nil nil org-context-enumerate-blockquote-environment)
(:context-enumerate-example-empty-environment nil nil org-context-enumerate-example-empty-environment)
(:context-enumerate-example-environment nil nil org-context-enumerate-example-environment)
(:context-enumerate-listing-empty-environment nil nil org-context-enumerate-listing-empty-environment)
(:context-enumerate-listing-environment nil nil org-context-enumerate-listing-environment)
(:context-enumerate-verse-empty-environment nil nil org-context-enumerate-verse-empty-environment)
(:context-enumerate-verse-environment nil nil org-context-enumerate-verse-environment)
(:context-example-environment nil nil org-context-example-environment)
(:context-export-quotes-alist nil nil org-context-export-quotes-alist)
(:context-fixed-environment nil nil org-context-fixed-environment)
(:context-float-default-placement nil nil org-context-float-default-placement)
(:context-format-clock-function nil nil org-context-format-clock-function)
(:context-format-drawer-function nil nil org-context-format-drawer-function)
(:context-format-headline-function nil nil org-context-format-headline-function)
(:context-format-inlinetask-function nil nil org-context-format-inlinetask-function)
(:context-format-timestamp-function nil nil org-context-format-timestamp-function)
(:context-header "CONTEXT_HEADER" nil nil newline)
(:context-header-extra "CONTEXT_HEADER_EXTRA" nil nil newline)
(:context-headline-command nil nil org-context-headline-command)
(:context-highlighted-langs nil nil org-context-highlighted-langs-alist)
(:context-image-default-height nil nil org-context-image-default-height)
(:context-image-default-option nil nil org-context-image-default-option)
(:context-image-default-scale nil nil org-context-image-default-scale)
(:context-image-default-width nil nil org-context-image-default-width)
(:context-inline-image-rules nil nil org-context-inline-image-rules)
(:context-inline-source-environment nil nil org-context-inline-source-environment)
(:context-inlinetask-command nil nil org-context-inlinetask-command)
(:context-inner-templates nil nil org-context-inner-templates-alist)
(:context-node-property-command nil nil org-context-node-property-command)
(:context-number-equations nil "numeq" org-context-number-equations)
(:context-planning-command nil nil org-context-planning-command)
(:context-preset "CONTEXT_PRESET" nil org-context-preset t)
(:context-presets nil nil org-context-presets-alist)
(:context-property-drawer-environment nil nil org-context-property-drawer-environment)
(:context-snippet "CONTEXT_SNIPPET" nil nil split)
(:context-snippets nil nil org-context-snippets-alist)
(:context-source-label nil nil org-context-source-label)
(:context-syntax-engine nil "syntax" org-context-syntax-engine)
(:context-table-body-style nil nil org-context-table-body-style)
(:context-table-bottomleft-style nil nil org-context-table-bottomleft-style)
(:context-table-bottomright-style nil nil org-context-table-bottomright-style)
(:context-table-bottomrow-style nil nil org-context-table-bottomrow-style)
(:context-table-colgroup-end-style nil nil org-context-table-colgroup-end-style)
(:context-table-colgroup-start-style nil nil org-context-table-colgroup-start-style)
(:context-table-footer-bottom-style nil nil org-context-table-footer-bottom-style)
(:context-table-footer-mid-style nil nil org-context-table-footer-mid-style)
(:context-table-footer-style nil nil org-context-table-footer-style)
(:context-table-footer-top-style nil nil org-context-table-footer-top-style)
(:context-table-header-bottom-style nil nil org-context-table-header-bottom-style)
(:context-table-header-mid-style nil nil org-context-table-header-mid-style)
(:context-table-header-style nil nil org-context-table-header-style)
(:context-table-header-top-style nil nil org-context-table-header-top-style)
(:context-table-leftcol-style nil nil org-context-table-leftcol-style)
(:context-table-rightcol-style nil nil org-context-table-rightcol-style)
(:context-table-rowgroup-end-style nil nil org-context-table-rowgroup-end-style)
(:context-table-rowgroup-start-style nil nil org-context-table-rowgroup-start-style)
(:context-table-topleft-style nil nil org-context-table-topleft-style)
(:context-table-topright-style nil nil org-context-table-topright-style)
(:context-table-toprow-style nil nil org-context-table-toprow-style)
(:context-table-location "TABLE_LOCATION" nil org-context-table-location parse)
(:context-table-header "TABLE_HEAD" nil org-context-table-head parse)
(:context-table-footer "TABLE_FOOT" nil org-context-table-foot parse)
(:context-table-option "TABLE_OPTION" nil org-context-table-option parse)
(:context-table-style "TABLE_STYLE" nil org-context-table-style parse)
(:context-table-float-style "TABLE_FLOAT" nil org-context-table-float-style parse)
(:context-table-split "TABLE_SPLIT" nil org-context-table-split parse)
(:context-texinfo-indices nil nil org-context-texinfo-indices-alist)
(:context-text-markup-alist nil nil org-context-text-markup-alist)
(:context-toc-command-alist nil nil org-context-toc-command-alist)
(:context-toc-title-command nil nil org-context-toc-title-command)
(:context-verse-environment nil nil org-context-verse-environment)
(:context-vim-langs-alist nil nil org-context-vim-langs-alist)
(:date "DATE" nil "\\currentdate" parse)
(:description "DESCRIPTION" nil nil parse)
(:keywords "KEYWORDS" nil nil parse)
(:subject "SUBJECT" nil nil parse)
(:subtitle "SUBTITLE" nil nil parse)))
;;; Constants
(defconst org-context-latex-math-environments-re
(format
"\\`[ \t]*\\\\begin{%s\\*?}"
(regexp-opt
'("equation" "eqnarray" "math" "displaymath"
"align" "gather" "multline" "flalign" "alignat"
"xalignat" "xxalignat"
"subequations"
;; breqn
"dmath" "dseries" "dgroup" "darray"
;; empheq
"empheq")))
"Regexp of LaTeX math environments.")
;;; User configuration variables
(defgroup org-export-context nil
"Options for exporting to ConTeXt."
:tag "Org ConTeXt"
:group 'org-export)
;;;; ConTeXt environments
;;;;; Table Styles
(defcustom org-context-table-body-style '("OrgTableBody" . "")
"The default style name for the body row group in tables.
Cons list of NAME, DEF. If DEF is nil, an empty definition is created."
:group 'org-export-context
:type '(cons (string :tag "Style Name")
(string :tag "Style Definition")))
(defcustom org-context-table-bottomleft-style '("OrgTableBottomLeftCell" . "")
"The default style name for the bottom left cell in tables.
Cons list of NAME, DEF. If DEF is nil, an empty definition is created."
:group 'org-export-context
:type '(cons (string :tag "Style Name")
(string :tag "Style Definition")))
(defcustom org-context-table-bottomright-style '("OrgTableBottomRightCell" . "")
"The default style name for the bottom right cell in tables.
Cons list of NAME, DEF. If DEF is nil, an empty definition is created."
:group 'org-export-context
:type '(cons (string :tag "Style Name")
(string :tag "Style Definition")))
(defcustom org-context-table-bottomrow-style '("OrgTableBottomRow" . "")
"The default style name for the bottom row in tables.
Cons list of NAME, DEF. If DEF is nil, an empty definition is created."
:group 'org-export-context
:type '(cons (string :tag "Style Name")
(string :tag "Style Definition")))
(defcustom org-context-table-colgroup-end-style '("OrgTableColGroupEnd" . "")
"The default style name for columns ending column groups in tables.
Cons list of NAME, DEF. If DEF is nil, an empty definition is created."
:group 'org-export-context
:type '(cons (string :tag "Style Name")
(string :tag "Style Definition")))
(defcustom org-context-table-colgroup-start-style '("OrgTableColGroupStart" . "")
"The default style name for columns starting column groups in tables.
Cons list of NAME, DEF. If DEF is nil, an empty definition is created."
:group 'org-export-context
:type '(cons (string :tag "Style Name")
(string :tag "Style Definition")))
(defcustom org-context-table-footer-bottom-style '("OrgTableFooterBottom" . "")
"The default style name for the bottom row in the footer row group in tables.
Cons list of NAME, DEF. If DEF is nil, an empty definition is created."
:group 'org-export-context
:type '(cons (string :tag "Style Name")
(string :tag "Style Definition")))
(defcustom org-context-table-footer-mid-style '("OrgTableFooterMid" . "")
"The default style name for footer rows where the footer is only one row.
Cons list of NAME, DEF. If DEF is nil, an empty definition is created."
:group 'org-export-context
:type '(cons (string :tag "Style Name")
(string :tag "Style Definition")))
(defcustom org-context-table-footer-style '("OrgTableFooter" . "")
"The default style name for the footer row group in tables.
Cons list of NAME, DEF. If DEF is nil, an empty definition is created."
:group 'org-export-context
:type '(cons (string :tag "Style Name")
(string :tag "Style Definition")))
(defcustom org-context-table-footer-top-style '("OrgTableFooterTop" . "")
"The default style name for the top row in the footer row group in tables.
Cons list of NAME, DEF. If DEF is nil, an empty definition is created."
:group 'org-export-context
:type '(cons (string :tag "Style Name")
(string :tag "Style Definition")))
(defcustom org-context-table-header-bottom-style '("OrgTableHeaderBottom" . "")
"The default style name for the bottom row in the header row group in tables.
Cons list of NAME, DEF. If DEF is nil, an empty definition is created."
:group 'org-export-context
:type '(cons (string :tag "Style Name")
(string :tag "Style Definition")))
(defcustom org-context-table-header-mid-style '("OrgTableHeaderMid" . "")
"The default style name for header rows where the header is only one row.
Cons list of NAME, DEF. If DEF is nil, an empty definition is created."
:group 'org-export-context
:type '(cons (string :tag "Style Name")
(string :tag "Style Definition")))
(defcustom org-context-table-header-style '("OrgTableHeader" . "")
"The default style name for the header row group in tables.
Cons list of NAME, DEF. If DEF is nil, an empty definition is created."
:group 'org-export-context
:type '(cons (string :tag "Style Name")
(string :tag "Style Definition")))
(defcustom org-context-table-header-top-style '("OrgTableHeaderTop" . "")
"The default style name for the top row in the header row group in tables.
Cons list of NAME, DEF. If DEF is nil, an empty definition is created."
:group 'org-export-context
:type '(cons (string :tag "Style Name")
(string :tag "Style Definition")))
(defcustom org-context-table-leftcol-style '("OrgTableLeftCol" . "")
"The default style name for the left column in tables.
Cons list of NAME, DEF. If DEF is nil, an empty definition is created."
:group 'org-export-context
:type '(cons (string :tag "Style Name")
(string :tag "Style Definition")))
(defcustom org-context-table-rightcol-style '("OrgTableRightCol" . "")
"The default style name for the right column in tables.
Cons list of NAME, DEF. If DEF is nil, an empty definition is created."
:group 'org-export-context
:type '(cons (string :tag "Style Name")
(string :tag "Style Definition")))
(defcustom org-context-table-rowgroup-start-style '("OrgTableRowGroupStart" . "")
"The default style name for rows starting row groups in tables.
Cons list of NAME, DEF. If DEF is nil, an empty definition is created."
:group 'org-export-context
:type '(cons (string :tag "Style Name")
(string :tag "Style Definition")))
(defcustom org-context-table-rowgroup-end-style '("OrgTableRowGroupEnd" . "")
"The default style name for rows ending row groups in tables.
Cons list of NAME, DEF. If DEF is nil, an empty definition is created."
:group 'org-export-context
:type '(cons (string :tag "Style Name")
(string :tag "Style Definition")))
(defcustom org-context-table-topleft-style '("OrgTableTopLeftCell" . "")
"The default style name for the top left cell in tables.
Cons list of NAME, DEF. If DEF is nil, an empty definition is created."
:group 'org-export-context
:type '(cons (string :tag "Style Name")
(string :tag "Style Definition")))
(defcustom org-context-table-topright-style '("OrgTableTopRightCell" . "")
"The default style name for the top right cell in tables.
Cons list of NAME, DEF. If DEF is nil, an empty definition is created."
:group 'org-export-context
:type '(cons (string :tag "Style Name")
(string :tag "Style Definition")))
(defcustom org-context-table-toprow-style '("OrgTableTopRow" . "")
"The default style name for the top row in tables.
Cons list of NAME, DEF. If DEF is nil, an empty definition is created."
:group 'org-export-context
:type '(cons (string :tag "Style Name")
(string :tag "Style Definition")))
;;;;; Element Environments
;; These environments wrap block elements to provide the core implementation.
(defcustom org-context-blockquote-environment
'("OrgBlockQuote" . "\\definenarrower[OrgBlockQuote][left=2em,right=2em]")
"The environment name of the block quote environment.
Cons list of NAME, DEF. If nil, block quotes aren't delimited."
:group 'org-export-context
:type '(cons (string :tag "Environment Name")
(string :tag "Environment Definition")))
(defcustom org-context-example-environment
'("OrgExample" . "\\definetyping[OrgExample][escape=yes]")
"The environment name of the example environment.
Cons list of NAME, DEF. If NAME is nil, examples are delimited
in a typing environment. If DEF is nil, a default typing environment
called NAME is created."
:group 'org-export-context
:type '(cons (string :tag "Environment Name")
(string :tag "Environment Definition")))
(defcustom org-context-fixed-environment
'("OrgFixed" . "\\definetextbackground
[OrgFixedBackground]
[backgroundcolor=white,
topoffset=1ex,
leftoffset=1em,
framecolor=black,
location=always,
before={\\blank[line]},
after={\\blank[line]}]
\\definetyping
[OrgFixed]
[before={\\starttextbackground[OrgFixedBackground]},
after={\\stoptextbackground}]")
"The environment name of the fixed-width environment.
Cons list of NAME, DEF. If nil, examples are enclosed in
\"\\starttyping\" / \"\\stoptying\""
:group 'org-export-context
:type '(cons (string :tag "Environment Name")
(string :tag "Environment Definition")))
(defcustom org-context-property-drawer-environment
'("OrgPropDrawer" . "\\definestartstop[OrgPropDrawer]
[before={\\startframedtext[frame=on,width=broad]},
after={\\stopframedtext}]")
"The environment name of the property drawer environment.
Cons list of NAME, DEF. If nil, examples are enclosed in
\"\\startframedtext\" / \"\\stopframedtext\""
:group 'org-export-context
:type '(cons (string :tag "Environment Name")
(string :tag "Environment Definition")))
(defcustom org-context-inline-source-environment
'("OrgInlineSrc" . "\\definetype[OrgInlineSrc]")
"The environment name of the inline source environment.
Cons list of NAME, DEF. If nil, examples are enclosed in
\"\\starttyping\" / \"\\stoptying\""
:group 'org-export-context
:type '(cons (string :tag "Environment Name")
(string :tag "Environment Definition")))
(defcustom org-context-block-source-environment
'("OrgBlkSrc" . "\\definetyping[OrgBlkSrc][escape=yes]")
"The environment name of the block source environment.
Cons list of NAME, DEF. If nil, examples are enclosed in
\"\\starttyping\" / \"\\stoptying\""
:group 'org-export-context
:type '(cons (string :tag "Environment Name")
(string :tag "Environment Definition")))
(defcustom org-context-verse-environment
'("OrgVerse" . "\\definelines[OrgVerse]")
"The environment name of the verse environment.
Cons list of NAME, DEF. If nil, verses aren't delimited."
:group 'org-export-context
:type '(cons (string :tag "Environment Name")
(string :tag "Environment Definition")))
;;;;; Enumeration environments
;; These environments wrap around element environments to allow them
;; to be enumerated in listings.
(defcustom org-context-enumerate-blockquote-empty-environment
'("OrgBlockQuoteEnumEmpty" . "\\defineenumeration
[OrgBlockQuoteEnumEmpty]
[alternative=empty
margin=0pt]")
"The enumeration of the unlabelled blockquote environment.
Cons list of NAME, DEF. By default, shares a counter with
`org-context-enumerate-blockquote-environment'. If nil, block
quotes are not wrapped in an enumeration"
:group 'org-export-context
:type '(cons (string :tag "Environment Name")
(string :tag "Environment Definition")))
(defcustom org-context-enumerate-blockquote-environment
'("OrgBlockQuoteEnum" . "\\defineenumeration
[OrgBlockQuoteEnum]
[OrgBlockQuoteEnumEmpty]
[title=yes,
text=Quote,
alternative=top]")
"The enumeration of the blockquote environment.
Cons list of NAME, DEF. By default, shares a counter with
`org-context-enumerate-blockquote-empty-environment'. If nil,
block quotes are not wrapped in an enumeration"
:group 'org-export-context
:type '(cons (string :tag "Environment Name")
(string :tag "Environment Definition")))
(defcustom org-context-enumerate-example-empty-environment
'("OrgExampleEnumEmpty" . "\\defineenumeration
[OrgExampleEnumEmpty]
[alternative=empty,
margin=0pt]")
"The enumeration of the unlabelled example environment.
Cons list of NAME, DEF. By default, shares a counter with
`org-context-enumerate-example-environment'. If nil, examples are
not wrapped in an enumeration"
:group 'org-export-context
:type '(cons (string :tag "Environment Name")
(string :tag "Environment Definition")))
(defcustom org-context-enumerate-example-environment
'("OrgExampleEnum" . "\\defineenumeration
[OrgExampleEnum]
[OrgExampleEnumEmpty]
[title=yes,
text=Example,
headalign=middle,
alternative=top]")
"The enumeration to wrap examples in.
Cons list of NAME, DEF. By default, shares a counter with
`org-context-enumerate-example-empty-environment' If nil,
examples are not wrapped in an enumeration"
:group 'org-export-context
:type '(cons (string :tag "Environment Name")
(string :tag "Environment Definition")))
(defcustom org-context-enumerate-listing-empty-environment
'("OrgListingEnumEmpty" . "\\defineenumeration
[OrgListingEnumEmpty]
[alternative=empty,
margin=0pt]")
"The enumeration for unlabelled listings.
Cons list of NAME, DEF. By default, shares a counter with
`org-context-enumerate-listing-environment'. If null, listings
are not enumerated."
:group 'org-export-context
:type '(cons (string :tag "Environment Name")
(string :tag "Environment Definition")))
(defcustom org-context-enumerate-listing-environment
'("OrgListingEnum" . "\\defineenumeration
[OrgListingEnum]
[OrgListingEnumEmpty]
[title=yes,
text=Listing,
headalign=middle,
alternative=top]")
"The enumeration for listings.
Cons list of NAME, DEF. By default, shares a counter with
`org-context-enumerate-listing-empty-environment'. If null,
listings are not enumerated."
:group 'org-export-context
:type '(cons (string :tag "Environment Name")
(string :tag "Environment Definition")))
(defcustom org-context-enumerate-verse-empty-environment
'("OrgVerseEnumEmpty" . "\\defineenumeration
[OrgVerseEnumEmpty]
[alternative=empty,
margin=0pt]")
"The environment name that wraps verses to list them.
Cons list of NAME, DEF. If nil, verses aren't enumerated."
:group 'org-export-context
:type '(cons (string :tag "Environment Name")
(string :tag "Environment Definition")))
(defcustom org-context-enumerate-verse-environment '("OrgVerseEnum" . "
\\defineenumeration
[OrgVerseEnum]
[OrgVerseEnumEmpty]
[title=yes,
text=Verse,
alternative=top]")
"The environment name that wraps verses to list them.
Cons list of NAME, DEF. If nil, verses aren't enumerated."
:group 'org-export-context
:type '(cons (string :tag "Environment Name")
(string :tag "Environment Definition")))
;;;; ConTeXt commands
;; These commands provide names and implementations of Org elements
;; in ConTeXt.
(defcustom org-context-bullet-off-command
'("OrgItemOff" . "\\define\\OrgItemOff{\\square}")
"The name of the command that creates bullets for uncompleted items.
Cons list of NAME, DEF. If nil, the command isn't created.
Command should take no arguments."
:group 'org-export-context
:type '(cons (string :tag "Command Name")
(string :tag "Command Definition")))
(defcustom org-context-bullet-on-command
'("OrgItemOn" . "\\define\\OrgItemOn{\\boxplus}")
"The name of the command that creates bullets for completed items.
Cons list of NAME, DEF. If nil, the command isn't created.
Command should take no arguments."
:group 'org-export-context
:type '(cons (string :tag "Command Name")
(string :tag "Command Definition")))
(defcustom org-context-bullet-trans-command
'("OrgItemTrans" . "\\define\\OrgItemTrans{\\boxtimes}")
"The name of the command that creates bullets for partially completed items.
Cons list of NAME, DEF. If nil, the command isn't created.
Command should take no arguments."
:group 'org-export-context
:type '(cons (string :tag "Command Name")
(string :tag "Command Definition")))
(defcustom org-context-clock-command
'("OrgClock" . "\\def\\OrgClock#1[#2]{%
\\getparameters
[OrgClock]
[y=,
m=,
d=,
H=,
M=,
I=,
S=,
#2]
\\doifnot{\\OrgClocky}{}{%
\\date[year=\\OrgClocky,month=\\OrgClockm,day=\\OrgClockd]
[year, --, mm, --, dd]}%
\\doifnot{\\OrgClockH}{}{T\\OrgClockH:\\OrgClockM%
\\doifnot{\\OrgClockS}{}{:\\OrgClockS}}
}")
"The name of the command that formats clocks.
Cons list of NAME, DEF. If nil, the command isn't created.
Command should take the following keyword arguments:
`y': The year
`m': The month
`d': The day
`H': The hour on a 24 hour clock
`I': The hour on a 12 hour clock
`M': The minute
`S': The second"
:group 'org-export-context
:type '(cons (string :tag "Command Name")
(string :tag "Command Definition")))
(defcustom org-context-description-command
'("OrgDesc" . "\\definedescription[OrgDesc]")
"The command name to be used for Org description items.
Cons list of NAME, DEF. If nil, \"\\description\" is used.
Should define a description environment."
:group 'org-export-context
:type '(cons (string :tag "Command Name")
(string :tag "Command Definition")))
(defcustom org-context-drawer-command
'("OrgDrawer" . "\\define[2]\\OrgDrawer{#2}")
"The name of the command that formats drawers.
Cons list of NAME, DEF. If nil, the command isn't created.
Command should take a single argument -- the contents of the
drawer."
:group 'org-export-context
:type '(cons string string))
(defcustom org-context-headline-command
'("OrgHeadline" . "\\def\\OrgHeadline#1[#2]{%
\\getparameters
[OrgHeadline]
[Todo=,
TodoType=,
Priority=,
Text=,
Tags=,
#2]
\\doifnot{\\OrgHeadlineTodo}{}{{\\sansbold{\\smallcaps{\\OrgHeadlineTodo}}\\space}}%
\\doifnot{\\OrgHeadlinePriority}{}{{\\inframed{\\OrgHeadlinePriority}\\space}}%
\\OrgHeadlineText%
\\doifnot{\\OrgHeadlineTags}{}{{\\hfill\\tt\\OrgHeadlineTags}}%
}")
"The name of the command that formats headlines.
Cons list of NAME, DEF. If nil, the command isn't created.
The command should take the following keyword arguments:
`Todo': The todo keyword (if any) for the headline
`TodoType': The type of the todo keyword for the headline
`Priority': The headline's priority (if any)
`Text': The text of the headline
`Tags': The tags of the headline (as a colon-delimited list)"
:group 'org-export-context
:type '(cons (string :tag "Command Name")
(string :tag "Command Definition")))
(defcustom org-context-inlinetask-command
'("OrgInlineTask" . "\\def\\OrgInlineTask#1[#2]{%
\\getparameters
[OrgInlineTask]
[Todo=,
TodoType=,
Priority=,
Title=,
Tags=,
Contents=,
#2]
\\blank[big]
\\startframedtext[align=normal, location=middle, width=0.6\\hsize]
\\startalignment[middle]
\\doifnot{\\OrgInlineTaskTodo}{}{\\sansbold{\\smallcaps{\\OrgInlineTaskTodo}} }%
\\doifnot{\\OrgInlineTaskPriority}{}{\\inframed{\\OrgInlineTaskPriority} }%
\\OrgInlineTaskTitle %
\\doifnot{\\OrgInlineTaskTags}{}{{\\crlf\\tt\\OrgInlineTaskTags} }%
\\crlf%
\\textrule
\\stopalignment
\\OrgInlineTaskContents
\\stopframedtext
\\blank[big]
}")
"The name of the command that formats inline tasks.
Cons list of NAME, DEF.The command should take the following
keyword arguments:
`Todo': The todo keyword (if any) for the headline
`TodoType': The type of the todo keyword for the headline
`Priority': The headline's priority (if any)
`Title': The title of the headline
`Tags': The tags of the headline (as a colon-delimited list)
`Contents': The contents of the inline tasks
If nil, returns a basic command with only the title and contents"
:group 'org-export-context
:type '(cons (string :tag "Command Name")
(string :tag "Command Definition")))
(defcustom org-context-node-property-command
'("OrgNodeProp" . "\\def\\OrgNodeProp#1[#2]{%
\\getparameters
[OrgNodeProp]
[key=,
value=,
#2]%
{\\tt \\OrgNodePropkey: \\OrgNodePropvalue}\\crlf}")
"The name of the command that formats nodes in drawers.
Cons list of NAME, DEF. Command should take the following keyword
arguments:
`key': The node property key
`value': The node property value"
:group 'org-export-context
:type '(cons (string :tag "Command Name")
(string :tag "Command Definition")))
(defcustom org-context-planning-command
'("OrgPlanning" . "\\def\\OrgPlanning#1[#2]{%
\\getparameters
[OrgPlanning]
[ClosedString=,
ClosedTime=,
DeadlineString=,
DeadlineTime=,
ScheduledString=,
ScheduledTime=,
#2]
\\doifnot{\\OrgPlanningClosedString}{}{\\OrgPlanningClosedString\\space}
\\doifnot{\\OrgPlanningClosedTime}{}{\\OrgPlanningClosedTime\\space}
\\doifnot{\\OrgPlanningDeadlineString}{}{\\OrgPlanningDeadlineString\\space}
\\doifnot{\\OrgPlanningDeadlineTime}{}{\\OrgPlanningDeadlineTime\\space}
\\doifnot{\\OrgPlanningScheduledString}{}{\\OrgPlanningScheduledString\\space}
\\doifnot{\\OrgPlanningScheduledTime}{}{\\OrgPlanningScheduledTime\\space}
\\crlf
}")
"The name of the command that formats planning items.
Cons list of NAME, DEF. If nil, just returns a plain text time
stamp and label. The command should accept the following keyword
arguments:
`ClosedString': The locally-defined CLOSED keyword
`ClosedTime': The time the item was closed
`DeadlineString': The locally-defined DEADLINE keyword
`DeadlineTime': The time of the deadline
`ScheduledString': The locally-defined SCHEDULED keyword
`ScheduledTime': The time scheduled"
:group 'org-export-context
:type '(cons (string :tag "Command Name")
(string :tag "Command Definition")))
(defcustom org-context-toc-title-command
'("\\OrgTitleContents" . "\\define\\OrgTitleContents{{\\tfc Contents}}")
"The command that titles the table of contents.
Cons list of NAME, DEF. "
:group 'org-export-context
:type '(cons (string :tag "Command Name")
(string :tag "Command Definitions")))
;;;; Element Configuration
;; These settings configure elements in Org.
(defcustom org-context-export-quotes-alist
'((primary-opening . "\\quotation{")
(primary-closing . "}")
(secondary-opening . "\\quote{")
(secondary-closing . "}")