@kirigami/php-prepros 1.7.2 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -109,6 +109,39 @@ Part of the **Kirigami** project ecosystem.
109
109
 
110
110
  ---
111
111
 
112
+ ## What's new in 1.9.0
113
+
114
+ - **`{% youtube %}` removed** — moved to
115
+ [`@kirigami/plugin-embed`](https://www.npmjs.com/package/@kirigami/plugin-embed),
116
+ which replaces the old plain-iframe output with a real oEmbed-backed card
117
+ (cover thumbnail, title, play button — no network call until the visitor
118
+ actually clicks play). If a project used the built-in `{% youtube %}`,
119
+ install the plugin; without it, the tag now falls through unresolved
120
+ (`{% youtube ID %}` printed as-is) rather than rendering an iframe.
121
+ `codepen`/`checklist`/`callout` are unaffected.
122
+
123
+ ---
124
+
125
+ ## What's new in 1.8.0
126
+
127
+ - **`{% img-asset %}` — a new built-in Markdown plugin.** Same pipeline as the
128
+ `<img asset>` HTML tag (`IMG::asset()`: resize, cache, publish under
129
+ `image.dest`), usable straight from Markdown text:
130
+
131
+ ```
132
+ {% img-asset photo.jpg %}
133
+ {% img-asset photo.jpg 800 %}
134
+ {% img-asset photo.jpg 800 600 %}
135
+ {% img-asset photo.jpg 800 600 cover %}
136
+ ```
137
+
138
+ Positional args: source path (relative to `image.source`), width, height,
139
+ and the literal `cover` keyword. Registered in `md.plugins.php` alongside
140
+ `codepen`/`youtube`/`checklist`/`callout` — available out of the box, drop
141
+ it with `MD::unregisterPlugin('img-asset')` if you don't want it.
142
+
143
+ ---
144
+
112
145
  ## What's new in 1.7.2
113
146
 
114
147
  - **Cleaner formatted output around highlighted code.** The de-indent script
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kirigami/php-prepros",
3
- "version": "1.7.2",
3
+ "version": "1.9.0",
4
4
  "description": "PHP preprocessor for the Kirigami static site generator. Compile PHP page templates to clean, deployable HTML — with zero server dependency.",
5
5
  "keywords": [
6
6
  "kirigami",
@@ -27,21 +27,6 @@ MD::registerPlugin('codepen', function (array $args, string $body): string {
27
27
  . "</iframe>";
28
28
  });
29
29
 
30
- // --- YouTube (inline) ---
31
- // {% youtube VIDEO_ID %}
32
- // {% youtube VIDEO_ID 560 315 %}
33
- MD::registerPlugin('youtube', function (array $args, string $body): string {
34
- $id = htmlspecialchars($args[0] ?? '', ENT_QUOTES, 'UTF-8');
35
- $width = intval($args[1] ?? 560);
36
- $height = intval($args[2] ?? 315);
37
- if ($id === '') return '<!-- youtube: missing id -->';
38
- return "<iframe width=\"{$width}\" height=\"{$height}\" "
39
- . "src=\"https://www.youtube.com/embed/{$id}\" "
40
- . "title=\"YouTube video player\" frameborder=\"0\" loading=\"lazy\" "
41
- . "allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" "
42
- . "allowfullscreen></iframe>";
43
- });
44
-
45
30
  // --- Checklist (multi-line block) ---
46
31
  // {% checklist
47
32
  // Do the dishes
@@ -89,4 +74,21 @@ MD::registerPlugin('callout', function (array $args, string $body): string {
89
74
 
90
75
  $titleHtml = $title ? "<strong>{$title}</strong><br>" : '';
91
76
  return "<div class=\"callout callout-{$type}\">{$titleHtml}{$content}</div>";
77
+ });
78
+
79
+ // --- Image asset (inline) — same pipeline as <img asset>, via IMG::asset() ---
80
+ // {% img-asset photo.jpg %}
81
+ // {% img-asset photo.jpg 800 %}
82
+ // {% img-asset photo.jpg 800 600 %}
83
+ // {% img-asset photo.jpg 800 600 cover %}
84
+ MD::registerPlugin('img-asset', function (array $args, string $body): string {
85
+ $path = trim($args[0] ?? '');
86
+ if ($path === '') return '<!-- img-asset: missing path -->';
87
+
88
+ $width = isset($args[1]) ? (int) $args[1] : 0;
89
+ $height = isset($args[2]) ? (int) $args[2] : 0;
90
+ $cover = isset($args[3]) && strtolower($args[3]) === 'cover';
91
+
92
+ $src = IMG::asset($path, $width, $height, $cover, PREPROS::$file);
93
+ return '<img src="' . htmlspecialchars($src, ENT_QUOTES, 'UTF-8') . '" alt="">';
92
94
  });