Skip to content

Ignore linebreaks between Chinese/Japanese characters in source code #792

@peng1999

Description

@peng1999

Typst currently support breaking a paragraph into several consecutive lines in source code, without introduce a newline in result PDF. The single newline in source code will just become a space. However, when working with scripts that do not using spaces between words, like Chinese and Japanese, we often not want to have the newline, nor the space.

In a paragraph like this:

中文
测试

In Chinese context, the most sensible result is 中文测试, without any spaces and newlines.

I propose implementing the following features in typst:

  1. Eliminate spaces between CJK characters in source code.
  2. Let trailing comment consume a linebreak in source code.
    This is because sometimes we have a inline frame and CJK detect will not work, so we need an opt-in method. I think the changed behavior can be minimal, comments will consume new line only if it has no space before it.
    For example, this code
    abc //
    def
    
    becomes abc def
    and
    abc//
    def
    
    becomes abcdef.
    Latin users often use the former one so they will not be affected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cjkChinese, Japanese, Korean typography.feature requestNew feature or requestsyntaxAbout syntax, parsing, etc.textRelated to the text category, which is all about text handling, shaping, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions