File tree 2 files changed +18
-8
lines changed
2 files changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -129,8 +129,7 @@ private function codeInternal($codeBlock)
129
129
if (($ codeBlock && \substr (\ltrim ($ this ->line ), 0 , 3 ) !== '``` ' )
130
130
|| \strpos ($ this ->line , $ this ->indentStr ) === 0
131
131
) {
132
- $ this ->markup .= "\n" ; // @todo: donot use \n for first line
133
- $ this ->markup .= $ codeBlock ? $ this ->line : \substr ($ this ->line , $ this ->indentLen );
132
+ $ this ->markup .= $ this ->codeLine ($ this ->line , $ codeBlock , $ this ->indentLen );
134
133
135
134
$ this ->pointer ++;
136
135
@@ -143,13 +142,9 @@ private function codeInternal($codeBlock)
143
142
144
143
protected function rule ()
145
144
{
146
- if ($ this ->trimmedPrevLine === ''
147
- && \preg_match (static ::RE_MD_RULE , $ this ->trimmedLine )
148
- ) {
149
- $ this ->markup .= "\n<hr /> " ;
145
+ $ this ->markup .= $ hr = $ this ->hr ($ this ->trimmedPrevLine , $ this ->trimmedLine );
150
146
151
- return \true;
152
- }
147
+ return (bool ) $ hr ;
153
148
}
154
149
155
150
protected function listt ()
Original file line number Diff line number Diff line change @@ -31,6 +31,13 @@ public function h($level, $line)
31
31
return '' ;
32
32
}
33
33
34
+ public function hr ($ prevLine , $ line )
35
+ {
36
+ if ($ prevLine === '' && \preg_match (BlockElementParser::RE_MD_RULE , $ line )) {
37
+ return "\n<hr /> " ;
38
+ }
39
+ }
40
+
34
41
public function codeStart ($ lang )
35
42
{
36
43
$ lang = isset ($ lang [1 ])
@@ -40,6 +47,14 @@ public function codeStart($lang)
40
47
return "\n<pre><code {$ lang }> " ;
41
48
}
42
49
50
+ public function codeLine ($ line , $ isBlock , $ indentLen = 4 )
51
+ {
52
+ $ code = "\n" ; // @todo: donot use \n for first line
53
+ $ code .= $ isBlock ? $ line : \substr ($ line , $ indentLen );
54
+
55
+ return $ code ;
56
+ }
57
+
43
58
public function tableStart ($ line , $ delim = '| ' )
44
59
{
45
60
$ table = "<table> \n<thead> \n<tr> \n" ;
You can’t perform that action at this time.
0 commit comments