tweaking...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2023-10-20 19:00:35 +03:00
parent 436bf6ffae
commit df7b74f1a3
2 changed files with 34 additions and 1 deletions

View File

@ -538,16 +538,48 @@ var styling = {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//
// XXX use ligatures for these???
var symbols = {
__proto__: plugin,
// XXX use a single regex with handler func to do these...
symbols: {
'>>': '»',
'<<': '«',
'->': '→',
'<-': '←',
'=>': '⇒',
'<=': '⇐',
'(i)': '🛈',
'(c)': '©',
'/!\\': '⚠',
},
get symbols_pattern(){
return new RegExp(`(?<!\\\\)(${
Object.keys(this.symbols)
.join('|')
.replace(/([\(\)\\\/])/g, '\\$1')
})`, 'g') },
__parse__: function(text, editor, elem){
var that = this
return text
.replace(this.symbols_pattern,
function(m){
return that.symbols[m] })
// characters...
/*
.replace(/(?<!\\)>>/gm, '»')
.replace(/(?<!\\)<</gm, '«')
.replace(/(?<![\\<])->/gm, '→')
.replace(/(?<![\\<])=>/gm, '⇒')
.replace(/(?<!\\)<-(?!>)/gm, '←')
.replace(/(?<!\\)<=(?!>)/gm, '⇐')
.replace(/(?<!\\)\(i\)/gm, '🛈')
.replace(/(?<!\\)\(c\)/gm, '©')
.replace(/(?<!\\)\/!\\/gm, '⚠')
//*/
.replace(/(?<!\\)---(?!-)/gm, '&mdash;')
.replace(/(?<!\\)--(?!-)/gm, '&ndash;') },
}

View File

@ -261,7 +261,8 @@ var setup = function(){
| 11 | 22 | 33 |
- Symbols -- _should these be ligatures?_
- (i), (c), /!\, ...
- -- and ---
- <-, ->, <=, =>, <<, >> _(not sure about these)_
- -- and ---
-
- ---
- ### Playground for testing