diff --git a/README.md b/README.md index a522fee..775e1af 100644 --- a/README.md +++ b/README.md @@ -98,12 +98,12 @@ Also, this mark can escape `{` and `}`. ##### Theme for argument A logging function created by this function can take multiple arguments. -A themed text to be converted to an argument has same format with a normal themed text but its theme name is a number starting from 1, which indicates the index of the argument, like `{2}` or `{2: alternative text }`. +A themed text to be converted to an argument has same format with a normal themed text but its theme name is a number starting from 1, which indicates the index of the argument, like `{2}` or `{2: Explanatory text }`. A block content in a theme block for argument is outputted alternatively when there is no argument corresponding to a number of a theme name. * `{ 1 }` → replaced with the second argument (the first argument except the themed text) of logging function, or an empty string if the second argument is not given. -* `{ 3 : yyyy }` → replaced with the fourth argument (the third argument except the themed text) of logging function, or `'yyyy'` if the fourth argument is not given. +* `{ 3 : yyyy }` → replaced with the fourth argument (the third argument except the themed text) of logging function, or an empty string if the fourth argument is not given. (`'yyyy'` is not used.) #### Parameters: diff --git a/lib/arg-theme.js b/lib/arg-theme.js index 92602cc..c5da0a4 100644 --- a/lib/arg-theme.js +++ b/lib/arg-theme.js @@ -9,7 +9,7 @@ function isArgTheme(themeName) { function convertArgTheme(args, themeName, nodeText) { var argIndex = toInteger(themeName); if (!argIndex || argIndex >= args.length || argIndex <= 0) { - return nodeText || ''; + return ''; } return args[argIndex]; diff --git a/test/lib/apply-theme.test.js b/test/lib/apply-theme.test.js index f0d2285..7a39a2f 100644 --- a/test/lib/apply-theme.test.js +++ b/test/lib/apply-theme.test.js @@ -150,7 +150,7 @@ describe('lib/apply-theme', function() { 'This text has arg-theme: A1, true and 222'); expect(apply(parsed, themeSet)).to.equal( - 'This text has arg-theme: , and Two'); + 'This text has arg-theme: , and '); }); it('Should support theme defined by nested properties', function() { diff --git a/test/lib/arg-theme.test.js b/test/lib/arg-theme.test.js index 92318be..43ad02e 100644 --- a/test/lib/arg-theme.test.js +++ b/test/lib/arg-theme.test.js @@ -22,15 +22,15 @@ describe('lib/arg-theme', function() { it('Should convert an arg identifier to an argument value', function() { var args = ['Arg0', 'Arg1', 'Arg2', 'Arg3']; - expect(argTheme.convert(args, '-1', 'X1-')).to.equal('X1-'); - expect(argTheme.convert(args, '0', 'X0')).to.equal('X0'); + expect(argTheme.convert(args, '-1', 'X1-')).to.equal(''); + expect(argTheme.convert(args, '0', 'X0')).to.equal(''); expect(argTheme.convert(args, '1', 'X1')).to.equal('Arg1'); expect(argTheme.convert(args, '2', 'X2')).to.equal('Arg2'); expect(argTheme.convert(args, '3', 'X3')).to.equal('Arg3'); - expect(argTheme.convert(args, '4', 'X4')).to.equal('X4'); + expect(argTheme.convert(args, '4', 'X4')).to.equal(''); - expect(argTheme.convert(args, '', 'X')).to.equal('X'); - expect(argTheme.convert(args, 'a', 'X')).to.equal('X'); + expect(argTheme.convert(args, '', 'X')).to.equal(''); + expect(argTheme.convert(args, 'a', 'X')).to.equal(''); }); }); diff --git a/test/theming-log.test.js b/test/theming-log.test.js index 8477a9f..913196b 100644 --- a/test/theming-log.test.js +++ b/test/theming-log.test.js @@ -183,11 +183,11 @@ describe('theming-log', function() { expect(logBuf).to.equal('This text has arg-theme: Arg2 and Arg1\n'); }); - it('Should replace arg-themes to block text when corresponding arg are' + - '\n\tnot exist', function() { + it('Should replace arg-themes to an empty string when corresponding' + + '\n\targ are not exist', function() { var log = themingLog(themes, origLogger); log('This text has arg-theme: {5} and {3: Three}', 'Arg1', 'Arg2'); - expect(logBuf).to.equal('This text has arg-theme: and Three\n'); + expect(logBuf).to.equal('This text has arg-theme: and \n'); }); it('Should replace arg-theme in nested theme', function() {