fix: disable "Search" keyword (#9856)
Related: #9816 #9830 I was so careless that I didn't know "Search" was also a keyword. I disabled that and fixed a minor bug. Co-authored-by: naskya <m@naskya.net> Reviewed-on: https://codeberg.org/calckey/calckey/pulls/9856 Co-authored-by: naskya <naskya@noreply.codeberg.org> Co-committed-by: naskya <naskya@noreply.codeberg.org>
This commit is contained in:
parent
de85e32b6b
commit
f7602be0e7
|
@ -12,7 +12,6 @@ import MkGoogle from "@/components/MkGoogle.vue";
|
||||||
import MkSparkle from "@/components/MkSparkle.vue";
|
import MkSparkle from "@/components/MkSparkle.vue";
|
||||||
import MkA from "@/components/global/MkA.vue";
|
import MkA from "@/components/global/MkA.vue";
|
||||||
import { host } from "@/config";
|
import { host } from "@/config";
|
||||||
import { MFM_TAGS } from "@/scripts/mfm-tags";
|
|
||||||
import { reducedMotion } from "@/scripts/reduced-motion";
|
import { reducedMotion } from "@/scripts/reduced-motion";
|
||||||
import { defaultStore } from "@/store";
|
import { defaultStore } from "@/store";
|
||||||
|
|
||||||
|
@ -461,7 +460,7 @@ export default defineComponent({
|
||||||
case "search": {
|
case "search": {
|
||||||
// Disable "search" keyword
|
// Disable "search" keyword
|
||||||
// (see the issue #9816 on Codeberg)
|
// (see the issue #9816 on Codeberg)
|
||||||
if (token.props.content.endsWith("search")) {
|
if (token.props.content.slice(-6).toLowerCase() === "search") {
|
||||||
const sentinel = "#";
|
const sentinel = "#";
|
||||||
let ast2 = (isPlain ? mfm.parseSimple : mfm.parse)(
|
let ast2 = (isPlain ? mfm.parseSimple : mfm.parse)(
|
||||||
token.props.content.slice(0, -6) + sentinel,
|
token.props.content.slice(0, -6) + sentinel,
|
||||||
|
@ -473,19 +472,32 @@ export default defineComponent({
|
||||||
ast2[ast2.length - 1].props.text = ast2[
|
ast2[ast2.length - 1].props.text = ast2[
|
||||||
ast2.length - 1
|
ast2.length - 1
|
||||||
].props.text.slice(0, -1);
|
].props.text.slice(0, -1);
|
||||||
|
} else {
|
||||||
|
// I don't think this scope is reachable
|
||||||
|
console.warn(
|
||||||
|
"Something went wrong while parsing MFM. Please send a bug report, if possible.",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let prefix = "\n";
|
let prefix = "\n";
|
||||||
if (
|
if (
|
||||||
index === 0 ||
|
index === 0 ||
|
||||||
["blockCode", "mathBlock", "search", "quote"].includes(
|
[
|
||||||
ast[index - 1].type,
|
"blockCode",
|
||||||
)
|
"center",
|
||||||
|
"mathBlock",
|
||||||
|
"quote",
|
||||||
|
"search",
|
||||||
|
].includes(ast[index - 1].type)
|
||||||
) {
|
) {
|
||||||
prefix = "";
|
prefix = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return [prefix, ...genEl(ast2), "search\n"];
|
return [
|
||||||
|
prefix,
|
||||||
|
...genEl(ast2),
|
||||||
|
`${token.props.content.slice(-6)}\n`,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
Loading…
Reference in New Issue