@kirigami/php-prepros 1.1.0 → 1.6.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.
@@ -3,7 +3,13 @@
3
3
 
4
4
 
5
5
  // =============================================================================
6
- // PLUGINS FOURNIS PAR DÉFAUT (optionnels, décommentez ce dont vous avez besoin)
6
+ // DEFAULT MARKDOWN PLUGINS
7
+ //
8
+ // Auto-loaded from md.class.php, so these are available in every render without
9
+ // any setup ("registered out of the box"). To drop one, call
10
+ // MD::unregisterPlugin('name') (or md_unregister_plugin('name')) from an
11
+ // `includes` file; to change one, MD::registerPlugin() your own under the same
12
+ // name.
7
13
  // =============================================================================
8
14
 
9
15
  // --- CodePen (inline) ---
@@ -13,7 +19,7 @@ MD::registerPlugin('codepen', function (array $args, string $body): string {
13
19
  $id = htmlspecialchars($args[0] ?? '', ENT_QUOTES, 'UTF-8');
14
20
  $user = htmlspecialchars($args[1] ?? 'anonymous', ENT_QUOTES, 'UTF-8');
15
21
  $height = intval($args[2] ?? 400);
16
- if ($id === '') return '<!-- codepen: id manquant -->';
22
+ if ($id === '') return '<!-- codepen: missing id -->';
17
23
  return "<iframe height=\"{$height}\" style=\"width:100%\" "
18
24
  . "scrolling=\"no\" "
19
25
  . "src=\"https://codepen.io/{$user}/embed/{$id}?default-tab=result\" "
@@ -28,7 +34,7 @@ MD::registerPlugin('youtube', function (array $args, string $body): string {
28
34
  $id = htmlspecialchars($args[0] ?? '', ENT_QUOTES, 'UTF-8');
29
35
  $width = intval($args[1] ?? 560);
30
36
  $height = intval($args[2] ?? 315);
31
- if ($id === '') return '<!-- youtube: id manquant -->';
37
+ if ($id === '') return '<!-- youtube: missing id -->';
32
38
  return "<iframe width=\"{$width}\" height=\"{$height}\" "
33
39
  . "src=\"https://www.youtube.com/embed/{$id}\" "
34
40
  . "title=\"YouTube video player\" frameborder=\"0\" loading=\"lazy\" "
@@ -36,22 +42,22 @@ MD::registerPlugin('youtube', function (array $args, string $body): string {
36
42
  . "allowfullscreen></iframe>";
37
43
  });
38
44
 
39
- // --- Checklist (bloc multi-ligne) ---
45
+ // --- Checklist (multi-line block) ---
40
46
  // {% checklist
41
- // Faire la vaisselle
42
- // Promener le chien
43
- // Lire un livre
47
+ // Do the dishes
48
+ // Walk the dog
49
+ // Read a book
44
50
  // %}
45
51
  //
46
- // Optionnellement avec un titre :
47
- // {% checklist "Mes tâches du jour"
48
- // Tâche 1
49
- // Tâche 2
52
+ // Optionally with a title:
53
+ // {% checklist "My tasks for today"
54
+ // Task 1
55
+ // Task 2
50
56
  // %}
51
57
  MD::registerPlugin('checklist', function (array $args, string $body): string {
52
58
  $title = !empty($args[0]) ? '<p class="checklist-title"><strong>' . htmlspecialchars($args[0], ENT_QUOTES, 'UTF-8') . '</strong></p>' : '';
53
59
  $items = array_filter(array_map('trim', explode("\n", $body)));
54
- if (empty($items)) return '<!-- checklist: aucun élément -->';
60
+ if (empty($items)) return '<!-- checklist: no items -->';
55
61
  $html = "<div class=\"checklist\">{$title}<ul>\n";
56
62
  foreach ($items as $item) {
57
63
  $html .= ' <li><label><input type="checkbox" /> ' . htmlspecialchars($item, ENT_QUOTES, 'UTF-8') . '</label></li>' . "\n";
@@ -59,22 +65,22 @@ MD::registerPlugin('checklist', function (array $args, string $body): string {
59
65
  return $html . "</ul></div>";
60
66
  });
61
67
 
62
- // --- Avertissement personnalisé (inline ou bloc) ---
63
- // Inline : {% callout warning "Attention !" Contenu sur une ligne %}
64
- // Bloc : {% callout danger "Titre"
65
- // Paragraphe 1
68
+ // --- Custom callout (inline or block) ---
69
+ // Inline: {% callout warning "Warning!" Content on one line %}
70
+ // Block : {% callout danger "Title"
71
+ // Paragraph 1
66
72
  //
67
- // Paragraphe 2
73
+ // Paragraph 2
68
74
  // %}
69
75
  MD::registerPlugin('callout', function (array $args, string $body): string {
70
76
  $validTypes = ['info', 'success', 'warning', 'danger'];
71
77
  $type = in_array($args[0] ?? '', $validTypes, true) ? $args[0] : 'info';
72
78
  $title = !empty($args[1]) ? htmlspecialchars($args[1], ENT_QUOTES, 'UTF-8') : '';
73
79
 
74
- // Contenu : $body si tag bloc, sinon les args restants sur la ligne d'ouverture
80
+ // Content: $body for a block tag, otherwise the remaining args on the opening line
75
81
  if ($body !== '') {
76
82
  $content = htmlspecialchars($body, ENT_QUOTES, 'UTF-8');
77
- // Remplace les doubles sauts de ligne par des <br><br> pour préserver les paragraphes
83
+ // Replace double line breaks with <br><br> to preserve paragraphs
78
84
  $content = str_replace("\n\n", '<br><br>', $content);
79
85
  $content = str_replace("\n", '<br>', $content);
80
86
  } else {