@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.
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
  // =============================================================================
6
- // PLUGINS FOURNIS PAR DÉFAUT (optionnels, décommentez ce dont vous avez besoin)
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 manquant -->';
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 manquant -->';
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 (bloc multi-ligne) ---
39
+ // --- Checklist (multi-line block) ---
40
40
  // {% checklist
41
- // Faire la vaisselle
42
- // Promener le chien
43
- // Lire un livre
41
+ // Do the dishes
42
+ // Walk the dog
43
+ // Read a book
44
44
  // %}
45
45
  //
46
- // Optionnellement avec un titre :
47
- // {% checklist "Mes tâches du jour"
48
- // Tâche 1
49
- // Tâche 2
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: aucun élément -->';
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
- // --- Avertissement personnalisé (inline ou bloc) ---
63
- // Inline : {% callout warning "Attention !" Contenu sur une ligne %}
64
- // Bloc : {% callout danger "Titre"
65
- // Paragraphe 1
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
- // Paragraphe 2
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
- // Contenu : $body si tag bloc, sinon les args restants sur la ligne d'ouverture
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
- // Remplace les doubles sauts de ligne par des <br><br> pour préserver les paragraphes
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 {