WordPress.org

Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #14481


Ignore:
Timestamp:
07/31/10 04:02:50 (5 years ago)
Author:
nacin
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #14481 – Description

    initial v1  
    1 Somewhat of a copy of a post to wp-hackers: I wrote my own implementation of shortcodes. It does things a bit 
    2 differently, has nested evaluation, and allows self-nesting. Since 
    3 there are some significant differences to the existing implementation, 
     1Somewhat of a copy of a post to wp-hackers: I wrote my own implementation of shortcodes. It does things a bit differently, has nested evaluation, and allows self-nesting. Since there are some significant differences to the existing implementation, 
    42 
    5 A lot of the changes are borrowed 
    6 from definitions in the HTML specification (particularly name and 
    7 attribute matching). The following are the comments at the top of my 
    8 shortcode file. I tried to keep track of all the differences (and 
    9 questions) there. 
     3A lot of the changes are borrowed from definitions in the HTML specification (particularly name and attribute matching). The following are the comments at the top of my shortcode file. I tried to keep track of all the differences (and questions) there. 
    104 
    11 From Test Cases 
     5== From Test Cases == 
     6 
    127(http://svn.automattic.com/wordpress-tests/wp-testcase/test_shortcode.php) 
    13 ========================================================================================== 
     8{{{ 
    149Shortcode Statuses (to implement, or not to implement?) 
    1510        enabled = the shortcode works as normal (default) 
     
    2217        disabled = the shortcode is not parsed at all.  e.g. 
    2318'[shortcode foo="bar"]' products '[shortcode foo="bar"]' 
     19}}} 
    2420 
     21== Major Differences/Improvements == 
    2522 
    26 Major Differences/Improvements: 
    27 =============================== 
    2823I. Addressing http://codex.wordpress.org/Shortcode_API#Limitations 
    2924 
    30        1. You can nest any tag at any depth regardless of ancestors 
    31 (Ticket #10702) 
     25 1. You can nest any tag at any depth regardless of ancestors (#10702) 
    3226 
    33        2. Tag and attribute names may match 
    34 /[A-Za-z][-A-Za-z0-9_:.]*//* (trialing /* because that comment ends), 
    35           with case-insensitive interpretation 
     27 2. Tag and attribute names may match: `/[A-Za-z][-A-Za-z0-9_:.]*//*` (trialing /* because that comment ends), with case-insensitive interpretation 
    3628 
    37        3. Interpretation doesn't get tripped up by things like hyphens 
     29 3. Interpretation doesn't get tripped up by things like hyphens 
    3830 
    39 II. Addressing Ticket #12760, 
     31== II. Addressing Ticket #12760, == 
    4032 
    41        1. Changed from fix in #6518 
    42           Reasoning: balancing double-square-brackets can have 
    43 misleading results with nesting 
     33 1. Changed from fix in #6518. Reasoning: balancing double-square-brackets can have misleading results with nesting 
    4434 
    45        2. Shortcodes escapable by using [[, ]] 
     35 2. Shortcodes escapable by using `[[`, `]]` 
    4636 
    47        3. ']]' is escaped "right to left", so '[shortcode]]]' would 
    48 evaluate to 'result]' 
     37 3. `]]` is escaped "right to left", so `[shortcode]]]` would evaluate to `result]` 
    4938 
    50        4. '[[' is escaped left to right '[[[shortcode]]]' => '[result]' 
     39 4. '[[' is escaped left to right `[[[shortcode]]]` => `[result]` 
    5140 
    52 III. Enhancements 
     41== III. Enhancements == 
    5342 
    54        1. Only matches valid shortcode for registered hooks, 
    55 everything else will appear as text 
     43 1. Only matches valid shortcode for registered hooks, everything else will appear as text 
    5644 
    57        2. Can register multiple hooks to single shortcode, uses 
    58 priority (default: 10) 
     45 2. Can register multiple hooks to single shortcode, uses priority (default: 10) 
    5946 
    60 IV. Conflicting Design Changes 
     47== IV. Conflicting Design Changes == 
    6148 
    62        1. Quoted literals are escaped by entities rather than cslashes 
     49 1. Quoted literals are escaped by entities rather than cslashes 
    6350 
    64        2. Inline (self-closing) shortcodes get passed content to 
    65 accomodate multiple callbacks 
     51 2. Inline (self-closing) shortcodes get passed content to accomodate multiple callbacks 
    6652 
    67        3. No equivalent to shortcode_parse_atts function 
    68           (Not marked private in function reference, but not 
    69 documented in shortcode API page) 
     53 3. No equivalent to shortcode_parse_atts function (Not marked private in function reference, but not documented in shortcode API page) 
    7054 
    71        4. Boolean attributes take the place of positional attributes 
    72           [foo bar] gets attributes array('bar' => 'bar') instead of 
    73 array('0' => 'bar') 
     55 4. Boolean attributes take the place of positional attributes `[foo bar]` gets attributes `array('bar' => 'bar')` instead of `array('0' => 'bar')` 
    7456 
    75        5. Disallows attribute and tag names that don't match 
    76 /[A-Za-z][-A-Za-z0-9_:.]*/ 
     57 5. Disallows attribute and tag names that don't match `/[A-Za-z][-A-Za-z0-9_:.]*/` 
    7758 
    78        6. Disallows unquoted attribute values (also boolean 
    79 attributes), unless they match /[-A-Za-z0-9_:.]+/ 
     59 6. Disallows unquoted attribute values (also boolean attributes), unless they match `/[-A-Za-z0-9_:.]+/` 
    8060 
     61== Basic Interpretation Method == 
    8162 
    82 Basic Interpretation Method: 
    83 ============================ 
    84 1. If an open tag is encountered, it is added to the stack 
     63 1. If an open tag is encountered, it is added to the stack 
    8564 
    86 2. If a close tag is encountered and there is no matching open tag on the stack 
    87   the close tag is ignored 
     65 2. If a close tag is encountered and there is no matching open tag on the stack the close tag is ignored 
    8866 
    89 3. If a close tag is encountered and there is a matching open tag on the stack 
    90   all opened tags on the stack before the matched tag will be 
    91 implicitly self-closed 
     67 3. If a close tag is encountered and there is a matching open tag on the stack all opened tags on the stack before the matched tag will be implicitly self-closed 
    9268 
    93 4. If text or an inline tag is encountered, it will be evaluated to its parent's 
    94   content immediately 
     69 4. If text or an inline tag is encountered, it will be evaluated to its parent's content immediately 
    9570 
    96 5. If tags are not closed by the end of the interpretation, they will 
    97 be implicitly 
    98   self-closed 
     71 5. If tags are not closed by the end of the interpretation, they will be implicitly self-closed 
    9972 
     73== Issues == 
    10074 
    101 Issues: 
    102 ======= 
    103 1. Haven't written new unit tests to reflect new functionality added, 
    104 functionality differences 
     75 1. Haven't written new unit tests to reflect new functionality added, functionality differences 
    10576 
    106 2. Documentation is not as good (though I hope most of the code is 
    107 self-explanatory) 
     77 2. Documentation is not as good (though I hope most of the code is self-explanatory) 
    10878 
    109 3. Not 100% backwards compatible 
     79 3. Not 100% backwards compatible