@@ -25,63 +25,63 @@ |
||
25 | 25 | if (!empty($this->data['attrs']['data-filename'])) { |
26 | 26 | $openingTag .= ' ' . $this->data['attrs']['data-filename']; |
27 | 27 | } |
28 | - $extraTag = ''; |
|
29 | - if (isset($this->data['attrs']['data-sln-old'])) |
|
30 | - { |
|
31 | - $sln_old = $this->data['attrs']['data-sln-old']; |
|
32 | - if (is_numeric($sln_old)) |
|
33 | - { |
|
34 | - $sln_old = (int) $sln_old; |
|
35 | - } |
|
36 | - else |
|
37 | - { |
|
38 | - $sln_old = 1; |
|
39 | - } |
|
40 | - } |
|
41 | - if (isset($this->data['attrs']['data-sln'])) |
|
42 | - { |
|
43 | - $start_line_numbers_at = $this->data['attrs']['data-sln']; |
|
44 | - if (is_numeric($start_line_numbers_at)) |
|
45 | - { |
|
46 | - $start_line_numbers_at = (int) $start_line_numbers_at; |
|
47 | - if ($start_line_numbers_at > 0) |
|
48 | - $extraTag .= 'enable_line_numbers="true", '; |
|
49 | - else |
|
50 | - $extraTag .= 'enable_line_numbers="false", '; |
|
51 | - $extraTag .= 'start_line_numbers_at="' . abs($start_line_numbers_at) .'"'; |
|
52 | - } |
|
53 | - else |
|
54 | - { |
|
55 | - $extraTag = 'enable_line_numbers="false"'; |
|
56 | - } |
|
57 | - } |
|
58 | - if (isset($this->data['attrs']['data-hle'])) |
|
59 | - { |
|
60 | - $highlight_lines_extra = $this->data['attrs']['data-hle']; |
|
61 | - $arr = explode(',', $highlight_lines_extra); |
|
62 | - $str = ''; |
|
63 | - foreach($arr as $val) |
|
64 | - { |
|
65 | - if ($str) $str .= ','; |
|
66 | - if (is_numeric($val)) |
|
67 | - { |
|
68 | - $ival = (int) $val; |
|
69 | - if ($sln_old > 0 && $ival > 0) |
|
70 | - $str .= $ival - $sln_old + 1; |
|
71 | - else |
|
72 | - $str .= abs($ival); |
|
73 | - } |
|
74 | - } |
|
75 | - if ($str) |
|
76 | - { |
|
77 | - if (!$extraTag) |
|
78 | - $extraTag = '['; |
|
79 | - else |
|
80 | - $extraTag .= ', '; |
|
81 | - $extraTag .= 'highlight_lines_extra="' . $str . '"'; |
|
82 | - } |
|
83 | - } |
|
84 | - if ($extraTag) $openingTag .= ' [' . $extraTag . ']'; |
|
28 | + $extraTag = ''; |
|
29 | + if (isset($this->data['attrs']['data-sln-old'])) |
|
30 | + { |
|
31 | + $sln_old = $this->data['attrs']['data-sln-old']; |
|
32 | + if (is_numeric($sln_old)) |
|
33 | + { |
|
34 | + $sln_old = (int) $sln_old; |
|
35 | + } |
|
36 | + else |
|
37 | + { |
|
38 | + $sln_old = 1; |
|
39 | + } |
|
40 | + } |
|
41 | + if (isset($this->data['attrs']['data-sln'])) |
|
42 | + { |
|
43 | + $start_line_numbers_at = $this->data['attrs']['data-sln']; |
|
44 | + if (is_numeric($start_line_numbers_at)) |
|
45 | + { |
|
46 | + $start_line_numbers_at = (int) $start_line_numbers_at; |
|
47 | + if ($start_line_numbers_at > 0) |
|
48 | + $extraTag .= 'enable_line_numbers="true", '; |
|
49 | + else |
|
50 | + $extraTag .= 'enable_line_numbers="false", '; |
|
51 | + $extraTag .= 'start_line_numbers_at="' . abs($start_line_numbers_at) .'"'; |
|
52 | + } |
|
53 | + else |
|
54 | + { |
|
55 | + $extraTag = 'enable_line_numbers="false"'; |
|
56 | + } |
|
57 | + } |
|
58 | + if (isset($this->data['attrs']['data-hle'])) |
|
59 | + { |
|
60 | + $highlight_lines_extra = $this->data['attrs']['data-hle']; |
|
61 | + $arr = explode(',', $highlight_lines_extra); |
|
62 | + $str = ''; |
|
63 | + foreach($arr as $val) |
|
64 | + { |
|
65 | + if ($str) $str .= ','; |
|
66 | + if (is_numeric($val)) |
|
67 | + { |
|
68 | + $ival = (int) $val; |
|
69 | + if ($sln_old > 0 && $ival > 0) |
|
70 | + $str .= $ival - $sln_old + 1; |
|
71 | + else |
|
72 | + $str .= abs($ival); |
|
73 | + } |
|
74 | + } |
|
75 | + if ($str) |
|
76 | + { |
|
77 | + if (!$extraTag) |
|
78 | + $extraTag = '['; |
|
79 | + else |
|
80 | + $extraTag .= ', '; |
|
81 | + $extraTag .= 'highlight_lines_extra="' . $str . '"'; |
|
82 | + } |
|
83 | + } |
|
84 | + if ($extraTag) $openingTag .= ' [' . $extraTag . ']'; |
|
85 | 85 | |
86 | 86 | $openingTag .= '>'; |
87 | 87 | return $openingTag . "\n" . $this->data['content'][0]['text'] . "\n</code>"; |
@@ -341,36 +341,36 @@ |
||
341 | 341 | $node = new Node('code_block'); |
342 | 342 | $node->attr('class', 'code ' . $lang); |
343 | 343 | $node->attr('data-language', $lang); |
344 | - $node->attr('data-filename', rtrim($file)); |
|
345 | - if ($ext) |
|
346 | - { |
|
347 | - if (isset($ext['start_line_numbers_at'])) |
|
348 | - { |
|
349 | - $start_line_numbers_at = $ext['start_line_numbers_at']; |
|
350 | - if (isset($ext['enable_line_numbers']) && ($ext['enable_line_numbers'] === false)) |
|
351 | - { |
|
352 | - $start_line_numbers_at = -$start_line_numbers_at; |
|
353 | - } |
|
354 | - $node->attr('data-sln', $start_line_numbers_at); |
|
355 | - $node->attr('data-sln-old', $start_line_numbers_at); |
|
356 | - } |
|
357 | - else |
|
358 | - { |
|
359 | - $node->attr('data-sln-old', '1'); |
|
360 | - } |
|
361 | - if (isset($ext['highlight_lines_extra'])) |
|
362 | - { |
|
363 | - $str = ''; |
|
364 | - asort($ext['highlight_lines_extra']); |
|
365 | - foreach($ext['highlight_lines_extra'] as $hle) |
|
366 | - { |
|
367 | - if ($str) $str .= ','; |
|
368 | - if ($start_line_numbers_at > 0) $hle += $start_line_numbers_at - 1; |
|
369 | - $str .= $hle; |
|
370 | - } |
|
371 | - $node->attr('data-hle', $str); |
|
372 | - } |
|
373 | - } |
|
344 | + $node->attr('data-filename', rtrim($file)); |
|
345 | + if ($ext) |
|
346 | + { |
|
347 | + if (isset($ext['start_line_numbers_at'])) |
|
348 | + { |
|
349 | + $start_line_numbers_at = $ext['start_line_numbers_at']; |
|
350 | + if (isset($ext['enable_line_numbers']) && ($ext['enable_line_numbers'] === false)) |
|
351 | + { |
|
352 | + $start_line_numbers_at = -$start_line_numbers_at; |
|
353 | + } |
|
354 | + $node->attr('data-sln', $start_line_numbers_at); |
|
355 | + $node->attr('data-sln-old', $start_line_numbers_at); |
|
356 | + } |
|
357 | + else |
|
358 | + { |
|
359 | + $node->attr('data-sln-old', '1'); |
|
360 | + } |
|
361 | + if (isset($ext['highlight_lines_extra'])) |
|
362 | + { |
|
363 | + $str = ''; |
|
364 | + asort($ext['highlight_lines_extra']); |
|
365 | + foreach($ext['highlight_lines_extra'] as $hle) |
|
366 | + { |
|
367 | + if ($str) $str .= ','; |
|
368 | + if ($start_line_numbers_at > 0) $hle += $start_line_numbers_at - 1; |
|
369 | + $str .= $hle; |
|
370 | + } |
|
371 | + $node->attr('data-hle', $str); |
|
372 | + } |
|
373 | + } |
|
374 | 374 | $this->nodestack->addTop($node); |
375 | 375 | $this->cdata(trim($text, "\n")); |
376 | 376 | $this->nodestack->drop('code_block'); |