This content has a colored background.
{/background}
-These shortcodes are part of the theme and are all located in the file `/theme/shortcodes.php`.
+These shortcodes are part of the theme and are all located in the file `/theme/functions.php`.
You can edit this file to change existing shortcodes or add even more.
An example-page with all shortcodes is provided with the installation: `/pages-en/shortcode-examples.md`
## Customization
-All customizable parts of flatMark are located in the `theme/` folder. This includes the main stylesheet (`theme/css/style.css`), a JavaScript file for interactive behavior (`theme/js/presets.js`), and the `theme/shortcodes.php` file where custom shortcodes can be defined. You can freely modify these files to match your design and functionality needs. Additional assets like images, fonts, or scripts can also be placed in this folder to keep everything neatly organized in one place.
+All customizable parts of flatMark are located in the `theme/` folder. This includes the main stylesheet (`theme/css/style.css`), a JavaScript file for interactive behavior (`theme/js/presets.js`), and the `theme/functions.php` file where custom shortcodes can be defined. You can freely modify these files to match your design and functionality needs. Additional assets like images, fonts, or scripts can also be placed in this folder to keep everything neatly organized in one place.
## flatMark as CMS
ob_start();
// Include shortcode functions (if file exists)
- if (file_exists('theme/shortcodes.php')) {
- require 'theme/shortcodes.php';
+ if (file_exists('theme/functions.php')) {
+ require 'theme/functions.php';
}
// Include Parsedown
$footerContent = $Parsedown->text($footerContent);
}
- // Apply theme/shortcodes.php before converting to HTML (if function exists)
+ // Apply theme/functions.php before converting to HTML (if function exists)
if (function_exists('processShortcodes')) {
$markdown = processShortcodes($markdown);
}
--- /dev/null
+<?php
+/**
+ * Shortcode definitions and handlers.
+ *
+ * @package flatMark
+ * @subpackage Theme
+ */
+
+ function processShortcodes($markdown) {
+
+ // Initialize Parsedown
+ $Parsedown = new Parsedown();
+
+ // Shortcode: code 1/2
+ $codeBlocks = [];
+ $markdown = preg_replace_callback('/\{code\}(.*?)\{\/code\}/s', function ($matches) use (&$codeBlocks) {
+ // Generate a unique placeholder
+ $placeholder = '[[[CODEBLOCK_' . count($codeBlocks) . ']]]';
+ // Store the raw code block content
+ $codeBlocks[$placeholder] = '<pre><code>' . htmlspecialchars($matches[1]) . '</code></pre>';
+ return $placeholder;
+ }, $markdown);
+
+ // Shortcode: extras for header
+ $pattern = '/\{extras\}(.*?)\{\/extras\}/s';
+ $markdown = preg_replace_callback($pattern, function ($matches) use ($Parsedown) {
+ // Process Markdown inside
+ $extrasContent = $Parsedown->text($matches[1]);
+ return '<div class="extras">' . $extrasContent . '</div>';
+ }, $markdown);
+
+ // Shortcode: year (current year)
+ $pattern = '/\{year\}/s';
+ $markdown = preg_replace_callback($pattern, function () {
+ return date("Y"); // Return current year
+ }, $markdown);
+
+ // Shortcode: columns with optional classes
+ $pattern = '/\{columns(.*?)\}(.*?)\{\/columns\}/s';
+ $markdown = preg_replace_callback($pattern, function ($matches) use ($Parsedown) {
+ // Capture the additional class (if any exists) directly after {columns}
+ $colsAttributes = trim($matches[1]); // e.g., "50-50" from {background 50-50}
+ $colsContent = $matches[2]; // Capture the content inside {columns} ... {/columns}
+
+ // Add prefix to the class
+ $colsPrefix = 'cols-'; // Define the prefix here
+ $colsClass = !empty($colsAttributes) ? $colsPrefix . $colsAttributes : ''; // Prefix added to class (e.g., cols-50-50)
+
+ // Split the columns by {columns-seperator}
+ $cols = preg_split('/\{columns-seperator\}/', $colsContent);
+
+ // Wrap each column in <div class="column">
+ $colHtml = '';
+ foreach ($cols as $col) {
+ $colHtml .= '<div class="column">' . $Parsedown->text(trim($col)) . '</div>';
+ }
+
+ // Wrap everything in a div and add class if available
+ return '<div class="columns ' . $colsClass . '">' . $colHtml . '</div>';
+ }, $markdown);
+
+ // Shortcode: background with optional class
+ $pattern = '/\{background(.*?)\}(.*?)\{\/background\}/s';
+ $markdown = preg_replace_callback($pattern, function ($matches) use ($Parsedown) {
+ // Capture the additional class (if any exists) directly after {background}
+ $bgAttributes = trim($matches[1]); // e.g., "color-01" from {background color-01}
+ $bgContent = $matches[2]; // Capture the content inside {background} ... {/background}
+
+ // Add prefix to the class
+ $bgPrefix = 'bg-'; // Define the prefix here
+ $bgClass = !empty($bgAttributes) ? $bgPrefix . $bgAttributes : ''; // Prefix added to class (e.g., bg-color-01)
+
+ // Convert the inner Markdown content
+ $bgHtml = $Parsedown->text($bgContent);
+
+ // Wrap everything in a div and add class if available
+ return '<div class="background ' . $bgClass . '">' . $bgHtml . '</div>';
+ }, $markdown);
+
+ // Shortcode: img rounded
+ $pattern = '/\{img-rounded\}(.*?)\{\/img-rounded\}/s';
+ $markdown = preg_replace_callback($pattern, function ($matches) use ($Parsedown) {
+ // Process Markdown
+ $imgRounded = $Parsedown->text($matches[1]);
+ return '<div class="img-rounded">' . $imgRounded . '</div>';
+ }, $markdown);
+
+ // Shortcode: output readme-file
+ $pattern = '/\{readme\}/s';
+ $markdown = preg_replace_callback($pattern, function () use ($Parsedown) {
+ $readmePath = __DIR__ . '/../README.md'; // path to root folder
+ if (file_exists($readmePath)) {
+ $readmeContent = file_get_contents($readmePath);
+ return '<div class="readme">' . $Parsedown->text($readmeContent) . '</div>';
+ } else {
+ return '<div class="readme"><em>README not found.</em></div>';
+ }
+ }, $markdown);
+
+ // Shortcode: code 2/2 - restore code blocks (so no shortcode inside was processed)
+ foreach ($codeBlocks as $placeholder => $codeBlock) {
+ $markdown = str_replace($placeholder, $codeBlock, $markdown);
+ }
+
+ return $markdown;
+
+ }
+
+?>
+
+
+++ /dev/null
-<?php
-/**
- * Shortcode definitions and handlers.
- *
- * @package flatMark
- * @subpackage Theme
- */
-
- function processShortcodes($markdown) {
-
- // Initialize Parsedown
- $Parsedown = new Parsedown();
-
- // Shortcode: code 1/2
- $codeBlocks = [];
- $markdown = preg_replace_callback('/\{code\}(.*?)\{\/code\}/s', function ($matches) use (&$codeBlocks) {
- // Generate a unique placeholder
- $placeholder = '[[[CODEBLOCK_' . count($codeBlocks) . ']]]';
- // Store the raw code block content
- $codeBlocks[$placeholder] = '<pre><code>' . htmlspecialchars($matches[1]) . '</code></pre>';
- return $placeholder;
- }, $markdown);
-
- // Shortcode: extras for header
- $pattern = '/\{extras\}(.*?)\{\/extras\}/s';
- $markdown = preg_replace_callback($pattern, function ($matches) use ($Parsedown) {
- // Process Markdown inside
- $extrasContent = $Parsedown->text($matches[1]);
- return '<div class="extras">' . $extrasContent . '</div>';
- }, $markdown);
-
- // Shortcode: year (current year)
- $pattern = '/\{year\}/s';
- $markdown = preg_replace_callback($pattern, function () {
- return date("Y"); // Return current year
- }, $markdown);
-
- // Shortcode: columns with optional classes
- $pattern = '/\{columns(.*?)\}(.*?)\{\/columns\}/s';
- $markdown = preg_replace_callback($pattern, function ($matches) use ($Parsedown) {
- // Capture the additional class (if any exists) directly after {columns}
- $colsAttributes = trim($matches[1]); // e.g., "50-50" from {background 50-50}
- $colsContent = $matches[2]; // Capture the content inside {columns} ... {/columns}
-
- // Add prefix to the class
- $colsPrefix = 'cols-'; // Define the prefix here
- $colsClass = !empty($colsAttributes) ? $colsPrefix . $colsAttributes : ''; // Prefix added to class (e.g., cols-50-50)
-
- // Split the columns by {columns-seperator}
- $cols = preg_split('/\{columns-seperator\}/', $colsContent);
-
- // Wrap each column in <div class="column">
- $colHtml = '';
- foreach ($cols as $col) {
- $colHtml .= '<div class="column">' . $Parsedown->text(trim($col)) . '</div>';
- }
-
- // Wrap everything in a div and add class if available
- return '<div class="columns ' . $colsClass . '">' . $colHtml . '</div>';
- }, $markdown);
-
- // Shortcode: background with optional class
- $pattern = '/\{background(.*?)\}(.*?)\{\/background\}/s';
- $markdown = preg_replace_callback($pattern, function ($matches) use ($Parsedown) {
- // Capture the additional class (if any exists) directly after {background}
- $bgAttributes = trim($matches[1]); // e.g., "color-01" from {background color-01}
- $bgContent = $matches[2]; // Capture the content inside {background} ... {/background}
-
- // Add prefix to the class
- $bgPrefix = 'bg-'; // Define the prefix here
- $bgClass = !empty($bgAttributes) ? $bgPrefix . $bgAttributes : ''; // Prefix added to class (e.g., bg-color-01)
-
- // Convert the inner Markdown content
- $bgHtml = $Parsedown->text($bgContent);
-
- // Wrap everything in a div and add class if available
- return '<div class="background ' . $bgClass . '">' . $bgHtml . '</div>';
- }, $markdown);
-
- // Shortcode: img rounded
- $pattern = '/\{img-rounded\}(.*?)\{\/img-rounded\}/s';
- $markdown = preg_replace_callback($pattern, function ($matches) use ($Parsedown) {
- // Process Markdown
- $imgRounded = $Parsedown->text($matches[1]);
- return '<div class="img-rounded">' . $imgRounded . '</div>';
- }, $markdown);
-
- // Shortcode: output readme-file
- $pattern = '/\{readme\}/s';
- $markdown = preg_replace_callback($pattern, function () use ($Parsedown) {
- $readmePath = __DIR__ . '/../README.md'; // path to root folder
- if (file_exists($readmePath)) {
- $readmeContent = file_get_contents($readmePath);
- return '<div class="readme">' . $Parsedown->text($readmeContent) . '</div>';
- } else {
- return '<div class="readme"><em>README not found.</em></div>';
- }
- }, $markdown);
-
- // Shortcode: code 2/2 - restore code blocks (so no shortcode inside was processed)
- foreach ($codeBlocks as $placeholder => $codeBlock) {
- $markdown = str_replace($placeholder, $codeBlock, $markdown);
- }
-
- return $markdown;
-
- }
-
-?>
-
-