mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 23:57:49 +00:00
Update docdown to avoid escaping characters in code snippets. [ci skip]
This commit is contained in:
@@ -999,7 +999,7 @@ _.zip(['fred', 'barney'], [30, 40], [true, false]);
|
||||
### <a id="_zipobjectkeys-values"></a>`_.zipObject(keys, [values=[]])`
|
||||
<a href="#_zipobjectkeys-values">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5333 "View in source") [Ⓣ][1]
|
||||
|
||||
Creates an object composed from arrays of `keys` and `values`. Provide either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]` or two arrays, one of `keys` and one of corresponding `values`.
|
||||
Creates an object composed from arrays of `keys` and `values`. Provide either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]` or two arrays, one of `keys` and one of corresponding `values`.
|
||||
|
||||
#### Aliases
|
||||
*_.object*
|
||||
@@ -2273,7 +2273,7 @@ jQuery('#docs').on('click', view.onClick);
|
||||
### <a id="_bindkeyobject-key-arg"></a>`_.bindKey(object, key, [arg])`
|
||||
<a href="#_bindkeyobject-key-arg">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5484 "View in source") [Ⓣ][1]
|
||||
|
||||
Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those provided to the bound function. This method differs from `_.bind` by allowing bound functions to reference methods that will be redefined or don't yet exist. See http://michaux.ca/articles/lazy-function-definition-pattern.
|
||||
Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those provided to the bound function. This method differs from `_.bind` by allowing bound functions to reference methods that will be redefined or don't yet exist. See http://michaux.ca/articles/lazy-function-definition-pattern.
|
||||
|
||||
#### Arguments
|
||||
1. `object` *(Object)*: The object the method belongs to.
|
||||
@@ -3823,7 +3823,7 @@ _.omit({ 'name': 'fred', 'age': 40 }, function(value) {
|
||||
### <a id="_pairsobject"></a>`_.pairs(object)`
|
||||
<a href="#_pairsobject">#</a> [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3067 "View in source") [Ⓣ][1]
|
||||
|
||||
Creates a two dimensional array of an object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`.
|
||||
Creates a two dimensional array of an object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`.
|
||||
|
||||
#### Arguments
|
||||
1. `object` *(Object)*: The object to inspect.
|
||||
@@ -4521,7 +4521,7 @@ In IE < `9` an objects own properties, shadowing non-enumerable ones, are made n
|
||||
|
||||
*(boolean)*: Detect if `Array#shift` and `Array#splice` augment array-like objects correctly.
|
||||
|
||||
Firefox < `10`, IE compatibility mode, and IE < `9` have buggy Array `shift()` and `splice()` functions that fail to remove the last element, `value[0]`, of array-like objects even though the `length` property is set to `0`. The `shift()` method is buggy in IE `8` compatibility mode, while `splice()` is buggy regardless of mode in IE < `9` and buggy in compatibility mode in IE `9`.
|
||||
Firefox < `10`, IE compatibility mode, and IE < `9` have buggy Array `shift()` and `splice()` functions that fail to remove the last element, `value[0]`, of array-like objects even though the `length` property is set to `0`. The `shift()` method is buggy in IE `8` compatibility mode, while `splice()` is buggy regardless of mode in IE < `9` and buggy in compatibility mode in IE `9`.
|
||||
|
||||
* * *
|
||||
|
||||
|
||||
68
vendor/docdown/src/DocDown/MarkdownGenerator.php
vendored
68
vendor/docdown/src/DocDown/MarkdownGenerator.php
vendored
@@ -27,7 +27,6 @@ class MarkdownGenerator {
|
||||
/**
|
||||
* The HTML for the open tag.
|
||||
*
|
||||
* @static
|
||||
* @memberOf MarkdownGenerator
|
||||
* @type string
|
||||
*/
|
||||
@@ -49,6 +48,15 @@ class MarkdownGenerator {
|
||||
*/
|
||||
public $source = '';
|
||||
|
||||
/**
|
||||
* The array of code snippets that are tokenized by `escape`.
|
||||
*
|
||||
* @private
|
||||
* @memberOf MarkdownGenerator
|
||||
* @type Array
|
||||
*/
|
||||
private $snippets = array();
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
@@ -132,21 +140,6 @@ class MarkdownGenerator {
|
||||
return trim($string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes special Markdown characters.
|
||||
*
|
||||
* @private
|
||||
* @memberOf Entry
|
||||
* @param {string} $string The string to escape.
|
||||
* @returns {string} Returns the escaped string.
|
||||
*/
|
||||
private function escape( $string ) {
|
||||
$string = preg_replace('/(?<!\\\)\*/', '*', $string);
|
||||
$string = preg_replace('/(?<!\\\)\[/', '[', $string);
|
||||
$string = preg_replace('/(?<!\\\)\]/', ']', $string);
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify a string by replacing named tokens with matching assoc. array values.
|
||||
*
|
||||
@@ -252,6 +245,23 @@ class MarkdownGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes special Markdown characters.
|
||||
*
|
||||
* @private
|
||||
* @memberOf Entry
|
||||
* @param {string} $string The string to escape.
|
||||
* @returns {string} Returns the escaped string.
|
||||
*/
|
||||
private function escape( $string ) {
|
||||
$string = preg_replace_callback('/`.*?\`/', array($this, 'swapSnippetsToTokens'), $string);
|
||||
$string = preg_replace('/(?<!\\\)\*/', '*', $string);
|
||||
$string = preg_replace('/(?<!\\\)\[/', '[', $string);
|
||||
$string = preg_replace('/(?<!\\\)\]/', ']', $string);
|
||||
$string = preg_replace_callback('/@@token@@/', array($this, 'swapTokensToSnippets'), $string);
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the entry's hash used to navigate the documentation.
|
||||
*
|
||||
@@ -298,6 +308,32 @@ class MarkdownGenerator {
|
||||
return $entry->isPlugin() ? '.prototype.' : '.';
|
||||
}
|
||||
|
||||
/**
|
||||
* Swaps code snippets with tokens as a `preg_replace_callback` callback
|
||||
* used by `escape`.
|
||||
*
|
||||
* @private
|
||||
* @memberOf Entry
|
||||
* @param {Array} $matches The array of regexp matches.
|
||||
* @returns {string} Returns the token.
|
||||
*/
|
||||
private function swapSnippetsToTokens( $matches ) {
|
||||
$this->snippets[] = $matches[0];
|
||||
return '@@token@@';
|
||||
}
|
||||
|
||||
/**
|
||||
* Swaps tokens with code snippets as a `preg_replace_callback` callback
|
||||
* used by `escape`.
|
||||
*
|
||||
* @private
|
||||
* @memberOf Entry
|
||||
* @returns {string} Returns the code snippet.
|
||||
*/
|
||||
private function swapTokensToSnippets() {
|
||||
return array_shift($this->snippets);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user