@@ -28,7 +28,7 @@ function __construct()
28
28
array_unshift ($ this ->DefinitionTypes ['[ ' ], 'Footnote ' );
29
29
30
30
# identify footnote markers before before links
31
- array_unshift ($ this ->SpanTypes ['[ ' ], 'FootnoteMarker ' );
31
+ array_unshift ($ this ->InlineTypes ['[ ' ], 'FootnoteMarker ' );
32
32
}
33
33
34
34
#
@@ -61,9 +61,9 @@ function text($text)
61
61
#
62
62
# Atx
63
63
64
- protected function identifyAtx ($ Line )
64
+ protected function blockHeader ($ Line )
65
65
{
66
- $ Block = parent ::identifyAtx ($ Line );
66
+ $ Block = parent ::blockHeader ($ Line );
67
67
68
68
if (preg_match ('/[ #]* ' .$ this ->attributesPattern .'[ ]*$/ ' , $ Block ['element ' ]['text ' ], $ matches , PREG_OFFSET_CAPTURE ))
69
69
{
@@ -80,7 +80,7 @@ protected function identifyAtx($Line)
80
80
#
81
81
# Definition List
82
82
83
- protected function identifyDefinitionList ($ Line , $ Block )
83
+ protected function blockDefinitionList ($ Line , $ Block )
84
84
{
85
85
if (isset ($ Block ['type ' ]))
86
86
{
@@ -115,7 +115,7 @@ protected function identifyDefinitionList($Line, $Block)
115
115
return $ Block ;
116
116
}
117
117
118
- protected function addToDefinitionList ($ Line , array $ Block )
118
+ protected function blockDefinitionListContinue ($ Line , array $ Block )
119
119
{
120
120
if ($ Line ['text ' ][0 ] === ': ' )
121
121
{
@@ -143,9 +143,9 @@ protected function addToDefinitionList($Line, array $Block)
143
143
#
144
144
# Setext
145
145
146
- protected function identifySetext ($ Line , array $ Block = null )
146
+ protected function blockSetextHeader ($ Line , array $ Block = null )
147
147
{
148
- $ Block = parent ::identifySetext ($ Line , $ Block );
148
+ $ Block = parent ::blockSetextHeader ($ Line , $ Block );
149
149
150
150
if (preg_match ('/[ ]* ' .$ this ->attributesPattern .'[ ]*$/ ' , $ Block ['element ' ]['text ' ], $ matches , PREG_OFFSET_CAPTURE ))
151
151
{
@@ -162,64 +162,16 @@ protected function identifySetext($Line, array $Block = null)
162
162
#
163
163
# Markup
164
164
165
- protected function completeMarkup ($ Block )
165
+ protected function blockMarkupComplete ($ Block )
166
166
{
167
- $ DOMDocument = new DOMDocument ;
168
-
169
- $ DOMDocument ->loadXML ($ Block ['element ' ], LIBXML_NOERROR | LIBXML_NOWARNING );
170
-
171
- if ($ DOMDocument ->documentElement === null )
172
- {
173
- return $ Block ;
174
- }
175
-
176
- $ result = $ DOMDocument ->documentElement ->getAttribute ('markdown ' );
177
-
178
- if ($ result !== '1 ' )
167
+ if ( ! isset ($ Block ['element ' ]['attributes ' ]['markdown ' ]) or $ Block ['element ' ]['attributes ' ]['markdown ' ] !== '1 ' )
179
168
{
180
169
return $ Block ;
181
170
}
182
171
183
- $ DOMDocument ->documentElement ->removeAttribute ('markdown ' );
184
-
185
- $ index = 0 ;
186
- $ nestedElements = array ();
187
-
188
- $ markdown = '' ;
189
-
190
- foreach ($ DOMDocument ->documentElement ->childNodes as $ Node )
191
- {
192
- if ($ Node instanceof DOMText)
193
- {
194
- $ markdown .= $ Node ->nodeValue ;
195
- }
196
- elseif ($ Node instanceof DOMNode)
197
- {
198
- $ nestedElements []= $ DOMDocument ->saveXML ($ Node );
199
-
200
- # replace nested elements with placeholders
201
- $ markdown .= '\x1A ' .$ index ++.'/ ' ;
202
- }
203
- else
204
- {
205
- continue ;
206
- }
207
- }
208
-
209
- foreach ($ nestedElements as $ index => $ nestedElement )
210
- {
211
- $ markdown = str_replace ('\x1A ' .$ index .'/ ' , $ nestedElement , $ markdown );
212
- }
213
-
214
- $ text = $ this ->text ($ markdown );
215
-
216
- # because we don't want markup to get encoded
217
- $ DOMDocument ->documentElement ->nodeValue = "\n" .'placeholder ' ."\n" ;
218
-
219
- $ markup = $ DOMDocument ->saveXML ($ DOMDocument ->documentElement );
220
- $ markup = str_replace ('placeholder ' , $ text , $ markup );
172
+ unset($ Block ['element ' ]['attributes ' ]['markdown ' ]);
221
173
222
- $ Block ['element ' ] = $ markup ;
174
+ $ Block ['element ' ][ ' text ' ] = "\n" . $ this -> text ( $ Block [ ' element ' ][ ' text ' ]). "\n" ;
223
175
224
176
return $ Block ;
225
177
}
@@ -231,7 +183,7 @@ protected function completeMarkup($Block)
231
183
#
232
184
# Abbreviation
233
185
234
- protected function identifyAbbreviation ($ Line )
186
+ protected function definitionAbbreviation ($ Line )
235
187
{
236
188
if (preg_match ('/^\*\[(.+?)\]:[ ]*(.+?)[ ]*$/ ' , $ Line ['text ' ], $ matches ))
237
189
{
@@ -247,7 +199,7 @@ protected function identifyAbbreviation($Line)
247
199
#
248
200
# Footnote
249
201
250
- protected function identifyFootnote ($ Line )
202
+ protected function definitionFootnote ($ Line )
251
203
{
252
204
if (preg_match ('/^\[\^(.+?)\]:[ ]?(.+)$/ ' , $ Line ['text ' ], $ matches ))
253
205
{
@@ -265,15 +217,15 @@ protected function identifyFootnote($Line)
265
217
}
266
218
267
219
#
268
- # Spans
220
+ # Inline Elements
269
221
#
270
222
271
223
#
272
224
# Footnote Marker
273
225
274
- protected function identifyFootnoteMarker ( $ Excerpt )
226
+ protected function inlineFootnoteMarker ( $ excerpt )
275
227
{
276
- if (preg_match ('/^\[\^(.+?)\]/ ' , $ Excerpt [ ' text ' ] , $ matches ))
228
+ if (preg_match ('/^\[\^(.+?)\]/ ' , $ excerpt , $ matches ))
277
229
{
278
230
$ name = $ matches [1 ];
279
231
@@ -312,11 +264,11 @@ protected function identifyFootnoteMarker($Excerpt)
312
264
#
313
265
# Link
314
266
315
- protected function identifyLink ( $ Excerpt )
267
+ protected function inlineLink ( $ excerpt )
316
268
{
317
- $ Span = parent ::identifyLink ( $ Excerpt );
269
+ $ Span = parent ::inlineLink ( $ excerpt );
318
270
319
- $ remainder = substr ($ Excerpt [ ' text ' ] , $ Span ['extent ' ]);
271
+ $ remainder = substr ($ excerpt , $ Span ['extent ' ]);
320
272
321
273
if (preg_match ('/^[ ]* ' .$ this ->attributesPattern .'/ ' , $ remainder , $ matches ))
322
274
{
@@ -331,9 +283,9 @@ protected function identifyLink($Excerpt)
331
283
#
332
284
# ~
333
285
334
- protected function readPlainText ($ text )
286
+ protected function unmarkedText ($ text )
335
287
{
336
- $ text = parent ::readPlainText ($ text );
288
+ $ text = parent ::unmarkedText ($ text );
337
289
338
290
if (isset ($ this ->Definitions ['Abbreviation ' ]))
339
291
{
0 commit comments