176 web animation techniques, each a live demo with plain settings and a ready-made prompt for your AI assistant. No dependencies, no build step.
HTML ai-promptsanimationcss-animationsfrontendgithub-pagesjavascriptmicrointeractionsmotion-designno-dependenciesreferencescroll-animationui-animationweb-animationweb-developmentwebgl
test: the markdown helper takes sections from the shared script and keeps only what the tests use
matined1090189ef2
diff --git a/tests/helpers/markdown.js b/tests/helpers/markdown.jsindex 2fac8dce..1f1bc55f 100644--- a/tests/helpers/markdown.js+++ b/tests/helpers/markdown.js@@ -1,56 +1,9 @@-/* Markdown helpers for the page tests: a README split into its sections, and its Key parameters table read as rows. */+/* Markdown helpers for the page tests: a README split into its sections (by the reader the page itself uses), and its Key parameters table read as rows. */'use strict';-function escapeHtml(s) {- return String(s).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');-}--// Text with Markdown code and bold markers removed, safe to insert as HTML.-function plain(s) {- return escapeHtml(String(s).replace(/`/g, '').replace(/\*\*/g, ''));-}--// Allow only relative paths, "#" anchors and http(s) URLs as link targets; anything else-// (e.g. a javascript: URL) is rejected and rendered as plain link text instead.-function isSafeHref(href) {- return /^(?:https?:|#|\.{0,2}\/|[\w.-]+(?:\/|$))/i.test(href) &&- !/^[a-z][a-z0-9+.-]*:/i.test(href.replace(/^https?:/i, ''));-}--// Inline Markdown from README prose. Inline code becomes plain text: the site shows no code.-function inline(md) {- return escapeHtml(md)- .replace(/`([^`]+)`/g, '$1')- .replace(/\[([^\]]+)\]\(([^)\s]+)\)/g, function (m, label, href) {- return isSafeHref(href) ? '<a href="' + href + '">' + label + '</a>' : label;- })- .replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>')- .replace(/\*([^*\n]+)\*/g, '<em>$1</em>');-}--// A README split into { "What it is": "...", ... } by its "## " headings.-function sections(md) {- var out = {}, current = null, buf = [];- String(md).replace(/\r\n?/g, '\n').split('\n').forEach(function (line) {- var m = /^##\s+(.+?)\s*$/.exec(line);- if (m) {- if (current) out[current] = buf.join('\n').trim();- current = m[1];- buf = [];- } else if (current) {- buf.push(line);- }- });- if (current) out[current] = buf.join('\n').trim();- return out;-}--// "Duration (`--dur`)" becomes "Duration": parentheticals that hold code are dropped.-function cleanName(s) {- return plain(String(s).replace(/\s*\(`[^`]*`[^)]*\)/g, ''));-}+const { sections } = require('../../assets/js/demo-page.js');-// The Key parameters table as [{ name, value, effect }], without its header and divider rows.+// The Key parameters table as its rows (each a list of cells), without the header row and the divider row.function table(text) {var rows = String(text || '').split('\n').filter(function (l) { return /^\s*\|/.test(l); })@@ -58,8 +11,7 @@ function table(text) {return l.trim().replace(/^\|/, '').replace(/\|$/, '').split('|').map(function (c) { return c.trim(); });});return rows.slice(1)- .filter(function (r) { return !r.every(function (c) { return /^:?-{2,}:?$/.test(c); }); })- .map(function (r) { return { name: cleanName(r[0] || ''), value: plain(r[1] || ''), effect: inline(r[2] || '') }; });+ .filter(function (r) { return !r.every(function (c) { return /^:?-{2,}:?$/.test(c); }); });}module.exports = { sections, table };