forked from FoundKeyGang/FoundKey
fix MFM fg/bg color regex
CSS colors are either 3 or 6 hex digits, not 3 to 6 (which would allow 4 and 5 digit hex codes, which are not accepted). Also adds an explicit null/undefined check. Changes the default color for the $[bg ] function to something different than the fg color so if you use both functions on a piece of text with default values, the text stays somewhat readable.
This commit is contained in:
parent
3f9b09e3e7
commit
989f0ce41d
1 changed files with 4 additions and 4 deletions
|
@ -197,14 +197,14 @@ export default defineComponent({
|
|||
break;
|
||||
}
|
||||
case 'fg': {
|
||||
let color = token.props.args.color;
|
||||
if (!/^[0-9a-f]{3,6}$/i.test(color)) color = 'f00';
|
||||
let color = token.props.args.color ?? 'f00';
|
||||
if (!/^([0-9a-f]{3}){1,2}$/i.test(color)) color = 'f00';
|
||||
style = `color: #${color};`;
|
||||
break;
|
||||
}
|
||||
case 'bg': {
|
||||
let color = token.props.args.color;
|
||||
if (!/^[0-9a-f]{3,6}$/i.test(color)) color = 'f00';
|
||||
let color = token.props.args.color ?? '0f0';
|
||||
if (!/^([0-9a-f]{3}){1,2}$/i.test(color)) color = '0f0';
|
||||
style = `background-color: #${color};`;
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue