diff --git a/website/src/pages/examples/index.astro b/website/src/pages/examples/index.astro index b1ceae11..c973f2eb 100644 --- a/website/src/pages/examples/index.astro +++ b/website/src/pages/examples/index.astro @@ -1,6 +1,8 @@ --- import * as tunes from '../../../src/repl/tunes.mjs'; import HeadCommon from '../../components/HeadCommon.astro'; + +import { getMetadata } from '../metadata_parser'; ---
@@ -12,7 +14,7 @@ import HeadCommon from '../../components/HeadCommon.astro'; Object.entries(tunes).map(([name, tune]) => (
diff --git a/website/src/pages/metadata_parser.js b/website/src/pages/metadata_parser.js
new file mode 100644
index 00000000..f6b8f628
--- /dev/null
+++ b/website/src/pages/metadata_parser.js
@@ -0,0 +1,16 @@
+export function getMetadata(raw_code) {
+ // https://stackoverflow.com/a/15123777
+ const comment_regexp = /\/\*([\s\S]*?)\*\/|([^\\:]|^)\/\/(.*)$/gm;
+
+ const tag_regexp = /@([a-z]*):? (.*)/gm
+ const tags = {};
+
+ for (const match of raw_code.matchAll(comment_regexp)) {
+ const comment = match[1] ? match[1] : '' + match[3] ? match[3] : '';
+ for (const tag_match of comment.trim().matchAll(tag_regexp)) {
+ tags[tag_match[1]] = tag_match[2].trim()
+ }
+ }
+
+ return tags;
+}
diff --git a/website/src/pages/swatch/list.json.js b/website/src/pages/swatch/list.json.js
index ecc1d41a..febc52aa 100644
--- a/website/src/pages/swatch/list.json.js
+++ b/website/src/pages/swatch/list.json.js
@@ -1,19 +1,4 @@
-export function getMetadata(raw_code) {
- // https://stackoverflow.com/a/15123777
- const comment_regexp = /\/\*([\s\S]*?)\*\/|([^\\:]|^)\/\/(.*)$/gm;
-
- const tag_regexp = /@([a-z]*):? (.*)/gm
- const tags = {};
-
- for (const match of raw_code.matchAll(comment_regexp)) {
- const comment = match[1] ? match[1] : '' + match[3] ? match[3] : '';
- for (const tag_match of comment.trim().matchAll(tag_regexp)) {
- tags[tag_match[1]] = tag_match[2].trim()
- }
- }
-
- return tags;
-}
+import { getMetadata } from '../metadata_parser';
export function getMyPatterns() {
const my = import.meta.glob('../../../../my-patterns/**', { as: 'raw', eager: true });