|
@@ -53,7 +53,7 @@ discard block |
|
|
block discarded – undo |
|
53
|
53
|
} |
|
54
|
54
|
|
|
55
|
55
|
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attributes |
|
56
|
|
- $html['body'] = preg_replace_callback('/<img(?<pre>[^>]*)src="(?<src>\/[^"]+\.svg)"(?<post>[^>]*?)[\s\/]*>/s', function (array $matches): string { // ^[/] |
|
|
56
|
+ $html['body'] = preg_replace_callback('/<img(?<pre>[^>]*)src="(?<src>\/[^"]+\.svg)"(?<post>[^>]*?)[\s\/]*>/s', function(array $matches): string { // ^[/] |
|
57
|
57
|
if (!isset($this->svgFileArr[$matches['src']])) { // check usage |
|
58
|
58
|
return $matches[0]; |
|
59
|
59
|
} |
|
@@ -63,7 +63,7 @@ discard block |
|
|
block discarded – undo |
|
63
|
63
|
}, $html['body']); |
|
64
|
64
|
|
|
65
|
65
|
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object#attributes |
|
66
|
|
- $html['body'] = preg_replace_callback('/<object(?<pre>[^>]*)data="(?<data>\/[^"]+\.svg)"(?<post>[^>]*?)[\s\/]*>(?:<\/object>)/s', function (array $matches): string { // ^[/] |
|
|
66
|
+ $html['body'] = preg_replace_callback('/<object(?<pre>[^>]*)data="(?<data>\/[^"]+\.svg)"(?<post>[^>]*?)[\s\/]*>(?:<\/object>)/s', function(array $matches): string { // ^[/] |
|
67
|
67
|
if (!isset($this->svgFileArr[$matches['data']])) { // check usage |
|
68
|
68
|
return $matches[0]; |
|
69
|
69
|
} |
|
@@ -87,7 +87,7 @@ discard block |
|
|
block discarded – undo |
|
87
|
87
|
} |
|
88
|
88
|
|
|
89
|
89
|
if (1 === preg_match('/<(?:style|defs|url\()/', $svg)) { |
|
90
|
|
- return null;# check links @ __construct |
|
|
90
|
+ return null; # check links @ __construct |
|
91
|
91
|
} |
|
92
|
92
|
|
|
93
|
93
|
$svg = preg_replace('/<\/svg>.*|xlink:|\s(?:(?:width|height|version|xmlns)|(?:[a-z\-]+\:[a-z\-]+))="[^"]*"/s', '', $svg); // clean !?: \s+(?<atr>[\w\-]+)=["\'](?<val>[^"\']+)["\'] |
|
@@ -126,7 +126,7 @@ discard block |
|
|
block discarded – undo |
|
126
|
126
|
|
|
127
|
127
|
$svg = preg_replace_callback( |
|
128
|
128
|
'/<use(?<pre>.*?)(?:xlink:)?href="(?<href>\/.+?\.svg)#[^"]+"(?<post>.*?)[\s\/]*>(?:<\/use>)?/s', |
|
129
|
|
- function (array $matches): string { |
|
|
129
|
+ function(array $matches): string { |
|
130
|
130
|
return sprintf('<use%s href="#%s"/>', $matches['pre'].$matches['post'], $this->convertFilePath($matches['href'])); |
|
131
|
131
|
}, |
|
132
|
132
|
'<svg xmlns="http://www.w3.org/2000/svg">' |