-
{
trigger: "n",
replacement: (sel) => {
sel = sel.split('\n').map(line => `> ${line}`).join('\n'); // 换行之后加上 '> '
sel = `> [!note]+ \$1\n` + sel + '\n\n'; // 添加 callout 相关头尾字符
return sel;
},
options: "vtA"
}, The snippet above is a well-executed, and there are several steps to use it:
This snippet saves my time, and it's easy to generalize the idea that I can intergrate some frequently-used callout styles into a "similar" regex snippet. So I created the following snippet which however doesn't work. {
trigger: /(e|i|t|f|q)/,
replacement: (sel,match) => { // 🔴 maybe something wrong about using both in meantime?
const callcharacter = match[1];
let calloutstyle;
switch (callcharacter) {
case "e": calloutstyle = `error`; break;
case "i": calloutstyle = `important`; break;
case "t": calloutstyle = `tip`; break;
case "f": calloutstyle = `fail`; break;
case "q": calloutstyle = `question`; break;
}
sel = sel.split('\n').map(line => `> ${line}`).join('\n'); // 每行前面加上 '> '
sel = `> [!${calloutstyle}]+ \$1\n` + sel + '\n\n'; // 添加
return sel;
},
options: "rvtA" // 🔴 maybe something wrong about 'rv' case?
}, I don't know what's wrong. Waiting for help😭 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
And after practice, I think it is not an excellent way to set trigger like above, because those selected texts always contain
{trigger: "n", replacement: "> [!note]+ ${VISUAL}", options: "vtA"},
{trigger: "!", replacement: "> [!important]+ ${VISUAL}", options: "vtA"},
{trigger: "1", replacement: "> [!important]+ ${VISUAL}", options: "vtA"},
{trigger: "/", replacement: "> [!question]+ ${VISUAL}", options: "vtA"},
{trigger: "?", replacement: "> [!question]+ ${VISUAL}", options: "vtA"},
{trigger: "g", replacement: "> [!askgpt]+ ${VISUAL}", options: "vtA"}, But still, I don't know how to integrate those snippets into one in It seems like to be the conflict to use |
Beta Was this translation helpful? Give feedback.
-
which lies in load your snippet variables from files. Sorry for my stupid neglect. |
Beta Was this translation helpful? Give feedback.
which lies in load your snippet variables from files.
Sorry for my stupid neglect.