Add formatting libraries to composer.json

This commit is contained in:
Kijin Sung 2016-03-17 20:37:43 +09:00
parent 59ee4a7387
commit 2b008f7be6
202 changed files with 28022 additions and 133 deletions

View file

@ -5,7 +5,7 @@ All rights reserved.
Based on Markdown
Copyright (c) 2003-2006 John Gruber
<http://daringfireball.net/>
<https://daringfireball.net/>
All rights reserved.
Redistribution and use in source and binary forms, with or without

View file

@ -8,7 +8,7 @@
#
# Original Markdown
# Copyright (c) 2004-2006 John Gruber
# <http://daringfireball.net/projects/markdown/>
# <https://daringfireball.net/projects/markdown/>
#
namespace Michelf;
@ -21,7 +21,7 @@ class Markdown implements MarkdownInterface {
### Version ###
const MARKDOWNLIB_VERSION = "1.5.0";
const MARKDOWNLIB_VERSION = "1.6.0";
### Simple Function Interface ###
@ -64,6 +64,9 @@ class Markdown implements MarkdownInterface {
# Optional header id="" generation callback function.
public $header_id_func = null;
# Optional function for converting code block content to HTML
public $code_block_content_func = null;
# Class attribute to toggle "enhanced ordered list" behaviour
# setting this to true will allow ordered lists to start from the index
@ -493,7 +496,7 @@ class Markdown implements MarkdownInterface {
"doImages" => 10,
"doAnchors" => 20,
# Make links out of things like `<http://example.com/>`
# Make links out of things like `<https://example.com/>`
# Must come after doAnchors, because you can use < and >
# delimiters in inline links like [this](<url>).
"doAutoLinks" => 30,
@ -1024,7 +1027,11 @@ class Markdown implements MarkdownInterface {
$codeblock = $matches[1];
$codeblock = $this->outdent($codeblock);
$codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES);
if ($this->code_block_content_func) {
$codeblock = call_user_func($this->code_block_content_func, $codeblock, "");
} else {
$codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES);
}
# trim leading newlines and trailing newlines
$codeblock = preg_replace('/\A\n+|\n+\z/', '', $codeblock);

View file

@ -8,7 +8,7 @@
#
# Original Markdown
# Copyright (c) 2004-2006 John Gruber
# <http://daringfireball.net/projects/markdown/>
# <https://daringfireball.net/projects/markdown/>
#
namespace Michelf;
@ -32,6 +32,11 @@ class MarkdownExtra extends \Michelf\Markdown {
public $fn_link_class = "footnote-ref";
public $fn_backlink_class = "footnote-backref";
# Content to be displayed within footnote backlinks. The default is '↩';
# the U+FE0E on the end is a Unicode variant selector used to prevent iOS
# from displaying the arrow character as an emoji.
public $fn_backlink_html = '&#8617;&#xFE0E;';
# Class name for table cell alignment (%% replaced left/center/right)
# For instance: 'go-%%' becomes 'go-left' or 'go-right' or 'go-center'
# If empty, the align attribute is used instead of a class name.
@ -42,7 +47,7 @@ class MarkdownExtra extends \Michelf\Markdown {
# Class attribute for code blocks goes on the `code` tag;
# setting this to true will put attributes on the `pre` tag instead.
public $code_attr_on_pre = false;
# Predefined abbreviations.
public $predef_abbr = array();
@ -131,11 +136,11 @@ class MarkdownExtra extends \Michelf\Markdown {
### Extra Attribute Parser ###
# Expression to use to catch attributes (includes the braces)
protected $id_class_attr_catch_re = '\{((?:[ ]*[#.a-z][-_:a-zA-Z0-9=]+){1,})[ ]*\}';
protected $id_class_attr_catch_re = '\{((?>[ ]*[#.a-z][-_:a-zA-Z0-9=]+){1,})[ ]*\}';
# Expression to use when parsing in a context when no capture is desired
protected $id_class_attr_nocatch_re = '\{(?:[ ]*[#.a-z][-_:a-zA-Z0-9=]+){1,}[ ]*\}';
protected $id_class_attr_nocatch_re = '\{(?>[ ]*[#.a-z][-_:a-zA-Z0-9=]+){1,}[ ]*\}';
protected function doExtraAttributes($tag_name, $attr, $defaultIdValue = null) {
protected function doExtraAttributes($tag_name, $attr, $defaultIdValue = null, $classes = array()) {
#
# Parse attributes caught by the $this->id_class_attr_catch_re expression
# and return the HTML-formatted list of attributes.
@ -145,14 +150,13 @@ class MarkdownExtra extends \Michelf\Markdown {
# In addition, this method also supports supplying a default Id value,
# which will be used to populate the id attribute in case it was not
# overridden.
if (empty($attr) && !$defaultIdValue) return "";
if (empty($attr) && !$defaultIdValue && empty($classes)) return "";
# Split on components
preg_match_all('/[#.a-z][-_:a-zA-Z0-9=]+/', $attr, $matches);
$elements = $matches[0];
# handle classes and ids (only first id taken into account)
$classes = array();
$attributes = array();
$id = false;
foreach ($elements as $element) {
@ -349,12 +353,10 @@ class MarkdownExtra extends \Michelf\Markdown {
# Fenced code block marker
(?<= ^ | \n )
[ ]{0,'.($indent+3).'}(?:~{3,}|`{3,})
[ ]*
(?:
\.?[-_:a-zA-Z0-9]+ # standalone class name
|
'.$this->id_class_attr_nocatch_re.' # extra attributes
)?
[ ]*
(?: \.?[-_:a-zA-Z0-9]+ )? # standalone class name
[ ]*
(?: '.$this->id_class_attr_nocatch_re.' )? # extra attributes
[ ]*
(?= \n )
' : '' ). ' # End (if not is span).
@ -410,7 +412,7 @@ class MarkdownExtra extends \Michelf\Markdown {
# Note: need to recheck the whole tag to disambiguate backtick
# fences from code spans
#
if (preg_match('{^\n?([ ]{0,'.($indent+3).'})(~{3,}|`{3,})[ ]*(?:\.?[-_:a-zA-Z0-9]+|'.$this->id_class_attr_nocatch_re.')?[ ]*\n?$}', $tag, $capture)) {
if (preg_match('{^\n?([ ]{0,'.($indent+3).'})(~{3,}|`{3,})[ ]*(?:\.?[-_:a-zA-Z0-9]+)?[ ]*(?:'.$this->id_class_attr_nocatch_re.')?[ ]*\n?$}', $tag, $capture)) {
# Fenced code block marker: find matching end marker.
$fence_indent = strlen($capture[1]); # use captured indent in re
$fence_re = $capture[2]; # use captured fence in re
@ -1294,7 +1296,9 @@ class MarkdownExtra extends \Michelf\Markdown {
[ ]*
(?:
\.?([-_:a-zA-Z0-9]+) # 2: standalone class name
|
)?
[ ]*
(?:
'.$this->id_class_attr_catch_re.' # 3: Extra attributes
)?
[ ]* \n # Whitespace and newline following marker.
@ -1318,17 +1322,23 @@ class MarkdownExtra extends \Michelf\Markdown {
$classname =& $matches[2];
$attrs =& $matches[3];
$codeblock = $matches[4];
$codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES);
if ($this->code_block_content_func) {
$codeblock = call_user_func($this->code_block_content_func, $codeblock, $classname);
} else {
$codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES);
}
$codeblock = preg_replace_callback('/^\n+/',
array($this, '_doFencedCodeBlocks_newlines'), $codeblock);
$classes = array();
if ($classname != "") {
if ($classname{0} == '.')
$classname = substr($classname, 1);
$attr_str = ' class="'.$this->code_class_prefix.$classname.'"';
} else {
$attr_str = $this->doExtraAttributes($this->code_attr_on_pre ? "pre" : "code", $attrs);
$classes[] = $this->code_class_prefix.$classname;
}
$attr_str = $this->doExtraAttributes($this->code_attr_on_pre ? "pre" : "code", $attrs, null, $classes);
$pre_attr_str = $this->code_attr_on_pre ? $attr_str : '';
$code_attr_str = $this->code_attr_on_pre ? '' : $attr_str;
$codeblock = "<pre$pre_attr_str><code$code_attr_str>$codeblock</code></pre>";
@ -1470,6 +1480,7 @@ class MarkdownExtra extends \Michelf\Markdown {
$title = $this->encodeAttribute($title);
$attr .= " title=\"$title\"";
}
$backlink_text = $this->fn_backlink_html;
$num = 0;
while (!empty($this->footnotes_ordered)) {
@ -1489,9 +1500,9 @@ class MarkdownExtra extends \Michelf\Markdown {
$note_id = $this->encodeAttribute($note_id);
# Prepare backlink, multiple backlinks if multiple references
$backlink = "<a href=\"#fnref:$note_id\"$attr>&#8617;</a>";
$backlink = "<a href=\"#fnref:$note_id\"$attr>$backlink_text</a>";
for ($ref_num = 2; $ref_num <= $ref_count; ++$ref_num) {
$backlink .= " <a href=\"#fnref$ref_num:$note_id\"$attr>&#8617;</a>";
$backlink .= " <a href=\"#fnref$ref_num:$note_id\"$attr>$backlink_text</a>";
}
# Add backlink to last paragraph; create new paragraph if needed.
if (preg_match('{</p>$}', $footnote)) {

View file

@ -8,7 +8,7 @@
#
# Original Markdown
# Copyright (c) 2004-2006 John Gruber
# <http://daringfireball.net/projects/markdown/>
# <https://daringfireball.net/projects/markdown/>
#
namespace Michelf;

View file

@ -1,13 +1,13 @@
PHP Markdown
============
PHP Markdown Lib 1.5.0 - 1 Mar 2015
PHP Markdown Lib 1.6.0 - 23 Dec 2015
by Michel Fortin
<https://michelf.ca/>
based on Markdown by John Gruber
<http://daringfireball.net/>
<https://daringfireball.net/>
Introduction
@ -25,7 +25,7 @@ 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
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)
* [Markdown Extra syntax additions](<https://michelf.ca/projects/php-markdown/extra/>)
— Michel Fortin
@ -174,6 +174,37 @@ PHP Markdown, please visit [michelf.ca/donate] or send Bitcoin to
Version History
---------------
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
@ -295,7 +326,7 @@ All rights reserved.
Based on Markdown
Copyright (c) 2003-2005 John Gruber
<http://daringfireball.net/>
<https://daringfireball.net/>
All rights reserved.
Redistribution and use in source and binary forms, with or without

View file

@ -14,7 +14,7 @@
},
{
"name": "John Gruber",
"homepage": "http://daringfireball.net/"
"homepage": "https://daringfireball.net/"
}
],
"require": {