Upgraded PHP Markdown library to version 1.7.0
This commit is contained in:
parent
d799662992
commit
c9214c2051
|
@ -1,11 +1,11 @@
|
||||||
PHP Markdown Lib
|
PHP Markdown Lib
|
||||||
Copyright (c) 2004-2014 Michel Fortin
|
Copyright (c) 2004-2016 Michel Fortin
|
||||||
<http://michelf.ca/>
|
<https://michelf.ca/>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Based on Markdown
|
Based on Markdown
|
||||||
Copyright (c) 2003-2006 John Gruber
|
Copyright (c) 2003-2006 John Gruber
|
||||||
<http://daringfireball.net/>
|
<https://daringfireball.net/>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
# Use this file if you cannot use class autoloading. It will include all the
|
// Use this file if you cannot use class autoloading. It will include all the
|
||||||
# files needed for the Markdown parser.
|
// files needed for the Markdown parser.
|
||||||
#
|
//
|
||||||
# Take a look at the PSR-0-compatible class autoloading implementation
|
// Take a look at the PSR-0-compatible class autoloading implementation
|
||||||
# in the Readme.php file if you want a simple autoloader setup.
|
// in the Readme.php file if you want a simple autoloader setup.
|
||||||
|
|
||||||
require_once dirname(__FILE__) . '/MarkdownInterface.php';
|
require_once dirname(__FILE__) . '/MarkdownInterface.php';
|
||||||
require_once dirname(__FILE__) . '/Markdown.php';
|
require_once dirname(__FILE__) . '/Markdown.php';
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,10 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
# Use this file if you cannot use class autoloading. It will include all the
|
// Use this file if you cannot use class autoloading. It will include all the
|
||||||
# files needed for the MarkdownExtra parser.
|
// files needed for the MarkdownExtra parser.
|
||||||
#
|
//
|
||||||
# Take a look at the PSR-0-compatible class autoloading implementation
|
// Take a look at the PSR-0-compatible class autoloading implementation
|
||||||
# in the Readme.php file if you want a simple autoloader setup.
|
// in the Readme.php file if you want a simple autoloader setup.
|
||||||
|
|
||||||
require_once dirname(__FILE__) . '/MarkdownInterface.php';
|
require_once dirname(__FILE__) . '/MarkdownInterface.php';
|
||||||
require_once dirname(__FILE__) . '/Markdown.php';
|
require_once dirname(__FILE__) . '/Markdown.php';
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,9 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
# Use this file if you cannot use class autoloading. It will include all the
|
// Use this file if you cannot use class autoloading. It will include all the
|
||||||
# files needed for the MarkdownInterface interface.
|
// files needed for the MarkdownInterface interface.
|
||||||
#
|
//
|
||||||
# Take a look at the PSR-0-compatible class autoloading implementation
|
// Take a look at the PSR-0-compatible class autoloading implementation
|
||||||
# in the Readme.php file if you want a simple autoloader setup.
|
// in the Readme.php file if you want a simple autoloader setup.
|
||||||
|
|
||||||
require_once dirname(__FILE__) . '/MarkdownInterface.php';
|
require_once dirname(__FILE__) . '/MarkdownInterface.php';
|
||||||
|
|
|
@ -1,34 +1,38 @@
|
||||||
<?php
|
<?php
|
||||||
#
|
/**
|
||||||
# Markdown - A text-to-HTML conversion tool for web writers
|
* Markdown - A text-to-HTML conversion tool for web writers
|
||||||
#
|
*
|
||||||
# PHP Markdown
|
* @package php-markdown
|
||||||
# Copyright (c) 2004-2014 Michel Fortin
|
* @author Michel Fortin <michel.fortin@michelf.com>
|
||||||
# <http://michelf.com/projects/php-markdown/>
|
* @copyright 2004-2016 Michel Fortin <https://michelf.com/projects/php-markdown/>
|
||||||
#
|
* @copyright (Original Markdown) 2004-2006 John Gruber <https://daringfireball.net/projects/markdown/>
|
||||||
# Original Markdown
|
*/
|
||||||
# Copyright (c) 2004-2006 John Gruber
|
|
||||||
# <http://daringfireball.net/projects/markdown/>
|
|
||||||
#
|
|
||||||
namespace Michelf;
|
namespace Michelf;
|
||||||
|
|
||||||
|
/**
|
||||||
#
|
* Markdown Parser Interface
|
||||||
# Markdown Parser Interface
|
*/
|
||||||
#
|
|
||||||
|
|
||||||
interface MarkdownInterface {
|
interface MarkdownInterface {
|
||||||
|
/**
|
||||||
|
* Initialize the parser and return the result of its transform method.
|
||||||
|
* This will work fine for derived classes too.
|
||||||
|
*
|
||||||
|
* @api
|
||||||
|
*
|
||||||
|
* @param string $text
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function defaultTransform($text);
|
||||||
|
|
||||||
#
|
/**
|
||||||
# Initialize the parser and return the result of its transform method.
|
* Main function. Performs some preprocessing on the input text
|
||||||
# This will work fine for derived classes too.
|
* and pass it through the document gamut.
|
||||||
#
|
*
|
||||||
public static function defaultTransform($text);
|
* @api
|
||||||
|
*
|
||||||
#
|
* @param string $text
|
||||||
# Main function. Performs some preprocessing on the input text
|
* @return string
|
||||||
# and pass it through the document gamut.
|
*/
|
||||||
#
|
public function transform($text);
|
||||||
public function transform($text);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
PHP Markdown
|
PHP Markdown
|
||||||
============
|
============
|
||||||
|
|
||||||
PHP Markdown Lib 1.4.1 - 4 May 2013
|
PHP Markdown Lib 1.7.0 - 29 Oct 2016
|
||||||
|
|
||||||
by Michel Fortin
|
by Michel Fortin
|
||||||
<http://michelf.ca/>
|
<https://michelf.ca/>
|
||||||
|
|
||||||
based on Markdown by John Gruber
|
based on Markdown by John Gruber
|
||||||
<http://daringfireball.net/>
|
<https://daringfireball.net/>
|
||||||
|
|
||||||
|
|
||||||
Introduction
|
Introduction
|
||||||
|
@ -25,10 +25,10 @@ software tool, originally written in Perl, that converts the plain text
|
||||||
markup to HTML. PHP Markdown is a port to PHP of the original Markdown
|
markup to HTML. PHP Markdown is a port to PHP of the original Markdown
|
||||||
program by John Gruber.
|
program by John Gruber.
|
||||||
|
|
||||||
* [Full documentation of the Markdown syntax](<http://daringfireball.net/projects/markdown/>)
|
* [Full documentation of the Markdown syntax](<https://daringfireball.net/projects/markdown/>)
|
||||||
- Daring Fireball (John Gruber)
|
— Daring Fireball (John Gruber)
|
||||||
* [Markdown Extra syntax additions](<http://michelf.ca/projects/php-markdown/extra/>)
|
* [Markdown Extra syntax additions](<https://michelf.ca/projects/php-markdown/extra/>)
|
||||||
- Michel Fortin
|
— Michel Fortin
|
||||||
|
|
||||||
|
|
||||||
Requirement
|
Requirement
|
||||||
|
@ -83,7 +83,7 @@ configuration variables:
|
||||||
|
|
||||||
To learn more, see the full list of [configuration variables].
|
To learn more, see the full list of [configuration variables].
|
||||||
|
|
||||||
[configuration variables]: http://michelf.ca/projects/php-markdown/configuration/
|
[configuration variables]: https://michelf.ca/projects/php-markdown/configuration/
|
||||||
|
|
||||||
|
|
||||||
### Usage without an autoloader
|
### Usage without an autoloader
|
||||||
|
@ -149,7 +149,7 @@ Development and Testing
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
Pull requests for fixing bugs are welcome. Proposed new features are
|
Pull requests for fixing bugs are welcome. Proposed new features are
|
||||||
going meticulously reviewed -- taking into account backward compatibility,
|
going to be meticulously reviewed -- taking into account backward compatibility,
|
||||||
potential side effects, and future extensibility -- before deciding on
|
potential side effects, and future extensibility -- before deciding on
|
||||||
acceptance or rejection.
|
acceptance or rejection.
|
||||||
|
|
||||||
|
@ -174,11 +174,80 @@ PHP Markdown, please visit [michelf.ca/donate] or send Bitcoin to
|
||||||
Version History
|
Version History
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
Unreleased
|
PHP Markdown Lib 1.7.0 (29 Oct 2016)
|
||||||
|
|
||||||
* Added the ability to insert custom HTML attributes everywhere an extra
|
* Added a `hard_wrap` configuration variable to make all newline characters
|
||||||
attribute block is allowed (links, images, headers). Credits to
|
in the text become `<br>` tags in the HTML output. By default, according
|
||||||
Peter Droogmans for providing the implementation.
|
to the standard Markdown syntax these newlines are ignored unless they a
|
||||||
|
preceded by two spaces. Thanks to Jonathan Cohlmeyer for the implementation.
|
||||||
|
|
||||||
|
* Improved the parsing of list items to fix problematic cases that came to
|
||||||
|
light with the addition of `hard_wrap`. This should have no effect on the
|
||||||
|
output except span-level list items that ended with two spaces (and thus
|
||||||
|
ended with a line break).
|
||||||
|
|
||||||
|
* Added a `code_span_content_func` configuration variable which takes a
|
||||||
|
function that will convert the content of the code span to HTML. This can
|
||||||
|
be useful to implement syntax highlighting. Although contrary to its
|
||||||
|
code block equivalent, there is no syntax for specifying a language.
|
||||||
|
Credits to styxit for the implementation.
|
||||||
|
|
||||||
|
* Fixed a Markdown Extra issue where two-space-at-end-of-line hard breaks
|
||||||
|
wouldn't work inside of HTML block elements such as `<p markdown="1">`
|
||||||
|
where the element expects only span-level content.
|
||||||
|
|
||||||
|
* In the parser code, switched to PHPDoc comment format. Thanks to
|
||||||
|
Robbie Averill for the help.
|
||||||
|
|
||||||
|
|
||||||
|
PHP Markdown Lib 1.6.0 (23 Dec 2015)
|
||||||
|
|
||||||
|
Note: this version was incorrectly released as 1.5.1 on Dec 22, a number
|
||||||
|
that contradicted the versioning policy.
|
||||||
|
|
||||||
|
* For fenced code blocks in Markdown Extra, can now set a class name for the
|
||||||
|
code block's language before the special attribute block. Previously, this
|
||||||
|
class name was only allowed in the absence of the special attribute block.
|
||||||
|
|
||||||
|
* Added a `code_block_content_func` configuration variable which takes a
|
||||||
|
function that will convert the content of the code block to HTML. This is
|
||||||
|
most useful for syntax highlighting. For fenced code blocks in Markdown
|
||||||
|
Extra, the function has access to the language class name (the one outside
|
||||||
|
of the special attribute block). Credits to Mario Konrad for providing the
|
||||||
|
implementation.
|
||||||
|
|
||||||
|
* The curled arrow character for the backlink in footnotes is now followed
|
||||||
|
by a Unicode variant selector to prevent it from being displayed in emoji
|
||||||
|
form on iOS.
|
||||||
|
|
||||||
|
Note that in older browsers the variant selector is often interpreted as a
|
||||||
|
separate character, making it visible after the arrow. So there is now a
|
||||||
|
also a `fn_backlink_html` configuration variable that can be used to set
|
||||||
|
the link text to something else. Credits to Dana for providing the
|
||||||
|
implementation.
|
||||||
|
|
||||||
|
* Fixed an issue in MarkdownExtra where long header lines followed by a
|
||||||
|
special attribute block would hit the backtrack limit an cause an empty
|
||||||
|
string to be returned.
|
||||||
|
|
||||||
|
|
||||||
|
PHP Markdown Lib 1.5.0 (1 Mar 2015)
|
||||||
|
|
||||||
|
* Added the ability start ordered lists with a number different from 1 and
|
||||||
|
and have that reflected in the HTML output. This can be enabled with
|
||||||
|
the `enhanced_ordered_lists` configuration variable for the Markdown
|
||||||
|
parser; it is enabled by default for Markdown Extra.
|
||||||
|
Credits to Matt Gorle for providing the implementation.
|
||||||
|
|
||||||
|
* Added the ability to insert custom HTML attributes with simple values
|
||||||
|
everywhere an extra attribute block is allowed (links, images, headers).
|
||||||
|
The value must be unquoted, cannot contains spaces and is limited to
|
||||||
|
alphanumeric ASCII characters.
|
||||||
|
Credits to Peter Droogmans for providing the implementation.
|
||||||
|
|
||||||
|
* Added a `header_id_func` configuration variable which takes a function
|
||||||
|
that can generate an `id` attribute value from the header text.
|
||||||
|
Credits to Evert Pot for providing the implementation.
|
||||||
|
|
||||||
* Added a `url_filter_func` configuration variable which takes a function
|
* Added a `url_filter_func` configuration variable which takes a function
|
||||||
that can rewrite any link or image URL to something different.
|
that can rewrite any link or image URL to something different.
|
||||||
|
@ -239,7 +308,7 @@ PHP Markdown Extra 1.2.6:
|
||||||
|
|
||||||
* Plugin interface for WordPress and other systems is no longer present in
|
* Plugin interface for WordPress and other systems is no longer present in
|
||||||
the Lib package. The classic package is still available if you need it:
|
the Lib package. The classic package is still available if you need it:
|
||||||
<http://michelf.ca/projects/php-markdown/classic/>
|
<https://michelf.ca/projects/php-markdown/classic/>
|
||||||
|
|
||||||
* Added `public` and `protected` protection attributes, plus a section about
|
* Added `public` and `protected` protection attributes, plus a section about
|
||||||
what is "public API" and what isn't in the Readme file.
|
what is "public API" and what isn't in the Readme file.
|
||||||
|
@ -277,13 +346,13 @@ Copyright and License
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
PHP Markdown Lib
|
PHP Markdown Lib
|
||||||
Copyright (c) 2004-2014 Michel Fortin
|
Copyright (c) 2004-2016 Michel Fortin
|
||||||
<http://michelf.ca/>
|
<https://michelf.ca/>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Based on Markdown
|
Based on Markdown
|
||||||
Copyright (c) 2003-2005 John Gruber
|
Copyright (c) 2003-2005 John Gruber
|
||||||
<http://daringfireball.net/>
|
<https://daringfireball.net/>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
# This file passes the content of the Readme.md file in the same directory
|
// This file passes the content of the Readme.md file in the same directory
|
||||||
# through the Markdown filter. You can adapt this sample code in any way
|
// through the Markdown filter. You can adapt this sample code in any way
|
||||||
# you like.
|
// you like.
|
||||||
|
|
||||||
# Install PSR-0-compatible class autoloader
|
// Install PSR-0-compatible class autoloader
|
||||||
spl_autoload_register(function($class){
|
spl_autoload_register(function($class){
|
||||||
require preg_replace('{\\\\|_(?!.*\\\\)}', DIRECTORY_SEPARATOR, ltrim($class, '\\')).'.php';
|
require preg_replace('{\\\\|_(?!.*\\\\)}', DIRECTORY_SEPARATOR, ltrim($class, '\\')).'.php';
|
||||||
});
|
});
|
||||||
|
|
||||||
# Get Markdown class
|
// Get Markdown class
|
||||||
use \Michelf\Markdown;
|
use \Michelf\Markdown;
|
||||||
|
|
||||||
# Read file and pass content through the Markdown parser
|
// Read file and pass content through the Markdown parser
|
||||||
$text = file_get_contents('Readme.md');
|
$text = file_get_contents('Readme.md');
|
||||||
$html = Markdown::defaultTransform($text);
|
$html = Markdown::defaultTransform($text);
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ $html = Markdown::defaultTransform($text);
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<?php
|
<?php
|
||||||
# Put HTML content in the document
|
// Put HTML content in the document
|
||||||
echo $html;
|
echo $html;
|
||||||
?>
|
?>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -2,19 +2,19 @@
|
||||||
"name": "michelf/php-markdown",
|
"name": "michelf/php-markdown",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"description": "PHP Markdown",
|
"description": "PHP Markdown",
|
||||||
"homepage": "http://michelf.ca/projects/php-markdown/",
|
"homepage": "https://michelf.ca/projects/php-markdown/",
|
||||||
"keywords": ["markdown"],
|
"keywords": ["markdown"],
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "Michel Fortin",
|
"name": "Michel Fortin",
|
||||||
"email": "michel.fortin@michelf.ca",
|
"email": "michel.fortin@michelf.ca",
|
||||||
"homepage": "http://michelf.ca/",
|
"homepage": "https://michelf.ca/",
|
||||||
"role": "Developer"
|
"role": "Developer"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "John Gruber",
|
"name": "John Gruber",
|
||||||
"homepage": "http://daringfireball.net/"
|
"homepage": "https://daringfireball.net/"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -22,10 +22,5 @@
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-0": { "Michelf": "" }
|
"psr-0": { "Michelf": "" }
|
||||||
},
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-lib": "1.4.x-dev"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user