summarylogtreecommitdiffstats
path: root/pandoc-fix.patch
blob: 4f44ef94e673b4c47872481101fd3e5e12ced1b8 (plain)
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
From d7a70345f468911ab024b06f030def5427588a4f Mon Sep 17 00:00:00 2001
From: BrLi <brli@chakralinux.org>
Date: Fri, 25 Dec 2020 12:29:56 +0800
Subject: [PATCH 1/7] paramatrized bibliography, fold cslstyle if-else
 statement into property

---
 CHANGELOG.md                                    |  6 ++++++
 source/app/service-providers/config-provider.js |  2 +-
 source/main/modules/export/run-pandoc.js        | 11 ++++-------
 source/renderer/dialog/preferences.js           |  2 +-
 4 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8d637001..6ba35b40 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+# 1.8.5
+
+## Pandoc Command update
+
+**In order to use the new command, make sure to "reset" it once, or (if it contains customisations) replace `--bibliography "$bibliography$" $cslstyle$` with `$bibliography$ $cslstyle$`.**
+
 # 1.8.4
 
 ## Deprecating 32 bit builds
diff --git a/source/app/service-providers/config-provider.js b/source/app/service-providers/config-provider.js
index ad5799fd..42ea83d3 100644
--- a/source/app/service-providers/config-provider.js
+++ b/source/app/service-providers/config-provider.js
@@ -118,7 +118,7 @@ module.exports = class ConfigProvider extends EventEmitter {
       'pandoc': '',
       'xelatex': '',
       // The pandoc command to be run on export
-      'pandocCommand': 'pandoc "$infile$" -f markdown $outflag$ $tpl$ $toc$ $tocdepth$ --citeproc --bibliography "$bibliography$" $cslstyle$ $standalone$ --pdf-engine=xelatex --mathjax -o "$outfile$"',
+      'pandocCommand': 'pandoc "$infile$" -f markdown $outflag$ $tpl$ $toc$ $tocdepth$ --citeproc $bibliography$ $cslstyle$ $standalone$ --pdf-engine=xelatex --mathjax -o "$outfile$"',
       'export': {
         'dir': 'temp', // Can either be "temp" or "cwd" (current working directory)
         'stripIDs': false, // Strip ZKN IDs such as @ID:<id>
diff --git a/source/main/modules/export/run-pandoc.js b/source/main/modules/export/run-pandoc.js
index 3874aa07..28dbadee 100644
--- a/source/main/modules/export/run-pandoc.js
+++ b/source/main/modules/export/run-pandoc.js
@@ -47,11 +47,8 @@ module.exports = async function (options) {
     throw new Error(trans('system.error.no_xelatex_message'), trans('system.error.no_xelatex_title'))
   }
 
-  // Add a custom CSL style if applicable
-  let cslstyle = ''
-  if (options.hasOwnProperty('cslStyle') && isFile(options.cslStyle)) {
-    cslstyle = `--csl "${options.cslStyle}"`
-  }
+  // Add bibliography if exists
+  let bibliography = global.config.get('export.cslLibrary')
 
   // Pandoc flags to be passed to the compiler
   let pandocFlags = {
@@ -59,8 +56,8 @@ module.exports = async function (options) {
     'infile': options.sourceFile,
     'toc': (options.pdf.toc && options.format === 'pdf') ? '--toc' : '',
     'tocdepth': (options.pdf.tocDepth) ? '--toc-depth=' + options.pdf.tocDepth : '',
-    'bibliography': global.config.get('export.cslLibrary'),
-    'cslstyle': cslstyle,
+    'bibliography': (global.config.get('export.cslLibrary')) ? `--bibliography "${bibliography}"` : '',
+    'cslstyle': (options.hasOwnProperty('cslStyle') && isFile(options.cslStyle)) ? `--csl + "${options.cslStyle}"` : '',
     'outfile': options.targetFile,
     'outflag': '-t ' + ((options.format === 'pdf') ? 'latex' : options.format),
     'format': options.format,
diff --git a/source/renderer/dialog/preferences.js b/source/renderer/dialog/preferences.js
index 15630b68..cce2a90c 100644
--- a/source/renderer/dialog/preferences.js
+++ b/source/renderer/dialog/preferences.js
@@ -190,7 +190,7 @@ class PreferencesDialog extends ZettlrDialog {
 
     // Reset the pandoc command
     $('#reset-pandoc-command').on('click', (e) => {
-      document.getElementById('pandocCommand').value = 'pandoc "$infile$" -f markdown $outflag$ $tpl$ $toc$ $tocdepth$ --citeproc --bibliography "$bibliography$" $cslstyle$ $standalone$ --pdf-engine=xelatex --mathjax -o "$outfile$"'
+      document.getElementById('pandocCommand').value = 'pandoc "$infile$" -f markdown $outflag$ $tpl$ $toc$ $tocdepth$ --citeproc $bibliography$ $cslstyle$ $standalone$ --pdf-engine=xelatex --mathjax -o "$outfile$"'
     })
 
     const reportTestResult = (resultTranslationKey) => {

From 7ed897e2d3f95f43a22defab71b9b380ea759ce0 Mon Sep 17 00:00:00 2001
From: BrLi <brli@chakralinux.org>
Date: Fri, 25 Dec 2020 13:48:25 +0800
Subject: [PATCH 2/7] remove typo + in command

---
 source/main/modules/export/run-pandoc.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source/main/modules/export/run-pandoc.js b/source/main/modules/export/run-pandoc.js
index 28dbadee..a2b2f10e 100644
--- a/source/main/modules/export/run-pandoc.js
+++ b/source/main/modules/export/run-pandoc.js
@@ -57,7 +57,7 @@ module.exports = async function (options) {
     'toc': (options.pdf.toc && options.format === 'pdf') ? '--toc' : '',
     'tocdepth': (options.pdf.tocDepth) ? '--toc-depth=' + options.pdf.tocDepth : '',
     'bibliography': (global.config.get('export.cslLibrary')) ? `--bibliography "${bibliography}"` : '',
-    'cslstyle': (options.hasOwnProperty('cslStyle') && isFile(options.cslStyle)) ? `--csl + "${options.cslStyle}"` : '',
+    'cslstyle': (options.hasOwnProperty('cslStyle') && isFile(options.cslStyle)) ? `--citeproc --csl "${options.cslStyle}"` : '',
     'outfile': options.targetFile,
     'outflag': '-t ' + ((options.format === 'pdf') ? 'latex' : options.format),
     'format': options.format,

From 238056421cf0d28926fa4901e1857e860fa35dd2 Mon Sep 17 00:00:00 2001
From: BrLi <brli@chakralinux.org>
Date: Fri, 25 Dec 2020 14:03:21 +0800
Subject: [PATCH 3/7] move --citeproc into cslstyle variable

---
 source/app/service-providers/config-provider.js | 2 +-
 source/renderer/dialog/preferences.js           | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/source/app/service-providers/config-provider.js b/source/app/service-providers/config-provider.js
index 42ea83d3..049c9188 100644
--- a/source/app/service-providers/config-provider.js
+++ b/source/app/service-providers/config-provider.js
@@ -118,7 +118,7 @@ module.exports = class ConfigProvider extends EventEmitter {
       'pandoc': '',
       'xelatex': '',
       // The pandoc command to be run on export
-      'pandocCommand': 'pandoc "$infile$" -f markdown $outflag$ $tpl$ $toc$ $tocdepth$ --citeproc $bibliography$ $cslstyle$ $standalone$ --pdf-engine=xelatex --mathjax -o "$outfile$"',
+      'pandocCommand': 'pandoc "$infile$" -f markdown $outflag$ $tpl$ $toc$ $tocdepth$ $cslstyle$ $bibliography$ $standalone$ --pdf-engine=xelatex --mathjax -o "$outfile$"',
       'export': {
         'dir': 'temp', // Can either be "temp" or "cwd" (current working directory)
         'stripIDs': false, // Strip ZKN IDs such as @ID:<id>
diff --git a/source/renderer/dialog/preferences.js b/source/renderer/dialog/preferences.js
index cce2a90c..a2ba8ba3 100644
--- a/source/renderer/dialog/preferences.js
+++ b/source/renderer/dialog/preferences.js
@@ -190,7 +190,7 @@ class PreferencesDialog extends ZettlrDialog {
 
     // Reset the pandoc command
     $('#reset-pandoc-command').on('click', (e) => {
-      document.getElementById('pandocCommand').value = 'pandoc "$infile$" -f markdown $outflag$ $tpl$ $toc$ $tocdepth$ --citeproc $bibliography$ $cslstyle$ $standalone$ --pdf-engine=xelatex --mathjax -o "$outfile$"'
+      document.getElementById('pandocCommand').value = 'pandoc "$infile$" -f markdown $outflag$ $tpl$ $toc$ $tocdepth$ $cslstyle$ $bibliography$ $standalone$ --pdf-engine=xelatex --mathjax -o "$outfile$"'
     })
 
     const reportTestResult = (resultTranslationKey) => {

From 40ba77f1539de8421438c1d61d4c1069866b405d Mon Sep 17 00:00:00 2001
From: BrLi <brli@chakralinux.org>
Date: Fri, 25 Dec 2020 14:09:29 +0800
Subject: [PATCH 4/7] isolate --citeproc parameter

---
 source/app/service-providers/config-provider.js | 2 +-
 source/main/modules/export/run-pandoc.js        | 3 ++-
 source/renderer/dialog/preferences.js           | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/source/app/service-providers/config-provider.js b/source/app/service-providers/config-provider.js
index 049c9188..bbb4d40d 100644
--- a/source/app/service-providers/config-provider.js
+++ b/source/app/service-providers/config-provider.js
@@ -118,7 +118,7 @@ module.exports = class ConfigProvider extends EventEmitter {
       'pandoc': '',
       'xelatex': '',
       // The pandoc command to be run on export
-      'pandocCommand': 'pandoc "$infile$" -f markdown $outflag$ $tpl$ $toc$ $tocdepth$ $cslstyle$ $bibliography$ $standalone$ --pdf-engine=xelatex --mathjax -o "$outfile$"',
+      'pandocCommand': 'pandoc "$infile$" -f markdown $outflag$ $tpl$ $toc$ $tocdepth$ $citeproc$ $cslstyle$ $bibliography$ $standalone$ --pdf-engine=xelatex --mathjax -o "$outfile$"',
       'export': {
         'dir': 'temp', // Can either be "temp" or "cwd" (current working directory)
         'stripIDs': false, // Strip ZKN IDs such as @ID:<id>
diff --git a/source/main/modules/export/run-pandoc.js b/source/main/modules/export/run-pandoc.js
index a2b2f10e..2ae386ef 100644
--- a/source/main/modules/export/run-pandoc.js
+++ b/source/main/modules/export/run-pandoc.js
@@ -56,8 +56,9 @@ module.exports = async function (options) {
     'infile': options.sourceFile,
     'toc': (options.pdf.toc && options.format === 'pdf') ? '--toc' : '',
     'tocdepth': (options.pdf.tocDepth) ? '--toc-depth=' + options.pdf.tocDepth : '',
+    'citeproc': (bibliography && isFile(options.cslStyle)) ? '--citeproc' : '',
     'bibliography': (global.config.get('export.cslLibrary')) ? `--bibliography "${bibliography}"` : '',
-    'cslstyle': (options.hasOwnProperty('cslStyle') && isFile(options.cslStyle)) ? `--citeproc --csl "${options.cslStyle}"` : '',
+    'cslstyle': (options.hasOwnProperty('cslStyle') && isFile(options.cslStyle)) ? `--csl "${options.cslStyle}"` : '',
     'outfile': options.targetFile,
     'outflag': '-t ' + ((options.format === 'pdf') ? 'latex' : options.format),
     'format': options.format,
diff --git a/source/renderer/dialog/preferences.js b/source/renderer/dialog/preferences.js
index a2ba8ba3..cc5b6448 100644
--- a/source/renderer/dialog/preferences.js
+++ b/source/renderer/dialog/preferences.js
@@ -190,7 +190,7 @@ class PreferencesDialog extends ZettlrDialog {
 
     // Reset the pandoc command
     $('#reset-pandoc-command').on('click', (e) => {
-      document.getElementById('pandocCommand').value = 'pandoc "$infile$" -f markdown $outflag$ $tpl$ $toc$ $tocdepth$ $cslstyle$ $bibliography$ $standalone$ --pdf-engine=xelatex --mathjax -o "$outfile$"'
+      document.getElementById('pandocCommand').value = 'pandoc "$infile$" -f markdown $outflag$ $tpl$ $toc$ $tocdepth$ $citeproc$ $cslstyle$ $bibliography$ $standalone$ --pdf-engine=xelatex --mathjax -o "$outfile$"'
     })
 
     const reportTestResult = (resultTranslationKey) => {

From f448a058b74cfff679f00a4dfcd70ae426959845 Mon Sep 17 00:00:00 2001
From: BrLi <brli@chakralinux.org>
Date: Fri, 25 Dec 2020 16:46:24 +0800
Subject: [PATCH 5/7] move --citeproc to $bibliography$

---
 source/app/service-providers/config-provider.js | 2 +-
 source/main/modules/export/run-pandoc.js        | 3 +--
 source/renderer/dialog/preferences.js           | 2 +-
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/source/app/service-providers/config-provider.js b/source/app/service-providers/config-provider.js
index bbb4d40d..672c9cfb 100644
--- a/source/app/service-providers/config-provider.js
+++ b/source/app/service-providers/config-provider.js
@@ -118,7 +118,7 @@ module.exports = class ConfigProvider extends EventEmitter {
       'pandoc': '',
       'xelatex': '',
       // The pandoc command to be run on export
-      'pandocCommand': 'pandoc "$infile$" -f markdown $outflag$ $tpl$ $toc$ $tocdepth$ $citeproc$ $cslstyle$ $bibliography$ $standalone$ --pdf-engine=xelatex --mathjax -o "$outfile$"',
+      'pandocCommand': 'pandoc "$infile$" -f markdown $outflag$ $tpl$ $toc$ $tocdepth$ $bibliography$ $cslstyle$ $standalone$ --pdf-engine=xelatex --mathjax -o "$outfile$"',
       'export': {
         'dir': 'temp', // Can either be "temp" or "cwd" (current working directory)
         'stripIDs': false, // Strip ZKN IDs such as @ID:<id>
diff --git a/source/main/modules/export/run-pandoc.js b/source/main/modules/export/run-pandoc.js
index 2ae386ef..af3b9817 100644
--- a/source/main/modules/export/run-pandoc.js
+++ b/source/main/modules/export/run-pandoc.js
@@ -56,8 +56,7 @@ module.exports = async function (options) {
     'infile': options.sourceFile,
     'toc': (options.pdf.toc && options.format === 'pdf') ? '--toc' : '',
     'tocdepth': (options.pdf.tocDepth) ? '--toc-depth=' + options.pdf.tocDepth : '',
-    'citeproc': (bibliography && isFile(options.cslStyle)) ? '--citeproc' : '',
-    'bibliography': (global.config.get('export.cslLibrary')) ? `--bibliography "${bibliography}"` : '',
+    'bibliography': (global.config.get('export.cslLibrary')) ? `--citeproc --bibliography "${bibliography}"` : '',
     'cslstyle': (options.hasOwnProperty('cslStyle') && isFile(options.cslStyle)) ? `--csl "${options.cslStyle}"` : '',
     'outfile': options.targetFile,
     'outflag': '-t ' + ((options.format === 'pdf') ? 'latex' : options.format),
diff --git a/source/renderer/dialog/preferences.js b/source/renderer/dialog/preferences.js
index cc5b6448..65a9957f 100644
--- a/source/renderer/dialog/preferences.js
+++ b/source/renderer/dialog/preferences.js
@@ -190,7 +190,7 @@ class PreferencesDialog extends ZettlrDialog {
 
     // Reset the pandoc command
     $('#reset-pandoc-command').on('click', (e) => {
-      document.getElementById('pandocCommand').value = 'pandoc "$infile$" -f markdown $outflag$ $tpl$ $toc$ $tocdepth$ $citeproc$ $cslstyle$ $bibliography$ $standalone$ --pdf-engine=xelatex --mathjax -o "$outfile$"'
+      document.getElementById('pandocCommand').value = 'pandoc "$infile$" -f markdown $outflag$ $tpl$ $toc$ $tocdepth$ $bibliography$ $cslstyle$ $standalone$ --pdf-engine=xelatex --mathjax -o "$outfile$"'
     })
 
     const reportTestResult = (resultTranslationKey) => {

From fc9e4ee487f67d131596c92b506ee062788631f4 Mon Sep 17 00:00:00 2001
From: BrLi <brli@chakralinux.org>
Date: Fri, 25 Dec 2020 17:47:42 +0800
Subject: [PATCH 6/7] remove explicit declare of bibliography, use global
 variable instead

---
 CHANGELOG.md                             | 2 +-
 source/main/modules/export/run-pandoc.js | 5 +----
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6ba35b40..86bf1fc2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,7 +2,7 @@
 
 ## Pandoc Command update
 
-**In order to use the new command, make sure to "reset" it once, or (if it contains customisations) replace `--bibliography "$bibliography$" $cslstyle$` with `$bibliography$ $cslstyle$`.**
+**In order to use the new command, make sure to "reset" it once, or (if it contains customisations) replace `--citeproc --bibliography "$bibliography$" $cslstyle$` with `$bibliography$ $cslstyle$`.**
 
 # 1.8.4
 
diff --git a/source/main/modules/export/run-pandoc.js b/source/main/modules/export/run-pandoc.js
index af3b9817..f5f9e692 100644
--- a/source/main/modules/export/run-pandoc.js
+++ b/source/main/modules/export/run-pandoc.js
@@ -47,16 +47,13 @@ module.exports = async function (options) {
     throw new Error(trans('system.error.no_xelatex_message'), trans('system.error.no_xelatex_title'))
   }
 
-  // Add bibliography if exists
-  let bibliography = global.config.get('export.cslLibrary')
-
   // Pandoc flags to be passed to the compiler
   let pandocFlags = {
     'tpl': (options.template) ? `--template="${options.template}"` : '',
     'infile': options.sourceFile,
     'toc': (options.pdf.toc && options.format === 'pdf') ? '--toc' : '',
     'tocdepth': (options.pdf.tocDepth) ? '--toc-depth=' + options.pdf.tocDepth : '',
-    'bibliography': (global.config.get('export.cslLibrary')) ? `--citeproc --bibliography "${bibliography}"` : '',
+    'bibliography': (global.config.get('export.cslLibrary')) ? `--citeproc --bibliography "${global.config.get('export.cslLibrary')}"` : '',
     'cslstyle': (options.hasOwnProperty('cslStyle') && isFile(options.cslStyle)) ? `--csl "${options.cslStyle}"` : '',
     'outfile': options.targetFile,
     'outflag': '-t ' + ((options.format === 'pdf') ? 'latex' : options.format),

From 994ec0b4ce01381b50cac05e8108374ff21aeff3 Mon Sep 17 00:00:00 2001
From: BrLi <brli@chakralinux.org>
Date: Sat, 26 Dec 2020 06:56:27 +0800
Subject: [PATCH 7/7] separate cslstyle and bibliography as per maintainer
 instruction

---
 source/main/modules/export/run-pandoc.js | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/source/main/modules/export/run-pandoc.js b/source/main/modules/export/run-pandoc.js
index f5f9e692..2402da71 100644
--- a/source/main/modules/export/run-pandoc.js
+++ b/source/main/modules/export/run-pandoc.js
@@ -47,14 +47,26 @@ module.exports = async function (options) {
     throw new Error(trans('system.error.no_xelatex_message'), trans('system.error.no_xelatex_title'))
   }
 
+  // Include CSL library if exist
+  let bibliography = ''
+  if (global.config.get('export.cslLibrary')) {
+    bibliography = `--citeproc --bibliography "${global.config.get('export.cslLibrary')}"`
+  }
+
+  // Add a custom CSL style if applicable
+  let cslstyle = ''
+  if (options.hasOwnProperty('cslStyle') && isFile(options.cslStyle)) {
+    cslstyle = `--csl "${options.cslStyle}"`
+  }
+
   // Pandoc flags to be passed to the compiler
   let pandocFlags = {
     'tpl': (options.template) ? `--template="${options.template}"` : '',
     'infile': options.sourceFile,
     'toc': (options.pdf.toc && options.format === 'pdf') ? '--toc' : '',
     'tocdepth': (options.pdf.tocDepth) ? '--toc-depth=' + options.pdf.tocDepth : '',
-    'bibliography': (global.config.get('export.cslLibrary')) ? `--citeproc --bibliography "${global.config.get('export.cslLibrary')}"` : '',
-    'cslstyle': (options.hasOwnProperty('cslStyle') && isFile(options.cslStyle)) ? `--csl "${options.cslStyle}"` : '',
+    'bibliography': bibliography,
+    'cslstyle': cslstyle,
     'outfile': options.targetFile,
     'outflag': '-t ' + ((options.format === 'pdf') ? 'latex' : options.format),
     'format': options.format,