|
@@ -29,7 +29,7 @@ $CATALOG = [
|
|
|
['id' => 4, 'name' => 'Gizmo', 'price' => 29.99, 'featured' => true, 'inStock' => true],
|
|
['id' => 4, 'name' => 'Gizmo', 'price' => 29.99, 'featured' => true, 'inStock' => true],
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
-$TYPES = ['counter', 'products', 'cart', 'user', 'notice'];
|
|
|
|
|
|
|
+$TYPES = ['counter', 'products', 'cart', 'user', 'notice', 'markdown'];
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// ---------------------------------------------------------------------------
|
|
|
// Helpers
|
|
// Helpers
|
|
@@ -200,6 +200,40 @@ function build_notice(): array
|
|
|
];
|
|
];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * Markdown sample for the stm-markdown section. Nowdoc (<<<'MD') so the
|
|
|
|
|
+ * markdown is passed through verbatim: no PHP interpolation, no escaping.
|
|
|
|
|
+ * Deliberately exercises the patterns the renderer is regression-tested for:
|
|
|
|
|
+ * emphasis across a line wrap, soft line breaks inside a paragraph, a wrapped
|
|
|
|
|
+ * list item, a fenced code block, reference + autolinks, and raw HTML that
|
|
|
|
|
+ * must come out as inert text.
|
|
|
|
|
+ */
|
|
|
|
|
+function build_markdown(): array
|
|
|
|
|
+{
|
|
|
|
|
+ $body = <<<'MD'
|
|
|
|
|
+**This bold span wraps
|
|
|
|
|
+onto a second line** without breaking.
|
|
|
|
|
+
|
|
|
|
|
+These lines form a single
|
|
|
|
|
+paragraph: one newline is a soft break, not a new paragraph.
|
|
|
|
|
+
|
|
|
|
|
+- A bullet whose text
|
|
|
|
|
+ continues on the next line.
|
|
|
|
|
+- A second bullet with `inline code`.
|
|
|
|
|
+
|
|
|
|
|
+```vala
|
|
|
|
|
+var page = new Html.page ();
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+A [reference link][docs] and an autolink <https://commonmark.org>.
|
|
|
|
|
+
|
|
|
|
|
+[docs]: https://commonmark.org "CommonMark"
|
|
|
|
|
+
|
|
|
|
|
+Raw HTML stays inert: <script>alert(1)</script> and [not a js link](javascript:alert(1)).
|
|
|
|
|
+MD;
|
|
|
|
|
+ return ['body' => $body];
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
/** Build the snapshot for a type with its demo scope/options. */
|
|
/** Build the snapshot for a type with its demo scope/options. */
|
|
|
function snap(string $type): ?array
|
|
function snap(string $type): ?array
|
|
|
{
|
|
{
|
|
@@ -209,6 +243,7 @@ function snap(string $type): ?array
|
|
|
case 'cart': return make_snapshot('cart', 'session', build_cart(), ['always' => true]);
|
|
case 'cart': return make_snapshot('cart', 'session', build_cart(), ['always' => true]);
|
|
|
case 'user': return make_snapshot('user', 'session', build_user(), ['stale' => true]);
|
|
case 'user': return make_snapshot('user', 'session', build_user(), ['stale' => true]);
|
|
|
case 'notice': return make_snapshot('notice', 'flow', build_notice());
|
|
case 'notice': return make_snapshot('notice', 'flow', build_notice());
|
|
|
|
|
+ case 'markdown': return make_snapshot('markdown', 'session', build_markdown());
|
|
|
}
|
|
}
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|