Created
May 29, 2019 23:19
-
-
Save leblanc-simon/798a4fde9b410b207b32744c728fc706 to your computer and use it in GitHub Desktop.
avoid double encoding with line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ParsedownCheckbox extends ParsedownExtra | |
{ | |
protected function checkboxUnchecked($text) | |
{ | |
if ($this->markupEscaped || $this->safeMode) { | |
$text = self::escape($text); | |
// Disable escape to convert data with line (avoid double encoding) | |
$this->disableEspace(); | |
$text = $this->line($text); | |
// Re-enable escape | |
$this->enableEspace(); | |
} else { | |
$text = $this->line($text); | |
} | |
return '<input type="checkbox" disabled /> '.$text; | |
} | |
protected function checkboxChecked($text) | |
{ | |
if ($this->markupEscaped || $this->safeMode) { | |
$text = self::escape($text); | |
// Disable escape to convert data with line (avoid double encoding) | |
$this->disableEspace(); | |
$text = $this->line($text); | |
// Re-enable escape | |
$this->enableEspace(); | |
} else { | |
$text = $this->line($text); | |
} | |
return '<input type="checkbox" checked disabled /> '.$text; | |
} | |
private function disableEspace() | |
{ | |
if ($this->markupEscaped) { | |
$this->setMarkupEscaped(false); | |
} | |
if ($this->safeMode) { | |
$this->setSafeMode(false); | |
} | |
} | |
private function enableEspace() | |
{ | |
if (!$this->markupEscaped) { | |
$this->setMarkupEscaped(true); | |
} | |
if (!$this->safeMode) { | |
$this->setSafeMode(true); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment