mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 04:22:07 +02:00
MDL-32576 import Markdown 1.2.5
This commit is contained in:
parent
ead4f180a0
commit
e4ba066f1d
@ -3,7 +3,7 @@
|
||||
# Markdown Extra - A text-to-HTML conversion tool for web writers
|
||||
#
|
||||
# PHP Markdown & Extra
|
||||
# Copyright (c) 2004-2009 Michel Fortin
|
||||
# Copyright (c) 2004-2012 Michel Fortin
|
||||
# <http://michelf.com/projects/php-markdown/>
|
||||
#
|
||||
# Original Markdown
|
||||
@ -12,8 +12,8 @@
|
||||
#
|
||||
|
||||
|
||||
define( 'MARKDOWN_VERSION', "1.0.1n" ); # Sat 10 Oct 2009
|
||||
define( 'MARKDOWNEXTRA_VERSION', "1.2.4" ); # Sat 10 Oct 2009
|
||||
define( 'MARKDOWN_VERSION', "1.0.1o" ); # Sun 8 Jan 2012
|
||||
define( 'MARKDOWNEXTRA_VERSION', "1.2.5" ); # Sun 8 Jan 2012
|
||||
|
||||
|
||||
#
|
||||
@ -71,7 +71,7 @@ function Markdown($text) {
|
||||
Plugin Name: Markdown Extra
|
||||
Plugin URI: http://michelf.com/projects/php-markdown/
|
||||
Description: <a href="http://daringfireball.net/projects/markdown/syntax">Markdown syntax</a> allows you to write using an easy-to-read, easy-to-write plain text format. Based on the original Perl version by <a href="http://daringfireball.net/">John Gruber</a>. <a href="http://michelf.com/projects/php-markdown/">More...</a>
|
||||
Version: 1.2.4
|
||||
Version: 1.2.5
|
||||
Author: Michel Fortin
|
||||
Author URI: http://michelf.com/
|
||||
*/
|
||||
@ -950,7 +950,7 @@ class Markdown_Parser {
|
||||
|
||||
# Re-usable patterns to match list item bullets and number markers:
|
||||
$marker_ul_re = '[*+-]';
|
||||
$marker_ol_re = '\d+[.]';
|
||||
$marker_ol_re = '\d+[\.]';
|
||||
$marker_any_re = "(?:$marker_ul_re|$marker_ol_re)";
|
||||
|
||||
$markers_relist = array(
|
||||
@ -1011,7 +1011,7 @@ class Markdown_Parser {
|
||||
function _doLists_callback($matches) {
|
||||
# Re-usable patterns to match list item bullets and number markers:
|
||||
$marker_ul_re = '[*+-]';
|
||||
$marker_ol_re = '\d+[.]';
|
||||
$marker_ol_re = '\d+[\.]';
|
||||
$marker_any_re = "(?:$marker_ul_re|$marker_ol_re)";
|
||||
|
||||
$list = $matches[1];
|
||||
@ -1141,17 +1141,17 @@ class Markdown_Parser {
|
||||
|
||||
|
||||
var $em_relist = array(
|
||||
'' => '(?:(?<!\*)\*(?!\*)|(?<!_)_(?!_))(?=\S|$)(?![.,:;]\s)',
|
||||
'' => '(?:(?<!\*)\*(?!\*)|(?<!_)_(?!_))(?=\S|$)(?![\.,:;]\s)',
|
||||
'*' => '(?<=\S|^)(?<!\*)\*(?!\*)',
|
||||
'_' => '(?<=\S|^)(?<!_)_(?!_)',
|
||||
);
|
||||
var $strong_relist = array(
|
||||
'' => '(?:(?<!\*)\*\*(?!\*)|(?<!_)__(?!_))(?=\S|$)(?![.,:;]\s)',
|
||||
'' => '(?:(?<!\*)\*\*(?!\*)|(?<!_)__(?!_))(?=\S|$)(?![\.,:;]\s)',
|
||||
'**' => '(?<=\S|^)(?<!\*)\*\*(?!\*)',
|
||||
'__' => '(?<=\S|^)(?<!_)__(?!_)',
|
||||
);
|
||||
var $em_strong_relist = array(
|
||||
'' => '(?:(?<!\*)\*\*\*(?!\*)|(?<!_)___(?!_))(?=\S|$)(?![.,:;]\s)',
|
||||
'' => '(?:(?<!\*)\*\*\*(?!\*)|(?<!_)___(?!_))(?=\S|$)(?![\.,:;]\s)',
|
||||
'***' => '(?<=\S|^)(?<!\*)\*\*\*(?!\*)',
|
||||
'___' => '(?<=\S|^)(?<!_)___(?!_)',
|
||||
);
|
||||
@ -1885,7 +1885,7 @@ class MarkdownExtra_Parser extends Markdown_Parser {
|
||||
|
|
||||
# Fenced code block marker
|
||||
(?> ^ | \n )
|
||||
[ ]{'.($indent).'}~~~+[ ]*\n
|
||||
[ ]{0,'.($indent).'}~~~+[ ]*\n
|
||||
' : '' ). ' # End (if not is span).
|
||||
)
|
||||
}xs';
|
||||
@ -1947,20 +1947,12 @@ class MarkdownExtra_Parser extends Markdown_Parser {
|
||||
}
|
||||
}
|
||||
#
|
||||
# Check for: Indented code block.
|
||||
#
|
||||
else if ($tag{0} == "\n" || $tag{0} == " ") {
|
||||
# Indented code block: pass it unchanged, will be handled
|
||||
# later.
|
||||
$parsed .= $tag;
|
||||
}
|
||||
#
|
||||
# Check for: Fenced code block marker.
|
||||
#
|
||||
else if ($tag{0} == "~") {
|
||||
else if (preg_match('{^\n?[ ]{0,'.($indent+3).'}~}', $tag)) {
|
||||
# Fenced code block marker: find matching end marker.
|
||||
$tag_re = preg_quote(trim($tag));
|
||||
if (preg_match('{^(?>.*\n)+?'.$tag_re.' *\n}', $text,
|
||||
if (preg_match('{^(?>.*\n)+?[ ]{0,'.($indent).'}'.$tag_re.'[ ]*\n}', $text,
|
||||
$matches))
|
||||
{
|
||||
# End marker found: pass text unchanged until marker.
|
||||
@ -1973,6 +1965,14 @@ class MarkdownExtra_Parser extends Markdown_Parser {
|
||||
}
|
||||
}
|
||||
#
|
||||
# Check for: Indented code block.
|
||||
#
|
||||
else if ($tag{0} == "\n" || $tag{0} == " ") {
|
||||
# Indented code block: pass it unchanged, will be handled
|
||||
# later.
|
||||
$parsed .= $tag;
|
||||
}
|
||||
#
|
||||
# Check for: Opening Block level tag or
|
||||
# Opening Context Block tag (like ins and del)
|
||||
# used as a block tag (tag is alone on it's line).
|
||||
@ -2588,17 +2588,17 @@ class MarkdownExtra_Parser extends Markdown_Parser {
|
||||
# work in the middle of a word.
|
||||
#
|
||||
var $em_relist = array(
|
||||
'' => '(?:(?<!\*)\*(?!\*)|(?<![a-zA-Z0-9_])_(?!_))(?=\S|$)(?![.,:;]\s)',
|
||||
'' => '(?:(?<!\*)\*(?!\*)|(?<![a-zA-Z0-9_])_(?!_))(?=\S|$)(?![\.,:;]\s)',
|
||||
'*' => '(?<=\S|^)(?<!\*)\*(?!\*)',
|
||||
'_' => '(?<=\S|^)(?<!_)_(?![a-zA-Z0-9_])',
|
||||
);
|
||||
var $strong_relist = array(
|
||||
'' => '(?:(?<!\*)\*\*(?!\*)|(?<![a-zA-Z0-9_])__(?!_))(?=\S|$)(?![.,:;]\s)',
|
||||
'' => '(?:(?<!\*)\*\*(?!\*)|(?<![a-zA-Z0-9_])__(?!_))(?=\S|$)(?![\.,:;]\s)',
|
||||
'**' => '(?<=\S|^)(?<!\*)\*\*(?!\*)',
|
||||
'__' => '(?<=\S|^)(?<!_)__(?![a-zA-Z0-9_])',
|
||||
);
|
||||
var $em_strong_relist = array(
|
||||
'' => '(?:(?<!\*)\*\*\*(?!\*)|(?<![a-zA-Z0-9_])___(?!_))(?=\S|$)(?![.,:;]\s)',
|
||||
'' => '(?:(?<!\*)\*\*\*(?!\*)|(?<![a-zA-Z0-9_])___(?!_))(?=\S|$)(?![\.,:;]\s)',
|
||||
'***' => '(?<=\S|^)(?<!\*)\*\*\*(?!\*)',
|
||||
'___' => '(?<=\S|^)(?<!_)___(?![a-zA-Z0-9_])',
|
||||
);
|
||||
|
36
lib/markdown_license.txt
Normal file
36
lib/markdown_license.txt
Normal file
@ -0,0 +1,36 @@
|
||||
PHP Markdown & Extra
|
||||
Copyright (c) 2004-2009 Michel Fortin
|
||||
<http://michelf.com/>
|
||||
All rights reserved.
|
||||
|
||||
Based on Markdown
|
||||
Copyright (c) 2003-2006 John Gruber
|
||||
<http://daringfireball.net/>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name "Markdown" nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
This software is provided by the copyright holders and contributors "as
|
||||
is" and any express or implied warranties, including, but not limited
|
||||
to, the implied warranties of merchantability and fitness for a
|
||||
particular purpose are disclaimed. In no event shall the copyright owner
|
||||
or contributors be liable for any direct, indirect, incidental, special,
|
||||
exemplary, or consequential damages (including, but not limited to,
|
||||
procurement of substitute goods or services; loss of use, data, or
|
||||
profits; or business interruption) however caused and on any theory of
|
||||
liability, whether in contract, strict liability, or tort (including
|
||||
negligence or otherwise) arising in any way out of the use of this
|
||||
software, even if advised of the possibility of such damage.
|
66
lib/tests/markdown_test.php
Normal file
66
lib/tests/markdown_test.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Test markdown text format
|
||||
*
|
||||
* @package core
|
||||
* @category phpunit
|
||||
* @copyright 2012 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
/**
|
||||
* This is not a complete markdown test, it just validates
|
||||
* Moodle integration works.
|
||||
*
|
||||
* See http://daringfireball.net/projects/markdown/basics
|
||||
* for more format information.
|
||||
*
|
||||
* @package core
|
||||
* @category phpunit
|
||||
* @copyright 2012 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class core_markdown_testcase extends basic_testcase {
|
||||
|
||||
public function test_paragraphs() {
|
||||
$text = "one\n\ntwo";
|
||||
$result = "<p>one</p>\n\n<p>two</p>\n";
|
||||
$this->assertEquals($result, markdown_to_html($text));
|
||||
}
|
||||
|
||||
public function test_headings() {
|
||||
$text = "Header 1\n====================\n\n## Header 2";
|
||||
$result = "<h1>Header 1</h1>\n\n<h2>Header 2</h2>\n";
|
||||
$this->assertEquals($result, markdown_to_html($text));
|
||||
}
|
||||
|
||||
public function test_lists() {
|
||||
$text = "* one\n* two\n* three\n";
|
||||
$result = "<ul>\n<li>one</li>\n<li>two</li>\n<li>three</li>\n</ul>\n";
|
||||
$this->assertEquals($result, markdown_to_html($text));
|
||||
}
|
||||
|
||||
public function test_links() {
|
||||
$text = "some [example link](http://example.com/)";
|
||||
$result = "<p>some <a href=\"http://example.com/\">example link</a></p>\n";
|
||||
$this->assertEquals($result, markdown_to_html($text));
|
||||
}
|
||||
}
|
@ -242,7 +242,7 @@
|
||||
<location>markdown.php</location>
|
||||
<name>Markdown original+extra</name>
|
||||
<license>BSD</license>
|
||||
<version>1.2.4</version>
|
||||
<version>1.2.5</version>
|
||||
<licenseversion></licenseversion>
|
||||
</library>
|
||||
<library>
|
||||
|
Loading…
x
Reference in New Issue
Block a user