Hopefully a less invasive fix for #3378 --------- Co-authored-by: Marvin Hagemeister <hello@marvinh.dev>
53 lines
1.6 KiB
TypeScript
53 lines
1.6 KiB
TypeScript
import Prism from "prismjs";
|
|
import "prismjs/components/prism-jsx.js";
|
|
import "prismjs/components/prism-typescript.js";
|
|
import "prismjs/components/prism-tsx.js";
|
|
import "prismjs/components/prism-diff.js";
|
|
import "prismjs/components/prism-json.js";
|
|
import "prismjs/components/prism-bash.js";
|
|
import "prismjs/components/prism-yaml.js";
|
|
import "prismjs/components/prism-ignore.js";
|
|
|
|
// deno-lint-ignore no-explicit-any
|
|
const languages = Prism.languages as any;
|
|
|
|
/** Extends `sh` with `deno` as a function token in Shell/Bash languages */
|
|
languages.sh.deno = {
|
|
pattern: /(^|[\s;|&]|[<>]\()(?:deno)(?=$|[)\s;|&])/,
|
|
lookbehind: true,
|
|
alias: "function",
|
|
};
|
|
languages.bash.deno = languages.sh.deno;
|
|
|
|
/**
|
|
* Adds `txt-files` language for file-structure code blocks.
|
|
*
|
|
* - Comments: Makes `#` and everything after a comment
|
|
* - Operator: Matches the file structure symbols like `├──`, `└──`, and `│ `
|
|
* - Root: Matches `<root>` or `<project root>` to indicate the root of the file structure
|
|
* - Remaining text is rendered as plain text
|
|
*
|
|
* @example
|
|
* ```txt-files
|
|
* <project root>
|
|
* ├── routes/ # File system based routes
|
|
* │ ├── _app.tsx # Renders the outer <html> content structure
|
|
* │ └── index.tsx # Renders /
|
|
* ├── dev.ts # Run this during development
|
|
* └── main.ts # Run this for production
|
|
* ```
|
|
*/
|
|
Prism.languages["txt-files"] = {
|
|
comment: {
|
|
pattern: /#.*|$/,
|
|
greedy: true,
|
|
},
|
|
operator: /├──|└──|│\s+ /,
|
|
root: {
|
|
pattern: /<root>|<project root>/,
|
|
alias: "function",
|
|
},
|
|
};
|
|
|
|
export { Prism };
|