Commit ca6922b2 authored by Pouya Kary's avatar Pouya Kary

fixed the length issue with blocks

parent 7b217908
......@@ -21,6 +21,16 @@
// ../../quartets/html-entities.quartet
const selectedBlockHTMl = /\<span class\="console\-highlight\-active\-block"\>(.*)\<\/span\>/g
//
// ─── HTML TEXT LENGTH COUNTER ───────────────────────────────────────────────────
//
function countHTMLEmbeddedTextLength ( text ) {
const element = document.createElement('div')
element.innerHTML = text
return element.innerText.length
}
//
// ─── TO UNICODE ─────────────────────────────────────────────────────────────────
//
......@@ -59,9 +69,11 @@
//
function quartetSequence ( code ) {
return '(?:' + code + ')'
// if ( sequenceRegEx.test( code ) ) return code
// return ( quartetGetStringLength( code ) <= 1 )? code : '(?:' + code + ')'
const length = countHTMLEmbeddedTextLength( code )
if ( length <= 1 )
return code
else
return '(?:' + code + ')'
}
//
......@@ -122,14 +134,6 @@
return text.replace(/ /g, '&nbsp;')
}
//
// ─── GET STRING LENGTH ──────────────────────────────────────────────────────────
//
function quartetGetStringLength ( code ) {
return code.replace( htmlSpecialEntities, ' ' ).length
}
//
// ─── SPACE DECODE ───────────────────────────────────────────────────────────────
//
......@@ -143,10 +147,14 @@
//
function quartetAlphabet ( sigma ) {
if ( sigma.length === 0 ) return ''
if ( sigma.length === 0 )
return ''
return quartetEncodeHTML(
( sigma.length === 1 )? sigma[ 0 ] : '[' + sigma.join('') + ']'
)
( sigma.length === 1 )
? sigma[ 0 ]
: '[' + sigma.join('') + ']'
)
}
//
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment