` 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|^)(? '(?:(? '(?<=\S|^)(? '(?<=\S|^)(?
@@ -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("\n$bq\n
")."\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 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 = "$url";
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 = "".$this->runSpanGamut($matches[1])." ";
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 = "".$this->runSpanGamut($matches[2])." ";
@@ -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("
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(
'' => '(?:(? '(?<=\S|^)(? '(?<=\S|^)(? '(?:(? '(?<=\S|^)(? '(?<=\S|^)(? '(?:(? '(?<=\S|^)(? '(?<=\S|^)(? 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 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];
diff --git a/Readme.md b/Readme.md
index dd1f664..aa15829 100644
--- a/Readme.md
+++ b/Readme.md
@@ -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.)