html.entities: minor refactor for clarity.
parent
50ca01a4d8
commit
d27fa562e8
|
@ -2316,9 +2316,7 @@ CONSTANT: html5 H{
|
||||||
{ "zwnj;" "\u00200c" }
|
{ "zwnj;" "\u00200c" }
|
||||||
}
|
}
|
||||||
|
|
||||||
: replace-charref ( str -- str' )
|
: numeric-charref ( str -- newstr )
|
||||||
"#" ?head [
|
|
||||||
! numeric charref
|
|
||||||
";" ?tail drop dup first "xX" member?
|
";" ?tail drop dup first "xX" member?
|
||||||
[ rest hex> ] [ dec> ] if invalid-charrefs ?at [
|
[ rest hex> ] [ dec> ] if invalid-charrefs ?at [
|
||||||
dup { [ 0xD800 0xDFFF between? ] [ 0x10FFFF > ] } 1||
|
dup { [ 0xD800 0xDFFF between? ] [ 0x10FFFF > ] } 1||
|
||||||
|
@ -2326,15 +2324,17 @@ CONSTANT: html5 H{
|
||||||
dup invalid-codepoints member?
|
dup invalid-codepoints member?
|
||||||
[ drop "" ] [ 1string ] if
|
[ drop "" ] [ 1string ] if
|
||||||
] if
|
] if
|
||||||
] unless
|
] unless ;
|
||||||
] [
|
|
||||||
! named charref
|
: named-charref ( str -- newstr )
|
||||||
html5 ?at [
|
html5 ?at [
|
||||||
! find the longest matching name
|
! find the longest matching name
|
||||||
dup dup length 1 (a,b) [ head html5 at ] with map-find
|
dup dup length 1 (a,b) [ head html5 at ] with map-find
|
||||||
[ swapd tail append ] [ drop "&" prepend ] if*
|
[ swapd tail append ] [ drop "&" prepend ] if*
|
||||||
] unless
|
] unless ;
|
||||||
] if ;
|
|
||||||
|
: replace-charref ( str -- newstr )
|
||||||
|
"#" ?head [ numeric-charref ] [ named-charref ] if ;
|
||||||
|
|
||||||
CONSTANT: re-charref
|
CONSTANT: re-charref
|
||||||
R/ &(#[0-9]+|#[xX][0-9a-fA-F]+|[^\t\n\f <&#;]{1,32});?/
|
R/ &(#[0-9]+|#[xX][0-9a-fA-F]+|[^\t\n\f <&#;]{1,32});?/
|
||||||
|
|
Loading…
Reference in New Issue