PluginProbe
OPcache Manager / 3.3.0
OPcache Manager v3.3.0
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.2.0 1.3.0 1.3.1 1.3.2 2.0.0 2.1.0 2.10.0 2.11.0 2.12.0 2.13.0 2.13.1 2.14.0 2.2.0 2.3.0 2.3.1 2.3.2 2.4.0 2.5.0 2.6.0 All 36 releases
opcache-manager / includes / libraries / markdown / inline / CodeTrait.php

CodeTrait.php in OPcache Manager 3.3.0, at includes/libraries/markdown/inline/CodeTrait.php

46 lines 911 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @copyright Copyright (c) 2014 Carsten Brandt
4 * @license https://github.com/cebe/markdown/blob/master/LICENSE
5 * @link https://github.com/cebe/markdown#readme
6 */
7
8 namespace cebe\markdownparser\inline;
9
10 /**
11 * Adds inline code elements
12 */
13 trait CodeTrait
14 {
15 /**
16 * Parses an inline code span `` ` ``.
17 * @marker `
18 */
19 protected function parseInlineCode($text)
20 {
21 if (preg_match('/^(``+)\s(.+?)\s\1/s', $text, $matches)) { // code with enclosed backtick
22 return [
23 [
24 'inlineCode',
25 $matches[2],
26 ],
27 strlen($matches[0])
28 ];
29 } elseif (preg_match('/^`(.+?)`/s', $text, $matches)) {
30 return [
31 [
32 'inlineCode',
33 $matches[1],
34 ],
35 strlen($matches[0])
36 ];
37 }
38 return [['text', $text[0]], 1];
39 }
40
41 protected function renderInlineCode($block)
42 {
43 return '<code>' . htmlspecialchars($block[1], ENT_NOQUOTES | ENT_SUBSTITUTE, 'UTF-8') . '</code>';
44 }
45 }
46