@kirigami/php-prepros 1.7.2 → 1.8.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 +20 -0
- package/package.json +1 -1
- package/src/libraries/md.plugins.php +17 -0
package/README.md
CHANGED
|
@@ -109,6 +109,26 @@ Part of the **Kirigami** project ecosystem.
|
|
|
109
109
|
|
|
110
110
|
---
|
|
111
111
|
|
|
112
|
+
## What's new in 1.8.0
|
|
113
|
+
|
|
114
|
+
- **`{% img-asset %}` — a new built-in Markdown plugin.** Same pipeline as the
|
|
115
|
+
`<img asset>` HTML tag (`IMG::asset()`: resize, cache, publish under
|
|
116
|
+
`image.dest`), usable straight from Markdown text:
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
{% img-asset photo.jpg %}
|
|
120
|
+
{% img-asset photo.jpg 800 %}
|
|
121
|
+
{% img-asset photo.jpg 800 600 %}
|
|
122
|
+
{% img-asset photo.jpg 800 600 cover %}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Positional args: source path (relative to `image.source`), width, height,
|
|
126
|
+
and the literal `cover` keyword. Registered in `md.plugins.php` alongside
|
|
127
|
+
`codepen`/`youtube`/`checklist`/`callout` — available out of the box, drop
|
|
128
|
+
it with `MD::unregisterPlugin('img-asset')` if you don't want it.
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
112
132
|
## What's new in 1.7.2
|
|
113
133
|
|
|
114
134
|
- **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.
|
|
3
|
+
"version": "1.8.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",
|
|
@@ -89,4 +89,21 @@ MD::registerPlugin('callout', function (array $args, string $body): string {
|
|
|
89
89
|
|
|
90
90
|
$titleHtml = $title ? "<strong>{$title}</strong><br>" : '';
|
|
91
91
|
return "<div class=\"callout callout-{$type}\">{$titleHtml}{$content}</div>";
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// --- Image asset (inline) — same pipeline as <img asset>, via IMG::asset() ---
|
|
95
|
+
// {% img-asset photo.jpg %}
|
|
96
|
+
// {% img-asset photo.jpg 800 %}
|
|
97
|
+
// {% img-asset photo.jpg 800 600 %}
|
|
98
|
+
// {% img-asset photo.jpg 800 600 cover %}
|
|
99
|
+
MD::registerPlugin('img-asset', function (array $args, string $body): string {
|
|
100
|
+
$path = trim($args[0] ?? '');
|
|
101
|
+
if ($path === '') return '<!-- img-asset: missing path -->';
|
|
102
|
+
|
|
103
|
+
$width = isset($args[1]) ? (int) $args[1] : 0;
|
|
104
|
+
$height = isset($args[2]) ? (int) $args[2] : 0;
|
|
105
|
+
$cover = isset($args[3]) && strtolower($args[3]) === 'cover';
|
|
106
|
+
|
|
107
|
+
$src = IMG::asset($path, $width, $height, $cover, PREPROS::$file);
|
|
108
|
+
return '<img src="' . htmlspecialchars($src, ENT_QUOTES, 'UTF-8') . '" alt="">';
|
|
92
109
|
});
|