Technical Notes
Installation
To install, use one of the following methods:
1) Manually:
Start from an existing Kirby installation (otherwise better to use method 2 or 3).
- download image from https://github.com/pgfactory/markdownplus, unzip and
- copy to site/plugins/markdownplus
2) Git:
In a terminal, run command:
git submodule add https://github.com/pgfactory/markdownplus.git site/plugins/markdownplus
This is assuming you already had an existing Kirby installation. If not, first execute command:
git clone https://github.com/getkirby/plainkit.git .
3) Composer:
In a terminal, run command:
composer require pgfactory/markdownplus
This is assuming you already had an existing Kirby installation. If not, first execute command:
composer create-project getkirby/plainkit .
Simplest Way to Use
Once the MarkdownPlus plugin is installed, any requests like ->kirbytext() or ->kt() will be executed by MarkdownPlus.
Thus, the simplest way to deploy MarkdownPlus would be a PHP template like this:
site/templates/default.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>TITLE</title>
</head>
<body>
<?= $page->text()->kirbytext(); ?>
</body>
</html>
(This is assuming that you write your page content in the page's meta-file in field Text:.)
More Elegant Way to Use
You could just write into meta-files:
Title: My Page
----
Text: (include: .md)*
Then you write your actual content as markdown in .md file(s) withing the page folders. Any files with an extension .md will be picked up, compiled and rendered. (Exception: .md files starting with - or _.)
Hint: Twig
MarkdownPlus works just fine with templates built on Twig.
Just install the Kirby plugin wearejust/kirby-twig.
git submodule add https://github.com/wearejust/kirby-twig.git site/plugins/kirby-twig
or
composer require wearejust/kirby-twig
Hint 2: PageFactory
MarkdownPlus is actually a building block of another Kirby plugin PageFactory.
Using PageFactory simplifies building web pages even further.
→ See PageFactory documentation.
Configuration
File site/config/config.php:
return [
'pgfactory.markdownplus.options' => [
// 'enableSmartypants' => false, // default: true
// 'enableIcons' => false, // default: true
// 'compileCodeBlocks' => false, // default: true
// 'divblockChars' => '@%$:', // default: '@%'
],
];
- enableSmartypants:
-
Enables MarkdownPlus' implementation of Smartypants such as =>.
See chapt. Smartypants - enableIcons:
-
Enables icon injection using syntax pattern :icon:.
See chapt. Icons - compileCodeBlocks:
-
When this option is enabled, MarkdownPlus identifies <code> … </code> segments and MD-compiles them. This lets you add styling to code blocks.
- divblockChars:
-
By default, characters @and % are enabled as markers for Div-Blocks.
This option lets you customize that set of characters.