From e692c2356d7f35ae537e24d8defee33023b8f416 Mon Sep 17 00:00:00 2001 From: uiolee <22849383+uiolee@users.noreply.github.com> Date: Tue, 29 Aug 2023 22:40:50 +0800 Subject: [PATCH] drop old config --- .directory | 4 --- lib/parseArgs.js | 90 ++++++++---------------------------------------- old.md | 82 ------------------------------------------- 3 files changed, 15 insertions(+), 161 deletions(-) delete mode 100644 .directory delete mode 100644 old.md diff --git a/.directory b/.directory deleted file mode 100644 index 7867747..0000000 --- a/.directory +++ /dev/null @@ -1,4 +0,0 @@ -[Dolphin] -PreviewsShown=true -Timestamp=2013,12,4,22,41,12 -Version=3 diff --git a/lib/parseArgs.js b/lib/parseArgs.js index 3b49f56..1e5166b 100644 --- a/lib/parseArgs.js +++ b/lib/parseArgs.js @@ -1,4 +1,4 @@ -module.exports = function parseArgs(data,options) { +module.exports = function parseArgs(data, options) { // if we are rendering a post, // `data` has the key `path` // https://github.com/hexojs/hexo/blob/2ed17cd105768df379dad8bbbe4df30964fe8f2d/lib/hexo/post.js#L269 @@ -9,7 +9,7 @@ module.exports = function parseArgs(data,options) { let standalone = "path" in data; let config = this.config?.pandoc; - var args = ['-M', 'pagetitle=dummy']; + var args = ["-M", "pagetitle=dummy"]; /* istanbul ignore else*/ // ignore testing the old interface @@ -19,85 +19,25 @@ module.exports = function parseArgs(data,options) { // if rendering embedded content if (!standalone) { // remove template, which only apply to standalong posts - let templateIdx = args.findIndex(item => item.startsWith("--template=")); + let templateIdx = args.findIndex((item) => + item.startsWith("--template=") + ); if (templateIdx > -1) { - args.splice(templateIdx, 1) + args.splice(templateIdx, 1); } } - } else { - // old yaml dictionary interface for argument specification - // deprecating due to #54 - // i.e., will keep the code for backward compatibility - // but will not provide support in the future - - var extensions = '', filters = [], extra = []; - // To satisfy pandoc's requirement that html5 must have a title. - // Since the markdown file is only rendered as body part, - // the title is never used and thus does not matter - var meta = []; - var math = '--mathjax'; - - if(config) { - if(config.extensions) { - config.extensions.forEach(function(extension) { - extensions += extension; - }); - } - - if(config.filters) { - config.filters.forEach(function(filter) { - filters.push('--filter'); - filters.push(filter); - }); - } - - if(config.extra) { - for(var e in config.extra) { - var eoption = config.extra[e]; - for (var key in eoption){ - extra.push('--' + key); - if(eoption[key]!=null) { - extra.push(eoption[key]); - } - } - } - } - - if(config.meta) { - config.meta.forEach(function(m) { - meta.push('-M'); - if(m.length) { - meta.push(m); - } else { - for(var m2 in m) { - meta.push(m2 + '=' + m[m2]); - } - } - }); - } - - if(config.mathEngine) { - if(typeof config.mathEngine === 'string') { - math = '--' + config.mathEngine; - } - } - } - - args = args - .concat([ '-f', 'markdown-smart'+extensions, '-t', 'html-smart', math]) - .concat(filters) - .concat(extra) - .concat(meta); - - // only apply template when rendering post, not tags - if (standalone && config && config.template) { - args.push("--template=" + config.template); - } + args = args.concat([ + "-f", + "markdown-smart", + "-t", + "html-smart", + "--mathjax", + ]); } // are we rendering a standalone post? - if(standalone) { + if (standalone) { // do not apply `--standalone`, // header/footer are to be added by Hexo @@ -112,4 +52,4 @@ module.exports = function parseArgs(data,options) { } return args; -} \ No newline at end of file +}; diff --git a/old.md b/old.md deleted file mode 100644 index d3dc818..0000000 --- a/old.md +++ /dev/null @@ -1,82 +0,0 @@ -You can pass additional arguments to pandoc through `_config.yml`. The default configuration is: - -```yml -pandoc: - filters: - extra: - template: - meta: - mathEngine: -``` - -* `filters` is a list of any pandoc filter installed on your path. -* `extra` is a list of mappings: - -```yml -extra: - - key: value -``` -passed to pandoc as `--key value`. - -* `template` is a template file you wish to use when pandoc generates your posts: - -``` yml -template: dir/.../template.html -``` - -will be passed to pandoc as `--template=dir/../template.html` - -The path of the template should be relative to the root of your blog. - -For example, the very simple template - -``` html -$if(toc)$ -
-$toc$ -
-$endif$ -$body$ -``` - -prepends table of contents to all your posts if variable `--toc` is also passed. To enable TOC, add to your `_config.yml`: - -``` yml -pandoc: - # other options - extra: - - toc: # will be passed as `--toc`. Note the colon - template: dir/../template.html -``` - -* `meta` is a list of anything you wish to be sent to pandoc as meta: - -```yml -meta: - - key: value1 - - value2 -``` -would be passed as `-M key=value1 -M value2`. - -`pandoc-citeproc` for example can be configured as: - -```yml -pandoc: - filters: - - pandoc-citeproc - extra: - - bibliography: "/path/to/bibfile.bib" - meta: - - suppress-bibliography -``` - -* `mathEngine` is an option for choosing math engine. By default, mathEngine is mathjax. - -For example, if you want to use KaTeX, you can pass `katex` to the mathEngine option: - -``` -pandoc: - mathEngine: katex -``` - -Then, the args of pandoc is this: `[..., "--katex", ...]` . \ No newline at end of file