summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2014-08-06 18:19:46 -0600
committerDan Allen <dan.j.allen@gmail.com>2014-08-06 18:19:46 -0600
commit27d7367cd16eb6cd91595f6cd85be9d1f2945719 (patch)
tree2171b0c0441901644d4d6334897bea3bea7aaa74
parentf2738271e8d95f79330c1c2f30075fe2c354a591 (diff)
fix crash when restoring nested passthroughs, update test
-rw-r--r--lib/asciidoctor/substitutors.rb10
-rw-r--r--test/substitutions_test.rb6
2 files changed, 8 insertions, 8 deletions
diff --git a/lib/asciidoctor/substitutors.rb b/lib/asciidoctor/substitutors.rb
index 08f114bb..2b31a0eb 100644
--- a/lib/asciidoctor/substitutors.rb
+++ b/lib/asciidoctor/substitutors.rb
@@ -326,11 +326,11 @@ module Substitutors
# Internal: Restore the passthrough text by reinserting into the placeholder positions
#
# text - The String text into which to restore the passthrough text
- # check - A Boolean indicating whether to check whether substitution is necessary (default: true)
+ # outer - A Boolean indicating whether we are in the outer call (default: true)
#
# returns The String text with the passthrough text restored
- def restore_passthroughs text, check = true
- if check && (@passthroughs.empty? || !text.include?(PASS_START))
+ def restore_passthroughs text, outer = true
+ if outer && (@passthroughs.empty? || !text.include?(PASS_START))
return text
end
@@ -344,8 +344,8 @@ module Substitutors
subbed_text.include?(PASS_START) ? restore_passthroughs(subbed_text, false) : subbed_text
}
ensure
- # free memory...we don't need these anymore
- @passthroughs.clear
+ # free memory if in outer call...we don't need these anymore
+ @passthroughs.clear if outer
end
# Public: Substitute special characters (i.e., encode XML)
diff --git a/test/substitutions_test.rb b/test/substitutions_test.rb
index 5bbef3ea..0b42312b 100644
--- a/test/substitutions_test.rb
+++ b/test/substitutions_test.rb
@@ -1235,9 +1235,9 @@ EOS
assert_equal 'some &lt;code&gt;{code}&lt;/code&gt; to study in the {language} programming language', result
end
- test 'restore nested passthroughs' do
- result = render_embedded_string %q(+I'm in pass:q[`mono`].+), :doctype => :inline
- assert_equal %q(I'm in <code>mono</code>.), result
+ test 'should restore nested passthroughs' do
+ result = render_embedded_string %q(+Sometimes you feel pass:q[`mono`].+ Sometimes you +$$don't$$+.), :doctype => :inline
+ assert_equal %q(Sometimes you feel <code>mono</code>. Sometimes you don't.), result
end
test 'should honor role on double plus passthrough' do