mirror of
https://github.com/erusev/parsedown.git
synced 2025-09-03 03:42:38 +02:00
Compare commits
38 Commits
test/sheph
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
0b274ac959 | ||
|
5b74b74145 | ||
|
95c7e4c3d7 | ||
|
c9dc49f68f | ||
|
28a9b057c7 | ||
|
e0082193b1 | ||
|
999fcf7886 | ||
|
582f9f9cd1 | ||
|
e76c4e44be | ||
|
cfb313fb1f | ||
|
9b14567c57 | ||
|
c65c451606 | ||
|
0476f3be5b | ||
|
9d00deadcd | ||
|
15048b0210 | ||
|
e7a3bccbae | ||
|
26362c5fe9 | ||
|
89880dd0a9 | ||
|
44fd383db7 | ||
|
54f1ffc214 | ||
|
6ae01284b8 | ||
|
26cfde9dbf | ||
|
232c57201e | ||
|
5362f4cbe3 | ||
|
b3e2fa192c | ||
|
908754bcdd | ||
|
1ff0382739 | ||
|
f5aa6fd1ca | ||
|
77947eda2f | ||
|
0586729b46 | ||
|
a86a4e19da | ||
|
6598f3860c | ||
|
1e5080190c | ||
|
1610e4747c | ||
|
3159a9d3cd | ||
|
dbee8ab4f2 | ||
|
dba4125b59 | ||
|
87b57bf3cb |
37
.github/workflows/unit-tests.yaml
vendored
Normal file
37
.github/workflows/unit-tests.yaml
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
on:
|
||||
- push
|
||||
- pull_request
|
||||
|
||||
jobs:
|
||||
phpunit:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
php:
|
||||
- '7.1'
|
||||
- '7.2'
|
||||
- '7.3'
|
||||
- '7.4'
|
||||
- '8.0'
|
||||
- '8.1'
|
||||
- '8.2'
|
||||
- '8.3'
|
||||
- '8.4'
|
||||
|
||||
steps:
|
||||
- name: Checkout the source code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '${{ matrix.php }}'
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer install
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
vendor/bin/phpunit
|
||||
vendor/bin/phpunit test/CommonMarkTestWeak.php || true
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
composer.lock
|
||||
vendor/
|
||||
.phpunit.result.cache
|
||||
|
28
.travis.yml
28
.travis.yml
@@ -1,28 +0,0 @@
|
||||
language: php
|
||||
|
||||
dist: trusty
|
||||
sudo: false
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- php: 5.3
|
||||
dist: precise
|
||||
- php: 5.4
|
||||
- php: 5.5
|
||||
- php: 5.6
|
||||
- php: 7.0
|
||||
- php: 7.1
|
||||
- php: 7.2
|
||||
- php: 7.3
|
||||
- php: nightly
|
||||
fast_finish: true
|
||||
allow_failures:
|
||||
- php: nightly
|
||||
|
||||
install:
|
||||
- composer install --prefer-dist --no-interaction --no-progress
|
||||
|
||||
script:
|
||||
- vendor/bin/phpunit
|
||||
- vendor/bin/phpunit test/CommonMarkTestWeak.php || true
|
||||
- '[ -z "$TRAVIS_TAG" ] || [ "$TRAVIS_TAG" == "$(php -r "require(\"Parsedown.php\"); echo Parsedown::version;")" ]'
|
@@ -17,7 +17,7 @@ class Parsedown
|
||||
{
|
||||
# ~
|
||||
|
||||
const version = '1.8.0-beta-7';
|
||||
const version = '1.8.0';
|
||||
|
||||
# ~
|
||||
|
||||
@@ -571,7 +571,7 @@ class Parsedown
|
||||
#
|
||||
# List
|
||||
|
||||
protected function blockList($Line, array $CurrentBlock = null)
|
||||
protected function blockList($Line, ?array $CurrentBlock = null)
|
||||
{
|
||||
list($name, $pattern) = $Line['text'][0] <= '-' ? array('ul', '[*+-]') : array('ol', '[0-9]{1,9}+[.\)]');
|
||||
|
||||
@@ -808,7 +808,7 @@ class Parsedown
|
||||
#
|
||||
# Setext
|
||||
|
||||
protected function blockSetextHeader($Line, array $Block = null)
|
||||
protected function blockSetextHeader($Line, ?array $Block = null)
|
||||
{
|
||||
if ( ! isset($Block) or $Block['type'] !== 'Paragraph' or isset($Block['interrupted']))
|
||||
{
|
||||
@@ -894,7 +894,7 @@ class Parsedown
|
||||
#
|
||||
# Table
|
||||
|
||||
protected function blockTable($Line, array $Block = null)
|
||||
protected function blockTable($Line, ?array $Block = null)
|
||||
{
|
||||
if ( ! isset($Block) or $Block['type'] !== 'Paragraph' or isset($Block['interrupted']))
|
||||
{
|
||||
|
39
README.md
39
README.md
@@ -1,31 +1,28 @@
|
||||
<!--  -->
|
||||
# Parsedown
|
||||
|
||||
<p align="center"><img alt="Parsedown" src="https://i.imgur.com/fKVY6Kz.png" width="240" /></p>
|
||||
|
||||
<h1>Parsedown</h1>
|
||||
|
||||
[](https://travis-ci.org/erusev/parsedown)
|
||||
[](https://packagist.org/packages/erusev/parsedown)
|
||||
[](https://packagist.org/packages/erusev/parsedown)
|
||||
[](https://packagist.org/packages/erusev/parsedown)
|
||||
|
||||
Better Markdown Parser in PHP - <a href="http://parsedown.org/demo">Demo</a>.
|
||||
Better Markdown Parser in PHP — <a href="https://parsedown.org/demo">demo</a>
|
||||
|
||||
## Features
|
||||
|
||||
* One File
|
||||
* No Dependencies
|
||||
* [Super Fast](http://parsedown.org/speed)
|
||||
* Extensible
|
||||
* [GitHub flavored](https://help.github.com/articles/github-flavored-markdown)
|
||||
* [Tested](http://parsedown.org/tests/) in 5.3 to 7.3
|
||||
* [Markdown Extra extension](https://github.com/erusev/parsedown-extra)
|
||||
- One file
|
||||
- No dependencies
|
||||
- [Super fast](http://parsedown.org/speed)
|
||||
- Extensible
|
||||
- [GitHub flavored](https://github.github.com/gfm)
|
||||
- [Tested](http://parsedown.org/tests/) in 5.3 to 7.3
|
||||
- [Markdown Extra extension](https://github.com/erusev/parsedown-extra)
|
||||
|
||||
## Installation
|
||||
|
||||
Install the [composer package]:
|
||||
|
||||
composer require erusev/parsedown
|
||||
```sh
|
||||
composer require erusev/parsedown
|
||||
```
|
||||
|
||||
Or download the [latest release] and include `Parsedown.php`
|
||||
|
||||
@@ -62,21 +59,19 @@ If instead, you wish to allow HTML within untrusted user-input, but still want o
|
||||
|
||||
In both cases you should strongly consider employing defence-in-depth measures, like [deploying a Content-Security-Policy](https://scotthelme.co.uk/content-security-policy-an-introduction/) (a browser security feature) so that your page is likely to be safe even if an attacker finds a vulnerability in one of the first lines of defence above.
|
||||
|
||||
#### Security of Parsedown Extensions
|
||||
|
||||
Safe mode does not necessarily yield safe results when using extensions to Parsedown. Extensions should be evaluated on their own to determine their specific safety against XSS.
|
||||
|
||||
## Escaping HTML
|
||||
|
||||
> ⚠️ **WARNING:** This method isn't safe from XSS!
|
||||
> WARNING: This method is not safe from XSS!
|
||||
|
||||
If you wish to escape HTML **in trusted input**, you can use the following:
|
||||
If you wish to escape HTML in trusted input, you can use the following:
|
||||
|
||||
```php
|
||||
$Parsedown->setMarkupEscaped(true);
|
||||
```
|
||||
|
||||
Beware that this still allows users to insert unsafe scripting vectors, such as links like `[xss](javascript:alert%281%29)`.
|
||||
Beware that this still allows users to insert unsafe scripting vectors, ex: `[xss](javascript:alert%281%29)`.
|
||||
|
||||
## Questions
|
||||
|
||||
@@ -97,3 +92,7 @@ It passes most of the CommonMark tests. Most of the tests that don't pass deal w
|
||||
**How can I help?**
|
||||
|
||||
Use it, star it, share it and if you feel generous, [donate](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=528P3NZQMP8N2).
|
||||
|
||||
**What else should I know?**
|
||||
|
||||
I also make [Nota](https://nota.md/) — a notes app designed for local Markdown files.
|
||||
|
@@ -13,11 +13,11 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.0",
|
||||
"php": ">=7.1",
|
||||
"ext-mbstring": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8.35"
|
||||
"phpunit/phpunit": "^7.5|^8.5|^9.6"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {"Parsedown": ""}
|
||||
|
@@ -1,17 +1,19 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test Parsedown against the CommonMark spec
|
||||
*
|
||||
* @link http://commonmark.org/ CommonMark
|
||||
*/
|
||||
class CommonMarkTestStrict extends PHPUnit_Framework_TestCase
|
||||
class CommonMarkTestStrict extends TestCase
|
||||
{
|
||||
const SPEC_URL = 'https://raw.githubusercontent.com/jgm/CommonMark/master/spec.txt';
|
||||
|
||||
protected $parsedown;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->parsedown = new TestParsedown();
|
||||
$this->parsedown->setUrlsLinked(false);
|
||||
|
@@ -17,7 +17,7 @@ class CommonMarkTestWeak extends CommonMarkTestStrict
|
||||
{
|
||||
protected $textLevelElementRegex;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp() : void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
|
@@ -15,4 +15,6 @@ still a fenced code block</code></pre>
|
||||
<pre><code>foo
|
||||
|
||||
|
||||
bar</code></pre>
|
||||
bar</code></pre>
|
||||
<pre><code class="language-php"><?php
|
||||
echo "Hello World";</code></pre>
|
@@ -35,4 +35,9 @@ foo
|
||||
|
||||
|
||||
bar
|
||||
```
|
||||
|
||||
```php some-class
|
||||
<?php
|
||||
echo "Hello World";
|
||||
```
|
Reference in New Issue
Block a user