Skip to content

Punctuation compression does not work with #show #5474

Open

Description

@OverflowCat

Description

#set text(lang: "zh", font: "Noto Serif CJK SC")

)。啊
).啊

#show "。": "."

)。啊 // this is incorrect
).啊

Reproduction URL

No response

Operating system

Web app

Typst version

  • I am using the latest version of Typst

Activity

  1. added
    bug
    on Nov 26, 2024
  2. added
    text
    on Nov 29, 2024
  3. added
    cjk
    on Feb 10, 2025
  4. mozhewen commented on Mar 16, 2025

    @mozhewen

    It's standard practice to use full-width periods in Chinese mathematical articles. Currently a workaround I can think of is:

    #show ")。": ")."
    #show "。": "."

    Or more generally use a regex for more punctuations.
    And this doesn't work if “)” is wrapped in strong or emph.

  5. OverflowCat commented on Mar 18, 2025

    @OverflowCat
    ContributorAuthor

    Or more generally use a regex for more punctuations.

    Aha, this should work:

    #show regex("[,。.、:;?!》)』」】〗〕〉]}“‘《(『「【〖〔〈[{,。.、:;]+"): it => it.text.replace("。", ".")

    And this doesn't work if “)” is wrapped in strong or emph.

    In this case, it is strong itself prevents the compression, rather than #show rules. The repr of #show differs between the two cases. Just wondering if compression is the desired behavior considering the semantic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcjktext

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions