support tables and emojies in markdown

This commit is contained in:
Evgeny Zinoviev 2023-03-02 02:17:52 +03:00
parent 6daf574fd3
commit 917d2622aa
6 changed files with 258 additions and 265 deletions

View File

@ -1,13 +1,24 @@
{ {
"require": { "require": {
"sixlive/parsedown-highlight": "^0.3.1", "gch1p/parsedown-highlight": "master",
"erusev/parsedown": "1.8.0-beta-5", "gch1p/parsedown-highlight-extended": "dev-main",
"erusev/parsedown": "1.8.0-beta-7",
"ext-mbstring": "*", "ext-mbstring": "*",
"ext-gd": "*", "ext-gd": "*",
"ext-mysqli": "*", "ext-mysqli": "*",
"ext-json": "*", "ext-json": "*",
"ext-sqlite3": "*" "ext-sqlite3": "*"
}, },
"repositories": [
{
"url": "https://github.com/gch1p/parsedown-highlight",
"type": "git"
},
{
"url": "https://github.com/gch1p/ParsedownHighlightExtended",
"type": "git"
}
],
"minimum-stability": "dev", "minimum-stability": "dev",
"prefer-stable": true, "prefer-stable": true,
"preferred-install": "dist" "preferred-install": "dist"

445
composer.lock generated
View File

@ -4,64 +4,20 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "cfed6325222efab0afd48dc69b6dd69b", "content-hash": "5a615af5a232dca9e536bd9217d54be6",
"packages": [ "packages": [
{
"name": "bhaktaraz/php-rss-generator",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/bhaktaraz/php-rss-generator.git",
"reference": "4c90e6e2fbb74f0dcb3cf6d1fcd4fa1a77b53f0d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/bhaktaraz/php-rss-generator/zipball/4c90e6e2fbb74f0dcb3cf6d1fcd4fa1a77b53f0d",
"reference": "4c90e6e2fbb74f0dcb3cf6d1fcd4fa1a77b53f0d",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Bhaktaraz\\RSSGenerator\\": "Source/Bhaktaraz/RSSGenerator/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Bhaktaraz Bhatta",
"email": "bhattabhakta@gmail.com"
}
],
"description": "Simple RSS generator library for PHP 5.5 or later.",
"homepage": "https://github.com/bhaktaraz/php-rss-generator",
"keywords": [
"Facebook product feed generator",
"feed",
"generator",
"rss",
"writer"
],
"time": "2019-01-08T12:17:22+00:00"
},
{ {
"name": "erusev/parsedown", "name": "erusev/parsedown",
"version": "1.8.0-beta-5", "version": "1.8.0-beta-7",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/erusev/parsedown.git", "url": "https://github.com/erusev/parsedown.git",
"reference": "c26a2ee4bf8ba0270daab7da0353f2525ca6564a" "reference": "fe7a50eceb4a3c867cc9fa9c0aa906b1067d1955"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/erusev/parsedown/zipball/c26a2ee4bf8ba0270daab7da0353f2525ca6564a", "url": "https://api.github.com/repos/erusev/parsedown/zipball/fe7a50eceb4a3c867cc9fa9c0aa906b1067d1955",
"reference": "c26a2ee4bf8ba0270daab7da0353f2525ca6564a", "reference": "fe7a50eceb4a3c867cc9fa9c0aa906b1067d1955",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -94,42 +50,202 @@
"markdown", "markdown",
"parser" "parser"
], ],
"time": "2018-06-11T18:15:32+00:00" "support": {
"issues": "https://github.com/erusev/parsedown/issues",
"source": "https://github.com/erusev/parsedown/tree/1.8.0-beta-7"
},
"time": "2019-03-17T18:47:21+00:00"
}, },
{ {
"name": "scrivo/highlight.php", "name": "erusev/parsedown-extra",
"version": "v9.15.8.0", "version": "0.8.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/scrivo/highlight.php.git", "url": "https://github.com/erusev/parsedown-extra.git",
"reference": "2626bf8731737b2487e54bda5a980f0e5a143320" "reference": "91ac3ff98f0cea243bdccc688df43810f044dcef"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/scrivo/highlight.php/zipball/2626bf8731737b2487e54bda5a980f0e5a143320", "url": "https://api.github.com/repos/erusev/parsedown-extra/zipball/91ac3ff98f0cea243bdccc688df43810f044dcef",
"reference": "2626bf8731737b2487e54bda5a980f0e5a143320", "reference": "91ac3ff98f0cea243bdccc688df43810f044dcef",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-json": "*", "erusev/parsedown": "^1.7.4"
"ext-mbstring": "*"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^4.8|^5.7", "phpunit/phpunit": "^4.8.35"
"symfony/finder": "^2.8"
},
"suggest": {
"ext-dom": "Needed to make use of the features in the utilities namespace"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
"psr-0": { "psr-0": {
"Highlight\\": "", "ParsedownExtra": ""
"HighlightUtilities\\": "" }
}, },
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Emanuil Rusev",
"email": "hello@erusev.com",
"homepage": "http://erusev.com"
}
],
"description": "An extension of Parsedown that adds support for Markdown Extra.",
"homepage": "https://github.com/erusev/parsedown-extra",
"keywords": [
"markdown",
"markdown extra",
"parsedown",
"parser"
],
"support": {
"issues": "https://github.com/erusev/parsedown-extra/issues",
"source": "https://github.com/erusev/parsedown-extra/tree/0.8.x"
},
"time": "2019-12-30T23:20:37+00:00"
},
{
"name": "gch1p/parsedown-highlight",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/gch1p/parsedown-highlight",
"reference": "d017545cc221f4becac0f7fc0570304ceabba846"
},
"require": {
"erusev/parsedown": "1.8.0-beta-7",
"erusev/parsedown-extra": "0.8.1",
"php": ">=7.1",
"scrivo/highlight.php": "^9.14"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.10",
"larapack/dd": "^1.0",
"phpunit/phpunit": "^6.0|^7.0",
"sempro/phpunit-pretty-print": "^1.0"
},
"default-branch": true,
"type": "library",
"autoload": {
"psr-4": {
"gch1p\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests"
}
},
"scripts": {
"test": [
"phpunit"
],
"styles:lint": [
"php-cs-fixer fix --dry-run --diff"
],
"styles:fix": [
"php-cs-fixer fix"
]
},
"license": [
"MIT"
],
"authors": [
{
"name": "TJ Miller",
"email": "oss@tjmiller.co",
"homepage": "https://tjmiller.co",
"role": "Developer"
}
],
"description": "Server side code block rendering for Parsedown",
"homepage": "https://github.com/gch1p/parsedown-highlight",
"keywords": [
"code",
"markdown",
"parsedown"
],
"time": "2023-03-01T22:25:56+00:00"
},
{
"name": "gch1p/parsedown-highlight-extended",
"version": "dev-main",
"source": {
"type": "git",
"url": "https://github.com/gch1p/ParsedownHighlightExtended",
"reference": "e2d9d7eae203680690d61877fbef2dc2df61dd0b"
},
"require": {
"erusev/parsedown": "^1.8-beta-6",
"erusev/parsedown-extra": "^0.8.0",
"gch1p/parsedown-highlight": "master",
"php": ">=7.2"
},
"default-branch": true,
"type": "library",
"autoload": {
"psr-0": {
"ParsedownExtended": ""
}
},
"license": [
"MIT"
],
"authors": [
{
"name": "Benjamin Hoegh",
"homepage": "https://github.com/benjaminhoegh"
}
],
"description": "An extension for ParsedownHighlight.",
"homepage": "https://github.com/gch1p/ParsedownHighlightExtended",
"keywords": [
"markdown",
"markdown extended",
"parsedown",
"parsedown extended"
],
"time": "2023-03-01T22:30:01+00:00"
},
{
"name": "scrivo/highlight.php",
"version": "v9.18.1.10",
"source": {
"type": "git",
"url": "https://github.com/scrivo/highlight.php.git",
"reference": "850f4b44697a2552e892ffe71490ba2733c2fc6e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/scrivo/highlight.php/zipball/850f4b44697a2552e892ffe71490ba2733c2fc6e",
"reference": "850f4b44697a2552e892ffe71490ba2733c2fc6e",
"shasum": ""
},
"require": {
"ext-json": "*",
"php": ">=5.4"
},
"require-dev": {
"phpunit/phpunit": "^4.8|^5.7",
"sabberworm/php-css-parser": "^8.3",
"symfony/finder": "^2.8|^3.4|^5.4",
"symfony/var-dumper": "^2.8|^3.4|^5.4"
},
"suggest": {
"ext-mbstring": "Allows highlighting code with unicode characters and supports language with unicode keywords"
},
"type": "library",
"autoload": {
"files": [ "files": [
"HighlightUtilities/functions.php" "HighlightUtilities/functions.php"
] ],
"psr-0": {
"Highlight\\": "",
"HighlightUtilities\\": ""
}
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
@ -144,7 +260,7 @@
{ {
"name": "Vladimir Jimenez", "name": "Vladimir Jimenez",
"homepage": "https://allejo.io", "homepage": "https://allejo.io",
"role": "Contributor" "role": "Maintainer"
}, },
{ {
"name": "Martin Folkers", "name": "Martin Folkers",
@ -160,193 +276,34 @@
"highlight.php", "highlight.php",
"syntax" "syntax"
], ],
"time": "2019-05-31T06:24:05+00:00" "support": {
}, "issues": "https://github.com/scrivo/highlight.php/issues",
{ "source": "https://github.com/scrivo/highlight.php"
"name": "sixlive/parsedown-highlight",
"version": "v0.3.1",
"source": {
"type": "git",
"url": "https://github.com/sixlive/parsedown-highlight.git",
"reference": "e05632eea4cf97c865a17d2b65f31c5b477a6a7a"
}, },
"dist": { "funding": [
"type": "zip",
"url": "https://api.github.com/repos/sixlive/parsedown-highlight/zipball/e05632eea4cf97c865a17d2b65f31c5b477a6a7a",
"reference": "e05632eea4cf97c865a17d2b65f31c5b477a6a7a",
"shasum": ""
},
"require": {
"erusev/parsedown": "1.8.0-beta-5",
"php": "^7.1|7.2",
"scrivo/highlight.php": "^9.14"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.10",
"larapack/dd": "^1.0",
"phpunit/phpunit": "^6.0|^7.0",
"sempro/phpunit-pretty-print": "^1.0"
},
"type": "library",
"autoload": {
"psr-4": {
"sixlive\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{ {
"name": "TJ Miller", "url": "https://github.com/allejo",
"email": "oss@tjmiller.co", "type": "github"
"homepage": "https://tjmiller.co",
"role": "Developer"
} }
], ],
"description": "Server side code block rendering for Parsedown", "time": "2022-12-17T21:53:22+00:00"
"homepage": "https://github.com/sixlive/parsedown-highlight",
"keywords": [
"code",
"markdown",
"parsedown"
],
"time": "2019-04-14T15:21:19+00:00"
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.11.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "82ebae02209c21113908c229e9883c419720738a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a",
"reference": "82ebae02209c21113908c229e9883c419720738a",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"suggest": {
"ext-ctype": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.11-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
},
{
"name": "Gert de Pagter",
"email": "BackEndTea@gmail.com"
}
],
"description": "Symfony polyfill for ctype functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"ctype",
"polyfill",
"portable"
],
"time": "2019-02-06T07:57:58+00:00"
},
{
"name": "twig/twig",
"version": "v1.42.1",
"source": {
"type": "git",
"url": "https://github.com/twigphp/Twig.git",
"reference": "671347603760a88b1e7288aaa9378f33687d7edf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/671347603760a88b1e7288aaa9378f33687d7edf",
"reference": "671347603760a88b1e7288aaa9378f33687d7edf",
"shasum": ""
},
"require": {
"php": ">=5.4.0",
"symfony/polyfill-ctype": "^1.8"
},
"require-dev": {
"psr/container": "^1.0",
"symfony/debug": "^2.7",
"symfony/phpunit-bridge": "^3.4.19|^4.1.8|^5.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.42-dev"
}
},
"autoload": {
"psr-0": {
"Twig_": "lib/"
},
"psr-4": {
"Twig\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com",
"homepage": "http://fabien.potencier.org",
"role": "Lead Developer"
},
{
"name": "Armin Ronacher",
"email": "armin.ronacher@active-4.com",
"role": "Project Founder"
},
{
"name": "Twig Team",
"homepage": "https://twig.symfony.com/contributors",
"role": "Contributors"
}
],
"description": "Twig, the flexible, fast, and secure template language for PHP",
"homepage": "https://twig.symfony.com",
"keywords": [
"templating"
],
"time": "2019-06-04T11:31:08+00:00"
} }
], ],
"packages-dev": [], "packages-dev": [],
"aliases": [], "aliases": [],
"minimum-stability": "dev", "minimum-stability": "dev",
"stability-flags": { "stability-flags": {
"bhaktaraz/php-rss-generator": 20 "gch1p/parsedown-highlight-extended": 20
}, },
"prefer-stable": true, "prefer-stable": true,
"prefer-lowest": false, "prefer-lowest": false,
"platform": [], "platform": {
"platform-dev": [] "ext-mbstring": "*",
"ext-gd": "*",
"ext-mysqli": "*",
"ext-json": "*",
"ext-sqlite3": "*"
},
"platform-dev": [],
"plugin-api-version": "2.3.0"
} }

View File

@ -17,7 +17,10 @@ class MySQLConnection extends CommonDatabase {
public function connect(): bool { public function connect(): bool {
$this->link = new mysqli(); $this->link = new mysqli();
return !!$this->link->real_connect($this->host, $this->user, $this->password, $this->database); $result = $this->link->real_connect($this->host, $this->user, $this->password, $this->database);
if ($result)
$this->link->set_charset('utf8mb4');
return !!$result;
} }
public function query(string $sql, ...$args): mysqli_result|bool { public function query(string $sql, ...$args): mysqli_result|bool {

View File

@ -180,6 +180,21 @@
color: $grey; color: $grey;
} }
table {
border-collapse: collapse;
border: 1px $border-color solid;
}
table thead td {
font-weight: bold;
}
table td, table th {
padding: 7px;
border: 1px $border-color solid;
}
table th {
padding-right: 12px;
}
table.table-100 { table.table-100 {
border-collapse: collapse; border-collapse: collapse;
border: 0; border: 0;

View File

@ -1,13 +1,16 @@
<?php <?php
use sixlive\ParsedownHighlight; class MyParsedown extends ParsedownExtended {
class MyParsedown extends ParsedownHighlight {
public function __construct( public function __construct(
protected bool $useImagePreviews = false protected bool $useImagePreviews = false
) { ) {
parent::__construct(); parent::__construct([
'tables' => [
'tablespan' => true
]
]);
$this->InlineTypes['{'][] = 'FileAttach'; $this->InlineTypes['{'][] = 'FileAttach';
$this->InlineTypes['{'][] = 'Image'; $this->InlineTypes['{'][] = 'Image';
$this->InlineTypes['{'][] = 'Video'; $this->InlineTypes['{'][] = 'Video';

View File

@ -22,24 +22,28 @@ CREATE TABLE `config` (
CREATE TABLE `pages` ( CREATE TABLE `pages` (
`short_name` char(64) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL, `short_name` char(64) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL,
`title` char(255) NOT NULL, `title` char(255) NOT NULL,
`md` text NOT NULL DEFAULT '', `md` text CHARACTER SET utf8mb4 NOT NULL DEFAULT '\'\'',
`html` text NOT NULL DEFAULT '', `html` text CHARACTER SET utf8mb4 NOT NULL DEFAULT '\'\'',
`ts` int(10) UNSIGNED NOT NULL DEFAULT 0, `ts` int(10) unsigned NOT NULL DEFAULT 0,
`update_ts` int(10) UNSIGNED NOT NULL DEFAULT 0, `update_ts` int(10) unsigned NOT NULL DEFAULT 0,
`visible` tinyint(3) UNSIGNED NOT NULL DEFAULT 0 `visible` tinyint(3) unsigned NOT NULL DEFAULT 0,
PRIMARY KEY (`short_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `posts` ( CREATE TABLE `posts` (
`id` int(10) UNSIGNED NOT NULL, `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`title` char(255) NOT NULL, `title` char(255) NOT NULL,
`md` text NOT NULL, `md` text CHARACTER SET utf8mb4 NOT NULL,
`html` text NOT NULL, `html` text CHARACTER SET utf8mb4 NOT NULL,
`text` text NOT NULL, `text` text CHARACTER SET utf8mb4 NOT NULL,
`ts` int(10) UNSIGNED NOT NULL DEFAULT 0, `ts` int(10) unsigned NOT NULL DEFAULT 0,
`update_ts` int(10) UNSIGNED NOT NULL DEFAULT 0, `update_ts` int(10) unsigned NOT NULL DEFAULT 0,
`visible` tinyint(1) UNSIGNED NOT NULL DEFAULT 0, `visible` tinyint(1) unsigned NOT NULL DEFAULT 0,
`short_name` char(64) NOT NULL `short_name` char(64) NOT NULL,
) ENGINE=InnoDB DEFAULT CHARSET=utf8; PRIMARY KEY (`id`),
UNIQUE KEY `short_name` (`short_name`),
KEY ` visible_ts_idx` (`visible`,`ts`)
) ENGINE=InnoDB AUTO_INCREMENT=66 DEFAULT CHARSET=utf8;
CREATE TABLE `posts_tags` ( CREATE TABLE `posts_tags` (
`id` int(11) NOT NULL, `id` int(11) NOT NULL,