File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,6 +28,25 @@ var replace = require( '@stdlib/string/base/replace' );
2828var RE_MARKDOWN_OR_CODE = / ( ` ` ` [ \s \S ] + ?` ` ` | ` [ \s \S ] * ?` ) | ( [ \\ * _ [ # ! ~ | ] ) / g;
2929
3030
31+ // FUNCTIONS //
32+
33+ /**
34+ * Callback invoked for each match of a Markdown special character.
35+ *
36+ * @private
37+ * @param {string } match - matched substring
38+ * @param {string } code - code block or inline code
39+ * @param {string } markdown - Markdown characters
40+ * @returns {string } replacement string
41+ */
42+ function onMatch ( match , code , markdown ) {
43+ if ( code ) {
44+ return code ;
45+ }
46+ return '\\' + markdown ;
47+ }
48+
49+
3150// MAIN //
3251
3352/**
@@ -52,22 +71,6 @@ var RE_MARKDOWN_OR_CODE = /(```[\s\S]+?```|`[\s\S]*?`)|([\\*_[#!~|])/g;
5271*/
5372function escapeMarkdown ( str ) {
5473 return replace ( str , RE_MARKDOWN_OR_CODE , onMatch ) ;
55-
56- /**
57- * Callback invoked for each match.
58- *
59- * @private
60- * @param {string } match - matched substring
61- * @param {string } code - code block or inline code
62- * @param {string } markdown - Markdown characters
63- * @returns {string } replacement string
64- */
65- function onMatch ( match , code , markdown ) {
66- if ( code ) {
67- return code ;
68- }
69- return '\\' + markdown ;
70- }
7174}
7275
7376
You can’t perform that action at this time.
0 commit comments