summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2017-07-13 01:55:32 -0600
committerDan Allen <dan.j.allen@gmail.com>2017-07-13 02:05:04 -0600
commit2f81b4e4be7dbd52f6e2df91c6403061bfb539ec (patch)
tree763d5187fe45455d72b763fa8803d422dba894b9 /lib
parent6c6e35dc20f0f0ad88279365cba7bd0a9c67d1e0 (diff)
allow the subs argument of apply_subs to be nil
- allow subs argument to be nil - fix API doc - split check for nil and empty subs
Diffstat (limited to 'lib')
-rw-r--r--lib/asciidoctor/substitutors.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/asciidoctor/substitutors.rb b/lib/asciidoctor/substitutors.rb
index 367b9cbc..39776305 100644
--- a/lib/asciidoctor/substitutors.rb
+++ b/lib/asciidoctor/substitutors.rb
@@ -77,12 +77,12 @@ module Substitutors
# Public: Apply the specified substitutions to the source.
#
# source - The String or String Array of text to process; must not be nil.
- # subs - The substitutions to perform; can be a Symbol or Symbol Array; must not be nil (default: :normal).
- # expand - A Boolean to control whether substitution aliases are expanded (default: false).
+ # subs - The substitutions to perform; can be a Symbol, Symbol Array or nil (default: NORMAL_SUBS).
+ # expand - A Boolean (or nil) to control whether substitution aliases are expanded (default: nil).
#
# Returns a String or String Array with substitutions applied, matching the type of source argument.
- def apply_subs source, subs = NORMAL_SUBS, expand = false
- if source.empty? || subs.empty?
+ def apply_subs source, subs = NORMAL_SUBS, expand = nil
+ if source.empty? || !subs
return source
elsif expand
if ::Symbol === subs
@@ -101,6 +101,8 @@ module Substitutors
return source
end
end
+ elsif subs.empty?
+ return source
end
text = (multiline = ::Array === source) ? source * LF : source