Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong translation of index terms inside parenthesis in DocBook backend #1581

Closed
shahryareiv opened this issue Nov 20, 2015 · 8 comments
Closed
Assignees
Labels
Milestone

Comments

@shahryareiv
Copy link
Contributor

This:

(something ((some indexterm)))

translates to:

(something <indexterm><primary>some indexterm)</primary></indexterm>some indexterm)

please note the extra ) in the index term.

@mojavelinux mojavelinux added the bug label Jan 2, 2016
@mojavelinux mojavelinux added this to the v1.5.4 milestone Jan 2, 2016
@mojavelinux mojavelinux self-assigned this Jan 2, 2016
@mojavelinux
Copy link
Member

This bug is present in AsciiDoc Python too, so it looks like we inherited it.

The workaround is to insert a zero-width space before the last ), though I recognize that is not ideal.

(something ((some indexterm)){zwsp})

@mojavelinux mojavelinux modified the milestones: v1.5.5, v1.5.4 Jan 2, 2016
@mojavelinux
Copy link
Member

In this case, I'd probably recommend the use of the indexterm2 inline macro.

(something indexterm2:[some indexterm])

When using the parenthetical form, it can be hard to determine the boundaries when adjacent to a parenthesis in the content. I'll see if I can find a way, but we'll have to see.

@shahryareiv
Copy link
Contributor Author

Thanks! I can see it is now scheduled for v1.5.5 so waiting is probably the best strategy for most of us.

@mojavelinux mojavelinux modified the milestones: v1.5.5, v1.5.6 Oct 3, 2016
@mojavelinux
Copy link
Member

I was able to work out how to solve this. We just needed to check more carefully about which surrounding brackets were captured.

mojavelinux added a commit to mojavelinux/asciidoctor that referenced this issue Jun 16, 2017
mojavelinux added a commit to mojavelinux/asciidoctor that referenced this issue Jun 16, 2017
…tting caught in indexterm

- check for captured leading and trailing brackets more carefully
- strip brackets that are not part of term and restore when converting text
- consolidate code to reduce redundant conditionals
- use slice with fixed positions when taking substrings
mojavelinux added a commit to mojavelinux/asciidoctor that referenced this issue Jun 17, 2017
…tting caught in indexterm

- check for captured leading and trailing brackets more carefully
- strip brackets that are not part of term and restore when converting text
- consolidate code to reduce redundant conditionals
- use slice with fixed positions when taking substrings
mojavelinux added a commit to mojavelinux/asciidoctor that referenced this issue Jun 17, 2017
…tting caught in indexterm

- check for captured leading and trailing brackets more carefully
- strip brackets that are not part of term and restore when converting text
- consolidate code to reduce redundant conditionals
- use slice with fixed positions when taking substrings
@ecki
Copy link

ecki commented Aug 9, 2017

I think this is not entirely fixed, when I have the following doc

= Test
Author
Version
:doctype: book

== chapter 1
test (((Index1)) is not hidden) but ((((Index2)))Index 2 is)

[index]
== Index

the followng result can be seen in the PDF:

chapter 1
test (Index1 is not hidden) but Index 2 is)
Index
@
(Index2, 1
I
Index1, 1

Instead of "test (Index1 is not hidden) but (Index 2 is)" with "Index2, 1"

I see this with asciidoctor.maven.plugin.version 1.5.5, asciidoctorj.version 1.5.6 and <asciidoctorj.pdf.version 1.5.0-alpha.15 on java 8u141 with jruby 9.1.8.0 on Win10 with Maven 3.5.0

@mojavelinux
Copy link
Member

mojavelinux commented Aug 9, 2017

I should be clear. There are going to be exceptions. The round bracket form a convenient short-hand. The regular-expression based parser simply doesn't have enough context to sort out what is content and what is markup when the content contains lots of round brackets. We shoot for making the most common cases work. Fo all others, I highly recommend the more definitive indexterm/indexterm2 macro.

@ecki
Copy link

ecki commented Aug 10, 2017

I understand it is not always possible, one improvement would be to not count ( or ) to the indexterm ever (unless inside quotes) can't imagine a situation where this would be desired

@mojavelinux
Copy link
Member

This may be covered in part by #2363.

Beyond that, we can't do anything until we fix #61. We have no way to look backwards or forwards in the string or to keep context. All we can do is try to make sense of what was matched...and we already do the checking we can do (when you add #2363).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants