Skip to content
Topaz6.0 · Before release
Download

Search documentation

Specification 6.0 · Not released · Tested product 5.21.3

Use arrow keys to choose a result. Press Enter to open.

Type an API name, diagnostic number, rule, or project topic.

    Library · std.typeset

    BreakKind.ClosingPunctuation

    Marks an admitted boundary after closing punctuation.

    BreakKind.ClosingPunctuation()
    Receiver
    Not applicable
    Minimum arity
    0
    Maximum arity
    0

    Declaration and parameters

    Link

    Availability

    Included by default: Pending

    Import std.typeset in language mode 5.21.

    The current compiler selects std/typeset.tpz for this language mode. Availability in other released editions and inclusion in each installed distribution are Pending.

    Source evidence

    Receiver

    Parameter constraints

    KinsokuRules is an explicit choice of boundary policy. AtlasDefault retains its fixed Atlas punctuation sets and context checks. It does not acquire new Unicode rules when the host changes.

    Unicode16Ko, Unicode16Zh, and Unicode16Ja use the ordered Unicode 16.0.0 UAX 14 revision 53 decisions. They retain non-tailorable prohibitions, mandatory breaks, and required opportunities before locale and custom typography rules.

    The Korean policy applies KLReq punctuation and fitting Hangul word handling. The Japanese policy applies strict JLReq kinsoku including small kana and numeric prefix and suffix contexts. The Chinese policy applies CLReq basic punctuation handling. The exact versioned character predicates are the referenced policy definitions.

    Unicode policies reject a cluster that crosses a mandatory line break with TypesetError.InvalidInput. A mandatory break after an intact cluster is a ForcedEnd opportunity even when more clusters follow. A cluster boundary inside a forbidden Unicode sequence is not an opportunity.

    LatinSpace marks an admitted boundary after a cluster whose text is U+0020. LatinHyphen marks an admitted boundary after an existing hyphen cluster. LatinSoftHyphen marks an admitted generated hyphen candidate. Neither category inserts a character into the input.

    ClosingPunctuation marks an admitted boundary after the selected closing-punctuation category. CjkCluster marks the admitted CJK or East Asian cluster category. HardFallback marks another admitted boundary or a permitted emergency word boundary. These categories do not authorize a break excluded by the selected policy.

    ForcedEnd marks the paragraph end or a mandatory Unicode boundary. BreakRule.Forced is the distinct planning constraint that prevents a plan from crossing that position. A ForcedEnd category on a caller-created penalty does not replace its BreakRule.

    For Unicode candidates, mandatory boundaries are classified first, followed by space, existing hyphen, closing punctuation, CJK or East Asian text, and HardFallback. Generated hyphens replace a missing or HardFallback category when admissible. Output ordering follows the cluster indices rather than category order.

    Result

    Effects

    Failures

    Result and effects

    Link

    The selected fixed or Unicode policy decides the boundary and punctuation category. The kind carries that classification to later planning.

    Resolved contracts

    Link

    Related entries

    Link

    std.typeset

    Keep boundary policy separate from break category

    Link

    Keep boundary policy separate from break category

    KinsokuRules is an explicit choice of boundary policy. AtlasDefault retains its fixed Atlas punctuation sets and context checks. It does not acquire new Unicode rules when the host changes.

    Unicode16Ko, Unicode16Zh, and Unicode16Ja use the ordered Unicode 16.0.0 UAX 14 revision 53 decisions. They retain non-tailorable prohibitions, mandatory breaks, and required opportunities before locale and custom typography rules.

    The Korean policy applies KLReq punctuation and fitting Hangul word handling. The Japanese policy applies strict JLReq kinsoku including small kana and numeric prefix and suffix contexts. The Chinese policy applies CLReq basic punctuation handling. The exact versioned character predicates are the referenced policy definitions.

    Unicode policies reject a cluster that crosses a mandatory line break with TypesetError.InvalidInput. A mandatory break after an intact cluster is a ForcedEnd opportunity even when more clusters follow. A cluster boundary inside a forbidden Unicode sequence is not an opportunity.

    LatinSpace marks an admitted boundary after a cluster whose text is U+0020. LatinHyphen marks an admitted boundary after an existing hyphen cluster. LatinSoftHyphen marks an admitted generated hyphen candidate. Neither category inserts a character into the input.

    ClosingPunctuation marks an admitted boundary after the selected closing-punctuation category. CjkCluster marks the admitted CJK or East Asian cluster category. HardFallback marks another admitted boundary or a permitted emergency word boundary. These categories do not authorize a break excluded by the selected policy.

    ForcedEnd marks the paragraph end or a mandatory Unicode boundary. BreakRule.Forced is the distinct planning constraint that prevents a plan from crossing that position. A ForcedEnd category on a caller-created penalty does not replace its BreakRule.

    For Unicode candidates, mandatory boundaries are classified first, followed by space, existing hyphen, closing punctuation, CJK or East Asian text, and HardFallback. Generated hyphens replace a missing or HardFallback category when admissible. Output ordering follows the cluster indices rather than category order.

    Why

    A locale policy decides whether a boundary can be used. A category tells the planner why that admitted boundary exists. Keeping those roles distinct lets the same paragraph model carry Unicode, locale, and caller-supplied constraints without treating a punctuation label as permission.

    Source evidence

    Select Japanese small-kana protection explicitly

    Link
    main.tpzSelect Japanese small-kana protection explicitlyOpen in Playground
    1. import std.typeset as ts
    2. import std.io
    3. import std.test
    4. let clusters = [ts.BreakCluster { text: "あ", advance: 1pt, trackingAfter: 0pt }, ts.BreakCluster { text: "ぁ", advance: 1pt, trackingAfter: 0pt }]
    5. let atlas = ts.BreakPolicy {
    6. mode: ts.BreakMode.Character(),
    7. rules: ts.KinsokuRules.AtlasDefault(),
    8. forbidBefore: [],
    9. forbidAfter: [],
    10. boundaryAllowed: [true, true],
    11. generatedHyphenEnds: [],
    12. protectFittingLatin: false,
    13. preserveShortWords: false,
    14. narrowestWordTarget: 0pt,
    15. bodyWordTarget: 0pt
    16. }
    17. let japanese = ts.BreakPolicy {
    18. mode: ts.BreakMode.Character(),
    19. rules: ts.KinsokuRules.Unicode16Ja(),
    20. forbidBefore: [],
    21. forbidAfter: [],
    22. boundaryAllowed: [true, true],
    23. generatedHyphenEnds: [],
    24. protectFittingLatin: false,
    25. preserveShortWords: false,
    26. narrowestWordTarget: 0pt,
    27. bodyWordTarget: 0pt
    28. }
    29. let a = test.assertOk(ts.classifyBreaks(clusters, atlas))
    30. let b = test.assertOk(ts.classifyBreaks(clusters, japanese))
    31. io.writeLine("{a.length} {b.length}")
    Expected outputexit 0
    2 1
    
    $ topaz run main.tpz · target product 5.21.3
    Expected result

    Expected result

    Execution completes. Exit code 0.

    Expected stdout
    1. 2 1
    Source evidence

    Keep a nonbreaking space protected in character mode

    Link
    main.tpzKeep a nonbreaking space protected in character modeOpen in Playground
    1. import std.typeset as ts
    2. import std.io
    3. import std.test
    4. let clusters = [ts.BreakCluster { text: "A", advance: 1pt, trackingAfter: 0pt }, ts.BreakCluster { text: " ", advance: 1pt, trackingAfter: 0pt }, ts.BreakCluster { text: "B", advance: 1pt, trackingAfter: 0pt }]
    5. let selected = ts.BreakPolicy {
    6. mode: ts.BreakMode.Character(),
    7. rules: ts.KinsokuRules.Unicode16Ja(),
    8. forbidBefore: [],
    9. forbidAfter: [],
    10. boundaryAllowed: [true, true, true],
    11. generatedHyphenEnds: [],
    12. protectFittingLatin: false,
    13. preserveShortWords: false,
    14. narrowestWordTarget: 0pt,
    15. bodyWordTarget: 0pt
    16. }
    17. let breaks = test.assertOk(ts.classifyBreaks(clusters, selected))
    18. io.writeLine("{breaks.length} {breaks[0].unitEnd}")
    Expected outputexit 0
    1 3
    
    $ topaz run main.tpz · target product 5.21.3
    Expected result

    Expected result

    Execution completes. Exit code 0.

    Expected stdout
    1. 1 3
    Source evidence

    Reject a cluster that hides a mandatory Unicode break

    Link
    main.tpzReject a cluster that hides a mandatory Unicode breakOpen in Playground
    1. import std.typeset as ts
    2. import std.io
    3. import std.test
    4. function outcome(value: Result<Array<ts.BreakOpportunity>, ts.TypesetError>) -> string {
    5. match (value) {
    6. case Ok(_) => "Ok"
    7. case Err(InvalidInput(_)) => "InvalidInput"
    8. case Err(InvalidPolicy(_)) => "InvalidPolicy"
    9. case Err(_) => "unexpected error"
    10. }
    11. }
    12. let clusters = [ts.BreakCluster { text: "A\nB", advance: 1pt, trackingAfter: 0pt }]
    13. let selected = ts.BreakPolicy {
    14. mode: ts.BreakMode.Character(),
    15. rules: ts.KinsokuRules.Unicode16Ja(),
    16. forbidBefore: [],
    17. forbidAfter: [],
    18. boundaryAllowed: [true],
    19. generatedHyphenEnds: [],
    20. protectFittingLatin: false,
    21. preserveShortWords: false,
    22. narrowestWordTarget: 0pt,
    23. bodyWordTarget: 0pt
    24. }
    25. io.writeLine(outcome(ts.classifyBreaks(clusters, selected)))
    Expected outputexit 0
    InvalidInput
    
    $ topaz run main.tpz · target product 5.21.3
    Expected result

    Expected result

    Execution completes. Exit code 0.

    Expected stdout
    1. InvalidInput
    Source evidence

    Menu

    Download