tereta/markdown

Maintainers

Package info

gitlab.com/tereta/library/markdown

Issues

pkg:composer/tereta/markdown

Statistics

Installs: 117

Dependents: 1

Suggesters: 0

Stars: 0

1.0.3 2026-05-05 21:27 UTC

This package is auto-updated.

Last update: 2026-05-05 18:29:45 UTC


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-generated id anchors;
  • 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 ![alt](url);
  • 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