Compare commits

..
3 Commits
Author SHA1 Message Date
IgorMino 6c6a6c7dfe inicializacia do existujuceho adresara
Merge branch 'main' of https://gitea.tpsoft.org/TPsoft.org/MD2HTML
2026-10-26 18:37:21 +01:00
IgorMino e7fad18c7e Remove vendor from tracking and update gitignore 2026-10-26 18:34:37 +01:00
IgorMino 80594366b7 Initial commit 2026-10-26 18:33:57 +01:00
6 changed files with 392 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
"/vendor/"
+50
View File
@@ -0,0 +1,50 @@
# AGENTS.md
## Purpose
This project is a small Markdown-to-HTML utility used behind NGINX.
When a `.md` file is requested, `md2html.php` loads the Markdown, converts it with Parsedown, and renders HTML styled by `markdown.css`.
## Key Files
- `md2html.php`: entrypoint for conversion and HTML output.
- `markdown.css`: visual styling for rendered Markdown (`.markdown-body`).
- `composer.json`: PHP dependency config (`erusev/parsedown`).
## Environment Assumptions
- Project root: `D:\www\md2html`
- Markdown files are resolved from `D:\www\...`
- CSS is currently linked as `//localhost/md2html/markdown.css`
## Change Priorities
1. Keep output readable on desktop and mobile.
2. Preserve Markdown semantics generated by Parsedown.
3. Avoid introducing JS unless explicitly required.
4. Keep the utility simple and fast.
## Styling Rules (`markdown.css`)
- Style only inside `.markdown-body` unless there is a strong reason to change global page behavior.
- Must cover: headings, links, lists, blockquotes, inline code, code blocks, tables, images, hr.
- Keep strong contrast and accessible font sizes.
- Ensure long code lines and wide tables remain usable on small screens (`overflow-x`).
- Prefer CSS variables for colors and spacing to simplify future theme changes.
## PHP Rules (`md2html.php`)
- Keep dependency loading via `vendor/autoload.php`.
- Keep response minimal: `<!doctype html>`, UTF-8 meta, stylesheet link, wrapped content.
- Do not remove `.md` extension guard.
- Any path-handling changes must remain compatible with Windows paths.
## Recommended Validation After Edits
1. Open at least one Markdown file with:
- headings (`#`, `##`, `###`)
- lists
- fenced code block
- table
- blockquote
- image
2. Verify layout on desktop and mobile width.
3. Verify links and code blocks remain readable.
## Non-Goals
- Building a full CMS.
- Adding heavy frontend frameworks.
- Replacing Parsedown unless explicitly requested.
+19
View File
@@ -0,0 +1,19 @@
{
"name": "igor/md2html",
"type": "project",
"license": "MIT",
"autoload": {
"psr-4": {
"Igor\\Md2html\\": "src/"
}
},
"authors": [
{
"name": "igor",
"email": "mino@tpsoft.org"
}
],
"require": {
"erusev/parsedown": "^1.7"
}
}
Generated
+69
View File
@@ -0,0 +1,69 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "9b8ae6f7614e5b41ba18814b6b6e7bb1",
"packages": [
{
"name": "erusev/parsedown",
"version": "1.7.4",
"source": {
"type": "git",
"url": "https://github.com/erusev/parsedown.git",
"reference": "cb17b6477dfff935958ba01325f2e8a2bfa6dab3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/erusev/parsedown/zipball/cb17b6477dfff935958ba01325f2e8a2bfa6dab3",
"reference": "cb17b6477dfff935958ba01325f2e8a2bfa6dab3",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35"
},
"type": "library",
"autoload": {
"psr-0": {
"Parsedown": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Emanuil Rusev",
"email": "hello@erusev.com",
"homepage": "http://erusev.com"
}
],
"description": "Parser for Markdown.",
"homepage": "http://parsedown.org",
"keywords": [
"markdown",
"parser"
],
"support": {
"issues": "https://github.com/erusev/parsedown/issues",
"source": "https://github.com/erusev/parsedown/tree/1.7.x"
},
"time": "2019-12-30T22:54:17+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": {},
"prefer-stable": false,
"prefer-lowest": false,
"platform": {},
"platform-dev": {},
"plugin-api-version": "2.6.0"
}
+233
View File
@@ -0,0 +1,233 @@
:root {
--page-bg: #f4efe8;
--paper-bg: #fffdf9;
--text: #24201c;
--muted: #6a5f52;
--line: #ddd3c5;
--accent: #0f6d8a;
--accent-soft: #d9eef4;
--quote-bg: #f4f8fa;
--code-bg: #1f2328;
--code-text: #f4f6f8;
}
*,
*::before,
*::after {
box-sizing: border-box;
}
html {
font-size: 17px;
line-height: 1.65;
-webkit-text-size-adjust: 100%;
}
body {
margin: 0;
color: var(--text);
background:
radial-gradient(circle at 15% 10%, #f8f2e8 0%, transparent 35%),
radial-gradient(circle at 90% 0%, #e4eef2 0%, transparent 30%),
var(--page-bg);
font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
}
.markdown-body {
width: min(90%, calc(100% - 2rem));
margin: 2.5rem auto 3rem;
padding: 2.25rem clamp(1.1rem, 2vw, 2.5rem);
background: var(--paper-bg);
border: 1px solid #ece3d6;
border-radius: 18px;
box-shadow:
0 12px 30px rgba(64, 49, 33, 0.08),
0 2px 6px rgba(64, 49, 33, 0.06);
}
.markdown-body > *:first-child {
margin-top: 0;
}
.markdown-body > *:last-child {
margin-bottom: 0;
}
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
font-family: "Avenir Next", "Segoe UI", "Trebuchet MS", sans-serif;
line-height: 1.22;
letter-spacing: 0.01em;
color: #1f2b33;
margin-top: 2.2rem;
margin-bottom: 0.85rem;
}
.markdown-body h1 {
font-size: clamp(2rem, 3.5vw, 2.8rem);
margin-top: 0.4rem;
padding-bottom: 0.45rem;
border-bottom: 2px solid var(--line);
}
.markdown-body h2 {
font-size: clamp(1.55rem, 2.3vw, 2rem);
padding-bottom: 0.3rem;
border-bottom: 1px solid var(--line);
}
.markdown-body h3 {
font-size: clamp(1.24rem, 1.8vw, 1.5rem);
}
.markdown-body h4 {
font-size: 1.13rem;
}
.markdown-body h5,
.markdown-body h6 {
font-size: 1rem;
color: #384a56;
}
.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body dl,
.markdown-body table,
.markdown-body blockquote {
margin: 1rem 0;
}
.markdown-body ul,
.markdown-body ol {
padding-left: 1.55rem;
}
.markdown-body li + li {
margin-top: 0.35rem;
}
.markdown-body a {
color: var(--accent);
text-decoration-thickness: 0.08em;
text-underline-offset: 0.13em;
}
.markdown-body a:hover {
color: #0a546a;
background: var(--accent-soft);
}
.markdown-body hr {
border: 0;
height: 1px;
margin: 2rem 0;
background: linear-gradient(to right, transparent, var(--line), transparent);
}
.markdown-body blockquote {
padding: 0.8rem 1rem 0.8rem 1.2rem;
border-left: 4px solid #8db9c8;
background: var(--quote-bg);
color: #30414e;
border-radius: 0 10px 10px 0;
}
.markdown-body code {
font-family: "JetBrains Mono", "Consolas", "Courier New", monospace;
font-size: 0.9em;
background: #efe7d9;
border-radius: 6px;
padding: 0.1em 0.35em;
}
.markdown-body pre {
background: var(--code-bg);
color: var(--code-text);
border-radius: 12px;
padding: 1rem 1.1rem;
overflow-x: auto;
margin: 1.25rem 0;
}
.markdown-body pre code {
background: transparent;
color: inherit;
padding: 0;
font-size: 0.9rem;
}
.markdown-body table {
width: 100%;
border-collapse: collapse;
display: block;
overflow-x: auto;
border: 1px solid var(--line);
border-radius: 10px;
}
.markdown-body th,
.markdown-body td {
border: 1px solid var(--line);
padding: 0.55rem 0.7rem;
text-align: left;
}
.markdown-body th {
font-family: "Avenir Next", "Segoe UI", "Trebuchet MS", sans-serif;
background: #f3eee5;
}
.markdown-body img {
max-width: 100%;
height: auto;
display: block;
margin: 1rem auto;
border-radius: 10px;
box-shadow: 0 5px 18px rgba(20, 22, 26, 0.14);
}
.markdown-body strong {
color: #1e1a14;
}
.markdown-body em {
color: #5b4f40;
}
.markdown-body :target {
scroll-margin-top: 1rem;
animation: mark-target 1.2s ease;
}
@keyframes mark-target {
0% {
background: #fff3c9;
}
100% {
background: transparent;
}
}
@media (max-width: 760px) {
html {
font-size: 16px;
}
.markdown-body {
width: calc(100% - 1rem);
margin: 0.75rem auto 1.2rem;
padding: 1rem;
border-radius: 14px;
}
.markdown-body pre {
border-radius: 10px;
padding: 0.85rem;
}
}
+20
View File
@@ -0,0 +1,20 @@
<?php
require 'vendor/autoload.php';
$path = $_GET['file'] ?? $_SERVER['REQUEST_URI'];
$file = realpath('d:/www/' . $path);
if (!$file || !str_ends_with($file, '.md')) {
http_response_code(404);
exit('Not found');
}
$md = file_get_contents($file);
$parser = new Parsedown();
echo '<!doctype html>';
echo '<meta charset="utf-8">';
echo '<link rel="stylesheet" href="//localhost/md2html/markdown.css">';
echo '<div class="markdown-body">';
echo $parser->text($md);
echo '</div>';