@kirigami/php-prepros 1.1.0 → 1.2.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 +1114 -869
- package/index.d.ts +75 -2
- package/index.js +1 -1
- package/package.json +4 -4
- package/src/libraries/curl.class.php +5 -0
- package/src/libraries/html.class.php +23 -22
- package/src/libraries/img.class.php +356 -16
- package/src/libraries/md.class.php +476 -170
- package/src/libraries/md.plugins.php +19 -19
- package/src/libraries/normalizer.class.php +310 -0
- package/src/libraries/prepros.class.php +36 -7
- package/src/libraries/prepros.plugins.php +24 -0
- package/src/libraries/schema.class.php +550 -0
- package/src/libraries/scraper.class.php +64 -59
- package/src/libraries/str.class.php +49 -15
- package/src/libraries/yaml.class.php +66 -66
- package/src/phpjs/fstat.js +9 -0
- package/src/prepros.js +51 -44
- package/src/utils/getfilestats.js +30 -0
- package/src/utils/isbinary.js +14 -14
- package/src/utils.inc.php +9 -8
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
// =============================================================================
|
|
6
|
-
// PLUGINS
|
|
6
|
+
// DEFAULT PLUGINS (optional, uncomment what you need)
|
|
7
7
|
// =============================================================================
|
|
8
8
|
|
|
9
9
|
// --- CodePen (inline) ---
|
|
@@ -13,7 +13,7 @@ MD::registerPlugin('codepen', function (array $args, string $body): string {
|
|
|
13
13
|
$id = htmlspecialchars($args[0] ?? '', ENT_QUOTES, 'UTF-8');
|
|
14
14
|
$user = htmlspecialchars($args[1] ?? 'anonymous', ENT_QUOTES, 'UTF-8');
|
|
15
15
|
$height = intval($args[2] ?? 400);
|
|
16
|
-
if ($id === '') return '<!-- codepen: id
|
|
16
|
+
if ($id === '') return '<!-- codepen: missing id -->';
|
|
17
17
|
return "<iframe height=\"{$height}\" style=\"width:100%\" "
|
|
18
18
|
. "scrolling=\"no\" "
|
|
19
19
|
. "src=\"https://codepen.io/{$user}/embed/{$id}?default-tab=result\" "
|
|
@@ -28,7 +28,7 @@ MD::registerPlugin('youtube', function (array $args, string $body): string {
|
|
|
28
28
|
$id = htmlspecialchars($args[0] ?? '', ENT_QUOTES, 'UTF-8');
|
|
29
29
|
$width = intval($args[1] ?? 560);
|
|
30
30
|
$height = intval($args[2] ?? 315);
|
|
31
|
-
if ($id === '') return '<!-- youtube: id
|
|
31
|
+
if ($id === '') return '<!-- youtube: missing id -->';
|
|
32
32
|
return "<iframe width=\"{$width}\" height=\"{$height}\" "
|
|
33
33
|
. "src=\"https://www.youtube.com/embed/{$id}\" "
|
|
34
34
|
. "title=\"YouTube video player\" frameborder=\"0\" loading=\"lazy\" "
|
|
@@ -36,22 +36,22 @@ MD::registerPlugin('youtube', function (array $args, string $body): string {
|
|
|
36
36
|
. "allowfullscreen></iframe>";
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
-
// --- Checklist (
|
|
39
|
+
// --- Checklist (multi-line block) ---
|
|
40
40
|
// {% checklist
|
|
41
|
-
//
|
|
42
|
-
//
|
|
43
|
-
//
|
|
41
|
+
// Do the dishes
|
|
42
|
+
// Walk the dog
|
|
43
|
+
// Read a book
|
|
44
44
|
// %}
|
|
45
45
|
//
|
|
46
|
-
//
|
|
47
|
-
// {% checklist "
|
|
48
|
-
//
|
|
49
|
-
//
|
|
46
|
+
// Optionally with a title:
|
|
47
|
+
// {% checklist "My tasks for today"
|
|
48
|
+
// Task 1
|
|
49
|
+
// Task 2
|
|
50
50
|
// %}
|
|
51
51
|
MD::registerPlugin('checklist', function (array $args, string $body): string {
|
|
52
52
|
$title = !empty($args[0]) ? '<p class="checklist-title"><strong>' . htmlspecialchars($args[0], ENT_QUOTES, 'UTF-8') . '</strong></p>' : '';
|
|
53
53
|
$items = array_filter(array_map('trim', explode("\n", $body)));
|
|
54
|
-
if (empty($items)) return '<!-- checklist:
|
|
54
|
+
if (empty($items)) return '<!-- checklist: no items -->';
|
|
55
55
|
$html = "<div class=\"checklist\">{$title}<ul>\n";
|
|
56
56
|
foreach ($items as $item) {
|
|
57
57
|
$html .= ' <li><label><input type="checkbox" /> ' . htmlspecialchars($item, ENT_QUOTES, 'UTF-8') . '</label></li>' . "\n";
|
|
@@ -59,22 +59,22 @@ MD::registerPlugin('checklist', function (array $args, string $body): string {
|
|
|
59
59
|
return $html . "</ul></div>";
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
-
// ---
|
|
63
|
-
// Inline
|
|
64
|
-
//
|
|
65
|
-
//
|
|
62
|
+
// --- Custom callout (inline or block) ---
|
|
63
|
+
// Inline: {% callout warning "Warning!" Content on one line %}
|
|
64
|
+
// Block : {% callout danger "Title"
|
|
65
|
+
// Paragraph 1
|
|
66
66
|
//
|
|
67
|
-
//
|
|
67
|
+
// Paragraph 2
|
|
68
68
|
// %}
|
|
69
69
|
MD::registerPlugin('callout', function (array $args, string $body): string {
|
|
70
70
|
$validTypes = ['info', 'success', 'warning', 'danger'];
|
|
71
71
|
$type = in_array($args[0] ?? '', $validTypes, true) ? $args[0] : 'info';
|
|
72
72
|
$title = !empty($args[1]) ? htmlspecialchars($args[1], ENT_QUOTES, 'UTF-8') : '';
|
|
73
73
|
|
|
74
|
-
//
|
|
74
|
+
// Content: $body for a block tag, otherwise the remaining args on the opening line
|
|
75
75
|
if ($body !== '') {
|
|
76
76
|
$content = htmlspecialchars($body, ENT_QUOTES, 'UTF-8');
|
|
77
|
-
//
|
|
77
|
+
// Replace double line breaks with <br><br> to preserve paragraphs
|
|
78
78
|
$content = str_replace("\n\n", '<br><br>', $content);
|
|
79
79
|
$content = str_replace("\n", '<br>', $content);
|
|
80
80
|
} else {
|