diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2019-03-11 23:56:02 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-11 23:56:02 -0600 |
| commit | 8e3e095076cd688c777a2d44cd54707d97d58c24 (patch) | |
| tree | d141174f1eb576390bb9a7cc16e71ad195cd14a8 | |
| parent | 4b29b49eb796d36716a3a5397d385ead37469b8b (diff) | |
resolves #2912 propogate ID assigned to inline passthrough (PR #3141)
| -rw-r--r-- | CHANGELOG.adoc | 1 | ||||
| -rw-r--r-- | lib/asciidoctor/substitutors.rb | 7 | ||||
| -rw-r--r-- | test/substitutions_test.rb | 5 |
3 files changed, 8 insertions, 5 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 38572b08..bb9f6f81 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -68,6 +68,7 @@ Enhancements / Compliance:: * AbstractBlock#find_by looks inside AsciiDoc table cells if traverse_documents selector option is true (#3101) * AbstractBlock#find_by finds table cells, which can be selected using the :table_cell context in the selector (#2524) * allow ampersand to be used in e-mail address (#2553) + * propogate ID assigned to inline passthrough (#2912) Improvements:: diff --git a/lib/asciidoctor/substitutors.rb b/lib/asciidoctor/substitutors.rb index 0923c45e..a6672503 100644 --- a/lib/asciidoctor/substitutors.rb +++ b/lib/asciidoctor/substitutors.rb @@ -232,7 +232,7 @@ module Substitutors if compat_mode old_behavior = true else - if (old_behavior = (attributes && (attributes.end_with? 'x-'))) + if (old_behavior = attributes && (attributes.end_with? 'x-')) attributes = attributes.slice 0, attributes.length - 2 end end @@ -319,7 +319,10 @@ module Substitutors if (pass = passthrus[$1.to_i]) subbed_text = apply_subs(pass[:text], pass[:subs]) if (type = pass[:type]) - subbed_text = Inline.new(self, :quoted, subbed_text, type: type, attributes: pass[:attributes]).convert + if (attributes = pass[:attributes]) + id = attributes.delete 'id' + end + subbed_text = Inline.new(self, :quoted, subbed_text, type: type, id: id, attributes: attributes).convert end subbed_text.include?(PASS_START) ? restore_passthroughs(subbed_text) : subbed_text else diff --git a/test/substitutions_test.rb b/test/substitutions_test.rb index 3a2d9522..176bd25f 100644 --- a/test/substitutions_test.rb +++ b/test/substitutions_test.rb @@ -34,7 +34,7 @@ context 'Substitutions' do assert_equal %(this<br>\nis<br>\n→ Asciidoctor<br>\n<br>\n), result end - test 'should expand subs passe to expand_subs' do + test 'should expand subs passed to expand_subs' do para = block_from_string %({program}\n*bold*\n2 > 1) para.document.attributes['program'] = 'Asciidoctor' assert_equal [:specialcharacters], (para.expand_subs [:specialchars]) @@ -567,8 +567,7 @@ context 'Substitutions' do test 'inline passthrough with id and role set using shorthand' do para = block_from_string '[#id.role]+pass+' - # FIXME id should be propogated - assert_equal '<span class="role">pass</span>', para.content + assert_equal '<span id="id" class="role">pass</span>', para.content end test 'should assign role attribute when shorthand style contains a role' do |
