Skip to content

Commit

Permalink
Merge pull request #991 from ecomfe/master
Browse files Browse the repository at this point in the history
chore: merge master to release for 5.4.2
  • Loading branch information
plainheart authored Mar 7, 2023
2 parents 870b3b2 + 9197e05 commit 4ff64f3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 11 additions & 3 deletions src/graphic/helper/parseText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -591,9 +591,17 @@ function pushTokens(
}


function isLatin(ch: string) {
function isAlphabeticLetter(ch: string) {
// Unicode Character Ranges
// https://jrgraphix.net/research/unicode_blocks.php
// The following ranges may not cover all letter ranges but only the more
// popular ones. Developers could make pull requests when they find those
// not covered.
let code = ch.charCodeAt(0);
return code >= 0x21 && code <= 0x17F;
return code >= 0x20 && code <= 0x24F // Latin
|| code >= 0x370 && code <= 0x10FF // Greek, Coptic, Cyrilic, and etc.
|| code >= 0x1200 && code <= 0x13FF // Ethiopic and Cherokee
|| code >= 0x1E00 && code <= 0x206F; // Latin and Greek extended
}

const breakCharMap = reduce(',&?/;] '.split(''), function (obj, ch) {
Expand All @@ -604,7 +612,7 @@ const breakCharMap = reduce(',&?/;] '.split(''), function (obj, ch) {
* If break by word. For latin languages.
*/
function isWordBreakChar(ch: string) {
if (isLatin(ch)) {
if (isAlphabeticLetter(ch)) {
if (breakCharMap[ch]) {
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/svg/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ export function vNodeToString(el: SVGVNode, opts?: {
opts = opts || {};
const S = opts.newline ? '\n' : '';
function convertElToString(el: SVGVNode): string {
const {children, tag, attrs} = el;
const {children, tag, attrs, text} = el;
return createElementOpen(tag, attrs)
+ encodeHTML(el.text)
+ (tag !== 'style' ? encodeHTML(text) : text || '')
+ (children ? `${S}${map(children, child => convertElToString(child)).join(S)}${S}` : '')
+ createElementClose(tag);
}
Expand Down

0 comments on commit 4ff64f3

Please sign in to comment.