use BookStack\Entities\Models\Page;
use BookStack\Entities\Tools\Markdown\MarkdownToHtml;
use BookStack\Exceptions\ImageUploadException;
-use BookStack\Facades\Theme;
-use BookStack\Theming\ThemeEvents;
use BookStack\Uploads\ImageRepo;
use BookStack\Uploads\ImageService;
use BookStack\Util\HtmlContentFilter;
$parser = new PageIncludeParser($doc, $contentProvider);
$nodesAdded = 1;
- for ($includeDepth = 0; $includeDepth < 3 && $nodesAdded !== 0; $includeDepth++) {
+ for ($includeDepth = 0; $includeDepth < 1 && $nodesAdded !== 0; $includeDepth++) {
$nodesAdded = $parser->parse();
}
+ if ($includeDepth > 1) {
+ $idMap = [];
+ $changeMap = [];
+ $this->updateIdsRecursively($doc->getBody(), 0, $idMap, $changeMap);
+ }
+
if (!config('app.allow_content_scripts')) {
HtmlContentFilter::removeScriptsFromDocument($doc);
}
$parentText = $parent->textContent;
$tagPos = strpos($parentText, $tag->tagContent);
$before = $tagPos < (strlen($parentText) / 2);
+ $this->toCleanup[] = $tag->domNode->parentNode;
if ($before) {
$parent->parentNode->insertBefore($tag->domNode, $parent);
{
foreach ($this->toCleanup as $element) {
$element->normalize();
- if ($element->parentNode && !$element->hasChildNodes()) {
- $element->parentNode->removeChild($element);
+ while ($element->parentNode && !$element->hasChildNodes()) {
+ $parent = $element->parentNode;
+ $parent->removeChild($element);
+ $element = $parent;
}
}
}
);
}
+ public function test_multi_source_elem_whole_document_with_nested_content_origin()
+ {
+ $this->runParserTest(
+ '<p><strong>{{@45}}</strong></p>',
+ ['45' => '<p>Testing</p><blockquote>This</blockquote>'],
+ '<p>Testing</p><blockquote>This</blockquote>',
+ );
+ }
+
public function test_multiple_tags_in_same_origin_with_inline_content()
{
$this->runParserTest(
$this->runParserTest(
'<div><p>This <strong>{{@45#content}}</strong> content is {{@45#content}}</p>{{@45#content}}</div>',
['45' => '<pre id="content">block</pre>'],
- '<div><pre id="content">block</pre><p>This <strong></strong> content is </p><pre id="content">block</pre><pre id="content">block</pre></div>',
+ '<div><pre id="content">block</pre><p>This content is </p><pre id="content">block</pre><pre id="content">block</pre></div>',
);
}