Перейти к содержимому
Топаз6.0 · До релиза
Загрузка →

Поиск в документации

Спецификация 6.0

Выберите результат стрелками и нажмите Enter, чтобы открыть его.

Введите имя API, номер диагностики, правило или тему проекта.

    Библиотека · std.typeset

    BreakKind.ForcedEnd

    Marks a terminal or mandatory Unicode boundary.

    BreakKind.ForcedEnd()
    Модуль
    std.typeset →
    Получатель
    Неприменимо
    Минимальное число аргументов
    0
    Максимальное число аргументов
    0

    Declaration and parameters

    Ссылка

    Доступность

    Включено по умолчанию · Не определено

    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.

    Получатель

    Ограничения параметров

    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 and effects

    Ссылка

    The classifier uses this category for the paragraph end and internal mandatory Unicode boundaries. Preserve the boundary during planning by assigning BreakRule.Forced() to its penalty.

    Resolved contracts

    Ссылка

    Related entries

    Ссылка

    std.typeset →

    Keep boundary policy separate from break category

    Ссылка
    Правилоtopaz.stdlib.contract.typeset-break-categories.rule

    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.

    Причина

    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.

    Select Japanese small-kana protection explicitly

    Ссылка
    main.tpzSelect Japanese small-kana protection explicitlyОткрыть песочницу →
    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}")
    Ожидаемый выводКод завершения 0
    2 1
    
    $ topaz run main.tpz · Целевой продукт 5.21.3
    Ожидаемый результат

    Ожидаемый результат

    Выполнение завершается. Код завершения 0.

    Ожидаемый стандартный вывод
    1. 2 1

    Keep a nonbreaking space protected in character mode

    Ссылка
    main.tpzKeep a nonbreaking space protected in character modeОткрыть песочницу →
    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}")
    Ожидаемый выводКод завершения 0
    1 3
    
    $ topaz run main.tpz · Целевой продукт 5.21.3
    Ожидаемый результат

    Ожидаемый результат

    Выполнение завершается. Код завершения 0.

    Ожидаемый стандартный вывод
    1. 1 3

    Reject a cluster that hides a mandatory Unicode break

    Ссылка
    main.tpzReject a cluster that hides a mandatory Unicode breakОткрыть песочницу →
    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)))
    Ожидаемый выводКод завершения 0
    InvalidInput
    
    $ topaz run main.tpz · Целевой продукт 5.21.3
    Ожидаемый результат

    Ожидаемый результат

    Выполнение завершается. Код завершения 0.

    Ожидаемый стандартный вывод
    1. InvalidInput

    Меню

    Загрузка →