UNPKG

pangu

Version:

Paranoid text spacing for good readability, to automatically insert whitespace between CJK (Chinese, Japanese, Korean) and half-width characters (alphabetical letters, numerical digits and symbols).

31 lines (30 loc) 1.42 kB
export type BoundarySpacingVerdict = 'none' | 'prepend-next' | 'append-current' | 'insert-element'; export type TextRunSpacingVerdict = 'trim-leading-space' | 'prepend-space' | 'apply-text-spacing'; export interface BoundarySpacingContext { currentTail: string; nextFirst: string; currentEndsWithSpace: boolean; nextStartsWithSpace: boolean; whitespaceBetween: boolean; contentBetween: boolean; spaceLikeSiblingAfterCurrent: boolean; spaceLikeSiblingAfterCurrentBoundary: boolean; spaceLikeSiblingBeforeNext: boolean; spaceLikeSiblingBeforeNextBoundary: boolean; currentBoundaryIsBlock: boolean; currentBoundaryIsSpaceSensitive: boolean; nextBoundaryIsBlock: boolean; nextBoundaryIsIgnored: boolean; nextBoundaryIsSpaceSensitive: boolean; hiddenBoundaryBefore: () => boolean; hiddenBoundaryAfter: () => boolean; inGridOrFlexContainer: () => boolean; } export interface TextRunSpacingContext { text: string; previousElementLastChar: string | null; hiddenBoundaryBefore: () => boolean; } export declare function decideBoundarySpacing(context: BoundarySpacingContext): "none" | "prepend-next" | "append-current" | "insert-element"; export declare function decideTextRunSpacing(context: TextRunSpacingContext): TextRunSpacingVerdict[]; export declare function respaceCurrentTail(currentTail: string, nextFirst: string): string | null;