Skip to content

Add Markdown parser and web documentation viewer#118

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/add-markdown-parser
Draft

Add Markdown parser and web documentation viewer#118
Copilot wants to merge 3 commits intomainfrom
copilot/add-markdown-parser

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 1, 2026

Replaces the static PDF manual with a Markdown-based documentation system rendered in-browser using the app's native styling, with support for GFM tables and merged/colspan cells via the || column-span syntax.

Changes

Dependency

  • Added league/commonmark ^2.8 — CommonMark + GFM extension (pipe tables, strikethrough, task lists, autolinks)

func/markdown.php

  • parse_markdown(string $markdown): string — parses Markdown and post-processes HTML to inject Bootstrap classes (table-bordered table-striped, table-dark thead, img-fluid, etc.) so rendered output matches native app styling
  • apply_cell_merging(string $html): string — post-processes the rendered HTML via DOMDocument to implement the || column-span syntax: GFM renders each || as an empty <td></td>; this function removes those empty cells and applies colspan to the preceding cell
  • html_input is set to 'strip' — raw HTML in Markdown files is stripped for security; merged tables must use the || syntax

docs/ — documentation viewer

  • docs/index.php — authenticated viewer; dynamically lists all .md files from docs/; file selection uses basename() + in_array() whitelist to block directory traversal
  • docs/manual_utilizador.md — user manual ported to Markdown (replaces the PDF)

assets/docs.css

  • Responsive two-column layout (sidebar + content area) built entirely on theme.css CSS variables — light/dark mode works automatically

Navigation updates

  • index.php — "Manual de Utilizador (PDF)" button replaced with "Documentação" → /docs/; nav link added
  • admin/index.php — "Documentação" link added to admin navbar

Merged/colspan table support

Merged cells are supported using the || column-span syntax directly in Markdown tables. Each || absorbs one additional column into the preceding cell's colspan:

| Column 1 | Column 2 | Column 3 |
| -------- | -------- | -------- |
| United with Column 2 || Column 3 |
| Single Line |||
  • Row 1: "United with Column 2" renders as <td colspan="2">, "Column 3" is in column 3
  • Row 2: "Single Line" renders as <td colspan="3">

Inline Markdown within cells (**bold**, *italic*, `code`) is fully preserved since merging happens after CommonMark renders the cell content.

Adding new documentation requires only dropping a .md file into docs/ — it appears in the sidebar automatically.

Copilot AI changed the title [WIP] Add Markdown parser and convert documentation to Markdown Add Markdown parser and web documentation viewer Apr 1, 2026
Copilot AI requested a review from marpisco April 1, 2026 08:56
@marpisco
Copy link
Copy Markdown
Owner

marpisco commented Apr 1, 2026

@copilot
No, table support must be done via markdown extended table syntax and not via a regular HTML table.

For example

Column 1 Column 2 Column 3
United with Column 2 Column 3
Single Line

Do you understand?

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 1, 2026

@copilot
No, table support must be done via markdown extended table syntax and not via a regular HTML table.

...

Done in commit 9204429.

The || column-span syntax is now implemented via apply_cell_merging() in func/markdown.php. GFM already parses || as an empty cell — the post-processor then uses DOMDocument to remove those empty <td></td> elements and applies colspan to the preceding cell accordingly:

| Column 1 | Column 2 | Column 3 |
| -------- | -------- | -------- |
| United with Column 2 || Column 3 |
| Single Line |||

Produces:

  • Row 1: <td colspan="2">United with Column 2</td><td>Column 3</td>
  • Row 2: <td colspan="3">Single Line</td>

Inline Markdown within cells (**bold**, *italic*, `code`) is fully preserved since the merging happens after CommonMark renders the cells. Raw HTML passthrough has been removed (html_input changed to 'strip'), so merged tables must use the || syntax.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/PHPMailer/PHPMailer/zipball/ebf1655bd5b99b3f97e1a3ec0a69e5f4cd7ea088
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/2MyyzD /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/dflydev/dflydev-dot-access-data/zipball/a23a2bf4f31d3518f3ecb38660c95715dfead60f
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/2MyyzD /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/guzzle/guzzle/zipball/b51ac707cfa420b7bfd4e4d5e510ba8008e822b4
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/2MyyzD /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/guzzle/promises/zipball/481557b130ef3790cf82b713667b43030dc9c957
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/2MyyzD /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/guzzle/psr7/zipball/21dc724a0583619cd1652f673303492272778051
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/2MyyzD /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/nette/schema/zipball/f0ab1a3cda782dbc5da270d28545236aa80c4002
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/2MyyzD /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/nette/utils/zipball/bb3ea637e3d131d72acc033cfc2746ee893349fe
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/2MyyzD /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/2MyyzD /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/2MyyzD /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/2MyyzD /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/2MyyzD /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/2MyyzD /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/deprecation-contracts/zipball/63afe740e99a13ba87ec199bb07bbdee937a5b62
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/2MyyzD /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/polyfill-php80/zipball/0cc9dd0f17f61d8131e7df6b84bd344899fe2608
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/2MyyzD /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/thephpleague/commonmark/zipball/59fb075d2101740c337c7216e3f32b36c204218b
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/2MyyzD /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/thephpleague/config/zipball/754b3604fb2984c71f4af4a9cbe7b57f346ec1f3
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/2MyyzD /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/thephpleague/oauth2-client/zipball/26e8c5da4f3d78cede7021e09b1330a0fc093d5e
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/2MyyzD /usr/bin/composer install --no-interaction (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adicionar um Markdown Parser, e passar a ter documentação por Markdown

2 participants