Macro parser fails to output a trailing percent sign (%) when it directly follows a macro (e.g., "%[page]%")

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

User avatar
rakunavi
User
Posts: 2236
Joined: Sat Sep 11, 2021 5:04 am

Macro parser fails to output a trailing percent sign (%) when it directly follows a macro (e.g., "%[page]%")

Post by rakunavi »

Hello all,

I would like to report a limitation in the macro parsing engine used in dialog text fields. I confirmed this behavior in the "Bookmark Every N-th Page" dialog, but it likely affects all dialogs that rely on the same macro system.

Problem:
It is currently impossible to end a text string with a percent sign (%) that immediately follows a macro value.

Steps to reproduce:
  1. Open the "Bookmark Every N-th Page" dialog.
  2. Enter %[page]% in the Bookmark Title Template field where macros are supported.
  3. The trailing % is ignored by the parser and does not appear in the bookmark output.
Attempted workarounds (all failed):
I tried several possible escape methods, but none allowed the percent sign to appear:

  • %[page]\%
    (backslash does not escape it)
    • %[page]`%
      (backquote does not escape it)
      • %[page]%%
        (outputs "5%%" rather than "5%" when the page number is 5, for example, so it's impossible to produce a single percent sign)
        • %[page]​%
          (even inserting a Zero‑Width Space U+200B between ] and % does not prevent the parser from swallowing the percent sign)
        Additional observation:
        This issue occurs only when the percent sign is the final character after a macro.
        If any additional character is appended (e.g., "%[page]%X" or "%[page]% "), the percent sign appears correctly.
        This strongly suggests that the parser incorrectly attempts to treat % as the beginning of another macro and fails to fall back to literal output when % is the final character.

        Expected behavior:
        After completing a macro such as %[page], the parser should treat subsequent characters literally, including a percent sign. This is a natural use case when users want to display values like "5%".

        Hoping that the above information will be of some help to you.
        Thank you for your hard work on this great software.

        Best regards,
        rakunavi

        - PDF-XChange Editor PRO Version: 11.0.1
        - OS Version: Windows 11 Pro / Home 25H2 Build 26200.8655
        - PC Model: GMKtec Nucbox M7 Pro with HUION Kamvas Pro 19 / Lenovo IdeaPad C340-15IWL
        Top needs for PDFXCE
        forum.pdf-xchange.com/viewtopic.php?t=39665 LassoTool
        forum.pdf-xchange.com/viewtopic.php?t=38554 CmtGarbled
        forum.pdf-xchange.com/viewtopic.php?t=37353 FullScrnMultiMon
        forum.pdf-xchange.com/viewtopic.php?t=41002 DisableTouchSelect
        User avatar
        Daniel - PDF-XChange
        Site Admin
        Posts: 13019
        Joined: Wed Jan 03, 2018 6:52 pm

        Re: Macro parser fails to output a trailing percent sign (%) when it directly follows a macro (e.g., "%[page]%")

        Post by Daniel - PDF-XChange »

        Hello, rakunavi

        Thank you for the report. I have raised it with the dev team for review and resolution.
        [edit] Fixed, and will be implemented in 11.1.0

        Kind regards,
        Dan McIntyre - Support Technician
        PDF-XChange Co. LTD

        +++++++++++++++++++++++++++++++++++
        Our Web site domain and email address has changed as of 26/10/2023.
        https://www.pdf-xchange.com
        [email protected]
        User avatar
        rakunavi
        User
        Posts: 2236
        Joined: Sat Sep 11, 2021 5:04 am

        Re: Macro parser fails to output a trailing percent sign (%) when it directly follows a macro (e.g., "%[page]%")

        Post by rakunavi »

        Hello Daniel, thank you for contacting developers.

        I'm amazed at how fast it is. I appreciate all the hard work and efforts.
        I look forward to the release of Version 11.1.0.

        Best regards,
        rakunavi
        Top needs for PDFXCE
        forum.pdf-xchange.com/viewtopic.php?t=39665 LassoTool
        forum.pdf-xchange.com/viewtopic.php?t=38554 CmtGarbled
        forum.pdf-xchange.com/viewtopic.php?t=37353 FullScrnMultiMon
        forum.pdf-xchange.com/viewtopic.php?t=41002 DisableTouchSelect
        User avatar
        Dimitar - PDF-XChange
        Site Admin
        Posts: 2731
        Joined: Mon Jan 15, 2018 9:01 am

        Macro parser fails to output a trailing percent sign (%) when it directly follows a macro (e.g., "%[page]%")

        Post by Dimitar - PDF-XChange »

        :)