Added protection attributes.

This commit is contained in:
Michel Fortin 2013-02-07 08:25:02 -05:00
parent a4004737d1
commit 7b88cf4d4c
2 changed files with 141 additions and 138 deletions

View file

@ -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.
@ -1692,23 +1692,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".
#
@ -1733,7 +1733,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)
{
#
@ -1971,7 +1971,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.
#
@ -2146,7 +2146,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,
@ -2156,7 +2156,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
}
function doHeaders($text) {
protected function doHeaders($text) {
#
# Redefined to add id and class attribute support.
#
@ -2196,7 +2196,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;
@ -2204,7 +2204,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>";
@ -2212,7 +2212,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
}
function doTables($text) {
protected function doTables($text) {
#
# Form HTML tables.
#
@ -2273,7 +2273,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];
@ -2283,7 +2283,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\"";
@ -2291,7 +2291,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];
@ -2354,7 +2354,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
}
function doDefLists($text) {
protected function doDefLists($text) {
#
# Form HTML definition lists.
#
@ -2396,7 +2396,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];
@ -2408,7 +2408,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.
@ -2451,7 +2451,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) {
@ -2460,7 +2460,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];
@ -2480,7 +2480,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
}
function doFencedCodeBlocks($text) {
protected function doFencedCodeBlocks($text) {
#
# Adding the fenced code block syntax to regular Markdown:
#
@ -2519,7 +2519,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];
@ -2540,7 +2540,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]));
}
@ -2550,24 +2550,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
@ -2605,7 +2605,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.
@ -2632,14 +2632,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.
@ -2651,7 +2651,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
}
function appendFootnotes($text) {
protected function appendFootnotes($text) {
#
# Append footnote list to text.
#
@ -2715,7 +2715,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*
@ -2759,7 +2759,7 @@ class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
### Abbreviations ###
function stripAbbreviations($text) {
protected function stripAbbreviations($text) {
#
# Strips abbreviations from text, stores titles in hash references.
#
@ -2774,7 +2774,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)
@ -2785,7 +2785,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.
#
@ -2801,7 +2801,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];

View file

@ -114,6 +114,9 @@ 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.)