1
1
<?php
2
+
2
3
/**
3
4
* This file is part of the ParsedownCheckbox package.
4
5
*
9
10
*/
10
11
class ParsedownCheckbox extends ParsedownExtra
11
12
{
12
- const VERSION = '0.1 .0 ' ;
13
+ const VERSION = '0.2 .0 ' ;
13
14
14
15
public function __construct ()
15
16
{
@@ -73,7 +74,7 @@ protected function checkboxUnchecked($text)
73
74
$ text = self ::escape ($ text );
74
75
}
75
76
76
- return '<input type="checkbox" disabled /> ' . $ text ;
77
+ return '<input type="checkbox" disabled /> ' . $ this -> format ( $ text) ;
77
78
}
78
79
79
80
protected function checkboxChecked ($ text )
@@ -82,6 +83,31 @@ protected function checkboxChecked($text)
82
83
$ text = self ::escape ($ text );
83
84
}
84
85
85
- return '<input type="checkbox" checked disabled /> ' .$ text ;
86
+ return '<input type="checkbox" checked disabled /> ' . $ this ->format ($ text );
87
+ }
88
+
89
+ /**
90
+ * Formats the checkbox label without double escaping.
91
+ * @param string $text the string to format
92
+ * @return string the formatted text
93
+ */
94
+ protected function format ($ text )
95
+ {
96
+ // backup settings
97
+ $ markup_escaped = $ this ->markupEscaped ;
98
+ $ safe_mode = $ this ->safeMode ;
99
+
100
+ // disable rules to prevent double escaping.
101
+ $ this ->setMarkupEscaped (false );
102
+ $ this ->setSafeMode (false );
103
+
104
+ // format line
105
+ $ text = $ this ->line ($ text );
106
+
107
+ // reset old values
108
+ $ this ->setMarkupEscaped ($ markup_escaped );
109
+ $ this ->setSafeMode ($ safe_mode );
110
+
111
+ return $ text ;
86
112
}
87
113
}
0 commit comments