From d7a70345f468911ab024b06f030def5427588a4f Mon Sep 17 00:00:00 2001 From: BrLi 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: 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 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 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: 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 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: 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 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: 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 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 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,