Skip to content

Commit

Permalink
resolves #3652 honor secondary and tertiary terms on indexterm macro …
Browse files Browse the repository at this point in the history
…when primary term is quoted and contains = (PR #4511)
  • Loading branch information
mojavelinux committed Nov 26, 2023
1 parent 8c02de1 commit d89c1ec
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Bug Fixes::
* Preserve paragraph breaks in normal table cell in manpage output (#4481)
* Style cells in head row as bold in manpage output (#4490)
* 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
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,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
Original file line number Diff line number Diff line change
Expand Up @@ -1595,6 +1595,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 d89c1ec

Please sign in to comment.