├── .node-version ├── packages ├── docs │ ├── README.md │ ├── shared │ │ └── x.d2 │ ├── src │ │ ├── content │ │ │ ├── docs │ │ │ │ ├── other │ │ │ │ │ ├── cache.md │ │ │ │ │ ├── fenceparser.md │ │ │ │ │ ├── sqlitecache.md │ │ │ │ │ ├── rehype-code-hook.md │ │ │ │ │ └── remark-code-hook.md │ │ │ │ ├── notes │ │ │ │ │ ├── graph-libraries.md │ │ │ │ │ └── space-time.md │ │ │ │ ├── examples │ │ │ │ │ ├── penrose-test.md │ │ │ │ │ └── graphviz-test.md │ │ │ │ ├── start-here │ │ │ │ │ ├── getting-started.md │ │ │ │ │ ├── strategy.md │ │ │ │ │ ├── accessibility.mdx │ │ │ │ │ ├── styling-with-css.mdx │ │ │ │ │ ├── configuration.md │ │ │ │ │ └── dark-scheme.mdx │ │ │ │ ├── index.mdx │ │ │ │ └── diagrams │ │ │ │ │ ├── mermaid.mdx │ │ │ │ │ ├── penrose.mdx │ │ │ │ │ ├── d2.mdx │ │ │ │ │ └── graphviz.mdx │ │ │ └── config.ts │ │ ├── env.d.ts │ │ ├── components │ │ │ ├── panzoom.ts │ │ │ ├── iframeTarget.ts │ │ │ ├── PageFrame.astro │ │ │ └── d2.ts │ │ └── styles │ │ │ └── custom.css │ ├── .vscode │ │ ├── extensions.json │ │ └── launch.json │ ├── tsconfig.json │ ├── .gitignore │ ├── public │ │ ├── favicon.svg │ │ └── logo.svg │ ├── package.json │ └── astro.config.mjs ├── rehype-code-hook │ ├── test │ │ └── fixtures │ │ │ ├── b.md │ │ │ ├── a2.out.html │ │ │ ├── a3.out.html │ │ │ ├── a.md │ │ │ └── a1.out.html │ ├── tsconfig.json │ ├── src │ │ └── waitFor.ts │ └── package.json ├── remark-code-hook │ ├── test │ │ └── fixtures │ │ │ ├── b.md │ │ │ ├── a2.out.html │ │ │ ├── a3.out.html │ │ │ ├── a.md │ │ │ └── a1.out.html │ ├── tsconfig.json │ ├── package.json │ └── README.md ├── rehype-d2 │ ├── test │ │ ├── fixtures │ │ │ └── a.md │ │ └── index.test.ts │ ├── tsconfig.json │ ├── README.md │ ├── src │ │ ├── index.ts │ │ └── d2.ts │ └── package.json ├── fenceparser │ ├── .gitignore │ ├── src │ │ ├── error.ts │ │ ├── index.ts │ │ └── lex.ts │ ├── tsconfig.json │ ├── test │ │ ├── utils.ts │ │ └── index.test.ts │ ├── package.json │ ├── LICENSE │ ├── CHANGELOG.md │ └── README.md ├── rehype-code-hook-img │ ├── test │ │ ├── fixtures │ │ │ ├── a.md │ │ │ ├── b.md │ │ │ ├── c.md │ │ │ ├── class.out.html │ │ │ ├── strategy_inline.out.html │ │ │ ├── strategy_undefined.out.html │ │ │ ├── strategy_img.out.html │ │ │ ├── strategy_data-url.out.html │ │ │ ├── strategy_in_meta.out.html │ │ │ ├── strategy_img-class-dark-mode.out.html │ │ │ └── strategy_picture-dark-mode.out.html │ │ └── index.test.ts │ ├── README.md │ ├── tsconfig.json │ ├── package.json │ └── src │ │ ├── index.ts │ │ └── types.ts ├── rehype-mermaid │ ├── test │ │ ├── fixtures │ │ │ ├── a.md │ │ │ └── a.html │ │ └── index.test.ts │ ├── tsconfig.json │ ├── README.md │ ├── package.json │ └── src │ │ └── index.ts ├── rehype-gnuplot │ ├── test │ │ ├── fixtures │ │ │ └── a.md │ │ └── index.test.ts │ ├── tsconfig.json │ ├── README.md │ ├── src │ │ └── index.ts │ └── package.json ├── rehype-graphviz │ ├── test │ │ ├── fixtures │ │ │ ├── a.md │ │ │ └── a.html │ │ └── index.test.ts │ ├── tsconfig.json │ ├── src │ │ ├── index.ts │ │ └── render.ts │ ├── README.md │ └── package.json ├── rehype-vizdom │ ├── test │ │ ├── fixtures │ │ │ ├── a.md │ │ │ └── a.html │ │ └── index.test.ts │ ├── tsconfig.json │ ├── src │ │ ├── index.ts │ │ └── render.ts │ ├── README.md │ └── package.json ├── pan-zoom │ ├── src │ │ ├── index.ts │ │ ├── utils.ts │ │ ├── utilsDom.ts │ │ ├── utilsMath.ts │ │ └── PanZoomUi.ts │ ├── tsconfig.json │ ├── package.json │ ├── css │ │ └── PanZoomUi.css │ └── logo │ │ ├── logo.svg │ │ └── logo-dark.svg ├── cache │ ├── tsconfig.json │ ├── package.json │ ├── src │ │ ├── index.ts │ │ └── config.ts │ └── README.md ├── sqlitecache │ ├── tsconfig.json │ └── package.json └── rehype-penrose │ ├── tsconfig.json │ ├── test │ ├── fixtures │ │ └── a.md │ └── index.test.ts │ ├── src │ ├── penrose.ts │ └── index.ts │ ├── package.json │ ├── README.md │ └── bin │ └── penrose.js ├── pnpm-workspace.yaml ├── experiments ├── rehype-color-chips │ ├── test │ │ ├── fixtures │ │ │ ├── a.md │ │ │ └── a.html │ │ └── index.test.ts │ ├── tsconfig.json │ ├── src │ │ └── index.ts │ ├── package.json │ └── README.md ├── rehype-starry-night │ ├── test │ │ ├── fixtures │ │ │ ├── a.md │ │ │ └── a.html │ │ └── index.test.ts │ ├── tsconfig.json │ ├── src │ │ └── index.ts │ ├── README.md │ └── package.json ├── astro-graphviz │ ├── index.ts │ ├── cache.ts │ ├── tsconfig.json │ ├── rehype.mjs │ ├── Graphviz.astro │ ├── README.md │ └── package.json ├── rehype-plantuml │ ├── test │ │ ├── fixtures │ │ │ ├── a.md │ │ │ ├── a-inline.html │ │ │ └── a1-datauri.html │ │ └── index.test.ts │ ├── tsconfig.json │ ├── src │ │ └── index.ts │ ├── package.json │ ├── README.md │ └── example.svg └── rehype-pintora │ ├── test │ ├── fixtures │ │ ├── a.md │ │ ├── a.html │ │ └── a.out.svg │ ├── index.test.ts │ └── pintora.test.ts │ ├── tsconfig.json │ ├── README.md │ ├── src │ ├── pintora.ts │ └── index.ts │ └── package.json ├── turbo.json ├── vitest.config.ts ├── tsconfig.json ├── package.json ├── .github └── workflows │ └── ci.yml ├── README.md ├── notes └── notes.md ├── .gitignore └── logo ├── logo-dark.svg └── logo.svg /.node-version: -------------------------------------------------------------------------------- 1 | v20.18.1 -------------------------------------------------------------------------------- /packages/docs/README.md: -------------------------------------------------------------------------------- 1 | # Demo 2 | -------------------------------------------------------------------------------- /packages/docs/shared/x.d2: -------------------------------------------------------------------------------- 1 | x: { 2 | shape: circle 3 | } -------------------------------------------------------------------------------- /packages/rehype-code-hook/test/fixtures/b.md: -------------------------------------------------------------------------------- 1 | `test` 2 | -------------------------------------------------------------------------------- /packages/remark-code-hook/test/fixtures/b.md: -------------------------------------------------------------------------------- 1 | `test` 2 | -------------------------------------------------------------------------------- /pnpm-workspace.yaml: -------------------------------------------------------------------------------- 1 | packages: 2 | - "packages/*" 3 | -------------------------------------------------------------------------------- /experiments/rehype-color-chips/test/fixtures/a.md: -------------------------------------------------------------------------------- 1 | `#fff000` 2 | -------------------------------------------------------------------------------- /packages/rehype-code-hook/test/fixtures/a2.out.html: -------------------------------------------------------------------------------- 1 | html -------------------------------------------------------------------------------- /packages/rehype-code-hook/test/fixtures/a3.out.html: -------------------------------------------------------------------------------- 1 | hast -------------------------------------------------------------------------------- /packages/remark-code-hook/test/fixtures/a2.out.html: -------------------------------------------------------------------------------- 1 | html -------------------------------------------------------------------------------- /packages/rehype-d2/test/fixtures/a.md: -------------------------------------------------------------------------------- 1 | ```d2 2 | x -> y 3 | ``` 4 | -------------------------------------------------------------------------------- /packages/fenceparser/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | coverage 4 | -------------------------------------------------------------------------------- /packages/remark-code-hook/test/fixtures/a3.out.html: -------------------------------------------------------------------------------- 1 | Alpha bravo charlie. -------------------------------------------------------------------------------- /packages/rehype-code-hook-img/test/fixtures/a.md: -------------------------------------------------------------------------------- 1 | ```test 2 | test 3 | ``` 4 | -------------------------------------------------------------------------------- /packages/rehype-mermaid/test/fixtures/a.md: -------------------------------------------------------------------------------- 1 | ```mermaid 2 | graph TD; A; 3 | ``` 4 | -------------------------------------------------------------------------------- /experiments/rehype-starry-night/test/fixtures/a.md: -------------------------------------------------------------------------------- 1 | ```js 2 | const x = "<"; 3 | ``` 4 | -------------------------------------------------------------------------------- /packages/rehype-code-hook-img/test/fixtures/b.md: -------------------------------------------------------------------------------- 1 | ```test class=y 2 | test 3 | ``` 4 | -------------------------------------------------------------------------------- /packages/rehype-gnuplot/test/fixtures/a.md: -------------------------------------------------------------------------------- 1 | ```gnuplot 2 | plot [-10:10] sin(x) 3 | ``` 4 | -------------------------------------------------------------------------------- /experiments/astro-graphviz/index.ts: -------------------------------------------------------------------------------- 1 | export { default as Graphviz } from "./Graphviz.astro"; 2 | -------------------------------------------------------------------------------- /experiments/rehype-plantuml/test/fixtures/a.md: -------------------------------------------------------------------------------- 1 | ```plantuml 2 | Bob->Alice : Hello! 3 | ``` 4 | -------------------------------------------------------------------------------- /packages/rehype-code-hook-img/test/fixtures/c.md: -------------------------------------------------------------------------------- 1 | ```test strategy=data-url 2 | test 3 | ``` 4 | -------------------------------------------------------------------------------- /packages/rehype-code-hook/test/fixtures/a.md: -------------------------------------------------------------------------------- 1 | ```js {3-4} fileName=test /a/ 2 | test 3 | ``` 4 | -------------------------------------------------------------------------------- /packages/rehype-graphviz/test/fixtures/a.md: -------------------------------------------------------------------------------- 1 | ```dot 2 | digraph G { Hello -> World } 3 | ``` 4 | -------------------------------------------------------------------------------- /packages/rehype-vizdom/test/fixtures/a.md: -------------------------------------------------------------------------------- 1 | ```vizdom 2 | digraph G { Hello -> World } 3 | ``` 4 | -------------------------------------------------------------------------------- /packages/remark-code-hook/test/fixtures/a.md: -------------------------------------------------------------------------------- 1 | ```js {3-4} fileName=test /a/ 2 | test 3 | ``` 4 | -------------------------------------------------------------------------------- /packages/docs/src/content/docs/other/cache.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "@beoe/cache" 3 | draft: true 4 | --- 5 | -------------------------------------------------------------------------------- /packages/rehype-code-hook/test/fixtures/a1.out.html: -------------------------------------------------------------------------------- 1 |
test
2 |
--------------------------------------------------------------------------------
/packages/remark-code-hook/test/fixtures/a1.out.html:
--------------------------------------------------------------------------------
1 | test
2 |
--------------------------------------------------------------------------------
/packages/rehype-code-hook-img/test/fixtures/class.out.html:
--------------------------------------------------------------------------------
1 | #fff000
const x = "<";
2 |
--------------------------------------------------------------------------------
/packages/docs/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "0.2.0",
3 | "configurations": [
4 | {
5 | "command": "./node_modules/.bin/astro dev",
6 | "name": "Development server",
7 | "request": "launch",
8 | "type": "node-terminal"
9 | }
10 | ]
11 | }
12 |
--------------------------------------------------------------------------------
/packages/rehype-code-hook-img/test/fixtures/strategy_img-class-dark-mode.out.html:
--------------------------------------------------------------------------------
1 | # Hello, world!
15 | ```
16 |
17 | which can look like this:
18 |
19 | ```md
20 | # Hello, world!
21 | ```
22 |
23 | ## Status
24 |
25 | Tried it out of curiosity (and it is kind of easy to do with `@beoe/rehype-code-hook`). There are other plugins that has better support, for example [`@shikijs/rehype`](https://shiki.matsu.io/packages/rehype).
26 |
27 | ## Usage
28 |
29 | ```js
30 | import rehypeStarryNight from "@beoe/rehype-starry-night";
31 |
32 | const html = await unified()
33 | .use(remarkParse)
34 | .use(remarkRehype)
35 | .use(rehypeMermaid)
36 | .use(rehypeStarryNight)
37 | .process(`markdown`);
38 | ```
39 |
40 | Don't forget to add CSS, for example:
41 |
42 | ```html
43 |
47 | ```
48 |
--------------------------------------------------------------------------------
/packages/remark-code-hook/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@beoe/remark-code-hook",
3 | "type": "module",
4 | "version": "0.1.0",
5 | "description": "remark plugin for code fences",
6 | "keywords": [
7 | "remark"
8 | ],
9 | "author": "stereobooster",
10 | "license": "MIT",
11 | "repository": {
12 | "type": "git",
13 | "url": "git+https://github.com/stereobooster/beoe.git",
14 | "directory": "packages/remark-code-hook"
15 | },
16 | "sideEffects": false,
17 | "exports": {
18 | ".": {
19 | "types": "./dist/index.d.ts",
20 | "import": "./dist/index.js"
21 | }
22 | },
23 | "main": "./dist/index.js",
24 | "module": "./dist/index.js",
25 | "files": [
26 | "dist"
27 | ],
28 | "types": "./dist/index.d.ts",
29 | "scripts": {
30 | "test": "vitest",
31 | "build": "rm -rf dist && tsc",
32 | "dev": "tsc --watch",
33 | "clean": "rm -rf dist"
34 | },
35 | "dependencies": {
36 | "@types/mdast": "^4.0.4",
37 | "unified": "^11.0.5",
38 | "unist-util-visit": "^5.0.0"
39 | },
40 | "devDependencies": {
41 | "rehype-raw": "^7.0.0",
42 | "rehype-stringify": "^10.0.1",
43 | "remark-parse": "^11.0.0",
44 | "remark-rehype": "^11.1.1"
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/packages/pan-zoom/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@beoe/pan-zoom",
3 | "version": "0.0.4",
4 | "description": "Pan and zoom for SVG images",
5 | "author": "stereobooster",
6 | "license": "MIT",
7 | "repository": {
8 | "type": "git",
9 | "url": "git+https://github.com/stereobooster/beoe.git",
10 | "directory": "packages/pan-zoom"
11 | },
12 | "keywords": [
13 | "svg",
14 | "pan",
15 | "zoom",
16 | "gestures",
17 | "touchscreen"
18 | ],
19 | "type": "module",
20 | "exports": {
21 | ".": {
22 | "types": "./dist/index.d.ts",
23 | "default": "./dist/index.js",
24 | "import": "./dist/index.js"
25 | },
26 | "./css/*.css": {
27 | "import": "./css/*.css",
28 | "require": "./css/*.css"
29 | }
30 | },
31 | "main": "./dist/index.js",
32 | "module": "./dist/index.js",
33 | "files": [
34 | "./dist/*",
35 | "./css/*"
36 | ],
37 | "types": "./dist/index.d.ts",
38 | "scripts": {
39 | "test": "vitest",
40 | "prepublishOnly": "npm run build",
41 | "build": "rm -rf dist && tsc",
42 | "dev": "tsc --watch",
43 | "clean": "rm -rf dist",
44 | "tsc": "tsc"
45 | },
46 | "devDependencies": {
47 | "mathjs": "^14.4.0"
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/packages/rehype-gnuplot/src/index.ts:
--------------------------------------------------------------------------------
1 | // @ts-expect-error The inferred type of '...' cannot be named without a reference to
2 | import type { Plugin } from "unified";
3 | // @ts-expect-error The inferred type of '...' cannot be named without a reference to
4 | import type { Root } from "hast";
5 | import { rehypeCodeHookImg } from "@beoe/rehype-code-hook-img";
6 | import { waitFor } from "@beoe/rehype-code-hook";
7 |
8 | // because gnuplot-wasm doesn't provide TS signatures
9 | type R = (x: string) => { svg: string };
10 | /**
11 | * If all gnuplot diagrams are cached it would not even load module in memory.
12 | * If there are diagrams, it would load module and first few renders would be async,
13 | * but all consequent renders would be sync
14 | */
15 | export const render = waitFor(
16 | async () => {
17 | // @ts-ignore
18 | const gnuplot = (await import("gnuplot-wasm")).default;
19 | return (gnuplot() as Promise<{ render: R }>).then(({ render }) => render);
20 | },
21 | (render) => (code: string) => render(code)
22 | );
23 |
24 | export type RehypeGnuplotConfig = {};
25 |
26 | export const rehypeGnuplot = rehypeCodeHookImg#bada55
15 | ```
16 |
17 | which can look like this:
18 |
19 | **TODO**: add screenshot
20 |
21 | ## Status
22 |
23 | Tried it out of curiosity (and it is kind of easy to do with `@beoe/rehype-code-hook`). There are other plugins for this: [rehype-color-chips](https://github.com/shreshthmohan/rehype-color-chips).
24 |
25 | Because it was an experiment I used all possible color variations from `validate-color` (`validateHTMLColor`, `validateHTMLColorSpecialName`, `validateHTMLColorName`), which I assume can have quite expensive Regexp. In production it is, probably, better to use cheaper checks.
26 |
27 | ## Usage
28 |
29 | ```js
30 | import rehypeColorChips from "@beoe/rehype-color-chips";
31 |
32 | const html = await unified()
33 | .use(remarkParse)
34 | .use(remarkRehype)
35 | .use(rehypeMermaid)
36 | .use(rehypeColorChips)
37 | .process(`markdown`);
38 | ```
39 |
40 | Don't forget to add CSS, for example:
41 |
42 | ```css
43 | .gfm-color-chip {
44 | width: 0.75rem;
45 | height: 0.75rem;
46 | margin-left: 0.3rem;
47 | display: inline-block;
48 | border-radius: 50%;
49 | }
50 | ```
51 |
--------------------------------------------------------------------------------
/experiments/rehype-plantuml/README.md:
--------------------------------------------------------------------------------
1 | # @beoe/rehype-plantuml
2 |
3 | Rehype plugin to generate [plantuml](https://www.plantuml.com/) diagrams in place of code fences. This:
4 |
5 | ````md
6 | ```plantuml
7 | Bob->Alice : Hello!
8 | ```
9 | ````
10 |
11 | will be converted to
12 |
13 | ```html
14 |
4 |
7 |
6 |
7 | A tiny, well-tested parser for parsing metadata out of fenced code blocks in Markdown.
8 | 9 |