tereta / markdown
Requires
- php: >=8.4
- tereta/application: ^1.0
- tereta/cli: ^1.0
- tereta/core: ^1.0
- tereta/db: ^1.0
- tereta/route: ^1.0
- tereta/theme: ^1.0
README
π Π ΡΡΡΠΊΠΈΠΉ | English
Table of Contents
Overview
Markdown parsing and rendering module. Converts Markdown files (.md) into HTML and binds them to site routes, so documentation pages can be served directly from source Markdown files.
Dependencies on other modules: Application, Cli, Config, Core, Db, Page, Route, Theme.
Usage
Bind a Markdown file to a route
./cli.php markdown:page add <site-identifier> "<route-path>" "<path-to-md-file>"
Example:
./cli.php markdown:page add framework "framework/application" "src/Tereta/Markdown/README.md"
The command resolves the site by identifier, creates (or updates) a route under the given path bound to the markdown controller, and stores the Markdown file reference in the markdown table. The page title is taken from the first top-level heading (# Title) of the file, falling back to the route path.
Remove a Markdown page
./cli.php markdown:page remove <site-identifier> "<path-to-md-file>"
Example:
./cli.php markdown:page remove framework "src/Tereta/Markdown/README.md"
Deletes both the markdown record and the associated route.
Runtime rendering
When a visitor requests a bound route, Tereta\Markdown\Controllers\View loads the file path from the markdown table, passes it through Tereta\Markdown\Services\Markdown::read(), and renders the markdown/view handle inside the general layout.
Paths are resolved as follows:
- absolute paths (
/...) are used as-is; - relative paths are resolved against
ROOT_DIRECTORY; http:///https://URLs are rejected.
Markdown Syntax
Supported constructs (handled by Services\Markdown::toHtml()):
- headings
#β¦######β rendered with auto-generatedidanchors; - paragraphs, line breaks, horizontal rule
---; - bold
**text**, italic*text*, bold-italic***text***; - inline code
`code`and fenced code blocks with language hint (```lang); - unordered (
-,*) and ordered (1.) lists; - blockquotes (
>); - links
[label](url)and images; - GFM-style tables with header/separator rows;
- HTML comment directives:
<!-- hidden --> β¦ <!-- /hidden -->β stripped from output;<!-- toc --> β¦ <!-- /toc -->β rendered as<nav class="toc">β¦</nav>.
Author and License
Author: Tereta Alexander
Website: tereta.dev
License: Apache License 2.0. See LICENSE.
www.ββββββββββββββββββββββββ βββββββββββββββββ ββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββ
βββ ββββββ ββββββββββββββ βββ ββββββββ
βββ ββββββ ββββββββββββββ βββ ββββββββ
βββ βββββββββββ βββββββββββ βββ βββ βββ
βββ βββββββββββ βββββββββββ βββ βββ βββ
.dev
Copyright (c) 2023-2026 Tereta Alexander