Skip to content

Commit

Permalink
resolves asciidoctor#3652 honor secondary and tertiary terms on index…
Browse files Browse the repository at this point in the history
…term macro when primary term is quoted and contains =
  • Loading branch information
mojavelinux committed Nov 2, 2023
1 parent df9cfb3 commit c90880f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Expand Up @@ -70,6 +70,7 @@ Bug Fixes::

* Preserve paragraph breaks in normal table cell in manpage output (#4481)
* Escape spaces in include target (using inline passthrough) when generating link from include directive (#4461)
* Honor secondary and tertiary terms on `indexterm` macro when primary term is quoted and contains an equals sign (#3652)

== 2.0.20 (2023-05-18) - @mojavelinux

Expand Down
9 changes: 8 additions & 1 deletion lib/asciidoctor/substitutors.rb
Expand Up @@ -446,7 +446,14 @@ def sub_macros text
# indexterm:[Tigers,Big cats]
if (attrlist = normalize_text $2, true, true).include? '='
if (primary = (attrs = (AttributeList.new attrlist, self).parse)[1])
attrs['terms'] = [primary]
terms = [primary]
if (secondary = attrs[2])
terms << secondary
if (tertiary = attrs[3])
terms << tertiary
end
end
attrs['terms'] = terms
if (see_also = attrs['see-also'])
attrs['see-also'] = (see_also.include? ',') ? (see_also.split ',').map {|it| it.lstrip } : [see_also]
end
Expand Down
11 changes: 11 additions & 0 deletions test/substitutions_test.rb
Expand Up @@ -1632,6 +1632,17 @@
assert_includes output, indexterm_html5
end

test 'should honor secondary and tertiary index terms when primary index term is quoted and contains equals sign' do
sentence = 'Assigning variables.'
expected = %(#{sentence}<indexterm><primary>name=value</primary><secondary>variable</secondary><tertiary>assignment</tertiary></indexterm>)
macros = ['indexterm:["name=value",variable,assignment]', '(((name=value,variable,assignment)))']
macros.each do |macro|
para = block_from_string %(#{sentence}#{macro}), backend: 'docbook'
output = (para.sub_macros para.source).tr ?\n, ''
assert_equal expected, output
end
end

context 'Button macro' do
test 'btn macro' do
para = block_from_string 'btn:[Save]', attributes: { 'experimental' => '' }
Expand Down

0 comments on commit c90880f

Please sign in to comment.