Skip to content

Commit

Permalink
add support of option asset-path
Browse files Browse the repository at this point in the history
  • Loading branch information
HakurouKen committed Sep 16, 2016
1 parent b377c66 commit 92d326b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
20 changes: 19 additions & 1 deletion bin/nodeppt
Original file line number Diff line number Diff line change
Expand Up @@ -34,33 +34,51 @@ program
console.log();
});

function assertPathWarn(){
console.warn('The asset-path params will be ignored when output all files.');
}

program
.command('generate')
.alias('release')
.usage('[file_path] [save_path]')
.description('export html file')
.option('-a, --all [false]', 'output all style(include js,css) file', false)
.option('-p, --asset-path','set the relative path of assets(in website), ignored when -a is specified')
.action(function (cmd, output, options) {
var filename = '';
var shouldAll = false;
var path = '';
if (typeof output !== 'string') {
options = output;
output = undefined;
}
if (typeof cmd === 'string') {
filename = cmd;
shouldAll = options.all;
if (options.assetPath && shouldAll ) {
assertPathWarn();
} else {
path = options.assetPath;
}
} else if (typeof cmd === 'object') {
shouldAll = cmd.all;
output = cmd.output;
if (cmd.assetPath && shouldAll ) {
assertPathWarn();
} else {
path = cmd.assetPath;
}
}
nodePPT.generate(filename, output, shouldAll, '');

nodePPT.generate(filename, output, shouldAll, path || '');
})
.on('--help', function () {
console.log(' Examples:');
console.log();
console.log(' nodeppt generate /markdown/path.md /output/path');
console.log(' nodeppt generate /markdown/path.md /output/path -a');
console.log(' nodeppt generate /markdown/path.md /output/path -p ../lib/nodeppt');
console.log();
});

Expand Down
1 change: 1 addition & 0 deletions lib/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ function generate(filepath, outputDir, rDir) {

//处理绝对路径的url
function handlerHTML(html, rDir) {
rDir = rDir.replace(/\/$/,'');
html = html.replace(/(src|href|url)([=|\(])(["'])\/\//gi, '$1$2$3<=PLACEHOLDER=>//')
.replace(/(src|href|url)([=|\(])(["'])\//gi, '$1$2$3' + rDir + '/')
.replace(/(src|href|url)([=|\(])(["'])<=PLACEHOLDER=>\//gi, '$1$2$3//')
Expand Down

0 comments on commit 92d326b

Please sign in to comment.