質問編集履歴
2
誤字修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -70,9 +70,31 @@
|
|
70
70
|
|
71
71
|
`<pre class="prettyprint linenums">` と `</pre>` の html が吐出されずに、`$content` の部分だけが実体参照されてでてきます。
|
72
72
|
|
73
|
+
```html
|
74
|
+
|
75
|
+
<pre class="prettyprint linenums">
|
76
|
+
|
77
|
+
<?php echo 'hoge'; ?>
|
78
|
+
|
79
|
+
</pre>
|
80
|
+
|
81
|
+
```
|
82
|
+
|
83
|
+
↑こう記述した記事が
|
84
|
+
|
85
|
+
```html
|
86
|
+
|
87
|
+
<?php echo 'hoge'; ?>
|
88
|
+
|
89
|
+
```
|
90
|
+
|
91
|
+
という html で吐き出されます。
|
92
|
+
|
93
|
+
`<pre class="prettyprint linenums">` と `</pre>` が、記事ソースから消えています。
|
73
94
|
|
74
95
|
|
96
|
+
|
75
|
-
|
97
|
+
どこで実装を間違っていますか?
|
76
98
|
|
77
99
|
|
78
100
|
|
1
誤字修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -34,7 +34,7 @@
|
|
34
34
|
|
35
35
|
1. まずは 正規表現の `preg_replace_callback` で `<pre class="prettyprint linenums">` と `</pre>` という文字列を判定
|
36
36
|
|
37
|
-
```
|
37
|
+
```php
|
38
38
|
|
39
39
|
$content = preg_replace_callback('/<pre(.*?)>(.+?)\<\/pre\>/s', 'self::_pre', $content);
|
40
40
|
|
@@ -58,7 +58,7 @@
|
|
58
58
|
|
59
59
|
2. `<?php echo 'hoge'; ?>` という 文字列(`$result[2]`)を `htmlspecialchars` で実体参照し、 $content に代入する
|
60
60
|
|
61
|
-
```
|
61
|
+
```php
|
62
62
|
|
63
63
|
$content = htmlspecialchars($result[2], ENT_QUOTES, 'UTF-8');
|
64
64
|
|