@@ -115,53 +115,54 @@ function parseContent($requestFile)
115
115
116
116
$ allowedImageTypes = '(\.png|\.jpg|\.jpeg|\.svg|\.gif|\.bmp|\.tif|\.tiff|\.webp) ' ;
117
117
118
+ $ src_path = '/ ' . $ path ;
118
119
119
120
// embedded pdf links
120
- $ replaces = '<embed src=" ' . $ path . '/ \\2" type="application/pdf" style="min-height:100vh;width:100%"> ' ;
121
+ $ replaces = '<embed src=" ' . $ src_path . '/ \\2" type="application/pdf" style="min-height:100vh;width:100%"> ' ;
121
122
$ pattern = array ('/(\!\[\[)(.*?.(?:pdf))(\]\])/ ' );
122
123
$ content = preg_replace ($ pattern , $ replaces , $ content );
123
124
124
125
// embedded mp4 links
125
126
$ replaces = '
126
- <video controls src=" ' . $ path . '/ \\2" type="video/mp4">
127
- <a class="internal-link" target="_blank" rel="noopener noreferrer" href=" ' . $ path . '/ ' . '\\2">Your browser does not support the video tag: Download \\2</a>
127
+ <video controls src=" ' . $ src_path . '/ \\2" type="video/mp4">
128
+ <a class="internal-link" target="_blank" rel="noopener noreferrer" href=" ' . $ src_path . '/ ' . '\\2">Your browser does not support the video tag: Download \\2</a>
128
129
</video> ' ;
129
130
$ pattern = array ('/(\!\[\[)(.*?.(?:mp4))(\]\])/ ' );
130
131
$ content = preg_replace ($ pattern , $ replaces , $ content );
131
132
132
133
133
134
// embedded m4a links
134
135
$ replaces = '
135
- <video controls src=" ' . $ path . '/ \\2" type="audio/x-m4a">
136
- <a class="internal-link" target="_blank" rel="noopener noreferrer" href=" ' . $ path . '/ ' . '\\2">Your browser does not support the audio tag: Download \\2</a>
136
+ <video controls src=" ' . $ src_path . '/ \\2" type="audio/x-m4a">
137
+ <a class="internal-link" target="_blank" rel="noopener noreferrer" href=" ' . $ src_path . '/ ' . '\\2">Your browser does not support the audio tag: Download \\2</a>
137
138
</video> ' ;
138
139
$ pattern = array ('/(\!\[\[)(.*?.(?:m4a))(\]\])/ ' );
139
140
$ content = preg_replace ($ pattern , $ replaces , $ content );
140
141
141
142
142
143
// links to other files with Alias
143
- $ replaces = '<a class="internal-link" target="_blank" rel="noopener noreferrer" href=" ' . $ path . '/ ' . '\\2"> \\3</a> ' ;
144
+ $ replaces = '<a class="internal-link" target="_blank" rel="noopener noreferrer" href=" ' . $ src_path . '/ ' . '\\2"> \\3</a> ' ;
144
145
$ pattern = array ('/(\[\[)(.*?.(?: ' . $ linkFileTypes . '))\|(.*)(\]\])/ ' );
145
146
$ content = preg_replace ($ pattern , $ replaces , $ content );
146
147
147
148
// links to other files without Alias
148
- $ replaces = '<a class="internal-link" target="_blank" rel="noopener noreferrer" href=" ' . $ path . '/ ' . '\\2"> \\2</a> ' ;
149
+ $ replaces = '<a class="internal-link" target="_blank" rel="noopener noreferrer" href=" ' . $ src_path . '/ ' . '\\2"> \\2</a> ' ;
149
150
$ pattern = array ('/(\[\[)(.*?.(?: ' . $ linkFileTypes . '))(\]\])/ ' );
150
151
$ content = preg_replace ($ pattern , $ replaces , $ content );
151
152
152
153
// img links with external target link
153
- $ replaces = 'noreferrer"><img class="images" width=" \\4" height=" \\5" alt="image not found" src=" ' . $ path . '/ \\2 \\3 ' . '"/> ' ;
154
+ $ replaces = 'noreferrer"><img class="images" width=" \\4" height=" \\5" alt="image not found" src=" ' . $ src_path . '/ \\2 \\3 ' . '"/> ' ;
154
155
$ pattern = array ('/noreferrer">(\!?\[\[)(.*?) ' .$ allowedImageTypes .'\|?(\d*)x?(\d*)(\]\])/ ' );
155
156
$ content = preg_replace ($ pattern , $ replaces , $ content );
156
157
157
158
// img links with size
158
- $ replaces = '<p><a href="#" class="pop"><img class="images" width=" \\4" height=" \\5" alt="image not found" src=" ' . $ path . '/ \\2 \\3 ' . '"/></a></p> ' ;
159
+ $ replaces = '<p><a href="#" class="pop"><img class="images" width=" \\4" height=" \\5" alt="image not found" src=" ' . $ src_path . '/ \\2 \\3 ' . '"/></a></p> ' ;
159
160
$ pattern = array ('/(\!?\[\[)(.*?) ' .$ allowedImageTypes .'\|?(\d*)x?(\d*)(\]\])/ ' );
160
161
$ content = preg_replace ($ pattern , $ replaces , $ content );
161
162
162
163
// centerise or right align images with "center"/"right" directive
163
164
$ pattern = '/(\!?\[\[)(.*?) ' .$ allowedImageTypes .'\|?(center|right)\|?(\d*)x?(\d*)(\]\])/ ' ;
164
- $ replaces = function ($ matches ) use ($ path ) {
165
+ $ replaces = function ($ matches ) use ($ src_path ) {
165
166
$ class = "images " ; // Default class for all images
166
167
if (strpos ($ matches [4 ], 'center ' ) !== false ) {
167
168
$ class .= " center " ; // Add 'center' class
@@ -170,17 +171,17 @@ function parseContent($requestFile)
170
171
}
171
172
$ width = $ matches [5 ] ?? 'auto ' ;
172
173
$ height = $ matches [6 ] ?? 'auto ' ;
173
- return '<p><a href="#" class="pop"><img class=" ' . $ class . '" src=" ' . $ path . '/ ' . $ matches [2 ] . $ matches [3 ] . '" width=" ' . $ width . '" height=" ' . $ height . '"/></a></p> ' ;
174
+ return '<p><a href="#" class="pop"><img class=" ' . $ class . '" src=" ' . $ src_path . '/ ' . $ matches [2 ] . $ matches [3 ] . '" width=" ' . $ width . '" height=" ' . $ height . '"/></a></p> ' ;
174
175
};
175
176
$ content = preg_replace_callback ($ pattern , $ replaces , $ content );
176
177
177
178
// img links with captions and size
178
- $ replaces = '<p><a href="#" class="pop"><img class="images" width=" \\5" height=" \\6" alt=" \\4" src=" ' . $ path . '/ \\2 \\3 ' . '"/></a></p> ' ;
179
+ $ replaces = '<p><a href="#" class="pop"><img class="images" width=" \\5" height=" \\6" alt=" \\4" src=" ' . $ src_path . '/ \\2 \\3 ' . '"/></a></p> ' ;
179
180
$ pattern = array ('/(\!?\[\[)(.*?) ' .$ allowedImageTypes .'\|?(.+\|)\|?(\d*)x?(\d*)(\]\])/ ' );
180
181
$ content = preg_replace ($ pattern , $ replaces , $ content );
181
182
182
183
// img links with captions
183
- $ replaces = '<p><a href="#" class="pop"><img class="images" alt=" \\4" src=" ' . $ path . '/ \\2 \\3 ' . '"/></a></p> ' ;
184
+ $ replaces = '<p><a href="#" class="pop"><img class="images" alt=" \\4" src=" ' . $ src_path . '/ \\2 \\3 ' . '"/></a></p> ' ;
184
185
$ pattern = array ('/(\!?\[\[)(.*?) ' .$ allowedImageTypes .'\|?(.+|)(\]\])/ ' );
185
186
$ content = preg_replace ($ pattern , $ replaces , $ content );
186
187
@@ -326,8 +327,9 @@ function ($matches) use ($path, $sameFolder) {
326
327
327
328
328
329
$ urlPath = $ newAbPath . '/ ' . $ linkFile ;
329
- if (substr ($ urlPath , 0 , 1 ) != '/ ' ) {
330
- $ urlPath = '/ ' . $ urlPath ;
330
+ if (substr ($ urlPath , 0 , 1 ) == '/ ' ) {
331
+ #$urlPath = '/' . $urlPath;
332
+ $ urlPath = substr ($ urlPath , 1 );
331
333
}
332
334
333
335
$ refName = '' ;
@@ -341,12 +343,13 @@ function ($matches) use ($path, $sameFolder) {
341
343
$ refName = '# ' . $ refName ;
342
344
$ href = 'href=" ' ;
343
345
} else {
344
- $ href = 'href="?link= ' ;
346
+ #$href = 'href="?link=';
347
+ $ href = 'href="/ ' ;
345
348
}
346
349
347
350
$ urlPath = str_replace ('& ' , '& ' , $ urlPath );
348
351
349
- $ urlPath = rawurlencode ($ urlPath );
352
+ # $urlPath = rawurlencode($urlPath);
350
353
$ urlPath = str_replace ('%23 ' , '# ' , $ urlPath );
351
354
352
355
return '<a class="internal-link ' . $ popupClass . '" ' . $ href . $ urlPath . $ refName . '"> ' . $ linkName . '</a> ' . $ popUpIcon ;
0 commit comments