diff options
| author | Dan Allen <dallen@redhat.com> | 2013-06-12 00:40:17 -0600 |
|---|---|---|
| committer | Dan Allen <dallen@redhat.com> | 2013-06-18 00:53:41 -0600 |
| commit | 004b41d6dbda54bc026348a8675f83395a183082 (patch) | |
| tree | 620a097776a27283708f9f5434462fbde42933ed /lib | |
| parent | c4b1f0e34c45857468c0673e60e7e808c5c59e9b (diff) | |
properly handle escaping scenarios
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/asciidoctor/substituters.rb | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/asciidoctor/substituters.rb b/lib/asciidoctor/substituters.rb index fb00dc3f..0c3acb4e 100644 --- a/lib/asciidoctor/substituters.rb +++ b/lib/asciidoctor/substituters.rb @@ -173,23 +173,23 @@ module Substituters # alias match for Ruby 1.8.7 compat m = $~ + unescaped_attrs = nil # honor the escape if m[3].start_with? '\\' - if m[2].nil? - next "#{m[1]}#{m[3][1..-1]}" - else - next "#{m[1]}[#{m[2]}]#{m[3][1..-1]}" - end + next m[2].nil? ? "#{m[1]}#{m[3][1..-1]}" : "#{m[1]}[#{m[2]}]#{m[3][1..-1]}" + elsif m[1] == '\\' && !m[2].nil? + unescaped_attrs = "[#{m[2]}]" end - attributes = {} - unless m[2].nil? + if unescaped_attrs.nil? && !m[2].nil? attributes = parse_attributes(m[2]) + else + attributes = {} end @passthroughs << {:text => m[4], :subs => [:specialcharacters], :attributes => attributes, :literal => true} index = @passthroughs.size - 1 - "#{m[1]}\e#{index}\e" + "#{unescaped_attrs || m[1]}\e#{index}\e" } unless !result.include?('`') result |
