Browse Source

fix: détection du langage sur les bloc de code via raccourci triple backtick, et trim des code inline via les raccourcis simple ou double backticks

remotes/checkIfPRContentChanged-1664471084067513464/master
Cerdic 2 months ago
parent
commit
a869456945
  1. 6
      wheels/spip/backticks.php

6
wheels/spip/backticks.php

@ -20,9 +20,9 @@ function replace_backticks($match) {
if (strlen($ticks) === 3) {
$langage = '';
if (preg_match(",^[\w]+\r?\n?,ims", $code, $r)) {
if (preg_match(",^[\w]+(\r\n?|\n),is", $code, $r)) {
$langage = rtrim($r[0]);
$code = substr($code, strlen($r[0]));
$code = substr($code, strlen($langage));
}
$html = spip_balisage_code($code, true, '', $langage);
@ -30,7 +30,7 @@ function replace_backticks($match) {
}
else {
// span code
$html = spip_balisage_code($code, false);
$html = spip_balisage_code(trim($code), false);
$mode = "span";
}

Loading…
Cancel
Save