diff options
author | petko <petko@524c5546-5005-0410-9a3e-e25e191bd360> | 2024-04-05 00:59:03 +0000 |
---|---|---|
committer | petko <petko@524c5546-5005-0410-9a3e-e25e191bd360> | 2024-04-05 00:59:03 +0000 |
commit | 7ac36c5a84330074fd0d403747fb30fe21b1c213 (patch) | |
tree | b2e8890d961b3e155ed509f6068d71ac2863d210 | |
parent | d0e124f0a397656c0cd0ae78d091cabcf48ad499 (diff) | |
download | pmwiki.svn-7ac36c5a84330074fd0d403747fb30fe21b1c213.tar.bz2 |
PmSyntax add rule for bracketlinks.
git-svn-id: svn://pmwiki.org/pmwiki/trunk@4681 524c5546-5005-0410-9a3e-e25e191bd360
-rw-r--r-- | pub/guiedit/pmwiki.syntax.css | 3 | ||||
-rw-r--r-- | pub/guiedit/pmwiki.syntax.js | 22 |
2 files changed, 19 insertions, 6 deletions
diff --git a/pub/guiedit/pmwiki.syntax.css b/pub/guiedit/pmwiki.syntax.css index ce1346ab..430776d2 100644 --- a/pub/guiedit/pmwiki.syntax.css +++ b/pub/guiedit/pmwiki.syntax.css @@ -196,6 +196,9 @@ code.pmhlt, .pmhlt code, #htext.pmhlt { .pmhlt .pmpunct { color: var(--pmsyntax-punct); } +.pmhlt .pmblink { + color: var(--pmsyntax-punct); +} .pmhlt .pmurl{ color: var(--pmsyntax-url); } diff --git a/pub/guiedit/pmwiki.syntax.js b/pub/guiedit/pmwiki.syntax.js index 8ff0e49a..025744f3 100644 --- a/pub/guiedit/pmwiki.syntax.js +++ b/pub/guiedit/pmwiki.syntax.js @@ -79,8 +79,9 @@ ['rdir', '!meta', /(\(:redirect)(.*?)(:\))/g], // urls can have percents so before wikistyle (populated by InterMap) - ['ttip', '=escaped', /(\[\[)(.*?\S)(?= *(?:\||\]\]))/g, /(")(.*)(")$/ ], // tooltop - ['link0', '=escaped', /\[\[.*?\S(?= *(?:\||\]\]))/g, /(\()(.*?)(\))/g],// hidden + ['ttip', '=escaped', /\[\[.*?\S(?= *(?:\||\]\]))/g, /(")(.*)(")$/ ], // tooltop + ['link0', '=escaped', /\[\[.*?\S(?= *(?:\||\]\]))/g, /(\()(.*?)(\))/g],// hidden + ['link1', 'bracketlink', /(\[\[ *)(.+?)( *\]\])/g ], ['_url'], // wikistyles @@ -135,6 +136,7 @@ custom_hrx[ '>'+hrx[i][0] ] = []; } + function PmHi(text){ var KPV = []; function Restore(all, n) { return KPV[parseInt(n)]; } @@ -144,7 +146,7 @@ return KeepToken+(KPV.length-1)+KeepToken; } function Keep(text, cname) { - if(!text) return ''; + if(text==='') return ''; text = span(cname, text); return keep0(text); } @@ -191,7 +193,14 @@ return keep0(PHSC(code)); } } - + function bracketlink(m, m1, m2, m3){ + var a = m2.match(/^(.+)( *\|.+)$/); + if(a) return m1+Keep(a[1], 'url')+a[2]+m3; + a = m2.match(/^(.+-> *)(.+)$/); + if(a) return m1+a[1]+Keep(a[2], 'url')+m3; + return m1+Keep(m2, 'url')+m3; + } + function PmHi1(text, rule){ var r = rule[0], s = rule[1]; if(r == '.restore') return text.replace(s, Restore); @@ -224,8 +233,9 @@ }); } } - if(typeof r == 'function') text = text.replace(s, r); - else text = text.replace(s, function(a){ + if(typeof r == 'function') return text.replace(s, r); + if(r == 'bracketlink') return text.replace(s, bracketlink); + text = text.replace(s, function(a){ var b = Array.from(arguments).slice(1, -2); if(r.match(/^[=!]/)) return Keep5(b, r); else return Keep(a, r); |