Search Results

Search found 7 results on 1 pages for 'peroyomas'.

Page 1/1 | 1 

  • WordPress: Problem with the shortcode regex

    - by peroyomas
    This is the regular expression used for "shortcodes" in WordPress (one for the whole tag, other for the attributes). return '(.?)\[('.$tagregexp.')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?(.?)'; $pattern = '/(\w+)\s*=\s*"([^"]*)"(?:\s|$)|(\w+)\s*=\s*\'([^\']*)\'(?:\s|$)|(\w+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/'; It parses stuff like [foo bar="baz"]content[/foo] or [foo /] In the WordPress trac they say it's a bit flawed, but my main problem is that it don't support shortcodes inside the attributes, like in [foo bar="[baz /]"]content[/foo] because the regex stops the main shortcode at the first appearance of a closing bracket, so in the example it renders [foo bar="[baz /] and "]content[/foo] shows as it is. Is there any way to change the regex so it bypass any ocurrence of [ with ] and its content when occurs between the opening tag or self-closing tag?

    Read the article

  • HTML/CSS: Keep the same height between the backgrounds of a term-description pair in a table-like de

    - by peroyomas
    I want to format a definition list in HTML as if it were a table with th in a column and td in another, with a background that alternates per row (although a background for the dt and another for the dd also fits for the problem), so I have this CSS: dl { font-family: Verdana, Geneva, sans-serif; font-size: 0.6em; overflow: hidden; width: 200px;; } dl dt { font-weight: bold; float: left; clear: left; padding-right: 1%; width: 48%; } dl dt:nth-of-type(odd), dl dd:nth-of-type(odd) { background-color: #EEE; } dl dt:nth-of-type(even), dl dd:nth-of-type(even) { background-color: #DDD; } dl dd { float: left; width: 50%; padding-left: 1%; margin-left: 0; } Example HTML: <dl> <dt>Key 1</dt> <dd>Value 1</dd> <dt>Very very very long key 2 </dt> <dd>Value 2</dd> <dt>Key 3</dt> <dd>Value 3 with<br /> line breaks</dd> <dt>Key 4</dt> <dd>Value 4</dd> </dl> The problem is that, due to the eventual height dissimilarity, "holes" with no background appears in the list: Is there a way to fix that?

    Read the article

  • Replace strings differently depending if is enclosed in braces or not.

    - by peroyomas
    I want to replace all instances of an specific words between braces with something else, unless it is written between double braces, while it should show as is it was written with single braces without the filter. I have tried a code but only works for the first match. The rest are shown depending of the first one: $foo = 'a {bar} b {{bar}} c {bar} d'; $baz = 'Chile'; preg_match_all( '/(\{?)\{(tin)\}(\}?)/i', $foo, $matches, PREG_SET_ORDER ); if ( !empty($matches) ) { foreach ( (array) $matches as $match ) { if( empty($match[1]) && empty($match[3])) { $tull = str_replace( $match[0], $baz, $foo ); } else { $tull = str_replace( $match[0], substr($match[0], 1, -1), $foo ) ; } } } echo $tull;

    Read the article

1