Making WordPress.org


Ignore:
Timestamp:
07/03/2020 03:11:38 AM (6 years ago)
Author:
dd32
Message:

Pinking shears, 10000

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/libs/michelf-php-markdown-1.6.0/Michelf/Markdown.php

    r2638 r10000  
    33# Markdown  -  A text-to-HTML conversion tool for web writers
    44#
    5 # PHP Markdown 
    6 # Copyright (c) 2004-2015 Michel Fortin 
     5# PHP Markdown
     6# Copyright (c) 2004-2015 Michel Fortin
    77# <https://michelf.ca/projects/php-markdown/>
    88#
    9 # Original Markdown 
    10 # Copyright (c) 2004-2006 John Gruber 
     9# Original Markdown
     10# Copyright (c) 2004-2006 John Gruber
    1111# <https://daringfireball.net/projects/markdown/>
    1212#
     
    7474    # 2. List item two
    7575    # 3. List item three
    76     # 
     76    #
    7777    # becomes
    7878    # <ol start="2">
     
    104104        $this->prepareItalicsAndBold();
    105105   
    106         $this->nested_brackets_re = 
     106        $this->nested_brackets_re =
    107107            str_repeat('(?>[^\[\]]+|\[', $this->nested_brackets_depth).
    108108            str_repeat('\])*', $this->nested_brackets_depth);
    109109   
    110         $this->nested_url_parenthesis_re = 
     110        $this->nested_url_parenthesis_re =
    111111            str_repeat('(?>[^()\s]+|\(', $this->nested_url_parenthesis_depth).
    112112            str_repeat('(?>\)))*', $this->nested_url_parenthesis_depth);
     
    132132    protected function setup() {
    133133    #
    134     # Called before the transformation process starts to setup parser 
     134    # Called before the transformation process starts to setup parser
    135135    # states.
    136136    #
     
    145145    protected function teardown() {
    146146    #
    147     # Called after the transformation process to clear any variable 
     147    # Called after the transformation process to clear any variable
    148148    # which may be taking up memory unnecessarly.
    149149    #
     
    257257        #
    258258        # *  List "a" is made of tags which can be both inline or block-level.
    259         #    These will be treated block-level when the start tag is alone on 
    260         #    its line, otherwise they're not matched here and will be taken as 
     259        #    These will be treated block-level when the start tag is alone on
     260        #    its line, otherwise they're not matched here and will be taken as
    261261        #    inline later.
    262262        # *  List "b" is made of tags which are always block-level;
     
    325325            (                       # save in $1
    326326
    327               # Match from `\n<tag>` to `</tag>\n`, handling nested tags 
     327              # Match from `\n<tag>` to `</tag>\n`, handling nested tags
    328328              # in between.
    329329                   
     
    346346                        (?=\n+|\Z)  # followed by a newline or end of document
    347347                   
    348             | # Special case just for <hr />. It was easier to make a special 
     348            | # Special case just for <hr />. It was easier to make a special
    349349              # case than to make the other regex more complicated.
    350350           
     
    392392    protected function hashPart($text, $boundary = 'X') {
    393393    #
    394     # Called whenever a tag must be hashed when a function insert an atomic 
     394    # Called whenever a tag must be hashed when a function insert an atomic
    395395    # element in the text stream. Passing $text to through this function gives
    396396    # a unique text-token which will be reverted back when calling unhash.
     
    438438    # Run block gamut tranformations.
    439439    #
    440         # We need to escape raw HTML in Markdown source before doing anything 
    441         # else. This need to be done for each block, and not only at the 
     440        # We need to escape raw HTML in Markdown source before doing anything
     441        # else. This need to be done for each block, and not only at the
    442442        # begining in the Markdown function since hashed blocks can be part of
    443         # list items and could have been indented. Indented blocks would have 
     443        # list items and could have been indented. Indented blocks would have
    444444        # been seen as a code block in a previous pass of hashHTMLBlocks.
    445445        $text = $this->hashHTMLBlocks($text);
     
    450450    protected function runBasicBlockGamut($text) {
    451451    #
    452     # Run block gamut tranformations, without hashing HTML blocks. This is 
     452    # Run block gamut tranformations, without hashing HTML blocks. This is
    453453    # useful when HTML blocks are known to be already hashed, like in the first
    454454    # whole-document pass.
     
    478478                $           # End of line.
    479479            }mx',
    480             "\n".$this->hashBlock("<hr$this->empty_element_suffix")."\n", 
     480            "\n".$this->hashBlock("<hr$this->empty_element_suffix")."\n",
    481481            $text);
    482482    }
     
    521521    protected function doHardBreaks($text) {
    522522        # Do hard breaks:
    523         return preg_replace_callback('/ {2,}\n/', 
     523        return preg_replace_callback('/ {2,}\n/',
    524524            array($this, '_doHardBreaks_callback'), $text);
    525525    }
     
    681681
    682682            )
    683             }xs', 
     683            }xs',
    684684            array($this, '_doImages_reference_callback'), $text);
    685685
     
    766766        #     Header 1
    767767        #     ========
    768         # 
     768        #
    769769        #     Header 2
    770770        #     --------
     
    988988        $tailing_blank_line =& $matches[5];
    989989
    990         if ($leading_line || $tailing_blank_line || 
     990        if ($leading_line || $tailing_blank_line ||
    991991            preg_match('/\n{2,}/', $item))
    992992        {
     
    11051105           
    11061106            #
    1107             # Each loop iteration search for the next emphasis token. 
     1107            # Each loop iteration search for the next emphasis token.
    11081108            # Each token is then passed to handleSpanToken.
    11091109            #
     
    11611161                    }
    11621162                } else {
    1163                     # Reached opening three-char emphasis marker. Push on token 
     1163                    # Reached opening three-char emphasis marker. Push on token
    11641164                    # stack; will be handled by the special condition above.
    11651165                    $em = $token{0};
     
    12351235
    12361236        $bq = preg_replace('/^/m', "  ", $bq);
    1237         # These leading spaces cause problem with <pre> content, 
     1237        # These leading spaces cause problem with <pre> content,
    12381238        # so we need to fix that:
    1239         $bq = preg_replace_callback('{(\s*<pre>.+?</pre>)}sx', 
     1239        $bq = preg_replace_callback('{(\s*<pre>.+?</pre>)}sx',
    12401240            array($this, '_doBlockQuotes_callback2'), $bq);
    12411241
     
    13591359    protected function encodeAmpsAndAngles($text) {
    13601360    #
    1361     # Smart processing for ampersands and angle brackets that need to 
     1361    # Smart processing for ampersands and angle brackets that need to
    13621362    # be encoded. Valid character entities are left alone unless the
    13631363    # no-entities mode is set.
     
    13681368            # Ampersand-encoding based entirely on Nat Irons's Amputator
    13691369            # MT plugin: <http://bumppo.net/projects/amputator/>
    1370             $text = preg_replace('/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/', 
     1370            $text = preg_replace('/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/',
    13711371                                '&amp;', $text);
    13721372        }
     
    14981498        while (1) {
    14991499            #
    1500             # Each loop iteration seach for either the next tag, the next 
    1501             # openning code span marker, or the next escaped character. 
     1500            # Each loop iteration seach for either the next tag, the next
     1501            # openning code span marker, or the next escaped character.
    15021502            # Each token is then passed to handleSpanToken.
    15031503            #
     
    15251525    protected function handleSpanToken($token, &$str) {
    15261526    #
    1527     # Handle $token provided by parseSpan by determining its nature and 
     1527    # Handle $token provided by parseSpan by determining its nature and
    15281528    # returning the corresponding value that should replace it.
    15291529    #
     
    15331533            case "`":
    15341534                # Search for end marker in remaining text.
    1535                 if (preg_match('/^(.*?[^`])'.preg_quote($token).'(?!`)(.*)$/sm', 
     1535                if (preg_match('/^(.*?[^`])'.preg_quote($token).'(?!`)(.*)$/sm',
    15361536                    $str, $matches))
    15371537                {
     
    15551555
    15561556
    1557     # String length function for detab. `_initDetab` will create a function to 
     1557    # String length function for detab. `_initDetab` will create a function to
    15581558    # hanlde UTF-8 if the default function does not exist.
    15591559    protected $utf8_strlen = 'mb_strlen';
     
    15641564    #
    15651565        # For each line we separate the line in blocks delemited by
    1566         # tab characters. Then we reconstruct every line by adding the 
     1566        # tab characters. Then we reconstruct every line by adding the
    15671567        # appropriate number of space between each blocks.
    15681568       
     
    15831583        foreach ($blocks as $block) {
    15841584            # Calculate amount of space, insert spaces, insert block.
    1585             $amount = $this->tab_width - 
     1585            $amount = $this->tab_width -
    15861586                $strlen($line, 'UTF-8') % $this->tab_width;
    15871587            $line .= str_repeat(" ", $amount) . $block;
     
    15921592    #
    15931593    # Check for the availability of the function in the `utf8_strlen` property
    1594     # (initially `mb_strlen`). If the function is not available, create a 
     1594    # (initially `mb_strlen`). If the function is not available, create a
    15951595    # function that will loosely count the number of UTF-8 characters with a
    15961596    # regular expression.
     
    15981598        if (function_exists($this->utf8_strlen)) return;
    15991599        $this->utf8_strlen = create_function('$text', 'return preg_match_all(
    1600             "/[\\\\x00-\\\\xBF]|[\\\\xC0-\\\\xFF][\\\\x80-\\\\xBF]*/", 
     1600            "/[\\\\x00-\\\\xBF]|[\\\\xC0-\\\\xFF][\\\\x80-\\\\xBF]*/",
    16011601            $text, $m);');
    16021602    }
     
    16071607    # Swap back in all the tags hashed by _HashHTMLBlocks.
    16081608    #
    1609         return preg_replace_callback('/(.)\x1A[0-9]+\1/', 
     1609        return preg_replace_callback('/(.)\x1A[0-9]+\1/',
    16101610            array($this, '_unhash_callback'), $text);
    16111611    }
Note: See TracChangeset for help on using the changeset viewer.