Merge branch 'lib-protected' into lib
Conflicts: Readme.md
This commit is contained in:
commit
2a18dd6244
2 changed files with 201 additions and 158 deletions
|
|
@ -32,11 +32,11 @@ class Markdown {
|
|||
|
||||
### Version ###
|
||||
|
||||
const MARKDOWNLIB_VERSION = "1.3-beta4";
|
||||
public const MARKDOWNLIB_VERSION = "1.3-beta4";
|
||||
|
||||
### Simple Function Interface ###
|
||||
|
||||
static function defaultTransform($text) {
|
||||
public static function defaultTransform($text) {
|
||||
#
|
||||
# Initialize the parser and return the result of its transform method.
|
||||
# This will work fine for derived classes too.
|
||||
|
|
@ -59,34 +59,34 @@ class Markdown {
|
|||
### Configuration Variables ###
|
||||
|
||||
# Change to ">" for HTML output.
|
||||
var $empty_element_suffix = " />";
|
||||
var $tab_width = 4;
|
||||
public $empty_element_suffix = " />";
|
||||
public $tab_width = 4;
|
||||
|
||||
# Change to `true` to disallow markup or entities.
|
||||
var $no_markup = false;
|
||||
var $no_entities = false;
|
||||
public $no_markup = false;
|
||||
public $no_entities = false;
|
||||
|
||||
# Predefined urls and titles for reference links and images.
|
||||
var $predef_urls = array();
|
||||
var $predef_titles = array();
|
||||
public $predef_urls = array();
|
||||
public $predef_titles = array();
|
||||
|
||||
|
||||
### Parser Implementation ###
|
||||
|
||||
# Regex to match balanced [brackets].
|
||||
# Needed to insert a maximum bracked depth while converting to PHP.
|
||||
var $nested_brackets_depth = 6;
|
||||
var $nested_brackets_re;
|
||||
protected $nested_brackets_depth = 6;
|
||||
protected $nested_brackets_re;
|
||||
|
||||
var $nested_url_parenthesis_depth = 4;
|
||||
var $nested_url_parenthesis_re;
|
||||
protected $nested_url_parenthesis_depth = 4;
|
||||
protected $nested_url_parenthesis_re;
|
||||
|
||||
# Table of hash values for escaped characters:
|
||||
var $escape_chars = '\`*_{}[]()>#+-.!';
|
||||
var $escape_chars_re;
|
||||
protected $escape_chars = '\`*_{}[]()>#+-.!';
|
||||
protected $escape_chars_re;
|
||||
|
||||
|
||||
function __construct() {
|
||||
public function __construct() {
|
||||
#
|
||||
# Constructor function. Initialize appropriate member variables.
|
||||
#
|
||||
|
|
@ -111,15 +111,15 @@ class Markdown {
|
|||
|
||||
|
||||
# Internal hashes used during transformation.
|
||||
var $urls = array();
|
||||
var $titles = array();
|
||||
var $html_hashes = array();
|
||||
protected $urls = array();
|
||||
protected $titles = array();
|
||||
protected $html_hashes = array();
|
||||
|
||||
# Status flag to avoid invalid nesting.
|
||||
var $in_anchor = false;
|
||||
protected $in_anchor = false;
|
||||
|
||||
|
||||
function setup() {
|
||||
protected function setup() {
|
||||
#
|
||||
# Called before the transformation process starts to setup parser
|
||||
# states.
|
||||
|
|
@ -132,7 +132,7 @@ class Markdown {
|
|||
$in_anchor = false;
|
||||
}
|
||||
|
||||
function teardown() {
|
||||
protected function teardown() {
|
||||
#
|
||||
# Called after the transformation process to clear any variable
|
||||
# which may be taking up memory unnecessarly.
|
||||
|
|
@ -143,7 +143,7 @@ class Markdown {
|
|||
}
|
||||
|
||||
|
||||
function transform($text) {
|
||||
protected function transform($text) {
|
||||
#
|
||||
# Main function. Performs some preprocessing on the input text
|
||||
# and pass it through the document gamut.
|
||||
|
|
@ -182,7 +182,7 @@ class Markdown {
|
|||
return $text . "\n";
|
||||
}
|
||||
|
||||
var $document_gamut = array(
|
||||
protected $document_gamut = array(
|
||||
# Strip link definitions, store in hashes.
|
||||
"stripLinkDefinitions" => 20,
|
||||
|
||||
|
|
@ -190,7 +190,7 @@ class Markdown {
|
|||
);
|
||||
|
||||
|
||||
function stripLinkDefinitions($text) {
|
||||
protected function stripLinkDefinitions($text) {
|
||||
#
|
||||
# Strips link definitions from text, stores the URLs and titles in
|
||||
# hash references.
|
||||
|
|
@ -224,7 +224,7 @@ class Markdown {
|
|||
$text);
|
||||
return $text;
|
||||
}
|
||||
function _stripLinkDefinitions_callback($matches) {
|
||||
protected function _stripLinkDefinitions_callback($matches) {
|
||||
$link_id = strtolower($matches[1]);
|
||||
$url = $matches[2] == '' ? $matches[3] : $matches[2];
|
||||
$this->urls[$link_id] = $url;
|
||||
|
|
@ -233,7 +233,7 @@ class Markdown {
|
|||
}
|
||||
|
||||
|
||||
function hashHTMLBlocks($text) {
|
||||
protected function hashHTMLBlocks($text) {
|
||||
if ($this->no_markup) return $text;
|
||||
|
||||
$less_than_tab = $this->tab_width - 1;
|
||||
|
|
@ -372,14 +372,14 @@ class Markdown {
|
|||
|
||||
return $text;
|
||||
}
|
||||
function _hashHTMLBlocks_callback($matches) {
|
||||
protected function _hashHTMLBlocks_callback($matches) {
|
||||
$text = $matches[1];
|
||||
$key = $this->hashBlock($text);
|
||||
return "\n\n$key\n\n";
|
||||
}
|
||||
|
||||
|
||||
function hashPart($text, $boundary = 'X') {
|
||||
protected function hashPart($text, $boundary = 'X') {
|
||||
#
|
||||
# Called whenever a tag must be hashed when a function insert an atomic
|
||||
# element in the text stream. Passing $text to through this function gives
|
||||
|
|
@ -402,7 +402,7 @@ class Markdown {
|
|||
}
|
||||
|
||||
|
||||
function hashBlock($text) {
|
||||
protected function hashBlock($text) {
|
||||
#
|
||||
# Shortcut function for hashPart with block-level boundaries.
|
||||
#
|
||||
|
|
@ -410,7 +410,7 @@ class Markdown {
|
|||
}
|
||||
|
||||
|
||||
var $block_gamut = array(
|
||||
protected $block_gamut = array(
|
||||
#
|
||||
# These are all the transformations that form block-level
|
||||
# tags like paragraphs, headers, and list items.
|
||||
|
|
@ -423,7 +423,7 @@ class Markdown {
|
|||
"doBlockQuotes" => 60,
|
||||
);
|
||||
|
||||
function runBlockGamut($text) {
|
||||
protected function runBlockGamut($text) {
|
||||
#
|
||||
# Run block gamut tranformations.
|
||||
#
|
||||
|
|
@ -437,7 +437,7 @@ class Markdown {
|
|||
return $this->runBasicBlockGamut($text);
|
||||
}
|
||||
|
||||
function runBasicBlockGamut($text) {
|
||||
protected function runBasicBlockGamut($text) {
|
||||
#
|
||||
# Run block gamut tranformations, without hashing HTML blocks. This is
|
||||
# useful when HTML blocks are known to be already hashed, like in the first
|
||||
|
|
@ -454,7 +454,7 @@ class Markdown {
|
|||
}
|
||||
|
||||
|
||||
function doHorizontalRules($text) {
|
||||
protected function doHorizontalRules($text) {
|
||||
# Do Horizontal Rules:
|
||||
return preg_replace(
|
||||
'{
|
||||
|
|
@ -472,7 +472,7 @@ class Markdown {
|
|||
}
|
||||
|
||||
|
||||
var $span_gamut = array(
|
||||
protected $span_gamut = array(
|
||||
#
|
||||
# These are all the transformations that occur *within* block-level
|
||||
# tags like paragraphs, headers, and list items.
|
||||
|
|
@ -496,7 +496,7 @@ class Markdown {
|
|||
"doHardBreaks" => 60,
|
||||
);
|
||||
|
||||
function runSpanGamut($text) {
|
||||
protected function runSpanGamut($text) {
|
||||
#
|
||||
# Run span gamut tranformations.
|
||||
#
|
||||
|
|
@ -508,17 +508,17 @@ class Markdown {
|
|||
}
|
||||
|
||||
|
||||
function doHardBreaks($text) {
|
||||
protected function doHardBreaks($text) {
|
||||
# Do hard breaks:
|
||||
return preg_replace_callback('/ {2,}\n/',
|
||||
array(&$this, '_doHardBreaks_callback'), $text);
|
||||
}
|
||||
function _doHardBreaks_callback($matches) {
|
||||
protected function _doHardBreaks_callback($matches) {
|
||||
return $this->hashPart("<br$this->empty_element_suffix\n");
|
||||
}
|
||||
|
||||
|
||||
function doAnchors($text) {
|
||||
protected function doAnchors($text) {
|
||||
#
|
||||
# Turn Markdown link shortcuts into XHTML <a> tags.
|
||||
#
|
||||
|
|
@ -588,7 +588,7 @@ class Markdown {
|
|||
$this->in_anchor = false;
|
||||
return $text;
|
||||
}
|
||||
function _doAnchors_reference_callback($matches) {
|
||||
protected function _doAnchors_reference_callback($matches) {
|
||||
$whole_match = $matches[1];
|
||||
$link_text = $matches[2];
|
||||
$link_id =& $matches[3];
|
||||
|
|
@ -622,7 +622,7 @@ class Markdown {
|
|||
}
|
||||
return $result;
|
||||
}
|
||||
function _doAnchors_inline_callback($matches) {
|
||||
protected function _doAnchors_inline_callback($matches) {
|
||||
$whole_match = $matches[1];
|
||||
$link_text = $this->runSpanGamut($matches[2]);
|
||||
$url = $matches[3] == '' ? $matches[4] : $matches[3];
|
||||
|
|
@ -643,7 +643,7 @@ class Markdown {
|
|||
}
|
||||
|
||||
|
||||
function doImages($text) {
|
||||
protected function doImages($text) {
|
||||
#
|
||||
# Turn Markdown image shortcuts into <img> tags.
|
||||
#
|
||||
|
|
@ -698,7 +698,7 @@ class Markdown {
|
|||
|
||||
return $text;
|
||||
}
|
||||
function _doImages_reference_callback($matches) {
|
||||
protected function _doImages_reference_callback($matches) {
|
||||
$whole_match = $matches[1];
|
||||
$alt_text = $matches[2];
|
||||
$link_id = strtolower($matches[3]);
|
||||
|
|
@ -726,7 +726,7 @@ class Markdown {
|
|||
|
||||
return $result;
|
||||
}
|
||||
function _doImages_inline_callback($matches) {
|
||||
protected function _doImages_inline_callback($matches) {
|
||||
$whole_match = $matches[1];
|
||||
$alt_text = $matches[2];
|
||||
$url = $matches[3] == '' ? $matches[4] : $matches[3];
|
||||
|
|
@ -745,7 +745,7 @@ class Markdown {
|
|||
}
|
||||
|
||||
|
||||
function doHeaders($text) {
|
||||
protected function doHeaders($text) {
|
||||
# Setext-style headers:
|
||||
# Header 1
|
||||
# ========
|
||||
|
|
@ -775,7 +775,7 @@ class Markdown {
|
|||
|
||||
return $text;
|
||||
}
|
||||
function _doHeaders_callback_setext($matches) {
|
||||
protected function _doHeaders_callback_setext($matches) {
|
||||
# Terrible hack to check we haven't found an empty list item.
|
||||
if ($matches[2] == '-' && preg_match('{^-(?: |$)}', $matches[1]))
|
||||
return $matches[0];
|
||||
|
|
@ -784,14 +784,14 @@ class Markdown {
|
|||
$block = "<h$level>".$this->runSpanGamut($matches[1])."</h$level>";
|
||||
return "\n" . $this->hashBlock($block) . "\n\n";
|
||||
}
|
||||
function _doHeaders_callback_atx($matches) {
|
||||
protected function _doHeaders_callback_atx($matches) {
|
||||
$level = strlen($matches[1]);
|
||||
$block = "<h$level>".$this->runSpanGamut($matches[2])."</h$level>";
|
||||
return "\n" . $this->hashBlock($block) . "\n\n";
|
||||
}
|
||||
|
||||
|
||||
function doLists($text) {
|
||||
protected function doLists($text) {
|
||||
#
|
||||
# Form HTML ordered (numbered) and unordered (bulleted) lists.
|
||||
#
|
||||
|
|
@ -857,7 +857,7 @@ class Markdown {
|
|||
|
||||
return $text;
|
||||
}
|
||||
function _doLists_callback($matches) {
|
||||
protected function _doLists_callback($matches) {
|
||||
# Re-usable patterns to match list item bullets and number markers:
|
||||
$marker_ul_re = '[*+-]';
|
||||
$marker_ol_re = '\d+[\.]';
|
||||
|
|
@ -875,9 +875,9 @@ class Markdown {
|
|||
return "\n". $result ."\n\n";
|
||||
}
|
||||
|
||||
var $list_level = 0;
|
||||
protected $list_level = 0;
|
||||
|
||||
function processListItems($list_str, $marker_any_re) {
|
||||
protected function processListItems($list_str, $marker_any_re) {
|
||||
#
|
||||
# Process the contents of a single ordered or unordered list, splitting it
|
||||
# into individual list items.
|
||||
|
|
@ -923,7 +923,7 @@ class Markdown {
|
|||
$this->list_level--;
|
||||
return $list_str;
|
||||
}
|
||||
function _processListItems_callback($matches) {
|
||||
protected function _processListItems_callback($matches) {
|
||||
$item = $matches[4];
|
||||
$leading_line =& $matches[1];
|
||||
$leading_space =& $matches[2];
|
||||
|
|
@ -948,7 +948,7 @@ class Markdown {
|
|||
}
|
||||
|
||||
|
||||
function doCodeBlocks($text) {
|
||||
protected function doCodeBlocks($text) {
|
||||
#
|
||||
# Process Markdown `<pre><code>` blocks.
|
||||
#
|
||||
|
|
@ -966,7 +966,7 @@ class Markdown {
|
|||
|
||||
return $text;
|
||||
}
|
||||
function _doCodeBlocks_callback($matches) {
|
||||
protected function _doCodeBlocks_callback($matches) {
|
||||
$codeblock = $matches[1];
|
||||
|
||||
$codeblock = $this->outdent($codeblock);
|
||||
|
|
@ -980,7 +980,7 @@ class Markdown {
|
|||
}
|
||||
|
||||
|
||||
function makeCodeSpan($code) {
|
||||
protected function makeCodeSpan($code) {
|
||||
#
|
||||
# Create a code span markup for $code. Called from handleSpanToken.
|
||||
#
|
||||
|
|
@ -989,24 +989,24 @@ class Markdown {
|
|||
}
|
||||
|
||||
|
||||
var $em_relist = array(
|
||||
protected $em_relist = array(
|
||||
'' => '(?:(?<!\*)\*(?!\*)|(?<!_)_(?!_))(?=\S|$)(?![\.,:;]\s)',
|
||||
'*' => '(?<=\S|^)(?<!\*)\*(?!\*)',
|
||||
'_' => '(?<=\S|^)(?<!_)_(?!_)',
|
||||
);
|
||||
var $strong_relist = array(
|
||||
protected $strong_relist = array(
|
||||
'' => '(?:(?<!\*)\*\*(?!\*)|(?<!_)__(?!_))(?=\S|$)(?![\.,:;]\s)',
|
||||
'**' => '(?<=\S|^)(?<!\*)\*\*(?!\*)',
|
||||
'__' => '(?<=\S|^)(?<!_)__(?!_)',
|
||||
);
|
||||
var $em_strong_relist = array(
|
||||
protected $em_strong_relist = array(
|
||||
'' => '(?:(?<!\*)\*\*\*(?!\*)|(?<!_)___(?!_))(?=\S|$)(?![\.,:;]\s)',
|
||||
'***' => '(?<=\S|^)(?<!\*)\*\*\*(?!\*)',
|
||||
'___' => '(?<=\S|^)(?<!_)___(?!_)',
|
||||
);
|
||||
var $em_strong_prepared_relist;
|
||||
protected $em_strong_prepared_relist;
|
||||
|
||||
function prepareItalicsAndBold() {
|
||||
protected function prepareItalicsAndBold() {
|
||||
#
|
||||
# Prepare regular expressions for searching emphasis tokens in any
|
||||
# context.
|
||||
|
|
@ -1028,7 +1028,7 @@ class Markdown {
|
|||
}
|
||||
}
|
||||
|
||||
function doItalicsAndBold($text) {
|
||||
protected function doItalicsAndBold($text) {
|
||||
$token_stack = array('');
|
||||
$text_stack = array('');
|
||||
$em = '';
|
||||
|
|
@ -1151,7 +1151,7 @@ class Markdown {
|
|||
}
|
||||
|
||||
|
||||
function doBlockQuotes($text) {
|
||||
protected function doBlockQuotes($text) {
|
||||
$text = preg_replace_callback('/
|
||||
( # Wrap whole match in $1
|
||||
(?>
|
||||
|
|
@ -1166,7 +1166,7 @@ class Markdown {
|
|||
|
||||
return $text;
|
||||
}
|
||||
function _doBlockQuotes_callback($matches) {
|
||||
protected function _doBlockQuotes_callback($matches) {
|
||||
$bq = $matches[1];
|
||||
# trim one level of quoting - trim whitespace-only lines
|
||||
$bq = preg_replace('/^[ ]*>[ ]?|^[ ]+$/m', '', $bq);
|
||||
|
|
@ -1180,14 +1180,14 @@ class Markdown {
|
|||
|
||||
return "\n". $this->hashBlock("<blockquote>\n$bq\n</blockquote>")."\n\n";
|
||||
}
|
||||
function _doBlockQuotes_callback2($matches) {
|
||||
protected function _doBlockQuotes_callback2($matches) {
|
||||
$pre = $matches[1];
|
||||
$pre = preg_replace('/^ /m', '', $pre);
|
||||
return $pre;
|
||||
}
|
||||
|
||||
|
||||
function formParagraphs($text) {
|
||||
protected function formParagraphs($text) {
|
||||
#
|
||||
# Params:
|
||||
# $text - string to process with html <p> tags
|
||||
|
|
@ -1257,7 +1257,7 @@ class Markdown {
|
|||
}
|
||||
|
||||
|
||||
function encodeAttribute($text) {
|
||||
protected function encodeAttribute($text) {
|
||||
#
|
||||
# Encode text for a double-quoted HTML attribute. This function
|
||||
# is *not* suitable for attributes enclosed in single quotes.
|
||||
|
|
@ -1268,7 +1268,7 @@ class Markdown {
|
|||
}
|
||||
|
||||
|
||||
function encodeAmpsAndAngles($text) {
|
||||
protected function encodeAmpsAndAngles($text) {
|
||||
#
|
||||
# Smart processing for ampersands and angle brackets that need to
|
||||
# be encoded. Valid character entities are left alone unless the
|
||||
|
|
@ -1289,7 +1289,7 @@ class Markdown {
|
|||
}
|
||||
|
||||
|
||||
function doAutoLinks($text) {
|
||||
protected function doAutoLinks($text) {
|
||||
$text = preg_replace_callback('{<((https?|ftp|dict):[^\'">\s]+)>}i',
|
||||
array(&$this, '_doAutoLinks_url_callback'), $text);
|
||||
|
||||
|
|
@ -1316,19 +1316,19 @@ class Markdown {
|
|||
|
||||
return $text;
|
||||
}
|
||||
function _doAutoLinks_url_callback($matches) {
|
||||
protected function _doAutoLinks_url_callback($matches) {
|
||||
$url = $this->encodeAttribute($matches[1]);
|
||||
$link = "<a href=\"$url\">$url</a>";
|
||||
return $this->hashPart($link);
|
||||
}
|
||||
function _doAutoLinks_email_callback($matches) {
|
||||
protected function _doAutoLinks_email_callback($matches) {
|
||||
$address = $matches[1];
|
||||
$link = $this->encodeEmailAddress($address);
|
||||
return $this->hashPart($link);
|
||||
}
|
||||
|
||||
|
||||
function encodeEmailAddress($addr) {
|
||||
protected function encodeEmailAddress($addr) {
|
||||
#
|
||||
# Input: an email address, e.g. "foo@example.com"
|
||||
#
|
||||
|
|
@ -1369,7 +1369,7 @@ class Markdown {
|
|||
}
|
||||
|
||||
|
||||
function parseSpan($str) {
|
||||
protected function parseSpan($str) {
|
||||
#
|
||||
# Take the string $str and parse it into tokens, hashing embeded HTML,
|
||||
# escaped characters and handling code spans.
|
||||
|
|
@ -1429,7 +1429,7 @@ class Markdown {
|
|||
}
|
||||
|
||||
|
||||
function handleSpanToken($token, &$str) {
|
||||
protected function handleSpanToken($token, &$str) {
|
||||
#
|
||||
# Handle $token provided by parseSpan by determining its nature and
|
||||
# returning the corresponding value that should replace it.
|
||||
|
|
@ -1453,7 +1453,7 @@ class Markdown {
|
|||
}
|
||||
|
||||
|
||||
function outdent($text) {
|
||||
protected function outdent($text) {
|
||||
#
|
||||
# Remove one level of line-leading tabs or spaces
|
||||
#
|
||||
|
|
@ -1463,9 +1463,9 @@ class Markdown {
|
|||
|
||||
# String length function for detab. `_initDetab` will create a function to
|
||||
# hanlde UTF-8 if the default function does not exist.
|
||||
var $utf8_strlen = 'mb_strlen';
|
||||
protected $utf8_strlen = 'mb_strlen';
|
||||
|
||||
function detab($text) {
|
||||
protected function detab($text) {
|
||||
#
|
||||
# Replace tabs with the appropriate amount of space.
|
||||
#
|
||||
|
|
@ -1478,7 +1478,7 @@ class Markdown {
|
|||
|
||||
return $text;
|
||||
}
|
||||
function _detab_callback($matches) {
|
||||
protected function _detab_callback($matches) {
|
||||
$line = $matches[0];
|
||||
$strlen = $this->utf8_strlen; # strlen function for UTF-8.
|
||||
|
||||
|
|
@ -1495,7 +1495,7 @@ class Markdown {
|
|||
}
|
||||
return $line;
|
||||
}
|
||||
function _initDetab() {
|
||||
protected function _initDetab() {
|
||||
#
|
||||
# Check for the availability of the function in the `utf8_strlen` property
|
||||
# (initially `mb_strlen`). If the function is not available, create a
|
||||
|
|
@ -1509,14 +1509,14 @@ class Markdown {
|
|||
}
|
||||
|
||||
|
||||
function unhash($text) {
|
||||
protected function unhash($text) {
|
||||
#
|
||||
# Swap back in all the tags hashed by _HashHTMLBlocks.
|
||||
#
|
||||
return preg_replace_callback('/(.)\x1A[0-9]+\1/',
|
||||
array(&$this, '_unhash_callback'), $text);
|
||||
}
|
||||
function _unhash_callback($matches) {
|
||||
protected function _unhash_callback($matches) {
|
||||
return $this->html_hashes[$matches[0]];
|
||||
}
|
||||
|
||||
|
|
@ -1540,34 +1540,34 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
### Configuration Variables ###
|
||||
|
||||
# Prefix for footnote ids.
|
||||
var $fn_id_prefix = "";
|
||||
public $fn_id_prefix = "";
|
||||
|
||||
# Optional title attribute for footnote links and backlinks.
|
||||
var $fn_link_title = "";
|
||||
var $fn_backlink_title = "";
|
||||
public $fn_link_title = "";
|
||||
public $fn_backlink_title = "";
|
||||
|
||||
# Optional class attribute for footnote links and backlinks.
|
||||
var $fn_link_class = "footnote-ref";
|
||||
var $fn_backlink_class = "footnote-backref";
|
||||
public $fn_link_class = "footnote-ref";
|
||||
public $fn_backlink_class = "footnote-backref";
|
||||
|
||||
# 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.
|
||||
var $table_align_class_tmpl = '';
|
||||
public $table_align_class_tmpl = '';
|
||||
|
||||
# Optional class prefix for fenced code block.
|
||||
var $code_class_prefix = "";
|
||||
public $code_class_prefix = "";
|
||||
# Class attribute for code blocks goes on the `code` tag;
|
||||
# setting this to true will put attributes on the `pre` tag instead.
|
||||
var $code_attr_on_pre = false;
|
||||
public $code_attr_on_pre = false;
|
||||
|
||||
# Predefined abbreviations.
|
||||
var $predef_abbr = array();
|
||||
public $predef_abbr = array();
|
||||
|
||||
|
||||
### Parser Implementation ###
|
||||
|
||||
function __construct() {
|
||||
public function __construct() {
|
||||
#
|
||||
# Constructor function. Initialize the parser object.
|
||||
#
|
||||
|
|
@ -1598,18 +1598,18 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
|
||||
|
||||
# Extra variables used during extra transformations.
|
||||
var $footnotes = array();
|
||||
var $footnotes_ordered = array();
|
||||
var $footnotes_ref_count = array();
|
||||
var $footnotes_numbers = array();
|
||||
var $abbr_desciptions = array();
|
||||
var $abbr_word_re = '';
|
||||
protected $footnotes = array();
|
||||
protected $footnotes_ordered = array();
|
||||
protected $footnotes_ref_count = array();
|
||||
protected $footnotes_numbers = array();
|
||||
protected $abbr_desciptions = array();
|
||||
protected $abbr_word_re = '';
|
||||
|
||||
# Give the current footnote number.
|
||||
var $footnote_counter = 1;
|
||||
protected $footnote_counter = 1;
|
||||
|
||||
|
||||
function setup() {
|
||||
protected function setup() {
|
||||
#
|
||||
# Setting up Extra-specific variables.
|
||||
#
|
||||
|
|
@ -1631,7 +1631,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
}
|
||||
}
|
||||
|
||||
function teardown() {
|
||||
protected function teardown() {
|
||||
#
|
||||
# Clearing Extra-specific variables.
|
||||
#
|
||||
|
|
@ -1649,11 +1649,11 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
### Extra Attribute Parser ###
|
||||
|
||||
# Expression to use to catch attributes (includes the braces)
|
||||
var $id_class_attr_catch_re = '\{((?:[ ]*[#.][-_:a-zA-Z0-9]+){1,})[ ]*\}';
|
||||
protected $id_class_attr_catch_re = '\{((?:[ ]*[#.][-_:a-zA-Z0-9]+){1,})[ ]*\}';
|
||||
# Expression to use when parsing in a context when no capture is desired
|
||||
var $id_class_attr_nocatch_re = '\{(?:[ ]*[#.][-_:a-zA-Z0-9]+){1,}[ ]*\}';
|
||||
protected $id_class_attr_nocatch_re = '\{(?:[ ]*[#.][-_:a-zA-Z0-9]+){1,}[ ]*\}';
|
||||
|
||||
function doExtraAttributes($tag_name, $attr) {
|
||||
protected function doExtraAttributes($tag_name, $attr) {
|
||||
#
|
||||
# Parse attributes caught by the $this->id_class_attr_catch_re expression
|
||||
# and return the HTML-formatted list of attributes.
|
||||
|
|
@ -1689,7 +1689,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
}
|
||||
|
||||
|
||||
function stripLinkDefinitions($text) {
|
||||
protected function stripLinkDefinitions($text) {
|
||||
#
|
||||
# Strips link definitions from text, stores the URLs and titles in
|
||||
# hash references.
|
||||
|
|
@ -1724,7 +1724,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
$text);
|
||||
return $text;
|
||||
}
|
||||
function _stripLinkDefinitions_callback($matches) {
|
||||
protected function _stripLinkDefinitions_callback($matches) {
|
||||
$link_id = strtolower($matches[1]);
|
||||
$url = $matches[2] == '' ? $matches[3] : $matches[2];
|
||||
$this->urls[$link_id] = $url;
|
||||
|
|
@ -1737,23 +1737,23 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
### HTML Block Parser ###
|
||||
|
||||
# Tags that are always treated as block tags:
|
||||
var $block_tags_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|form|fieldset|iframe|hr|legend|article|section|nav|aside|hgroup|header|footer|figcaption';
|
||||
protected $block_tags_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|form|fieldset|iframe|hr|legend|article|section|nav|aside|hgroup|header|footer|figcaption';
|
||||
|
||||
# Tags treated as block tags only if the opening tag is alone on its line:
|
||||
var $context_block_tags_re = 'script|noscript|ins|del|iframe|object|source|track|param|math|svg|canvas|audio|video';
|
||||
protected $context_block_tags_re = 'script|noscript|ins|del|iframe|object|source|track|param|math|svg|canvas|audio|video';
|
||||
|
||||
# Tags where markdown="1" default to span mode:
|
||||
var $contain_span_tags_re = 'p|h[1-6]|li|dd|dt|td|th|legend|address';
|
||||
protected $contain_span_tags_re = 'p|h[1-6]|li|dd|dt|td|th|legend|address';
|
||||
|
||||
# Tags which must not have their contents modified, no matter where
|
||||
# they appear:
|
||||
var $clean_tags_re = 'script|math|svg';
|
||||
protected $clean_tags_re = 'script|math|svg';
|
||||
|
||||
# Tags that do not need to be closed.
|
||||
var $auto_close_tags_re = 'hr|img|param|source|track';
|
||||
protected $auto_close_tags_re = 'hr|img|param|source|track';
|
||||
|
||||
|
||||
function hashHTMLBlocks($text) {
|
||||
protected function hashHTMLBlocks($text) {
|
||||
#
|
||||
# Hashify HTML Blocks and "clean tags".
|
||||
#
|
||||
|
|
@ -1778,7 +1778,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
|
||||
return $text;
|
||||
}
|
||||
function _hashHTMLBlocks_inMarkdown($text, $indent = 0,
|
||||
protected function _hashHTMLBlocks_inMarkdown($text, $indent = 0,
|
||||
$enclosing_tag_re = '', $span = false)
|
||||
{
|
||||
#
|
||||
|
|
@ -2016,7 +2016,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
|
||||
return array($parsed, $text);
|
||||
}
|
||||
function _hashHTMLBlocks_inHTML($text, $hash_method, $md_attr) {
|
||||
protected function _hashHTMLBlocks_inHTML($text, $hash_method, $md_attr) {
|
||||
#
|
||||
# Parse HTML, calling _HashHTMLBlocks_InMarkdown for block tags.
|
||||
#
|
||||
|
|
@ -2191,7 +2191,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
}
|
||||
|
||||
|
||||
function hashClean($text) {
|
||||
protected function hashClean($text) {
|
||||
#
|
||||
# Called whenever a tag must be hashed when a function inserts a "clean" tag
|
||||
# in $text, it passes through this function and is automaticaly escaped,
|
||||
|
|
@ -2201,7 +2201,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
}
|
||||
|
||||
|
||||
function doAnchors($text) {
|
||||
protected function doAnchors($text) {
|
||||
#
|
||||
# Turn Markdown link shortcuts into XHTML <a> tags.
|
||||
#
|
||||
|
|
@ -2272,7 +2272,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
$this->in_anchor = false;
|
||||
return $text;
|
||||
}
|
||||
function _doAnchors_reference_callback($matches) {
|
||||
protected function _doAnchors_reference_callback($matches) {
|
||||
$whole_match = $matches[1];
|
||||
$link_text = $matches[2];
|
||||
$link_id =& $matches[3];
|
||||
|
|
@ -2308,7 +2308,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
}
|
||||
return $result;
|
||||
}
|
||||
function _doAnchors_inline_callback($matches) {
|
||||
protected function _doAnchors_inline_callback($matches) {
|
||||
$whole_match = $matches[1];
|
||||
$link_text = $this->runSpanGamut($matches[2]);
|
||||
$url = $matches[3] == '' ? $matches[4] : $matches[3];
|
||||
|
|
@ -2332,7 +2332,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
}
|
||||
|
||||
|
||||
function doImages($text) {
|
||||
protected function doImages($text) {
|
||||
#
|
||||
# Turn Markdown image shortcuts into <img> tags.
|
||||
#
|
||||
|
|
@ -2388,7 +2388,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
|
||||
return $text;
|
||||
}
|
||||
function _doImages_reference_callback($matches) {
|
||||
protected function _doImages_reference_callback($matches) {
|
||||
$whole_match = $matches[1];
|
||||
$alt_text = $matches[2];
|
||||
$link_id = strtolower($matches[3]);
|
||||
|
|
@ -2418,7 +2418,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
|
||||
return $result;
|
||||
}
|
||||
function _doImages_inline_callback($matches) {
|
||||
protected function _doImages_inline_callback($matches) {
|
||||
$whole_match = $matches[1];
|
||||
$alt_text = $matches[2];
|
||||
$url = $matches[3] == '' ? $matches[4] : $matches[3];
|
||||
|
|
@ -2439,7 +2439,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
}
|
||||
|
||||
|
||||
function doHeaders($text) {
|
||||
protected function doHeaders($text) {
|
||||
#
|
||||
# Redefined to add id and class attribute support.
|
||||
#
|
||||
|
|
@ -2479,7 +2479,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
|
||||
return $text;
|
||||
}
|
||||
function _doHeaders_callback_setext($matches) {
|
||||
protected function _doHeaders_callback_setext($matches) {
|
||||
if ($matches[3] == '-' && preg_match('{^- }', $matches[1]))
|
||||
return $matches[0];
|
||||
$level = $matches[3]{0} == '=' ? 1 : 2;
|
||||
|
|
@ -2487,7 +2487,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
$block = "<h$level$attr>".$this->runSpanGamut($matches[1])."</h$level>";
|
||||
return "\n" . $this->hashBlock($block) . "\n\n";
|
||||
}
|
||||
function _doHeaders_callback_atx($matches) {
|
||||
protected function _doHeaders_callback_atx($matches) {
|
||||
$level = strlen($matches[1]);
|
||||
$attr = $this->doExtraAttributes("h$level", $dummy =& $matches[3]);
|
||||
$block = "<h$level$attr>".$this->runSpanGamut($matches[2])."</h$level>";
|
||||
|
|
@ -2495,7 +2495,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
}
|
||||
|
||||
|
||||
function doTables($text) {
|
||||
protected function doTables($text) {
|
||||
#
|
||||
# Form HTML tables.
|
||||
#
|
||||
|
|
@ -2556,7 +2556,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
|
||||
return $text;
|
||||
}
|
||||
function _doTable_leadingPipe_callback($matches) {
|
||||
protected function _doTable_leadingPipe_callback($matches) {
|
||||
$head = $matches[1];
|
||||
$underline = $matches[2];
|
||||
$content = $matches[3];
|
||||
|
|
@ -2566,7 +2566,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
|
||||
return $this->_doTable_callback(array($matches[0], $head, $underline, $content));
|
||||
}
|
||||
function _doTable_makeAlignAttr($alignname)
|
||||
protected function _doTable_makeAlignAttr($alignname)
|
||||
{
|
||||
if (empty($this->table_align_class_tmpl))
|
||||
return " align=\"$alignname\"";
|
||||
|
|
@ -2574,7 +2574,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
$classname = str_replace('%%', $alignname, $this->table_align_class_tmpl);
|
||||
return " class=\"$classname\"";
|
||||
}
|
||||
function _doTable_callback($matches) {
|
||||
protected function _doTable_callback($matches) {
|
||||
$head = $matches[1];
|
||||
$underline = $matches[2];
|
||||
$content = $matches[3];
|
||||
|
|
@ -2638,7 +2638,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
}
|
||||
|
||||
|
||||
function doDefLists($text) {
|
||||
protected function doDefLists($text) {
|
||||
#
|
||||
# Form HTML definition lists.
|
||||
#
|
||||
|
|
@ -2680,7 +2680,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
|
||||
return $text;
|
||||
}
|
||||
function _doDefLists_callback($matches) {
|
||||
protected function _doDefLists_callback($matches) {
|
||||
# Re-usable patterns to match list item bullets and number markers:
|
||||
$list = $matches[1];
|
||||
|
||||
|
|
@ -2692,7 +2692,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
}
|
||||
|
||||
|
||||
function processDefListItems($list_str) {
|
||||
protected function processDefListItems($list_str) {
|
||||
#
|
||||
# Process the contents of a single definition list, splitting it
|
||||
# into individual term and definition list items.
|
||||
|
|
@ -2735,7 +2735,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
|
||||
return $list_str;
|
||||
}
|
||||
function _processDefListItems_callback_dt($matches) {
|
||||
protected function _processDefListItems_callback_dt($matches) {
|
||||
$terms = explode("\n", trim($matches[1]));
|
||||
$text = '';
|
||||
foreach ($terms as $term) {
|
||||
|
|
@ -2744,7 +2744,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
}
|
||||
return $text . "\n";
|
||||
}
|
||||
function _processDefListItems_callback_dd($matches) {
|
||||
protected function _processDefListItems_callback_dd($matches) {
|
||||
$leading_line = $matches[1];
|
||||
$marker_space = $matches[2];
|
||||
$def = $matches[3];
|
||||
|
|
@ -2764,7 +2764,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
}
|
||||
|
||||
|
||||
function doFencedCodeBlocks($text) {
|
||||
protected function doFencedCodeBlocks($text) {
|
||||
#
|
||||
# Adding the fenced code block syntax to regular Markdown:
|
||||
#
|
||||
|
|
@ -2803,7 +2803,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
|
||||
return $text;
|
||||
}
|
||||
function _doFencedCodeBlocks_callback($matches) {
|
||||
protected function _doFencedCodeBlocks_callback($matches) {
|
||||
$classname =& $matches[2];
|
||||
$attrs =& $matches[3];
|
||||
$codeblock = $matches[4];
|
||||
|
|
@ -2824,7 +2824,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
|
||||
return "\n\n".$this->hashBlock($codeblock)."\n\n";
|
||||
}
|
||||
function _doFencedCodeBlocks_newlines($matches) {
|
||||
protected function _doFencedCodeBlocks_newlines($matches) {
|
||||
return str_repeat("<br$this->empty_element_suffix",
|
||||
strlen($matches[0]));
|
||||
}
|
||||
|
|
@ -2834,24 +2834,24 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
# Redefining emphasis markers so that emphasis by underscore does not
|
||||
# work in the middle of a word.
|
||||
#
|
||||
var $em_relist = array(
|
||||
protected $em_relist = array(
|
||||
'' => '(?:(?<!\*)\*(?!\*)|(?<![a-zA-Z0-9_])_(?!_))(?=\S|$)(?![\.,:;]\s)',
|
||||
'*' => '(?<=\S|^)(?<!\*)\*(?!\*)',
|
||||
'_' => '(?<=\S|^)(?<!_)_(?![a-zA-Z0-9_])',
|
||||
);
|
||||
var $strong_relist = array(
|
||||
protected $strong_relist = array(
|
||||
'' => '(?:(?<!\*)\*\*(?!\*)|(?<![a-zA-Z0-9_])__(?!_))(?=\S|$)(?![\.,:;]\s)',
|
||||
'**' => '(?<=\S|^)(?<!\*)\*\*(?!\*)',
|
||||
'__' => '(?<=\S|^)(?<!_)__(?![a-zA-Z0-9_])',
|
||||
);
|
||||
var $em_strong_relist = array(
|
||||
protected $em_strong_relist = array(
|
||||
'' => '(?:(?<!\*)\*\*\*(?!\*)|(?<![a-zA-Z0-9_])___(?!_))(?=\S|$)(?![\.,:;]\s)',
|
||||
'***' => '(?<=\S|^)(?<!\*)\*\*\*(?!\*)',
|
||||
'___' => '(?<=\S|^)(?<!_)___(?![a-zA-Z0-9_])',
|
||||
);
|
||||
|
||||
|
||||
function formParagraphs($text) {
|
||||
protected function formParagraphs($text) {
|
||||
#
|
||||
# Params:
|
||||
# $text - string to process with html <p> tags
|
||||
|
|
@ -2889,7 +2889,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
|
||||
### Footnotes
|
||||
|
||||
function stripFootnotes($text) {
|
||||
protected function stripFootnotes($text) {
|
||||
#
|
||||
# Strips link definitions from text, stores the URLs and titles in
|
||||
# hash references.
|
||||
|
|
@ -2916,14 +2916,14 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
$text);
|
||||
return $text;
|
||||
}
|
||||
function _stripFootnotes_callback($matches) {
|
||||
protected function _stripFootnotes_callback($matches) {
|
||||
$note_id = $this->fn_id_prefix . $matches[1];
|
||||
$this->footnotes[$note_id] = $this->outdent($matches[2]);
|
||||
return ''; # String that will replace the block
|
||||
}
|
||||
|
||||
|
||||
function doFootnotes($text) {
|
||||
protected function doFootnotes($text) {
|
||||
#
|
||||
# Replace footnote references in $text [^id] with a special text-token
|
||||
# which will be replaced by the actual footnote marker in appendFootnotes.
|
||||
|
|
@ -2935,7 +2935,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
}
|
||||
|
||||
|
||||
function appendFootnotes($text) {
|
||||
protected function appendFootnotes($text) {
|
||||
#
|
||||
# Append footnote list to text.
|
||||
#
|
||||
|
|
@ -2999,7 +2999,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
}
|
||||
return $text;
|
||||
}
|
||||
function _appendFootnotes_callback($matches) {
|
||||
protected function _appendFootnotes_callback($matches) {
|
||||
$node_id = $this->fn_id_prefix . $matches[1];
|
||||
|
||||
# Create footnote marker only if it has a corresponding footnote *and*
|
||||
|
|
@ -3043,7 +3043,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
|
||||
### Abbreviations ###
|
||||
|
||||
function stripAbbreviations($text) {
|
||||
protected function stripAbbreviations($text) {
|
||||
#
|
||||
# Strips abbreviations from text, stores titles in hash references.
|
||||
#
|
||||
|
|
@ -3058,7 +3058,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
$text);
|
||||
return $text;
|
||||
}
|
||||
function _stripAbbreviations_callback($matches) {
|
||||
protected function _stripAbbreviations_callback($matches) {
|
||||
$abbr_word = $matches[1];
|
||||
$abbr_desc = $matches[2];
|
||||
if ($this->abbr_word_re)
|
||||
|
|
@ -3069,7 +3069,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
}
|
||||
|
||||
|
||||
function doAbbreviations($text) {
|
||||
protected function doAbbreviations($text) {
|
||||
#
|
||||
# Find defined abbreviations in text and wrap them in <abbr> elements.
|
||||
#
|
||||
|
|
@ -3085,7 +3085,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
|
|||
}
|
||||
return $text;
|
||||
}
|
||||
function _doAbbreviations_callback($matches) {
|
||||
protected function _doAbbreviations_callback($matches) {
|
||||
$abbr = $matches[0];
|
||||
if (isset($this->abbr_desciptions[$abbr])) {
|
||||
$desc = $this->abbr_desciptions[$abbr];
|
||||
|
|
|
|||
67
Readme.md
67
Readme.md
|
|
@ -33,8 +33,8 @@ Full documentation of Markdown's syntax is available on John's
|
|||
Markdown page: <http://daringfireball.net/projects/markdown/>
|
||||
|
||||
|
||||
Installation and Requirement
|
||||
----------------------------
|
||||
Requirement
|
||||
-----------
|
||||
|
||||
This library package requires PHP 5.3 or later.
|
||||
|
||||
|
|
@ -49,29 +49,35 @@ releases defaults to 1 000 000, which is usually fine.
|
|||
Usage
|
||||
-----
|
||||
|
||||
You can use PHP Markdown easily in your PHP program. This library package
|
||||
is meant to be used with autoloading, so putting the 'Michelf' folder
|
||||
in your include path should be enough for this to work:
|
||||
This library package is meant to be used with class autoloading. For autoloading
|
||||
to work, your project needs have setup a PSR-0-compatible autoloader. See the
|
||||
included Readme.php file for a minimal autoloader setup. (If you don't want to
|
||||
use autoloading you can do a classic `require_once` to manually include the
|
||||
files prior use instead.)
|
||||
|
||||
With class autoloading in place, putting the 'Michelf' folder in your
|
||||
include path should be enough for this to work:
|
||||
|
||||
use \Michelf\Markdown;
|
||||
$my_html = Markdown::defaultTransform($my_text);
|
||||
|
||||
PHP Markdown Extra is also available the same way:
|
||||
Markdown Extra syntax is also available the same way:
|
||||
|
||||
use \Michelf\MarkdownExtra;
|
||||
$my_html = MarkdownExtra::defaultTransform($my_text);
|
||||
|
||||
If you wish to use PHP Markdown with another text filter function
|
||||
built to parse HTML, you should filter the text *after* the Markdown
|
||||
built to parse HTML, you should filter the text *after* the `transform`
|
||||
function call. This is an example with [PHP SmartyPants][psp]:
|
||||
|
||||
use \Michelf\Markdown, \Michelf\SmartyPants;
|
||||
$my_html = Markdown::defaultTransform($my_text);
|
||||
$my_html = SmartyPants::defaultTransform($my_html);
|
||||
|
||||
All these examples are using the static `markdown` function found inside the
|
||||
parser class. If you want to customize the parser, you can also instantiate
|
||||
it directly and change some configuration variables:
|
||||
All these examples are using the static `defaultTransform` static function
|
||||
found inside the parser class. If you want to customize the parser
|
||||
configuration, you can also instantiate it directly and change some
|
||||
configuration variables:
|
||||
|
||||
use \Michelf\MarkdownExtra;
|
||||
$parser = new MarkdownExtra;
|
||||
|
|
@ -95,6 +101,35 @@ To do this, you must set the `empty_element_suffix` variable of the parser
|
|||
object to ">".
|
||||
|
||||
|
||||
Public API and Versionning Policy
|
||||
---------------------------------
|
||||
|
||||
Version numbers are of the form *major*.*minor*.*patch*.
|
||||
|
||||
The public API of PHP Markdown consist of the two parser classes `Markdown`
|
||||
and `MarkdownExtra`, their constructors, the `transform` and `defaultTransform`
|
||||
functions and their configuration variables. The public API is stable for
|
||||
a given major version number. It might get additions when the minor version
|
||||
number increments.
|
||||
|
||||
**Protected members are not considered public API.** This is unconventionnal
|
||||
and deserves an explanation. Incrementing the major version number every time
|
||||
the underlying implementation of something changes is going to give nonsential
|
||||
version numbers for the vast majority of people who just use the parser.
|
||||
Protected members are meant to create parser subclasses that behave in
|
||||
different ways. Very few people create parser subclasses. I don't want to
|
||||
discourage it by making everything private, but at the same time I can't
|
||||
guarenty any stable hook between versions if you use protected members.
|
||||
|
||||
**Syntax changes** will increment the minor number for new features, and the
|
||||
patch number for small corrections. A *new feature* is something that needs a
|
||||
change in the syntax documentation. Note that since PHP Markdown Lib includes
|
||||
two parsers, a syntax change for either of them will increment the minor
|
||||
number. Also note that there is nothigng perfectly backward-compatible with the
|
||||
Markdown syntax: all inputs are always valid, so new features always replace
|
||||
something that was previously legal, although generally non-sensial to do.
|
||||
|
||||
|
||||
Bugs
|
||||
----
|
||||
|
||||
|
|
@ -114,12 +149,13 @@ Version History
|
|||
|
||||
Current Lib:
|
||||
|
||||
* Added `public` and `protected` protection attributes, plus a section about
|
||||
what is "public API" and what isn't in the Readme.
|
||||
|
||||
* Changed HTML output for footnotes: now instead of adding `rel` and `rev`
|
||||
attributes, footnotes links have the class name `footnote-ref` and
|
||||
backlinks `footnote-backref`. (This change only affect Lib branch.)
|
||||
|
||||
* Corrected namespace capitalization in composer package definition file.
|
||||
|
||||
|
||||
Current Extra:
|
||||
|
||||
|
|
@ -141,6 +177,11 @@ Current Extra:
|
|||
markers are missing on the separator line below column headers.
|
||||
|
||||
|
||||
Lib 1.3-beta5 (3 Feb 2013):
|
||||
|
||||
* Corrected namespace capitalization in composer package definition file.
|
||||
|
||||
|
||||
Lib 1.3-beta4 (21 Jan 2013):
|
||||
|
||||
* Changed namespace name from michelf (lowercase) to Michelf (capitalized).
|
||||
|
|
@ -154,6 +195,8 @@ Lib 1.3-beta2 (14 Jan 2013):
|
|||
* Fixed missing autoloading information for composer.
|
||||
|
||||
|
||||
Lib 1.3-beta1 (13 Jan 2013):
|
||||
|
||||
Extra 1.2.6 (13 Jan 2013):
|
||||
|
||||
* Headers can now have a class attribute. You can add a class inside the
|
||||
|
|
|
|||
Loading…
Reference in a new issue