Browse Source

Merge b2164cbdc6 into a6d1d484e5

pull/1145/merge
Yoo Seung-jun 2 weeks ago
committed by GitHub
parent
commit
87032e644e
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 15
      lib/rules_inline/state_inline.mjs

15
lib/rules_inline/state_inline.mjs

@ -3,6 +3,17 @@
import Token from '../token.mjs' import Token from '../token.mjs'
import { isWhiteSpace, isPunctChar, isMdAsciiPunct } from '../common/utils.mjs' import { isWhiteSpace, isPunctChar, isMdAsciiPunct } from '../common/utils.mjs'
// Check if the character is a CJK character.
//
// ranges:
// - 0x4E00 - 0x9FFF : CJK Unified Ideographs
// - 0xAC00 - 0xD7A3 : Hangul Syllables
//
function isCJK (code) {
return (code >= 0x4E00 && code <= 0x9FFF) ||
(code >= 0xAC00 && code <= 0xD7A3)
}
function StateInline (src, md, env, outTokens) { function StateInline (src, md, env, outTokens) {
this.src = src this.src = src
this.env = env this.env = env
@ -106,10 +117,12 @@ StateInline.prototype.scanDelims = function (start, canSplitWord) {
const isLastWhiteSpace = isWhiteSpace(lastChar) const isLastWhiteSpace = isWhiteSpace(lastChar)
const isNextWhiteSpace = isWhiteSpace(nextChar) const isNextWhiteSpace = isWhiteSpace(nextChar)
const isNextCJK = isCJK(nextChar)
const left_flanking = const left_flanking =
!isNextWhiteSpace && (!isNextPunctChar || isLastWhiteSpace || isLastPunctChar) !isNextWhiteSpace && (!isNextPunctChar || isLastWhiteSpace || isLastPunctChar)
const right_flanking = const right_flanking =
!isLastWhiteSpace && (!isLastPunctChar || isNextWhiteSpace || isNextPunctChar) !isLastWhiteSpace && (!isLastPunctChar || isNextWhiteSpace || isNextPunctChar || isNextCJK)
const can_open = left_flanking && (canSplitWord || !right_flanking || isLastPunctChar) const can_open = left_flanking && (canSplitWord || !right_flanking || isLastPunctChar)
const can_close = right_flanking && (canSplitWord || !left_flanking || isNextPunctChar) const can_close = right_flanking && (canSplitWord || !left_flanking || isNextPunctChar)

Loading…
Cancel
Save