feat: add highlighting Markdown parser <3

This commit is contained in:
David Bailey 2024-01-22 16:22:11 +01:00
parent 8e69a9139f
commit 9354f9f556
6 changed files with 613 additions and 50 deletions

View file

@ -4,6 +4,9 @@
"twig/markdown-extra": "^3.6",
"league/commonmark": "^2.4",
"spatie/yaml-front-matter": "^2.0",
"laminas/laminas-feed": "^2.6"
"laminas/laminas-feed": "^2.6",
"erusev/parsedown": "^1.7",
"erusev/parsedown-extra": "^0.8.1",
"scrivo/highlight.php": "v9.18.1.10"
}
}

604
www/composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "ae80529cc2442878a51f38de1f7017a4",
"content-hash": "34ef4bdab7508bbe6f60a1a56e33d08c",
"packages": [
{
"name": "dflydev/dot-access-data",
@ -81,6 +81,442 @@
},
"time": "2022-10-27T11:44:00+00:00"
},
{
"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"
},
{
"name": "erusev/parsedown-extra",
"version": "0.8.1",
"source": {
"type": "git",
"url": "https://github.com/erusev/parsedown-extra.git",
"reference": "91ac3ff98f0cea243bdccc688df43810f044dcef"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/erusev/parsedown-extra/zipball/91ac3ff98f0cea243bdccc688df43810f044dcef",
"reference": "91ac3ff98f0cea243bdccc688df43810f044dcef",
"shasum": ""
},
"require": {
"erusev/parsedown": "^1.7.4"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35"
},
"type": "library",
"autoload": {
"psr-0": {
"ParsedownExtra": ""
}
},
"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": "laminas/laminas-escaper",
"version": "2.13.0",
"source": {
"type": "git",
"url": "https://github.com/laminas/laminas-escaper.git",
"reference": "af459883f4018d0f8a0c69c7a209daef3bf973ba"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laminas/laminas-escaper/zipball/af459883f4018d0f8a0c69c7a209daef3bf973ba",
"reference": "af459883f4018d0f8a0c69c7a209daef3bf973ba",
"shasum": ""
},
"require": {
"ext-ctype": "*",
"ext-mbstring": "*",
"php": "~8.1.0 || ~8.2.0 || ~8.3.0"
},
"conflict": {
"zendframework/zend-escaper": "*"
},
"require-dev": {
"infection/infection": "^0.27.0",
"laminas/laminas-coding-standard": "~2.5.0",
"maglnet/composer-require-checker": "^3.8.0",
"phpunit/phpunit": "^9.6.7",
"psalm/plugin-phpunit": "^0.18.4",
"vimeo/psalm": "^5.9"
},
"type": "library",
"autoload": {
"psr-4": {
"Laminas\\Escaper\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"description": "Securely and safely escape HTML, HTML attributes, JavaScript, CSS, and URLs",
"homepage": "https://laminas.dev",
"keywords": [
"escaper",
"laminas"
],
"support": {
"chat": "https://laminas.dev/chat",
"docs": "https://docs.laminas.dev/laminas-escaper/",
"forum": "https://discourse.laminas.dev",
"issues": "https://github.com/laminas/laminas-escaper/issues",
"rss": "https://github.com/laminas/laminas-escaper/releases.atom",
"source": "https://github.com/laminas/laminas-escaper"
},
"funding": [
{
"url": "https://funding.communitybridge.org/projects/laminas-project",
"type": "community_bridge"
}
],
"time": "2023-10-10T08:35:13+00:00"
},
{
"name": "laminas/laminas-feed",
"version": "2.6.0",
"source": {
"type": "git",
"url": "https://github.com/laminas/laminas-feed.git",
"reference": "c1594cb32b117d3b409d4beee12c724cb26daa71"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laminas/laminas-feed/zipball/c1594cb32b117d3b409d4beee12c724cb26daa71",
"reference": "c1594cb32b117d3b409d4beee12c724cb26daa71",
"shasum": ""
},
"require": {
"laminas/laminas-escaper": "~2.5",
"laminas/laminas-stdlib": "~2.5",
"laminas/laminas-zendframework-bridge": "^1.0",
"php": ">=5.5"
},
"replace": {
"zendframework/zend-feed": "self.version"
},
"require-dev": {
"fabpot/php-cs-fixer": "1.7.*",
"laminas/laminas-cache": "~2.5",
"laminas/laminas-db": "~2.5",
"laminas/laminas-http": "~2.5",
"laminas/laminas-validator": "~2.5",
"phpunit/phpunit": "~4.0",
"psr/http-message": "^1.0"
},
"suggest": {
"laminas/laminas-cache": "Laminas\\Cache component, for optionally caching feeds between requests",
"laminas/laminas-db": "Laminas\\Db component, for use with PubSubHubbub",
"laminas/laminas-http": "Laminas\\Http for PubSubHubbub, and optionally for use with Laminas\\Feed\\Reader",
"laminas/laminas-servicemanager": "Laminas\\ServiceManager component, for easily extending ExtensionManager implementations",
"laminas/laminas-validator": "Laminas\\Validator component, for validating feeds and Atom entries in the Writer subcomponent",
"psr/http-message": "PSR-7 ^1.0, if you wish to use Laminas\\Feed\\Reader\\Http\\Psr7ResponseDecorator"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.6-dev",
"dev-develop": "2.7-dev"
}
},
"autoload": {
"psr-4": {
"Laminas\\Feed\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"description": "provides functionality for consuming RSS and Atom feeds",
"homepage": "https://laminas.dev",
"keywords": [
"feed",
"laminas"
],
"support": {
"chat": "https://laminas.dev/chat",
"docs": "https://docs.laminas.dev/laminas-feed/",
"forum": "https://discourse.laminas.dev",
"issues": "https://github.com/laminas/laminas-feed/issues",
"rss": "https://github.com/laminas/laminas-feed/releases.atom",
"source": "https://github.com/laminas/laminas-feed"
},
"time": "2019-12-31T16:50:31+00:00"
},
{
"name": "laminas/laminas-hydrator",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/laminas/laminas-hydrator.git",
"reference": "acab29a3327a70be0a653d88906655b15de15517"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laminas/laminas-hydrator/zipball/acab29a3327a70be0a653d88906655b15de15517",
"reference": "acab29a3327a70be0a653d88906655b15de15517",
"shasum": ""
},
"require": {
"laminas/laminas-stdlib": "^2.5.1",
"laminas/laminas-zendframework-bridge": "^1.0",
"php": ">=5.5"
},
"replace": {
"zendframework/zend-hydrator": "self.version"
},
"require-dev": {
"laminas/laminas-eventmanager": "^2.5.1",
"laminas/laminas-filter": "^2.5.1",
"laminas/laminas-inputfilter": "^2.5.1",
"laminas/laminas-serializer": "^2.5.1",
"laminas/laminas-servicemanager": "^2.5.1",
"phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "^2.0@dev"
},
"suggest": {
"laminas/laminas-eventmanager": "^2.5.1, to support aggregate hydrator usage",
"laminas/laminas-filter": "^2.5.1, to support naming strategy hydrator usage",
"laminas/laminas-serializer": "^2.5.1, to use the SerializableStrategy",
"laminas/laminas-servicemanager": "^2.5.1, to support hydrator plugin manager usage"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev",
"dev-develop": "1.1-dev"
}
},
"autoload": {
"psr-4": {
"Laminas\\Hydrator\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"homepage": "https://laminas.dev",
"keywords": [
"hydrator",
"laminas"
],
"support": {
"chat": "https://laminas.dev/chat",
"docs": "https://docs.laminas.dev/laminas-hydrator/",
"forum": "https://discourse.laminas.dev",
"issues": "https://github.com/laminas/laminas-hydrator/issues",
"rss": "https://github.com/laminas/laminas-hydrator/releases.atom",
"source": "https://github.com/laminas/laminas-hydrator"
},
"time": "2019-12-31T17:06:20+00:00"
},
{
"name": "laminas/laminas-stdlib",
"version": "2.7.4",
"source": {
"type": "git",
"url": "https://github.com/laminas/laminas-stdlib.git",
"reference": "b69e2741673daabdf720bc76668448ceb1e4c537"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laminas/laminas-stdlib/zipball/b69e2741673daabdf720bc76668448ceb1e4c537",
"reference": "b69e2741673daabdf720bc76668448ceb1e4c537",
"shasum": ""
},
"require": {
"laminas/laminas-hydrator": "~1.0",
"laminas/laminas-zendframework-bridge": "^1.0",
"php": ">=5.5"
},
"replace": {
"zendframework/zend-stdlib": "self.version"
},
"require-dev": {
"athletic/athletic": "~0.1",
"fabpot/php-cs-fixer": "1.7.*",
"laminas/laminas-config": "~2.5",
"laminas/laminas-eventmanager": "~2.5",
"laminas/laminas-filter": "~2.5",
"laminas/laminas-inputfilter": "~2.5",
"laminas/laminas-serializer": "~2.5",
"laminas/laminas-servicemanager": "~2.5",
"phpunit/phpunit": "~4.0"
},
"suggest": {
"laminas/laminas-eventmanager": "To support aggregate hydrator usage",
"laminas/laminas-filter": "To support naming strategy hydrator usage",
"laminas/laminas-serializer": "Laminas\\Serializer component",
"laminas/laminas-servicemanager": "To support hydrator plugin manager usage"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.7-dev",
"dev-develop": "2.8-dev"
}
},
"autoload": {
"psr-4": {
"Laminas\\Stdlib\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"homepage": "https://laminas.dev",
"keywords": [
"laminas",
"stdlib"
],
"support": {
"chat": "https://laminas.dev/chat",
"docs": "https://docs.laminas.dev/laminas-stdlib/",
"forum": "https://discourse.laminas.dev",
"issues": "https://github.com/laminas/laminas-stdlib/issues",
"rss": "https://github.com/laminas/laminas-stdlib/releases.atom",
"source": "https://github.com/laminas/laminas-stdlib"
},
"time": "2019-12-31T17:51:00+00:00"
},
{
"name": "laminas/laminas-zendframework-bridge",
"version": "1.8.0",
"source": {
"type": "git",
"url": "https://github.com/laminas/laminas-zendframework-bridge.git",
"reference": "eb0d96c708b92177a92bc2239543d3ed523452c6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laminas/laminas-zendframework-bridge/zipball/eb0d96c708b92177a92bc2239543d3ed523452c6",
"reference": "eb0d96c708b92177a92bc2239543d3ed523452c6",
"shasum": ""
},
"require": {
"php": "~8.1.0 || ~8.2.0 || ~8.3.0"
},
"require-dev": {
"phpunit/phpunit": "^10.4",
"psalm/plugin-phpunit": "^0.18.0",
"squizlabs/php_codesniffer": "^3.7.1",
"vimeo/psalm": "^5.16.0"
},
"type": "library",
"extra": {
"laminas": {
"module": "Laminas\\ZendFrameworkBridge"
}
},
"autoload": {
"files": [
"src/autoload.php"
],
"psr-4": {
"Laminas\\ZendFrameworkBridge\\": "src//"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"description": "Alias legacy ZF class names to Laminas Project equivalents.",
"keywords": [
"ZendFramework",
"autoloading",
"laminas",
"zf"
],
"support": {
"forum": "https://discourse.laminas.dev/",
"issues": "https://github.com/laminas/laminas-zendframework-bridge/issues",
"rss": "https://github.com/laminas/laminas-zendframework-bridge/releases.atom",
"source": "https://github.com/laminas/laminas-zendframework-bridge"
},
"funding": [
{
"url": "https://funding.communitybridge.org/projects/laminas-project",
"type": "community_bridge"
}
],
"abandoned": true,
"time": "2023-11-24T13:56:19+00:00"
},
{
"name": "league/commonmark",
"version": "2.4.1",
@ -333,16 +769,16 @@
},
{
"name": "nette/utils",
"version": "v4.0.2",
"version": "v4.0.3",
"source": {
"type": "git",
"url": "https://github.com/nette/utils.git",
"reference": "cead6637226456b35e1175cc53797dd585d85545"
"reference": "a9d127dd6a203ce6d255b2e2db49759f7506e015"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/utils/zipball/cead6637226456b35e1175cc53797dd585d85545",
"reference": "cead6637226456b35e1175cc53797dd585d85545",
"url": "https://api.github.com/repos/nette/utils/zipball/a9d127dd6a203ce6d255b2e2db49759f7506e015",
"reference": "a9d127dd6a203ce6d255b2e2db49759f7506e015",
"shasum": ""
},
"require": {
@ -413,9 +849,9 @@
],
"support": {
"issues": "https://github.com/nette/utils/issues",
"source": "https://github.com/nette/utils/tree/v4.0.2"
"source": "https://github.com/nette/utils/tree/v4.0.3"
},
"time": "2023-09-19T11:58:07+00:00"
"time": "2023-10-29T21:02:13+00:00"
},
{
"name": "psr/event-dispatcher",
@ -468,22 +904,100 @@
"time": "2019-01-08T18:20:26+00:00"
},
{
"name": "spatie/yaml-front-matter",
"version": "2.0.7",
"name": "scrivo/highlight.php",
"version": "v9.18.1.10",
"source": {
"type": "git",
"url": "https://github.com/spatie/yaml-front-matter.git",
"reference": "f49f228994de70827ca857efffdd3bd7703aea34"
"url": "https://github.com/scrivo/highlight.php.git",
"reference": "850f4b44697a2552e892ffe71490ba2733c2fc6e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/yaml-front-matter/zipball/f49f228994de70827ca857efffdd3bd7703aea34",
"reference": "f49f228994de70827ca857efffdd3bd7703aea34",
"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": [
"HighlightUtilities/functions.php"
],
"psr-0": {
"Highlight\\": "",
"HighlightUtilities\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Geert Bergman",
"homepage": "http://www.scrivo.org/",
"role": "Project Author"
},
{
"name": "Vladimir Jimenez",
"homepage": "https://allejo.io",
"role": "Maintainer"
},
{
"name": "Martin Folkers",
"homepage": "https://twobrain.io",
"role": "Contributor"
}
],
"description": "Server side syntax highlighter that supports 185 languages. It's a PHP port of highlight.js",
"keywords": [
"code",
"highlight",
"highlight.js",
"highlight.php",
"syntax"
],
"support": {
"issues": "https://github.com/scrivo/highlight.php/issues",
"source": "https://github.com/scrivo/highlight.php"
},
"funding": [
{
"url": "https://github.com/allejo",
"type": "github"
}
],
"time": "2022-12-17T21:53:22+00:00"
},
{
"name": "spatie/yaml-front-matter",
"version": "2.0.8",
"source": {
"type": "git",
"url": "https://github.com/spatie/yaml-front-matter.git",
"reference": "f2f1f749a405fafc9d6337067c92c062d51a581c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/yaml-front-matter/zipball/f2f1f749a405fafc9d6337067c92c062d51a581c",
"reference": "f2f1f749a405fafc9d6337067c92c062d51a581c",
"shasum": ""
},
"require": {
"php": "^7.0|^8.0",
"symfony/yaml": "^3.0|^4.0|^5.0|^6.0"
"symfony/yaml": "^3.0|^4.0|^5.0|^6.0|^7.0"
},
"require-dev": {
"phpunit/phpunit": "^9.0"
@ -515,7 +1029,7 @@
"yaml"
],
"support": {
"source": "https://github.com/spatie/yaml-front-matter/tree/2.0.7"
"source": "https://github.com/spatie/yaml-front-matter/tree/2.0.8"
},
"funding": [
{
@ -527,11 +1041,11 @@
"type": "github"
}
],
"time": "2022-04-06T12:03:55+00:00"
"time": "2023-12-04T10:02:52+00:00"
},
{
"name": "symfony/deprecation-contracts",
"version": "v3.3.0",
"version": "v3.4.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/deprecation-contracts.git",
@ -578,7 +1092,7 @@
"description": "A generic function and convention to trigger deprecation notices",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/deprecation-contracts/tree/v3.3.0"
"source": "https://github.com/symfony/deprecation-contracts/tree/v3.4.0"
},
"funding": [
{
@ -846,28 +1360,27 @@
},
{
"name": "symfony/yaml",
"version": "v6.3.3",
"version": "v7.0.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "e23292e8c07c85b971b44c1c4b87af52133e2add"
"reference": "0055b230c408428b9b5cde7c55659555be5c0278"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/e23292e8c07c85b971b44c1c4b87af52133e2add",
"reference": "e23292e8c07c85b971b44c1c4b87af52133e2add",
"url": "https://api.github.com/repos/symfony/yaml/zipball/0055b230c408428b9b5cde7c55659555be5c0278",
"reference": "0055b230c408428b9b5cde7c55659555be5c0278",
"shasum": ""
},
"require": {
"php": ">=8.1",
"symfony/deprecation-contracts": "^2.5|^3",
"php": ">=8.2",
"symfony/polyfill-ctype": "^1.8"
},
"conflict": {
"symfony/console": "<5.4"
"symfony/console": "<6.4"
},
"require-dev": {
"symfony/console": "^5.4|^6.0"
"symfony/console": "^6.4|^7.0"
},
"bin": [
"Resources/bin/yaml-lint"
@ -898,7 +1411,7 @@
"description": "Loads and dumps YAML files",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/yaml/tree/v6.3.3"
"source": "https://github.com/symfony/yaml/tree/v7.0.0"
},
"funding": [
{
@ -914,32 +1427,32 @@
"type": "tidelift"
}
],
"time": "2023-07-31T07:08:24+00:00"
"time": "2023-11-07T10:26:03+00:00"
},
{
"name": "twig/markdown-extra",
"version": "v3.7.1",
"version": "v3.8.0",
"source": {
"type": "git",
"url": "https://github.com/twigphp/markdown-extra.git",
"reference": "83dfa86a0379f784ea30bdb9c15a356b8aabf780"
"reference": "b6e4954ab60030233df5d293886b5404558daac8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twigphp/markdown-extra/zipball/83dfa86a0379f784ea30bdb9c15a356b8aabf780",
"reference": "83dfa86a0379f784ea30bdb9c15a356b8aabf780",
"url": "https://api.github.com/repos/twigphp/markdown-extra/zipball/b6e4954ab60030233df5d293886b5404558daac8",
"reference": "b6e4954ab60030233df5d293886b5404558daac8",
"shasum": ""
},
"require": {
"php": ">=7.1.3",
"twig/twig": "^2.7|^3.0"
"php": ">=7.2.5",
"twig/twig": "^3.0"
},
"require-dev": {
"erusev/parsedown": "^1.7",
"league/commonmark": "^1.0|^2.0",
"league/html-to-markdown": "^4.8|^5.0",
"michelf/php-markdown": "^1.8|^2.0",
"symfony/phpunit-bridge": "^5.4|^6.3"
"symfony/phpunit-bridge": "^6.4|^7.0"
},
"type": "library",
"autoload": {
@ -970,7 +1483,7 @@
"twig"
],
"support": {
"source": "https://github.com/twigphp/markdown-extra/tree/v3.7.1"
"source": "https://github.com/twigphp/markdown-extra/tree/v3.8.0"
},
"funding": [
{
@ -982,30 +1495,31 @@
"type": "tidelift"
}
],
"time": "2023-07-29T15:34:56+00:00"
"time": "2023-11-21T14:02:01+00:00"
},
{
"name": "twig/twig",
"version": "v3.7.1",
"version": "v3.8.0",
"source": {
"type": "git",
"url": "https://github.com/twigphp/Twig.git",
"reference": "a0ce373a0ca3bf6c64b9e3e2124aca502ba39554"
"reference": "9d15f0ac07f44dc4217883ec6ae02fd555c6f71d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/a0ce373a0ca3bf6c64b9e3e2124aca502ba39554",
"reference": "a0ce373a0ca3bf6c64b9e3e2124aca502ba39554",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/9d15f0ac07f44dc4217883ec6ae02fd555c6f71d",
"reference": "9d15f0ac07f44dc4217883ec6ae02fd555c6f71d",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
"symfony/polyfill-ctype": "^1.8",
"symfony/polyfill-mbstring": "^1.3"
"symfony/polyfill-mbstring": "^1.3",
"symfony/polyfill-php80": "^1.22"
},
"require-dev": {
"psr/container": "^1.0|^2.0",
"symfony/phpunit-bridge": "^5.4.9|^6.3"
"symfony/phpunit-bridge": "^5.4.9|^6.3|^7.0"
},
"type": "library",
"autoload": {
@ -1041,7 +1555,7 @@
],
"support": {
"issues": "https://github.com/twigphp/Twig/issues",
"source": "https://github.com/twigphp/Twig/tree/v3.7.1"
"source": "https://github.com/twigphp/Twig/tree/v3.8.0"
},
"funding": [
{
@ -1053,7 +1567,7 @@
"type": "tidelift"
}
],
"time": "2023-08-28T11:09:02+00:00"
"time": "2023-11-21T18:54:41+00:00"
}
],
"packages-dev": [],

39
www/dergdown.php Normal file
View file

@ -0,0 +1,39 @@
<?php
use Highlight\Highlighter;
class Dergdown extends ParsedownExtra
{
protected $highlighter;
public function __construct()
{
$this->highlighter = new Highlighter();
}
protected function blockFencedCodeComplete($block)
{
if (! isset($block['element']['text']['attributes'])) {
return $block;
}
$code = $block['element']['text']['text'];
$languageClass = $block['element']['text']['attributes']['class'];
$language = explode('-', $languageClass);
try {
$highlighted = $this->highlighter->highlight($language[1], $code);
$block['element']['text']['attributes']['class'] = vsprintf('%s hljs %s', [
$languageClass,
$highlighted->language,
]);
$block['element']['text']['rawHtml'] = $highlighted->value;
unset($block['element']['text']['text']);
} catch (DomainException $e) {
}
return $block;
}
}

View file

@ -6,6 +6,7 @@ require_once 'vendor/autoload.php';
require_once 'post_adapter.php';
require_once 'fontawesome.php';
require_once 'dergdown.php';
use Symfony\Component\Yaml\Yaml;
@ -31,6 +32,12 @@ use Twig\Extra\Markdown\DefaultMarkdown;
use Twig\Extra\Markdown\MarkdownRuntime;
use Twig\RuntimeLoader\RuntimeLoaderInterface;
function dergdown_to_html($text) {
$Parsedown = new Dergdown();
return $Parsedown->text($text);
}
function deduce_user_agent() {
$real_agent=$_SERVER['HTTP_USER_AGENT'];
@ -109,6 +116,8 @@ function render_twig($template, $args = []) {
$args['age_gate'] = (!isset($_COOKIE['AgeConfirmed'])) && isset($SITE_CONFIG['age_gate']);
$args['content_html'] ??= dergdown_to_html($post['post_content'] ?? '');
echo $twig->render($template, $args);
}

View file

@ -10,8 +10,6 @@
{{ parent() }}
<meta property="og:type" content="image" />
<meta name="twitter:card" content="summary_large_image">
<meta name="robots" content="max-image-preview:large">
{%endblock %}
{%block content_article%}
@ -21,7 +19,7 @@
</a>
<figcaption>
{{ post.post_content|markdown_to_html }}
{{ content_html|raw }}
</figcaption>
</figure>
{%endblock%}

View file

@ -9,5 +9,5 @@
{%endblock %}
{%block content_article%}
{{ post['post_content']|markdown_to_html }}
{{ content_html|raw }}
{% endblock %}