forked from vikasrawal/orgmk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.html
2981 lines (2585 loc) · 129 KB
/
README.html
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
<!-- <xml version="1.0" encoding="utf-8"> -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta name="generator" content=
"HTML Tidy for Cygwin (vers 1st September 2004), see www.w3.org" />
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Org-mode" />
<meta name="author" content="Fabrice Niessen" />
<meta name="description" content=
"Orgmk completely automates the export of Org documents." />
<meta name="keywords" content=
"org-mode, orgmk, export, automate, emacs, pdf, latex, html" />
<link rel="stylesheet" type="text/css" href=
"http://www.pirilampo.org/styles/bigblow/css/htmlize.css" />
<link rel="stylesheet" type="text/css" href=
"http://www.pirilampo.org/styles/bigblow/css/bigblow.css" />
<link rel="stylesheet" type="text/css" href=
"http://www.pirilampo.org/styles/bigblow/css/hideshow.css" />
<script type="text/javascript" src=
"http://www.pirilampo.org/styles/bigblow/js/jquery-1.11.0.min.js">
</script>
<script type="text/javascript" src=
"http://www.pirilampo.org/styles/bigblow/js/jquery-ui-1.10.2.min.js">
</script>
<script type="text/javascript" src=
"http://www.pirilampo.org/styles/bigblow/js/jquery.localscroll-min.js">
</script>
<script type="text/javascript" src=
"http://www.pirilampo.org/styles/bigblow/js/jquery.scrollTo-1.4.3.1-min.js">
</script>
<script type="text/javascript" src=
"http://www.pirilampo.org/styles/bigblow/js/jquery.zclip.min.js">
</script>
<script type="text/javascript" src=
"http://www.pirilampo.org/styles/bigblow/js/bigblow.js">
</script>
<script type="text/javascript" src=
"http://www.pirilampo.org/styles/bigblow/js/hideshow.js">
</script>
</head>
<body>
<div id="content">
<h1 class="title"></h1>
<div id="outline-container-sec-1" class="outline-2">
<h2 id="sec-1"><span class="section-number-2">1</span> Export Org mode
documents to HTML, PDF, etc. <a href=
"http://opensource.org/licenses/GPL-3.0"><object type="image/svg+xml"
data="http://img.shields.io/:license-gpl-blue.svg">
Sorry, your browser does not support SVG.
</object></a> <a href=
"https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=VCVAS6KPDQ4JC&lc=BE&item_number=orgmk&currency_code=EUR&bn=PP-DonationsBF:btn_donate_LG.gif:NonHosted">
<img src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif"
alt="btn_donate_LG.gif" /></a></h2>
<div class="outline-text-2" id="text-1"></div>
<div id="outline-container-sec-1-1" class="outline-3">
<h3 id="sec-1-1"><span class="section-number-3">1.1</span>
Overview</h3>
<div class="outline-text-3" id="text-1-1"></div>
<div id="outline-container-sec-1-1-1" class="outline-4">
<h4 id="sec-1-1-1"><span class="section-number-4">1.1.1</span>
Description</h4>
<div class="outline-text-4" id="text-1-1-1">
<p>Orgmk is a suite of Bash scripts for <b>automating the
conversion of Org mode documents to different formats</b> (such as
HTML or PDF) from the command line.</p><script src=
"http://platform.twitter.com/widgets.js" type="text/javascript">
</script> <a href="https://twitter.com/share" class="twitter-share-button"
data-via="f_niessen">Tweet</a>
<p>The scripts run on both Unix and Microsoft Windows (with
Cygwin).</p>
</div>
</div>
<div id="outline-container-sec-1-1-2" class="outline-4">
<h4 id="sec-1-1-2"><span class="section-number-4">1.1.2</span>
Objectives</h4>
<div class="outline-text-4" id="text-1-1-2">
<p>The first goal is to <b>be more productive</b>, by running the
export only when the source Org files are updated.</p>
<p>The second goal is to <b>share some common Emacs and Org
configuration inside your</b> <b>team</b>, separately of what you
have in your personal Emacs configuration file.</p>
<p>Finally, the third goal is also to <b>offload compilation into
an external batch Emacs process</b>, allowing you to go on editing
or working while exporting the documents.</p>
</div>
</div>
<div id="outline-container-sec-1-1-3" class="outline-4">
<h4 id="sec-1-1-3"><span class="section-number-4">1.1.3</span>
Quotations</h4>
<div class="outline-text-4" id="text-1-1-3">
<p>“If one has been trying to bulk convert many quickly changing
org-documents, he will appreciate the power and flexibility of this
tool.”<br />
– <i>z27</i></p>
<p>“orgmk is a wonderful tool, and, as far as I know, still
unique.”<br />
– <i>Priyadarshan</i></p>
</div>
</div>
<div id="outline-container-sec-1-1-4" class="outline-4">
<h4 id="sec-1-1-4"><span class="section-number-4">1.1.4</span>
Requirements</h4>
<div class="outline-text-4" id="text-1-1-4"></div>
<div id="outline-container-unnumbered-1" class="outline-5">
<h5 id="unnumbered-1">Emacs 24</h5>
<div class="outline-text-5" id="text-unnumbered-1">
<p>Emacs version 24 (for the “package” facility) must be in your
<code>PATH</code>.</p>
</div>
</div>
<div id="outline-container-unnumbered-2" class="outline-5">
<h5 id="unnumbered-2">Org 8</h5>
<div class="outline-text-5" id="text-unnumbered-2">
<p>Org mode version 8 (or later) is required.</p>
<p>If such a version is not bundled with your Emacs, Org 8 will
be automatically installed – if you accept it! – through
ELPA.</p>
</div>
</div>
<div id="outline-container-unnumbered-3" class="outline-5">
<h5 id="unnumbered-3">LaTeX (PDF)</h5>
<div class="outline-text-5" id="text-unnumbered-3">
<p>A working LaTeX installation is required for exporting to PDF.
If it is not yet installed on your system, install <a href=
"http://www.tug.org/texlive/">TeX Live</a> (for example).</p>
</div>
</div>
</div>
</div>
<div id="outline-container-sec-1-2" class="outline-3">
<h3 id="sec-1-2"><span class="section-number-3">1.2</span> Usage</h3>
<div class="outline-text-3" id="text-1-2">
<p>Org files can have the extension <code>.org</code> or
<code>.txt</code>.</p>
</div>
<div id="outline-container-sec-1-2-1" class="outline-4">
<h4 id="sec-1-2-1"><span class="section-number-4">1.2.1</span>
Standalone scripts</h4>
<div class="outline-text-4" id="text-1-2-1">
<ul class="org-ul">
<li>
<p>For “weaving” files (producing the formatted documentation
files):</p>
<div class="org-src-container">
<pre class="src src-shell">
org2html [OPTION] FILE
org2latex [OPTION] FILE
org2pdf [OPTION] FILE
org2beamerpdf [OPTION] FILE
org2odt [OPTION] FILE
org2txt [OPTION] FILE
</pre>
</div>
</li>
<li>
<p>For “tangling” files:</p>
<div class="org-src-container">
<pre class="src src-shell">
org-tangle FILE
</pre>
</div>
</li>
</ul>
</div>
</div>
<div id="outline-container-sec-1-2-2" class="outline-4">
<h4 id="sec-1-2-2"><span class="section-number-4">1.2.2</span>
Makefile wrapper</h4>
<div class="outline-text-4" id="text-1-2-2">
<div class="org-src-container">
<pre class="src src-shell">
orgmk [OPTION]
orgmk [OPTION] [html | pdf]
orgmk [OPTION] [FILE]
</pre>
</div>
<p>Currently, <code>orgmk</code> does not tangle Org files.</p>
</div>
</div>
</div>
<div id="outline-container-sec-1-3" class="outline-3">
<h3 id="sec-1-3"><span class="section-number-3">1.3</span> Options</h3>
<div class="outline-text-3" id="text-1-3"></div>
<div id="outline-container-sec-1-3-1" class="outline-4">
<h4 id="sec-1-3-1"><span class="section-number-4">1.3.1</span>
Standalone scripts</h4>
<div class="outline-text-4" id="text-1-3-1">
<dl class="org-dl">
<dt><code>-h</code>, <code>--help</code></dt>
<dd>Print usage information and exit.</dd>
<dt><code>-y</code></dt>
<dd>
<p>Authorize the update of the source file (update of dynamic
blocks and re-computation of tables) without confirmation.</p>
<p>Before the conversion, the standalone scripts will try to
<b>update all dynamic blocks and recompute all tables</b> in
the source Org file, a <b>potentially destructive operation</b>
for which the programs require confirmation: in case the source
file gets updated, you will be queried to overwrite the source
file with the updated version of the file – that’s because the
environment variable <code>UPDATE_SRC</code> defaults to
<code>query</code>.</p>
<p>To avoid the question, you can also set that variable to
<code>yes</code> or <code>no</code> in a personal configuration
file, <code>~/.orgmk-rc</code>.</p>
<p>Note that, by design, the command line argument
<code>-y</code> is passed to every
<code>org2<BACKEND></code> script called from
<code>orgmk</code>, so that <code>orgmk</code> doesn’t wait for
answers.</p>
</dd>
<dt><code>--body-only</code></dt>
<dd>Export only body (for HTML and LaTeX).</dd>
</dl>
</div>
</div>
<div id="outline-container-sec-1-3-2" class="outline-4">
<h4 id="sec-1-3-2"><span class="section-number-4">1.3.2</span>
Makefile wrapper</h4>
<div class="outline-text-4" id="text-1-3-2">
<dl class="org-dl">
<dt><code>-h</code>, <code>--help</code></dt>
<dd>Print usage information and exit.</dd>
<dt><code>-r</code>, <code>--recursive</code></dt>
<dd>
<p>Export all Org files <b>under each directory,
recursively</b>.</p>
<p>It just calls <code>orgmk.mk</code> with the argument
<code>ALLSUBDIRS=yes</code>.</p>
<p>By default, <code>orgmk</code> exports all Org files (which
need it) in the current directory only.</p>
</dd>
</dl>
</div>
</div>
</div>
<div id="outline-container-sec-1-4" class="outline-3">
<h3 id="sec-1-4"><span class="section-number-3">1.4</span> Files</h3>
<div class="outline-text-3" id="text-1-4">
<p><i>$HOME/.orgmk-rc</i></p>
</div>
</div>
<div id="outline-container-sec-1-5" class="outline-3">
<h3 id="sec-1-5"><span class="section-number-3">1.5</span>
Examples</h3>
<div class="outline-text-3" id="text-1-5"></div>
<div id="outline-container-sec-1-5-1" class="outline-4">
<h4 id="sec-1-5-1"><span class="section-number-4">1.5.1</span> Update
all documents</h4>
<div class="outline-text-4" id="text-1-5-1">
<p>Regenerate HTML and/or PDF files for Org files that have been
modified.</p>
<div class="org-src-container">
<pre class="src src-shell">
orgmk
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-1-5-2" class="outline-4">
<h4 id="sec-1-5-2"><span class="section-number-4">1.5.2</span> Update
specific types of documents</h4>
<div class="outline-text-4" id="text-1-5-2">
<p>Regenerate HTML only for the Org files that have been
changed.</p>
<div class="org-src-container">
<pre class="src src-shell">
orgmk html
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-1-5-3" class="outline-4">
<h4 id="sec-1-5-3"><span class="section-number-4">1.5.3</span> Update
specific document</h4>
<div class="outline-text-4" id="text-1-5-3">
<p>Regenerate (or create for the first time) the file
<code>thesis.pdf</code> from the Org file <code>thesis.org</code>
or <code>thesis.txt</code>. <b>Don’t require confirmation for
updating the source file.</b></p>
<div class="org-src-container">
<pre class="src src-shell">
orgmk thesis.pdf
</pre>
</div>
<p>Regenerate (or create for the first time) the file
<code>thesis.pdf</code> from the Org file <code>thesis.org</code>.
Require confirmation for updating the source file.</p>
<div class="org-src-container">
<pre class="src src-shell">
org2pdf thesis.org
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-sec-1-6" class="outline-3">
<h3 id="sec-1-6"><span class="section-number-3">1.6</span>
Installation</h3>
<div class="outline-text-3" id="text-1-6">
<p>The installation process consists of creating symbolic links from
the standard <b>final directories</b> on your machine to the
<code>orgmk</code> executables.</p>
</div>
<div id="outline-container-sec-1-6-1" class="outline-4">
<h4 id="sec-1-6-1"><span class="section-number-4">1.6.1</span> New
install</h4>
<div class="outline-text-4" id="text-1-6-1">
<ol class="org-ol">
<li>
<p><b>Extract</b> the latest version of <code>orgmk</code>.</p>
<div class="org-src-container">
<pre class="src src-shell">
git clone git@github.com:fniessen/orgmk.git
</pre>
</div>
</li>
<li>
<p>Create configuration files which record where
<code>orgmk</code> has been extracted on your host machine.</p>
<div class="org-src-container">
<pre class="src src-shell">
make
</pre>
</div>
</li>
<li>
<p>By default, the <code>orgmk</code> executable and the
standalone scripts (<code>org2html</code>,
<code>org2pdf</code>, etc.) are installed to the
<code>/usr/local/bin</code> so that all users are able to run
them.</p>
<p>If you want to <b>change the destination directory</b>,
create a <code>Make.params</code> file with the target
directory. For example:</p>
<div class="org-src-container">
<pre class="src src-makefile">
<span class="org-variable-name">BIN_DIR</span>=~/bin
</pre>
</div>
<p>If needed, add that directory to your <code>PATH</code>.</p>
<p><b>Install</b> <code>orgmk</code> (executable and standalone
scripts that you run) to the <code>BIN_DIR</code> location by
typing:</p>
<div class="org-src-container">
<pre class="src src-shell">
make install
</pre>
</div>
</li>
</ol>
<p>At this point, everything should be ready for use.</p>
</div>
</div>
<div id="outline-container-sec-1-6-2" class="outline-4">
<h4 id="sec-1-6-2"><span class="section-number-4">1.6.2</span>
Makefile for installation</h4>
<div class="outline-text-4" id="text-1-6-2">
<div class="org-src-container">
<pre class="src src-makefile">
<span class="org-comment-delimiter">### </span><span class=
"org-comment">-*- Makefile -*- definition file for Orgmk</span>
<span class="org-comment-delimiter"># </span><span class=
"org-comment">To install `orgmk', type `make' and then `make install'.</span>
<span class="org-variable-name">PWD</span>=$(<span class=
"org-variable-name">shell</span> pwd)
<span class="org-variable-name">BIN_DIR</span>=/usr/local/bin
-include Make.params
<span class="org-variable-name">ORGMK_ROOT</span>=$(<span class=
"org-variable-name">PWD</span>)
<span class="org-variable-name">ORGMK_EL</span>=$(<span class=
"org-variable-name">ORGMK_ROOT</span>)/site-lisp/orgmk.el
<span class="org-comment-delimiter"># </span><span class=
"org-comment">WARNING: ORGMK_EL must contain the correct path to the</span>
<span class="org-comment-delimiter"># </span><span class=
"org-comment">`orgmk.el' file according to the Emacs version used (Windows,</span>
<span class="org-comment-delimiter"># </span><span class=
"org-comment">Cygwin or Linux path)</span>
<span class="org-variable-name">EMACS_SYSTEM_TYPE</span>=$(<span class=
"org-variable-name">shell</span> emacs -batch --eval <span class=
"org-string">"(message \"%s\" system-type)"</span> 2>&1)
ifeq ($(<span class="org-variable-name">EMACS_SYSTEM_TYPE</span>),windows-nt)
<span class="org-variable-name">ORGMK_EL</span>:=<span class=
"org-string">"$(</span><span class="org-variable-name"><span class=
"org-string">shell</span></span><span class=
"org-string"> cygpath --mixed $(</span><span class=
"org-variable-name"><span class="org-string">ORGMK_EL</span></span><span class=
"org-string">))"</span>
endif
<span class="org-variable-name">ORGMK_INIT</span>=orgmk-init
<span class="org-variable-name">ORGMK_SYSTEM_CONFIG</span>=orgmk.conf
<span class="org-variable-name">ORGMK_UPDATE</span>=orgmk-update-src
<span class=
"org-variable-name">ORGMK_UPDATE_CHECK_DIFF</span>=orgmk-update-src-check-diff
<span class="org-variable-name">ORG2HTML</span>=org2html
<span class="org-variable-name">ORG2LATEX</span>=org2latex
<span class="org-variable-name">ORG2PDF</span>=org2pdf
<span class="org-variable-name">ORG2BEAMERPDF</span>=org2beamerpdf
<span class="org-variable-name">ORG2ODT</span>=org2odt
<span class="org-variable-name">ORG2TXT</span>=org2txt
<span class="org-variable-name">ORGTANGLE</span>=org-tangle
<span class="org-variable-name">ORGMK_MAKE_SETUP</span>=orgmk-stow-orgmk.mk
<span class="org-variable-name">ORGMK_MAKE_RUN</span>=orgmk
<span class="org-comment-delimiter">## </span><span class=
"org-comment">MAKE</span>
<span class="org-comment-delimiter"># </span><span class=
"org-comment">Ensure `all' is the default target</span>
<span class=
"org-makefile-targets">all</span>: orgmk-system-config orgmk-stow-mk <span class="org-comment-delimiter"># </span><span class="org-comment">Create Orgmk system files</span>
<span class="org-makefile-targets">.PHONY</span>: orgmk-system-config
<span class=
"org-makefile-targets">orgmk-system-config</span>: <span class="org-comment-delimiter"># </span><span class="org-comment">Create file with location of `orgmk.el'</span>
<span class="org-whitespace-tab"> </span><span class=
"org-type">@</span><span class="org-makefile-shell">echo </span><span class=
"org-makefile-shell"><span class=
"org-string">"Generating system-wide configuration file..."</span></span>
<span class="org-whitespace-tab"> </span>echo <span class=
"org-string">"ORGMK_EL=$(</span><span class="org-variable-name"><span class=
"org-string">ORGMK_EL</span></span><span class=
"org-string">)"</span> > bin/$(<span class=
"org-variable-name">ORGMK_SYSTEM_CONFIG</span>)
<span class="org-whitespace-tab"> </span><span class=
"org-type">@</span><span class="org-makefile-shell">echo</span>
<span class="org-makefile-targets">.PHONY</span>: orgmk-stow-mk
<span class=
"org-makefile-targets">orgmk-stow-mk</span>: <span class="org-comment-delimiter"># </span><span class="org-comment">Create core file for `orgmk'</span>
<span class="org-whitespace-tab"> </span><span class=
"org-type">@</span><span class="org-makefile-shell">echo </span><span class=
"org-makefile-shell"><span class=
"org-string">"Generating setup file..."</span></span>
<span class="org-whitespace-tab"> </span>echo <span class=
"org-string">"#!/bin/sh"</span> > bin/$(<span class=
"org-variable-name">ORGMK_MAKE_SETUP</span>)
<span class="org-whitespace-tab"> </span>echo <span class=
"org-string">"ln -f -s $(</span><span class="org-variable-name"><span class=
"org-string">PWD</span></span><span class=
"org-string">)/bin/orgmk.mk orgmk.mk"</span> >> bin/$(<span class=
"org-variable-name">ORGMK_MAKE_SETUP</span>)
<span class="org-whitespace-tab"> </span>chmod u+x bin/$(<span class=
"org-variable-name">ORGMK_MAKE_SETUP</span>)
<span class="org-whitespace-tab"> </span><span class=
"org-type">@</span><span class="org-makefile-shell">echo</span>
<span class="org-comment-delimiter">## </span><span class=
"org-comment">MAKE INSTALL</span>
<span class="org-makefile-targets">.PHONY</span>: install
<span class=
"org-makefile-targets">install</span>: <span class="org-comment-delimiter"># </span><span class="org-comment">Create symlinks to Orgmk scripts</span>
<span class="org-whitespace-tab"> </span><span class=
"org-type">@</span><span class="org-makefile-shell">echo </span><span class=
"org-makefile-shell"><span class=
"org-string">"Creating symlinks..."</span></span>
<span class="org-whitespace-tab"> </span>ln -f -s $(<span class=
"org-variable-name">PWD</span>)/bin/$(<span class=
"org-variable-name">ORGMK_INIT</span>) $(<span class=
"org-variable-name">BIN_DIR</span>)/$(<span class=
"org-variable-name">ORGMK_INIT</span>)
<span class="org-whitespace-tab"> </span>ln -f -s $(<span class=
"org-variable-name">PWD</span>)/bin/$(<span class=
"org-variable-name">ORGMK_SYSTEM_CONFIG</span>) $(<span class=
"org-variable-name">BIN_DIR</span>)/$(<span class=
"org-variable-name">ORGMK_SYSTEM_CONFIG</span>)
<span class="org-whitespace-tab"> </span>ln -f -s $(<span class=
"org-variable-name">PWD</span>)/bin/$(<span class=
"org-variable-name">ORGMK_UPDATE</span>) $(<span class=
"org-variable-name">BIN_DIR</span>)/$(<span class=
"org-variable-name">ORGMK_UPDATE</span>)
<span class="org-whitespace-tab"> </span>ln -f -s $(<span class=
"org-variable-name">PWD</span>)/bin/$(<span class=
"org-variable-name">ORGMK_UPDATE_CHECK_DIFF</span>) $(<span class=
"org-variable-name">BIN_DIR</span>)/$(<span class=
"org-variable-name">ORGMK_UPDATE_CHECK_DIFF</span>)
<span class="org-whitespace-tab"> </span>ln -f -s $(<span class=
"org-variable-name">PWD</span>)/bin/$(<span class=
"org-variable-name">ORG2HTML</span>) $(<span class=
"org-variable-name">BIN_DIR</span>)/$(<span class=
"org-variable-name">ORG2HTML</span>)
<span class="org-whitespace-tab"> </span>ln -f -s $(<span class=
"org-variable-name">PWD</span>)/bin/$(<span class=
"org-variable-name">ORG2LATEX</span>) $(<span class=
"org-variable-name">BIN_DIR</span>)/$(<span class=
"org-variable-name">ORG2LATEX</span>)
<span class="org-whitespace-tab"> </span>ln -f -s $(<span class=
"org-variable-name">PWD</span>)/bin/$(<span class=
"org-variable-name">ORG2PDF</span>) $(<span class=
"org-variable-name">BIN_DIR</span>)/$(<span class=
"org-variable-name">ORG2PDF</span>)
<span class="org-whitespace-tab"> </span>ln -f -s $(<span class=
"org-variable-name">PWD</span>)/bin/$(<span class=
"org-variable-name">ORG2BEAMERPDF</span>) $(<span class=
"org-variable-name">BIN_DIR</span>)/$(<span class=
"org-variable-name">ORG2BEAMERPDF</span>)
<span class="org-whitespace-tab"> </span>ln -f -s $(<span class=
"org-variable-name">PWD</span>)/bin/$(<span class=
"org-variable-name">ORG2ODT</span>) $(<span class=
"org-variable-name">BIN_DIR</span>)/$(<span class=
"org-variable-name">ORG2ODT</span>)
<span class="org-whitespace-tab"> </span>ln -f -s $(<span class=
"org-variable-name">PWD</span>)/bin/$(<span class=
"org-variable-name">ORG2TXT</span>) $(<span class=
"org-variable-name">BIN_DIR</span>)/$(<span class=
"org-variable-name">ORG2TXT</span>)
<span class="org-whitespace-tab"> </span>ln -f -s $(<span class=
"org-variable-name">PWD</span>)/bin/$(<span class=
"org-variable-name">ORGTANGLE</span>) $(<span class=
"org-variable-name">BIN_DIR</span>)/$(<span class=
"org-variable-name">ORGTANGLE</span>)
<span class="org-whitespace-tab"> </span>ln -f -s $(<span class=
"org-variable-name">PWD</span>)/bin/$(<span class=
"org-variable-name">ORGMK_MAKE_SETUP</span>) $(<span class=
"org-variable-name">BIN_DIR</span>)/$(<span class=
"org-variable-name">ORGMK_MAKE_SETUP</span>)
<span class="org-whitespace-tab"> </span>ln -f -s $(<span class=
"org-variable-name">PWD</span>)/bin/$(<span class=
"org-variable-name">ORGMK_MAKE_RUN</span>) $(<span class=
"org-variable-name">BIN_DIR</span>)/$(<span class=
"org-variable-name">ORGMK_MAKE_RUN</span>)
<span class="org-comment-delimiter">### </span><span class=
"org-comment">Makefile ends here</span>
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-sec-1-7" class="outline-3">
<h3 id="sec-1-7"><span class="section-number-3">1.7</span> Standalone
scripts</h3>
<div class="outline-text-3" id="text-1-7"></div>
<div id="outline-container-sec-1-7-1" class="outline-4">
<h4 id="sec-1-7-1"><span class="section-number-4">1.7.1</span>
Orgmk-init</h4>
<div class="outline-text-4" id="text-1-7-1">
<p>The <code>orgmk-init</code> script contains the common part used
to setup Emacs and Org in order to export to HTML, PDF, etc.</p>
</div>
<div id="outline-container-unnumbered-4" class="outline-5">
<h5 id="unnumbered-4">Functions</h5>
<div class="outline-text-5" id="text-unnumbered-4">
<div class="org-src-container">
<pre class="src src-shell">
<span class="org-function-name">Usage</span> ()
{
cat << EOF 1>&2
<span class="org-sh-heredoc">Usage: $(basename $0) [OPTION] FILE</span>
<span class="org-sh-heredoc">Convert FILE to another format.</span>
<span class="org-sh-heredoc"> -h, --help display this help and exit</span>
<span class=
"org-sh-heredoc"> -y authorize update of the source file without confirmation</span>
<span class=
"org-sh-heredoc"> --body-only export only body (for HTML and LaTeX exports)</span>
<span class=
"org-sh-heredoc">Report $(basename $0) bugs to fni@missioncriticalit.com</span>
<span class="org-sh-heredoc">EOF</span>
<span class="org-keyword">exit</span> 1
}
</pre>
</div>
<div class="org-src-container">
<pre class="src src-shell">
<span class="org-function-name">die</span> () {
printf <span class=
"org-string">"$(basename $0): $@\n"</span> > /dev/stderr
<span class="org-keyword">exit</span> 2 <span class=
"org-comment-delimiter"># </span><span class=
"org-comment">an error occurred</span>
}
</pre>
</div>
<div class="org-src-container">
<pre class="src src-shell">
<span class="org-function-name">CleanUp</span> ()
{
<span class="org-comment-delimiter"># </span><span class=
"org-comment">restore backed up target file if it hasn't been produced</span>
<span class="org-keyword">if</span> [ <span class=
"org-negation-char">!</span> -z $<span class=
"org-variable-name">FILE_TARGET</span> ]; <span class="org-keyword">then</span>
<span class="org-keyword">if</span> [ -r $<span class=
"org-variable-name">FILE_TARGET</span>.orig ]; <span class=
"org-keyword">then</span>
<span class="org-keyword">if</span> [ <span class=
"org-negation-char">!</span> -r $<span class=
"org-variable-name">FILE_TARGET</span> ]; <span class="org-keyword">then</span>
printf <span class=
"org-string">"Recovering OLD file $FILE_TARGET...\n"</span>
mv $<span class=
"org-variable-name">FILE_TARGET</span>.orig $<span class=
"org-variable-name">FILE_TARGET</span>
<span class="org-keyword">else</span>
rm $<span class="org-variable-name">FILE_TARGET</span>.orig
<span class="org-keyword">fi</span>
<span class="org-keyword">fi</span>
<span class="org-keyword">fi</span>
<span class="org-comment-delimiter"># </span><span class=
"org-comment">display log file, if present</span>
<span class="org-keyword">if</span> [ <span class=
"org-negation-char">!</span> -z $<span class=
"org-variable-name">FILE_LOG</span> ]; <span class="org-keyword">then</span>
<span class="org-keyword">if</span> [ -r $<span class=
"org-variable-name">FILE_LOG</span> ]; <span class="org-keyword">then</span>
grep -e <span class=
"org-string">"^!.*"</span> -A 3 -B 1 $<span class=
"org-variable-name">FILE_LOG</span>
<span class="org-keyword">fi</span>
<span class="org-keyword">fi</span>
<span class="org-comment-delimiter"># </span><span class=
"org-comment">remove the temporary copy of the source Org file</span>
<span class="org-keyword">if</span> [ <span class=
"org-negation-char">!</span> -z $<span class=
"org-variable-name">FILE_SRC_UPDT</span> ]; <span class=
"org-keyword">then</span>
rm -f $<span class="org-variable-name">FILE_SRC_UPDT</span>
<span class="org-keyword">fi</span>
}
</pre>
</div>
</div>
</div>
<div id="outline-container-unnumbered-5" class="outline-5">
<h5 id="unnumbered-5">Runtime</h5>
<div class="outline-text-5" id="text-unnumbered-5">
<div class="org-src-container">
<pre class="src src-emacs-lisp" id="current-time">
(format-time-string <span class="org-string">"%Y%m%d.%H%M"</span>)
</pre>
</div>
<div class="org-src-container">
<pre class="src src-shell">
cat << EOF
<span class=
"org-sh-heredoc">This is $(basename $0), version: 20150219.1617.</span>
<span class="org-sh-heredoc">EOF</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-shell">
<span class="org-comment-delimiter"># </span><span class=
"org-comment">perform housekeeping on program exit or a variety of signals</span>
<span class="org-comment-delimiter"># </span><span class=
"org-comment">(EXIT, HUP, INT, QUIT, TERM)</span>
<span class="org-keyword">trap</span> CleanUp 0 1 2 3 15
</pre>
</div>
<div class="org-src-container">
<pre class="src src-shell">
<span class="org-comment-delimiter"># </span><span class=
"org-comment">load the system-wide config file (definition of `ORGMK_EL')</span>
. orgmk.conf
<span class="org-keyword">if</span> [ <span class=
"org-string">"$ORGMK_EL"</span> = <span class=
"org-string">""</span> ]; <span class="org-keyword">then</span>
printf <span class=
"org-string">"ORGMK_EL variable not defined, please check your setup!\n"</span>
<span class="org-keyword">exit</span> 2
<span class="org-keyword">fi</span>
<span class="org-comment-delimiter"># </span><span class=
"org-comment">source the user config file (default for `UPDATE_SRC', etc.)</span>
<span class="org-variable-name">ORGMK_USER_CONF</span>=$<span class=
"org-variable-name">HOME</span>/.orgmk-rc
<span class="org-keyword">if</span> [ -r $<span class=
"org-variable-name">ORGMK_USER_CONF</span> ]; <span class=
"org-keyword">then</span>
. $<span class="org-variable-name">ORGMK_USER_CONF</span>
<span class="org-keyword">fi</span>
<span class="org-builtin">export</span> UPDATE_SRC
<span class="org-comment-delimiter"># </span><span class=
"org-comment">set a default value</span>
<span class="org-builtin">export</span> <span class=
"org-variable-name">BODY_ONLY</span>=<span class="org-string">"no"</span>
<span class="org-keyword">while </span><span class=
"org-builtin">true</span>; <span class="org-keyword">do</span>
<span class="org-keyword">case</span> <span class=
"org-string">"$1"</span><span class="org-keyword"> in</span>
-y ) <span class="org-variable-name">UPDATE_SRC</span>=<span class=
"org-string">"yes"</span>; <span class="org-builtin">shift</span> ;;
--body-only ) <span class=
"org-variable-name">BODY_ONLY</span>=<span class=
"org-string">"yes"</span>; <span class="org-builtin">shift</span> ;;
-h | --help ) Usage ;;
* ) <span class="org-keyword">break</span> ;;
<span class="org-keyword">esac</span>
<span class="org-keyword">done</span>
<span class="org-comment-delimiter"># </span><span class=
"org-comment">now do something with $@</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-shell">
<span class="org-keyword">if</span> [ $<span class=
"org-variable-name">#</span> -ne 1 ]; <span class="org-keyword">then</span>
Usage
<span class="org-keyword">fi</span>
<span class="org-variable-name">FILE_SRC_ORIG</span>=$<span class=
"org-variable-name">1</span>
<span class="org-keyword">if</span> [ <span class=
"org-negation-char">!</span> -r <span class=
"org-string">"$FILE_SRC_ORIG"</span> ]; <span class="org-keyword">then</span>
die <span class="org-string">"Cannot read file $FILE_SRC_ORIG"</span>
<span class="org-keyword">fi</span>
<span class="org-variable-name">FILE_SRC_UPDT</span>=<span class=
"org-string">"${FILE_SRC_ORIG%.*}.orgmk"</span> <span class=
"org-comment-delimiter"># </span><span class=
"org-comment">replace extension</span>
<span class="org-comment-delimiter"># </span><span class=
"org-comment">The temporary file only differ by its extension (`.orgmk'), so that the</span>
<span class="org-comment-delimiter"># </span><span class=
"org-comment">exported file will be named <orig file name>.<backend ext>.</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-shell">
<span class="org-variable-name">FILE_LOG</span>=<span class=
"org-string">"${FILE_SRC_ORIG%.*}.log"</span>
rm -f $<span class="org-variable-name">FILE_LOG</span>
</pre>
</div>
<p>If the PDF file isn’t produced (for example, because of an
<i>undefined control sequence</i>), there is no PDF file anymore;
hence, <code>orgmk</code> would ignore the source file in future
calls, and the PDF file (now, missing…) would completely
disappear from the user attention.</p>
<p>To avoid that, we must make a backup of the target file before
the export, and put it back if there is no target file
produced.</p>
<div class="org-src-container">
<pre class="src src-shell">
<span class="org-variable-name">FILE_TARGET</span>=<span class=
"org-string">"${FILE_SRC_ORIG%.*}.$TARGET_EXT"</span>
<span class="org-comment-delimiter"># </span><span class=
"org-comment">back up previous version of target file</span>
<span class="org-keyword">if</span> [ -r $<span class=
"org-variable-name">FILE_TARGET</span> ]; <span class="org-keyword">then</span>
mv $<span class="org-variable-name">FILE_TARGET</span> $<span class=
"org-variable-name">FILE_TARGET</span>.orig
<span class="org-keyword">fi</span>
</pre>
</div>
<p>Note that, like with the <code>patch</code> command, the
original file is saved with the <code>.orig</code> extension.</p>
<div class="org-src-container">
<pre class="src src-shell">
<span class="org-variable-name">EMACS</span>=emacs
<span class="org-variable-name">WHICH_EMACS</span>=$(<span class=
"org-builtin">which</span> $<span class="org-variable-name">EMACS</span>)
<span class="org-variable-name">EMACS_FLAGS</span>=<span class=
"org-string">"--eval \"(progn (message \\\"Launching $WHICH_EMACS...\\\") (message \\\"Emacs %s (%s)\\\" emacs-version system-type))\""</span>
<span class="org-variable-name">EMACS_BATCH</span>=<span class=
"org-string">"emacs --batch -Q $EMACS_FLAGS"</span>
<span class="org-variable-name">ORG_FLAGS</span>=<span class=
"org-string">""</span>
<span class="org-variable-name">ORGMK</span>=<span class=
"org-string">"$EMACS_BATCH $ORG_FLAGS --eval \"(message \\\"Loading ${ORGMK_EL}...\\\")\" -l $ORGMK_EL"</span>
<span class="org-variable-name">ORGMK_UPDATE_FLAGS</span>=<span class=
"org-string">"-f org-update-all-dblocks -f org-table-iterate-buffer-tables --eval \"(write-file \\\"${FILE_SRC_UPDT##*/}\\\")\""</span> <span class="org-comment-delimiter"># </span><span class="org-comment">base name</span>
</pre>
</div>
<div class="note">
<p><b>Batch option</b><br />
Font Lock mode is disabled by default in batch mode. That
generates errors with some Java code blocks. Hence, one
workaround, in that case, is to call Emacs without batch mode
(and, then, to add <code>-f kill-emacs</code>, or simply
<code>--kill</code>, at the end of the command line).</p>
</div>
</div>
</div>
</div>
<div id="outline-container-sec-1-7-2" class="outline-4">
<h4 id="sec-1-7-2"><span class="section-number-4">1.7.2</span>
org2html</h4>
<div class="outline-text-4" id="text-1-7-2">
<p>The <code>org2html</code> script converts an Org file to
HTML.</p>
<div class="org-src-container">
<pre class="src src-shell">
<span class="org-variable-name">TARGET_EXT</span>=html
. orgmk-init
<span class="org-keyword">case</span> $<span class=
"org-variable-name">BODY_ONLY</span><span class="org-keyword"> in</span>
<span class="org-string">"yes"</span>)
<span class="org-builtin">eval</span> $<span class=
"org-variable-name">ORGMK</span> $<span class=
"org-variable-name">FILE_SRC_ORIG</span> $<span class=
"org-variable-name">ORGMK_UPDATE_FLAGS</span> -f org-html-export-body-only-to-html <span class="org-sh-escaped-newline">\</span>
|| die <span class=
"org-string">"Exported file wasn't produced"</span>
;;
<span class="org-string">"no"</span>)
<span class="org-builtin">eval</span> $<span class=
"org-variable-name">ORGMK</span> $<span class=
"org-variable-name">FILE_SRC_ORIG</span> $<span class=
"org-variable-name">ORGMK_UPDATE_FLAGS</span> -f org-html-export-to-html <span class="org-sh-escaped-newline">\</span>
|| die <span class=
"org-string">"Exported file wasn't produced"</span>
<span class="org-keyword">esac</span>
orgmk-update-src-check-diff <span class=
"org-string">"$FILE_SRC_ORIG"</span> <span class=
"org-string">"$FILE_SRC_UPDT"</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-1-7-3" class="outline-4">
<h4 id="sec-1-7-3"><span class="section-number-4">1.7.3</span>
org2latex</h4>
<div class="outline-text-4" id="text-1-7-3">
<p>The <code>org2latex</code> script converts an Org file to
LaTeX.</p>
<div class="org-src-container">
<pre class="src src-shell">
<span class="org-variable-name">TARGET_EXT</span>=tex
. orgmk-init
<span class="org-keyword">case</span> $<span class=
"org-variable-name">BODY_ONLY</span><span class="org-keyword"> in</span>
<span class="org-string">"yes"</span>)
<span class="org-builtin">eval</span> $<span class=
"org-variable-name">ORGMK</span> $<span class=
"org-variable-name">FILE_SRC_ORIG</span> $<span class=
"org-variable-name">ORGMK_UPDATE_FLAGS</span> -f org-latex-export-body-only-to-latex <span class="org-sh-escaped-newline">\</span>
|| die <span class=
"org-string">"Exported file wasn't produced"</span>
;;
<span class="org-string">"no"</span>)
<span class="org-builtin">eval</span> $<span class=
"org-variable-name">ORGMK</span> $<span class=
"org-variable-name">FILE_SRC_ORIG</span> $<span class=
"org-variable-name">ORGMK_UPDATE_FLAGS</span> -f org-latex-export-to-latex <span class="org-sh-escaped-newline">\</span>
|| die <span class=
"org-string">"Exported file wasn't produced"</span>
<span class="org-keyword">esac</span>
orgmk-update-src-check-diff <span class=
"org-string">"$FILE_SRC_ORIG"</span> <span class=
"org-string">"$FILE_SRC_UPDT"</span>
</pre>
</div>
</div>
</div>
<div id="outline-container-sec-1-7-4" class="outline-4">
<h4 id="sec-1-7-4"><span class="section-number-4">1.7.4</span>
org2pdf</h4>
<div class="outline-text-4" id="text-1-7-4">
<p>The <code>org2pdf</code> script converts an Org file to PDF.</p>
<p>It tries to detect whether the target is a standard LaTeX
document or a Beamer presentation by searching for the string
<code>#+BEAMER_THEME:</code> inside the Org source.</p>
<div class="org-src-container">
<pre class="src src-shell">
<span class="org-variable-name">TARGET_EXT</span>=pdf
. orgmk-init