Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drop old config #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .directory

This file was deleted.

90 changes: 15 additions & 75 deletions lib/parseArgs.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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

Expand All @@ -112,4 +52,4 @@ module.exports = function parseArgs(data,options) {
}

return args;
}
};
82 changes: 0 additions & 82 deletions old.md

This file was deleted.