1. Go to this page and download the library: Download hananils/kirby-tree-methods library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hananils / kirby-tree-methods example snippets
// Set the starting headline level to three,
// making the document start as `h3` instead of `h1`
<?= $page->text()->toTree()->level(3)
<div class="wrapper">
<p class="intro">These are Markdown paragraphs that an editor wrote that needs to be wrapped with special markup.</p>
</div>
<div class="wrapper">
<p>But the editor shouldn't have to care about markup in his Markdown document.</p>
</div>
// Group elements, starting each group with a `strong` element
$page
->text()
->toTree()
->wrap()
'div',
'p[strong]',
'p[following-sibling::*[1][strong]]',
[
'class' => 'question-or-answer',
]
);
// Select all paragraphs
$tree->select('p');
// Make all `h1` a `h3`, all `h2` a `h4` …
$tree->level(3);
// Rename all `strong` to `em`
$tree->select('//strong')->setName('em');
// Set the class `example` to all paragraphs
$tree->select('p')->setAttribute('class', 'example');