add image support anywhere in text
@@ -2,7 +2,7 @@
2
2
"type": "chapter",
3
3
"number": 1,
4
4
"title": "Mage Test",
5
"description": "This is a test chapter. It tests to see if the system works.",
5
"description": "%%66logo.png%%This is a test chapter. It tests to see if the system works.",
6
6
"subheaders": [
7
7
{
8
8
"name": "Material",
@@ -2,7 +2,7 @@2
"type": "chapter",2
"type": "chapter",3
"number": 1,3
"number": 1,4
"title": "Mage Test",4
"title": "Mage Test",5
"description": "This is a test chapter. It tests to see if the system works.",5
"description": "%%66logo.png%%This is a test chapter. It tests to see if the system works.",6
"subheaders": [6
"subheaders": [7
{7
{8
"name": "Material",8
"name": "Material",The contents of this binary file are not shown.
@@ -205,6 +205,11 @@ article {
205
205
align-items: center;
206
206
}
207
207
208
.inlineImage {
209
align-content: center;
210
text-align: center;
211
}
212
208
213
.searchResultArticle {
209
214
border: 1px solid #ddd;
210
215
border-radius: 12px;
@@ -205,6 +205,11 @@ article {205
align-items: center;205
align-items: center;206
}206
}207
207
208
.inlineImage {209
align-content: center;210
text-align: center;211
}212
208
.searchResultArticle {213
.searchResultArticle {209
border: 1px solid #ddd;214
border: 1px solid #ddd;210
border-radius: 12px;215
border-radius: 12px;@@ -75,7 +75,7 @@ final class TemplateRenderer
75
75
* 4) entire lists of a complete folder
76
76
*/
77
77
private function renderTemplateString(string $template, array $data): string
78
{
78
{
79
79
// 1) Child-template tags: [[moves:proficiency.move]]
80
80
$template = preg_replace_callback(
81
81
'/\[\[\s*([a-zA-Z0-9_.-]+)\s*:\s*([a-zA-Z0-9_.-]+)\s*\]\]/',
@@ -175,6 +175,13 @@ final class TemplateRenderer
175
175
$template
176
176
);
177
177
178
// 5) Escaped images %%path%%
179
$template = preg_replace_callback(
180
'/\%\%\s*([a-zA-Z0-9_.-]+)\s*\%\%/',
181
fn($m) => '<div class="inlineImage"><img src="images' . DIRECTORY_SEPARATOR . $m[1] . '"/></div>',
182
$template
183
);
184
178
185
if (isset($data['wikiPath']))
179
186
$template = str_replace("<<url>>", "?path=" . $data['wikiPath'], $template);
180
187
@@ -75,7 +75,7 @@ final class TemplateRenderer75
* 4) entire lists of a complete folder75
* 4) entire lists of a complete folder76
*/76
*/77
private function renderTemplateString(string $template, array $data): string77
private function renderTemplateString(string $template, array $data): string78
{ 78
{79
// 1) Child-template tags: [[moves:proficiency.move]]79
// 1) Child-template tags: [[moves:proficiency.move]]80
$template = preg_replace_callback(80
$template = preg_replace_callback(81
'/\[\[\s*([a-zA-Z0-9_.-]+)\s*:\s*([a-zA-Z0-9_.-]+)\s*\]\]/',81
'/\[\[\s*([a-zA-Z0-9_.-]+)\s*:\s*([a-zA-Z0-9_.-]+)\s*\]\]/',@@ -175,6 +175,13 @@ final class TemplateRenderer175
$template175
$template176
);176
);177
177
178
// 5) Escaped images %%path%%179
$template = preg_replace_callback(180
'/\%\%\s*([a-zA-Z0-9_.-]+)\s*\%\%/',181
fn($m) => '<div class="inlineImage"><img src="images' . DIRECTORY_SEPARATOR . $m[1] . '"/></div>',182
$template183
);184
178
if (isset($data['wikiPath']))185
if (isset($data['wikiPath']))179
$template = str_replace("<<url>>", "?path=" . $data['wikiPath'], $template);186
$template = str_replace("<<url>>", "?path=" . $data['wikiPath'], $template);180
187