[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 /******/ (() => { // webpackBootstrap 2 /******/ var __webpack_modules__ = ({ 3 4 /***/ 7734: 5 /***/ ((module) => { 6 7 "use strict"; 8 9 10 // do not edit .js files directly - edit src/index.jst 11 12 13 var envHasBigInt64Array = typeof BigInt64Array !== 'undefined'; 14 15 16 module.exports = function equal(a, b) { 17 if (a === b) return true; 18 19 if (a && b && typeof a == 'object' && typeof b == 'object') { 20 if (a.constructor !== b.constructor) return false; 21 22 var length, i, keys; 23 if (Array.isArray(a)) { 24 length = a.length; 25 if (length != b.length) return false; 26 for (i = length; i-- !== 0;) 27 if (!equal(a[i], b[i])) return false; 28 return true; 29 } 30 31 32 if ((a instanceof Map) && (b instanceof Map)) { 33 if (a.size !== b.size) return false; 34 for (i of a.entries()) 35 if (!b.has(i[0])) return false; 36 for (i of a.entries()) 37 if (!equal(i[1], b.get(i[0]))) return false; 38 return true; 39 } 40 41 if ((a instanceof Set) && (b instanceof Set)) { 42 if (a.size !== b.size) return false; 43 for (i of a.entries()) 44 if (!b.has(i[0])) return false; 45 return true; 46 } 47 48 if (ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) { 49 length = a.length; 50 if (length != b.length) return false; 51 for (i = length; i-- !== 0;) 52 if (a[i] !== b[i]) return false; 53 return true; 54 } 55 56 57 if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags; 58 if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf(); 59 if (a.toString !== Object.prototype.toString) return a.toString() === b.toString(); 60 61 keys = Object.keys(a); 62 length = keys.length; 63 if (length !== Object.keys(b).length) return false; 64 65 for (i = length; i-- !== 0;) 66 if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false; 67 68 for (i = length; i-- !== 0;) { 69 var key = keys[i]; 70 71 if (!equal(a[key], b[key])) return false; 72 } 73 74 return true; 75 } 76 77 // true if both NaN, false otherwise 78 return a!==a && b!==b; 79 }; 80 81 82 /***/ }), 83 84 /***/ 5373: 85 /***/ ((__unused_webpack_module, exports) => { 86 87 "use strict"; 88 var __webpack_unused_export__; 89 /** 90 * @license React 91 * react-is.production.min.js 92 * 93 * Copyright (c) Facebook, Inc. and its affiliates. 94 * 95 * This source code is licensed under the MIT license found in the 96 * LICENSE file in the root directory of this source tree. 97 */ 98 var b=Symbol.for("react.element"),c=Symbol.for("react.portal"),d=Symbol.for("react.fragment"),e=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),g=Symbol.for("react.provider"),h=Symbol.for("react.context"),k=Symbol.for("react.server_context"),l=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),n=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),t=Symbol.for("react.offscreen"),u;u=Symbol.for("react.module.reference"); 99 function v(a){if("object"===typeof a&&null!==a){var r=a.$$typeof;switch(r){case b:switch(a=a.type,a){case d:case f:case e:case m:case n:return a;default:switch(a=a&&a.$$typeof,a){case k:case h:case l:case q:case p:case g:return a;default:return r}}case c:return r}}}__webpack_unused_export__=h;__webpack_unused_export__=g;__webpack_unused_export__=b;__webpack_unused_export__=l;__webpack_unused_export__=d;__webpack_unused_export__=q;__webpack_unused_export__=p;__webpack_unused_export__=c;__webpack_unused_export__=f;__webpack_unused_export__=e;__webpack_unused_export__=m; 100 __webpack_unused_export__=n;__webpack_unused_export__=function(){return!1};__webpack_unused_export__=function(){return!1};__webpack_unused_export__=function(a){return v(a)===h};__webpack_unused_export__=function(a){return v(a)===g};__webpack_unused_export__=function(a){return"object"===typeof a&&null!==a&&a.$$typeof===b};__webpack_unused_export__=function(a){return v(a)===l};__webpack_unused_export__=function(a){return v(a)===d};__webpack_unused_export__=function(a){return v(a)===q};__webpack_unused_export__=function(a){return v(a)===p}; 101 __webpack_unused_export__=function(a){return v(a)===c};__webpack_unused_export__=function(a){return v(a)===f};__webpack_unused_export__=function(a){return v(a)===e};__webpack_unused_export__=function(a){return v(a)===m};__webpack_unused_export__=function(a){return v(a)===n}; 102 exports.isValidElementType=function(a){return"string"===typeof a||"function"===typeof a||a===d||a===f||a===e||a===m||a===n||a===t||"object"===typeof a&&null!==a&&(a.$$typeof===q||a.$$typeof===p||a.$$typeof===g||a.$$typeof===h||a.$$typeof===l||a.$$typeof===u||void 0!==a.getModuleId)?!0:!1};__webpack_unused_export__=v; 103 104 105 /***/ }), 106 107 /***/ 8529: 108 /***/ ((module, __unused_webpack_exports, __webpack_require__) => { 109 110 "use strict"; 111 112 113 if (true) { 114 module.exports = __webpack_require__(5373); 115 } else {} 116 117 118 /***/ }), 119 120 /***/ 9681: 121 /***/ ((module) => { 122 123 var characterMap = { 124 "À": "A", 125 "Á": "A", 126 "Â": "A", 127 "Ã": "A", 128 "Ä": "A", 129 "Å": "A", 130 "Ấ": "A", 131 "Ắ": "A", 132 "Ẳ": "A", 133 "Ẵ": "A", 134 "Ặ": "A", 135 "Æ": "AE", 136 "Ầ": "A", 137 "Ằ": "A", 138 "Ȃ": "A", 139 "Ả": "A", 140 "Ạ": "A", 141 "Ẩ": "A", 142 "Ẫ": "A", 143 "Ậ": "A", 144 "Ç": "C", 145 "Ḉ": "C", 146 "È": "E", 147 "É": "E", 148 "Ê": "E", 149 "Ë": "E", 150 "Ế": "E", 151 "Ḗ": "E", 152 "Ề": "E", 153 "Ḕ": "E", 154 "Ḝ": "E", 155 "Ȇ": "E", 156 "Ẻ": "E", 157 "Ẽ": "E", 158 "Ẹ": "E", 159 "Ể": "E", 160 "Ễ": "E", 161 "Ệ": "E", 162 "Ì": "I", 163 "Í": "I", 164 "Î": "I", 165 "Ï": "I", 166 "Ḯ": "I", 167 "Ȋ": "I", 168 "Ỉ": "I", 169 "Ị": "I", 170 "Ð": "D", 171 "Ñ": "N", 172 "Ò": "O", 173 "Ó": "O", 174 "Ô": "O", 175 "Õ": "O", 176 "Ö": "O", 177 "Ø": "O", 178 "Ố": "O", 179 "Ṍ": "O", 180 "Ṓ": "O", 181 "Ȏ": "O", 182 "Ỏ": "O", 183 "Ọ": "O", 184 "Ổ": "O", 185 "Ỗ": "O", 186 "Ộ": "O", 187 "Ờ": "O", 188 "Ở": "O", 189 "Ỡ": "O", 190 "Ớ": "O", 191 "Ợ": "O", 192 "Ù": "U", 193 "Ú": "U", 194 "Û": "U", 195 "Ü": "U", 196 "Ủ": "U", 197 "Ụ": "U", 198 "Ử": "U", 199 "Ữ": "U", 200 "Ự": "U", 201 "Ý": "Y", 202 "à": "a", 203 "á": "a", 204 "â": "a", 205 "ã": "a", 206 "ä": "a", 207 "å": "a", 208 "ấ": "a", 209 "ắ": "a", 210 "ẳ": "a", 211 "ẵ": "a", 212 "ặ": "a", 213 "æ": "ae", 214 "ầ": "a", 215 "ằ": "a", 216 "ȃ": "a", 217 "ả": "a", 218 "ạ": "a", 219 "ẩ": "a", 220 "ẫ": "a", 221 "ậ": "a", 222 "ç": "c", 223 "ḉ": "c", 224 "è": "e", 225 "é": "e", 226 "ê": "e", 227 "ë": "e", 228 "ế": "e", 229 "ḗ": "e", 230 "ề": "e", 231 "ḕ": "e", 232 "ḝ": "e", 233 "ȇ": "e", 234 "ẻ": "e", 235 "ẽ": "e", 236 "ẹ": "e", 237 "ể": "e", 238 "ễ": "e", 239 "ệ": "e", 240 "ì": "i", 241 "í": "i", 242 "î": "i", 243 "ï": "i", 244 "ḯ": "i", 245 "ȋ": "i", 246 "ỉ": "i", 247 "ị": "i", 248 "ð": "d", 249 "ñ": "n", 250 "ò": "o", 251 "ó": "o", 252 "ô": "o", 253 "õ": "o", 254 "ö": "o", 255 "ø": "o", 256 "ố": "o", 257 "ṍ": "o", 258 "ṓ": "o", 259 "ȏ": "o", 260 "ỏ": "o", 261 "ọ": "o", 262 "ổ": "o", 263 "ỗ": "o", 264 "ộ": "o", 265 "ờ": "o", 266 "ở": "o", 267 "ỡ": "o", 268 "ớ": "o", 269 "ợ": "o", 270 "ù": "u", 271 "ú": "u", 272 "û": "u", 273 "ü": "u", 274 "ủ": "u", 275 "ụ": "u", 276 "ử": "u", 277 "ữ": "u", 278 "ự": "u", 279 "ý": "y", 280 "ÿ": "y", 281 "Ā": "A", 282 "ā": "a", 283 "Ă": "A", 284 "ă": "a", 285 "Ą": "A", 286 "ą": "a", 287 "Ć": "C", 288 "ć": "c", 289 "Ĉ": "C", 290 "ĉ": "c", 291 "Ċ": "C", 292 "ċ": "c", 293 "Č": "C", 294 "č": "c", 295 "C̆": "C", 296 "c̆": "c", 297 "Ď": "D", 298 "ď": "d", 299 "Đ": "D", 300 "đ": "d", 301 "Ē": "E", 302 "ē": "e", 303 "Ĕ": "E", 304 "ĕ": "e", 305 "Ė": "E", 306 "ė": "e", 307 "Ę": "E", 308 "ę": "e", 309 "Ě": "E", 310 "ě": "e", 311 "Ĝ": "G", 312 "Ǵ": "G", 313 "ĝ": "g", 314 "ǵ": "g", 315 "Ğ": "G", 316 "ğ": "g", 317 "Ġ": "G", 318 "ġ": "g", 319 "Ģ": "G", 320 "ģ": "g", 321 "Ĥ": "H", 322 "ĥ": "h", 323 "Ħ": "H", 324 "ħ": "h", 325 "Ḫ": "H", 326 "ḫ": "h", 327 "Ĩ": "I", 328 "ĩ": "i", 329 "Ī": "I", 330 "ī": "i", 331 "Ĭ": "I", 332 "ĭ": "i", 333 "Į": "I", 334 "į": "i", 335 "İ": "I", 336 "ı": "i", 337 "IJ": "IJ", 338 "ij": "ij", 339 "Ĵ": "J", 340 "ĵ": "j", 341 "Ķ": "K", 342 "ķ": "k", 343 "Ḱ": "K", 344 "ḱ": "k", 345 "K̆": "K", 346 "k̆": "k", 347 "Ĺ": "L", 348 "ĺ": "l", 349 "Ļ": "L", 350 "ļ": "l", 351 "Ľ": "L", 352 "ľ": "l", 353 "Ŀ": "L", 354 "ŀ": "l", 355 "Ł": "l", 356 "ł": "l", 357 "Ḿ": "M", 358 "ḿ": "m", 359 "M̆": "M", 360 "m̆": "m", 361 "Ń": "N", 362 "ń": "n", 363 "Ņ": "N", 364 "ņ": "n", 365 "Ň": "N", 366 "ň": "n", 367 "ʼn": "n", 368 "N̆": "N", 369 "n̆": "n", 370 "Ō": "O", 371 "ō": "o", 372 "Ŏ": "O", 373 "ŏ": "o", 374 "Ő": "O", 375 "ő": "o", 376 "Œ": "OE", 377 "œ": "oe", 378 "P̆": "P", 379 "p̆": "p", 380 "Ŕ": "R", 381 "ŕ": "r", 382 "Ŗ": "R", 383 "ŗ": "r", 384 "Ř": "R", 385 "ř": "r", 386 "R̆": "R", 387 "r̆": "r", 388 "Ȓ": "R", 389 "ȓ": "r", 390 "Ś": "S", 391 "ś": "s", 392 "Ŝ": "S", 393 "ŝ": "s", 394 "Ş": "S", 395 "Ș": "S", 396 "ș": "s", 397 "ş": "s", 398 "Š": "S", 399 "š": "s", 400 "Ţ": "T", 401 "ţ": "t", 402 "ț": "t", 403 "Ț": "T", 404 "Ť": "T", 405 "ť": "t", 406 "Ŧ": "T", 407 "ŧ": "t", 408 "T̆": "T", 409 "t̆": "t", 410 "Ũ": "U", 411 "ũ": "u", 412 "Ū": "U", 413 "ū": "u", 414 "Ŭ": "U", 415 "ŭ": "u", 416 "Ů": "U", 417 "ů": "u", 418 "Ű": "U", 419 "ű": "u", 420 "Ų": "U", 421 "ų": "u", 422 "Ȗ": "U", 423 "ȗ": "u", 424 "V̆": "V", 425 "v̆": "v", 426 "Ŵ": "W", 427 "ŵ": "w", 428 "Ẃ": "W", 429 "ẃ": "w", 430 "X̆": "X", 431 "x̆": "x", 432 "Ŷ": "Y", 433 "ŷ": "y", 434 "Ÿ": "Y", 435 "Y̆": "Y", 436 "y̆": "y", 437 "Ź": "Z", 438 "ź": "z", 439 "Ż": "Z", 440 "ż": "z", 441 "Ž": "Z", 442 "ž": "z", 443 "ſ": "s", 444 "ƒ": "f", 445 "Ơ": "O", 446 "ơ": "o", 447 "Ư": "U", 448 "ư": "u", 449 "Ǎ": "A", 450 "ǎ": "a", 451 "Ǐ": "I", 452 "ǐ": "i", 453 "Ǒ": "O", 454 "ǒ": "o", 455 "Ǔ": "U", 456 "ǔ": "u", 457 "Ǖ": "U", 458 "ǖ": "u", 459 "Ǘ": "U", 460 "ǘ": "u", 461 "Ǚ": "U", 462 "ǚ": "u", 463 "Ǜ": "U", 464 "ǜ": "u", 465 "Ứ": "U", 466 "ứ": "u", 467 "Ṹ": "U", 468 "ṹ": "u", 469 "Ǻ": "A", 470 "ǻ": "a", 471 "Ǽ": "AE", 472 "ǽ": "ae", 473 "Ǿ": "O", 474 "ǿ": "o", 475 "Þ": "TH", 476 "þ": "th", 477 "Ṕ": "P", 478 "ṕ": "p", 479 "Ṥ": "S", 480 "ṥ": "s", 481 "X́": "X", 482 "x́": "x", 483 "Ѓ": "Г", 484 "ѓ": "г", 485 "Ќ": "К", 486 "ќ": "к", 487 "A̋": "A", 488 "a̋": "a", 489 "E̋": "E", 490 "e̋": "e", 491 "I̋": "I", 492 "i̋": "i", 493 "Ǹ": "N", 494 "ǹ": "n", 495 "Ồ": "O", 496 "ồ": "o", 497 "Ṑ": "O", 498 "ṑ": "o", 499 "Ừ": "U", 500 "ừ": "u", 501 "Ẁ": "W", 502 "ẁ": "w", 503 "Ỳ": "Y", 504 "ỳ": "y", 505 "Ȁ": "A", 506 "ȁ": "a", 507 "Ȅ": "E", 508 "ȅ": "e", 509 "Ȉ": "I", 510 "ȉ": "i", 511 "Ȍ": "O", 512 "ȍ": "o", 513 "Ȑ": "R", 514 "ȑ": "r", 515 "Ȕ": "U", 516 "ȕ": "u", 517 "B̌": "B", 518 "b̌": "b", 519 "Č̣": "C", 520 "č̣": "c", 521 "Ê̌": "E", 522 "ê̌": "e", 523 "F̌": "F", 524 "f̌": "f", 525 "Ǧ": "G", 526 "ǧ": "g", 527 "Ȟ": "H", 528 "ȟ": "h", 529 "J̌": "J", 530 "ǰ": "j", 531 "Ǩ": "K", 532 "ǩ": "k", 533 "M̌": "M", 534 "m̌": "m", 535 "P̌": "P", 536 "p̌": "p", 537 "Q̌": "Q", 538 "q̌": "q", 539 "Ř̩": "R", 540 "ř̩": "r", 541 "Ṧ": "S", 542 "ṧ": "s", 543 "V̌": "V", 544 "v̌": "v", 545 "W̌": "W", 546 "w̌": "w", 547 "X̌": "X", 548 "x̌": "x", 549 "Y̌": "Y", 550 "y̌": "y", 551 "A̧": "A", 552 "a̧": "a", 553 "B̧": "B", 554 "b̧": "b", 555 "Ḑ": "D", 556 "ḑ": "d", 557 "Ȩ": "E", 558 "ȩ": "e", 559 "Ɛ̧": "E", 560 "ɛ̧": "e", 561 "Ḩ": "H", 562 "ḩ": "h", 563 "I̧": "I", 564 "i̧": "i", 565 "Ɨ̧": "I", 566 "ɨ̧": "i", 567 "M̧": "M", 568 "m̧": "m", 569 "O̧": "O", 570 "o̧": "o", 571 "Q̧": "Q", 572 "q̧": "q", 573 "U̧": "U", 574 "u̧": "u", 575 "X̧": "X", 576 "x̧": "x", 577 "Z̧": "Z", 578 "z̧": "z", 579 "й":"и", 580 "Й":"И", 581 "ё":"е", 582 "Ё":"Е", 583 }; 584 585 var chars = Object.keys(characterMap).join('|'); 586 var allAccents = new RegExp(chars, 'g'); 587 var firstAccent = new RegExp(chars, ''); 588 589 function matcher(match) { 590 return characterMap[match]; 591 } 592 593 var removeAccents = function(string) { 594 return string.replace(allAccents, matcher); 595 }; 596 597 var hasAccents = function(string) { 598 return !!string.match(firstAccent); 599 }; 600 601 module.exports = removeAccents; 602 module.exports.has = hasAccents; 603 module.exports.remove = removeAccents; 604 605 606 /***/ }), 607 608 /***/ 1030: 609 /***/ (function(module, exports, __webpack_require__) { 610 611 var __WEBPACK_AMD_DEFINE_RESULT__;;/*! showdown v 1.9.1 - 02-11-2019 */ 612 (function(){ 613 /** 614 * Created by Tivie on 13-07-2015. 615 */ 616 617 function getDefaultOpts (simple) { 618 'use strict'; 619 620 var defaultOptions = { 621 omitExtraWLInCodeBlocks: { 622 defaultValue: false, 623 describe: 'Omit the default extra whiteline added to code blocks', 624 type: 'boolean' 625 }, 626 noHeaderId: { 627 defaultValue: false, 628 describe: 'Turn on/off generated header id', 629 type: 'boolean' 630 }, 631 prefixHeaderId: { 632 defaultValue: false, 633 describe: 'Add a prefix to the generated header ids. Passing a string will prefix that string to the header id. Setting to true will add a generic \'section-\' prefix', 634 type: 'string' 635 }, 636 rawPrefixHeaderId: { 637 defaultValue: false, 638 describe: 'Setting this option to true will prevent showdown from modifying the prefix. This might result in malformed IDs (if, for instance, the " char is used in the prefix)', 639 type: 'boolean' 640 }, 641 ghCompatibleHeaderId: { 642 defaultValue: false, 643 describe: 'Generate header ids compatible with github style (spaces are replaced with dashes, a bunch of non alphanumeric chars are removed)', 644 type: 'boolean' 645 }, 646 rawHeaderId: { 647 defaultValue: false, 648 describe: 'Remove only spaces, \' and " from generated header ids (including prefixes), replacing them with dashes (-). WARNING: This might result in malformed ids', 649 type: 'boolean' 650 }, 651 headerLevelStart: { 652 defaultValue: false, 653 describe: 'The header blocks level start', 654 type: 'integer' 655 }, 656 parseImgDimensions: { 657 defaultValue: false, 658 describe: 'Turn on/off image dimension parsing', 659 type: 'boolean' 660 }, 661 simplifiedAutoLink: { 662 defaultValue: false, 663 describe: 'Turn on/off GFM autolink style', 664 type: 'boolean' 665 }, 666 excludeTrailingPunctuationFromURLs: { 667 defaultValue: false, 668 describe: 'Excludes trailing punctuation from links generated with autoLinking', 669 type: 'boolean' 670 }, 671 literalMidWordUnderscores: { 672 defaultValue: false, 673 describe: 'Parse midword underscores as literal underscores', 674 type: 'boolean' 675 }, 676 literalMidWordAsterisks: { 677 defaultValue: false, 678 describe: 'Parse midword asterisks as literal asterisks', 679 type: 'boolean' 680 }, 681 strikethrough: { 682 defaultValue: false, 683 describe: 'Turn on/off strikethrough support', 684 type: 'boolean' 685 }, 686 tables: { 687 defaultValue: false, 688 describe: 'Turn on/off tables support', 689 type: 'boolean' 690 }, 691 tablesHeaderId: { 692 defaultValue: false, 693 describe: 'Add an id to table headers', 694 type: 'boolean' 695 }, 696 ghCodeBlocks: { 697 defaultValue: true, 698 describe: 'Turn on/off GFM fenced code blocks support', 699 type: 'boolean' 700 }, 701 tasklists: { 702 defaultValue: false, 703 describe: 'Turn on/off GFM tasklist support', 704 type: 'boolean' 705 }, 706 smoothLivePreview: { 707 defaultValue: false, 708 describe: 'Prevents weird effects in live previews due to incomplete input', 709 type: 'boolean' 710 }, 711 smartIndentationFix: { 712 defaultValue: false, 713 description: 'Tries to smartly fix indentation in es6 strings', 714 type: 'boolean' 715 }, 716 disableForced4SpacesIndentedSublists: { 717 defaultValue: false, 718 description: 'Disables the requirement of indenting nested sublists by 4 spaces', 719 type: 'boolean' 720 }, 721 simpleLineBreaks: { 722 defaultValue: false, 723 description: 'Parses simple line breaks as <br> (GFM Style)', 724 type: 'boolean' 725 }, 726 requireSpaceBeforeHeadingText: { 727 defaultValue: false, 728 description: 'Makes adding a space between `#` and the header text mandatory (GFM Style)', 729 type: 'boolean' 730 }, 731 ghMentions: { 732 defaultValue: false, 733 description: 'Enables github @mentions', 734 type: 'boolean' 735 }, 736 ghMentionsLink: { 737 defaultValue: 'https://github.com/{u}', 738 description: 'Changes the link generated by @mentions. Only applies if ghMentions option is enabled.', 739 type: 'string' 740 }, 741 encodeEmails: { 742 defaultValue: true, 743 description: 'Encode e-mail addresses through the use of Character Entities, transforming ASCII e-mail addresses into its equivalent decimal entities', 744 type: 'boolean' 745 }, 746 openLinksInNewWindow: { 747 defaultValue: false, 748 description: 'Open all links in new windows', 749 type: 'boolean' 750 }, 751 backslashEscapesHTMLTags: { 752 defaultValue: false, 753 description: 'Support for HTML Tag escaping. ex: \<div>foo\</div>', 754 type: 'boolean' 755 }, 756 emoji: { 757 defaultValue: false, 758 description: 'Enable emoji support. Ex: `this is a :smile: emoji`', 759 type: 'boolean' 760 }, 761 underline: { 762 defaultValue: false, 763 description: 'Enable support for underline. Syntax is double or triple underscores: `__underline word__`. With this option enabled, underscores no longer parses into `<em>` and `<strong>`', 764 type: 'boolean' 765 }, 766 completeHTMLDocument: { 767 defaultValue: false, 768 description: 'Outputs a complete html document, including `<html>`, `<head>` and `<body>` tags', 769 type: 'boolean' 770 }, 771 metadata: { 772 defaultValue: false, 773 description: 'Enable support for document metadata (defined at the top of the document between `«««` and `»»»` or between `---` and `---`).', 774 type: 'boolean' 775 }, 776 splitAdjacentBlockquotes: { 777 defaultValue: false, 778 description: 'Split adjacent blockquote blocks', 779 type: 'boolean' 780 } 781 }; 782 if (simple === false) { 783 return JSON.parse(JSON.stringify(defaultOptions)); 784 } 785 var ret = {}; 786 for (var opt in defaultOptions) { 787 if (defaultOptions.hasOwnProperty(opt)) { 788 ret[opt] = defaultOptions[opt].defaultValue; 789 } 790 } 791 return ret; 792 } 793 794 function allOptionsOn () { 795 'use strict'; 796 var options = getDefaultOpts(true), 797 ret = {}; 798 for (var opt in options) { 799 if (options.hasOwnProperty(opt)) { 800 ret[opt] = true; 801 } 802 } 803 return ret; 804 } 805 806 /** 807 * Created by Tivie on 06-01-2015. 808 */ 809 810 // Private properties 811 var showdown = {}, 812 parsers = {}, 813 extensions = {}, 814 globalOptions = getDefaultOpts(true), 815 setFlavor = 'vanilla', 816 flavor = { 817 github: { 818 omitExtraWLInCodeBlocks: true, 819 simplifiedAutoLink: true, 820 excludeTrailingPunctuationFromURLs: true, 821 literalMidWordUnderscores: true, 822 strikethrough: true, 823 tables: true, 824 tablesHeaderId: true, 825 ghCodeBlocks: true, 826 tasklists: true, 827 disableForced4SpacesIndentedSublists: true, 828 simpleLineBreaks: true, 829 requireSpaceBeforeHeadingText: true, 830 ghCompatibleHeaderId: true, 831 ghMentions: true, 832 backslashEscapesHTMLTags: true, 833 emoji: true, 834 splitAdjacentBlockquotes: true 835 }, 836 original: { 837 noHeaderId: true, 838 ghCodeBlocks: false 839 }, 840 ghost: { 841 omitExtraWLInCodeBlocks: true, 842 parseImgDimensions: true, 843 simplifiedAutoLink: true, 844 excludeTrailingPunctuationFromURLs: true, 845 literalMidWordUnderscores: true, 846 strikethrough: true, 847 tables: true, 848 tablesHeaderId: true, 849 ghCodeBlocks: true, 850 tasklists: true, 851 smoothLivePreview: true, 852 simpleLineBreaks: true, 853 requireSpaceBeforeHeadingText: true, 854 ghMentions: false, 855 encodeEmails: true 856 }, 857 vanilla: getDefaultOpts(true), 858 allOn: allOptionsOn() 859 }; 860 861 /** 862 * helper namespace 863 * @type {{}} 864 */ 865 showdown.helper = {}; 866 867 /** 868 * TODO LEGACY SUPPORT CODE 869 * @type {{}} 870 */ 871 showdown.extensions = {}; 872 873 /** 874 * Set a global option 875 * @static 876 * @param {string} key 877 * @param {*} value 878 * @returns {showdown} 879 */ 880 showdown.setOption = function (key, value) { 881 'use strict'; 882 globalOptions[key] = value; 883 return this; 884 }; 885 886 /** 887 * Get a global option 888 * @static 889 * @param {string} key 890 * @returns {*} 891 */ 892 showdown.getOption = function (key) { 893 'use strict'; 894 return globalOptions[key]; 895 }; 896 897 /** 898 * Get the global options 899 * @static 900 * @returns {{}} 901 */ 902 showdown.getOptions = function () { 903 'use strict'; 904 return globalOptions; 905 }; 906 907 /** 908 * Reset global options to the default values 909 * @static 910 */ 911 showdown.resetOptions = function () { 912 'use strict'; 913 globalOptions = getDefaultOpts(true); 914 }; 915 916 /** 917 * Set the flavor showdown should use as default 918 * @param {string} name 919 */ 920 showdown.setFlavor = function (name) { 921 'use strict'; 922 if (!flavor.hasOwnProperty(name)) { 923 throw Error(name + ' flavor was not found'); 924 } 925 showdown.resetOptions(); 926 var preset = flavor[name]; 927 setFlavor = name; 928 for (var option in preset) { 929 if (preset.hasOwnProperty(option)) { 930 globalOptions[option] = preset[option]; 931 } 932 } 933 }; 934 935 /** 936 * Get the currently set flavor 937 * @returns {string} 938 */ 939 showdown.getFlavor = function () { 940 'use strict'; 941 return setFlavor; 942 }; 943 944 /** 945 * Get the options of a specified flavor. Returns undefined if the flavor was not found 946 * @param {string} name Name of the flavor 947 * @returns {{}|undefined} 948 */ 949 showdown.getFlavorOptions = function (name) { 950 'use strict'; 951 if (flavor.hasOwnProperty(name)) { 952 return flavor[name]; 953 } 954 }; 955 956 /** 957 * Get the default options 958 * @static 959 * @param {boolean} [simple=true] 960 * @returns {{}} 961 */ 962 showdown.getDefaultOptions = function (simple) { 963 'use strict'; 964 return getDefaultOpts(simple); 965 }; 966 967 /** 968 * Get or set a subParser 969 * 970 * subParser(name) - Get a registered subParser 971 * subParser(name, func) - Register a subParser 972 * @static 973 * @param {string} name 974 * @param {function} [func] 975 * @returns {*} 976 */ 977 showdown.subParser = function (name, func) { 978 'use strict'; 979 if (showdown.helper.isString(name)) { 980 if (typeof func !== 'undefined') { 981 parsers[name] = func; 982 } else { 983 if (parsers.hasOwnProperty(name)) { 984 return parsers[name]; 985 } else { 986 throw Error('SubParser named ' + name + ' not registered!'); 987 } 988 } 989 } 990 }; 991 992 /** 993 * Gets or registers an extension 994 * @static 995 * @param {string} name 996 * @param {object|function=} ext 997 * @returns {*} 998 */ 999 showdown.extension = function (name, ext) { 1000 'use strict'; 1001 1002 if (!showdown.helper.isString(name)) { 1003 throw Error('Extension \'name\' must be a string'); 1004 } 1005 1006 name = showdown.helper.stdExtName(name); 1007 1008 // Getter 1009 if (showdown.helper.isUndefined(ext)) { 1010 if (!extensions.hasOwnProperty(name)) { 1011 throw Error('Extension named ' + name + ' is not registered!'); 1012 } 1013 return extensions[name]; 1014 1015 // Setter 1016 } else { 1017 // Expand extension if it's wrapped in a function 1018 if (typeof ext === 'function') { 1019 ext = ext(); 1020 } 1021 1022 // Ensure extension is an array 1023 if (!showdown.helper.isArray(ext)) { 1024 ext = [ext]; 1025 } 1026 1027 var validExtension = validate(ext, name); 1028 1029 if (validExtension.valid) { 1030 extensions[name] = ext; 1031 } else { 1032 throw Error(validExtension.error); 1033 } 1034 } 1035 }; 1036 1037 /** 1038 * Gets all extensions registered 1039 * @returns {{}} 1040 */ 1041 showdown.getAllExtensions = function () { 1042 'use strict'; 1043 return extensions; 1044 }; 1045 1046 /** 1047 * Remove an extension 1048 * @param {string} name 1049 */ 1050 showdown.removeExtension = function (name) { 1051 'use strict'; 1052 delete extensions[name]; 1053 }; 1054 1055 /** 1056 * Removes all extensions 1057 */ 1058 showdown.resetExtensions = function () { 1059 'use strict'; 1060 extensions = {}; 1061 }; 1062 1063 /** 1064 * Validate extension 1065 * @param {array} extension 1066 * @param {string} name 1067 * @returns {{valid: boolean, error: string}} 1068 */ 1069 function validate (extension, name) { 1070 'use strict'; 1071 1072 var errMsg = (name) ? 'Error in ' + name + ' extension->' : 'Error in unnamed extension', 1073 ret = { 1074 valid: true, 1075 error: '' 1076 }; 1077 1078 if (!showdown.helper.isArray(extension)) { 1079 extension = [extension]; 1080 } 1081 1082 for (var i = 0; i < extension.length; ++i) { 1083 var baseMsg = errMsg + ' sub-extension ' + i + ': ', 1084 ext = extension[i]; 1085 if (typeof ext !== 'object') { 1086 ret.valid = false; 1087 ret.error = baseMsg + 'must be an object, but ' + typeof ext + ' given'; 1088 return ret; 1089 } 1090 1091 if (!showdown.helper.isString(ext.type)) { 1092 ret.valid = false; 1093 ret.error = baseMsg + 'property "type" must be a string, but ' + typeof ext.type + ' given'; 1094 return ret; 1095 } 1096 1097 var type = ext.type = ext.type.toLowerCase(); 1098 1099 // normalize extension type 1100 if (type === 'language') { 1101 type = ext.type = 'lang'; 1102 } 1103 1104 if (type === 'html') { 1105 type = ext.type = 'output'; 1106 } 1107 1108 if (type !== 'lang' && type !== 'output' && type !== 'listener') { 1109 ret.valid = false; 1110 ret.error = baseMsg + 'type ' + type + ' is not recognized. Valid values: "lang/language", "output/html" or "listener"'; 1111 return ret; 1112 } 1113 1114 if (type === 'listener') { 1115 if (showdown.helper.isUndefined(ext.listeners)) { 1116 ret.valid = false; 1117 ret.error = baseMsg + '. Extensions of type "listener" must have a property called "listeners"'; 1118 return ret; 1119 } 1120 } else { 1121 if (showdown.helper.isUndefined(ext.filter) && showdown.helper.isUndefined(ext.regex)) { 1122 ret.valid = false; 1123 ret.error = baseMsg + type + ' extensions must define either a "regex" property or a "filter" method'; 1124 return ret; 1125 } 1126 } 1127 1128 if (ext.listeners) { 1129 if (typeof ext.listeners !== 'object') { 1130 ret.valid = false; 1131 ret.error = baseMsg + '"listeners" property must be an object but ' + typeof ext.listeners + ' given'; 1132 return ret; 1133 } 1134 for (var ln in ext.listeners) { 1135 if (ext.listeners.hasOwnProperty(ln)) { 1136 if (typeof ext.listeners[ln] !== 'function') { 1137 ret.valid = false; 1138 ret.error = baseMsg + '"listeners" property must be an hash of [event name]: [callback]. listeners.' + ln + 1139 ' must be a function but ' + typeof ext.listeners[ln] + ' given'; 1140 return ret; 1141 } 1142 } 1143 } 1144 } 1145 1146 if (ext.filter) { 1147 if (typeof ext.filter !== 'function') { 1148 ret.valid = false; 1149 ret.error = baseMsg + '"filter" must be a function, but ' + typeof ext.filter + ' given'; 1150 return ret; 1151 } 1152 } else if (ext.regex) { 1153 if (showdown.helper.isString(ext.regex)) { 1154 ext.regex = new RegExp(ext.regex, 'g'); 1155 } 1156 if (!(ext.regex instanceof RegExp)) { 1157 ret.valid = false; 1158 ret.error = baseMsg + '"regex" property must either be a string or a RegExp object, but ' + typeof ext.regex + ' given'; 1159 return ret; 1160 } 1161 if (showdown.helper.isUndefined(ext.replace)) { 1162 ret.valid = false; 1163 ret.error = baseMsg + '"regex" extensions must implement a replace string or function'; 1164 return ret; 1165 } 1166 } 1167 } 1168 return ret; 1169 } 1170 1171 /** 1172 * Validate extension 1173 * @param {object} ext 1174 * @returns {boolean} 1175 */ 1176 showdown.validateExtension = function (ext) { 1177 'use strict'; 1178 1179 var validateExtension = validate(ext, null); 1180 if (!validateExtension.valid) { 1181 console.warn(validateExtension.error); 1182 return false; 1183 } 1184 return true; 1185 }; 1186 1187 /** 1188 * showdownjs helper functions 1189 */ 1190 1191 if (!showdown.hasOwnProperty('helper')) { 1192 showdown.helper = {}; 1193 } 1194 1195 /** 1196 * Check if var is string 1197 * @static 1198 * @param {string} a 1199 * @returns {boolean} 1200 */ 1201 showdown.helper.isString = function (a) { 1202 'use strict'; 1203 return (typeof a === 'string' || a instanceof String); 1204 }; 1205 1206 /** 1207 * Check if var is a function 1208 * @static 1209 * @param {*} a 1210 * @returns {boolean} 1211 */ 1212 showdown.helper.isFunction = function (a) { 1213 'use strict'; 1214 var getType = {}; 1215 return a && getType.toString.call(a) === '[object Function]'; 1216 }; 1217 1218 /** 1219 * isArray helper function 1220 * @static 1221 * @param {*} a 1222 * @returns {boolean} 1223 */ 1224 showdown.helper.isArray = function (a) { 1225 'use strict'; 1226 return Array.isArray(a); 1227 }; 1228 1229 /** 1230 * Check if value is undefined 1231 * @static 1232 * @param {*} value The value to check. 1233 * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`. 1234 */ 1235 showdown.helper.isUndefined = function (value) { 1236 'use strict'; 1237 return typeof value === 'undefined'; 1238 }; 1239 1240 /** 1241 * ForEach helper function 1242 * Iterates over Arrays and Objects (own properties only) 1243 * @static 1244 * @param {*} obj 1245 * @param {function} callback Accepts 3 params: 1. value, 2. key, 3. the original array/object 1246 */ 1247 showdown.helper.forEach = function (obj, callback) { 1248 'use strict'; 1249 // check if obj is defined 1250 if (showdown.helper.isUndefined(obj)) { 1251 throw new Error('obj param is required'); 1252 } 1253 1254 if (showdown.helper.isUndefined(callback)) { 1255 throw new Error('callback param is required'); 1256 } 1257 1258 if (!showdown.helper.isFunction(callback)) { 1259 throw new Error('callback param must be a function/closure'); 1260 } 1261 1262 if (typeof obj.forEach === 'function') { 1263 obj.forEach(callback); 1264 } else if (showdown.helper.isArray(obj)) { 1265 for (var i = 0; i < obj.length; i++) { 1266 callback(obj[i], i, obj); 1267 } 1268 } else if (typeof (obj) === 'object') { 1269 for (var prop in obj) { 1270 if (obj.hasOwnProperty(prop)) { 1271 callback(obj[prop], prop, obj); 1272 } 1273 } 1274 } else { 1275 throw new Error('obj does not seem to be an array or an iterable object'); 1276 } 1277 }; 1278 1279 /** 1280 * Standardidize extension name 1281 * @static 1282 * @param {string} s extension name 1283 * @returns {string} 1284 */ 1285 showdown.helper.stdExtName = function (s) { 1286 'use strict'; 1287 return s.replace(/[_?*+\/\\.^-]/g, '').replace(/\s/g, '').toLowerCase(); 1288 }; 1289 1290 function escapeCharactersCallback (wholeMatch, m1) { 1291 'use strict'; 1292 var charCodeToEscape = m1.charCodeAt(0); 1293 return '¨E' + charCodeToEscape + 'E'; 1294 } 1295 1296 /** 1297 * Callback used to escape characters when passing through String.replace 1298 * @static 1299 * @param {string} wholeMatch 1300 * @param {string} m1 1301 * @returns {string} 1302 */ 1303 showdown.helper.escapeCharactersCallback = escapeCharactersCallback; 1304 1305 /** 1306 * Escape characters in a string 1307 * @static 1308 * @param {string} text 1309 * @param {string} charsToEscape 1310 * @param {boolean} afterBackslash 1311 * @returns {XML|string|void|*} 1312 */ 1313 showdown.helper.escapeCharacters = function (text, charsToEscape, afterBackslash) { 1314 'use strict'; 1315 // First we have to escape the escape characters so that 1316 // we can build a character class out of them 1317 var regexString = '([' + charsToEscape.replace(/([\[\]\\])/g, '\\$1') + '])'; 1318 1319 if (afterBackslash) { 1320 regexString = '\\\\' + regexString; 1321 } 1322 1323 var regex = new RegExp(regexString, 'g'); 1324 text = text.replace(regex, escapeCharactersCallback); 1325 1326 return text; 1327 }; 1328 1329 /** 1330 * Unescape HTML entities 1331 * @param txt 1332 * @returns {string} 1333 */ 1334 showdown.helper.unescapeHTMLEntities = function (txt) { 1335 'use strict'; 1336 1337 return txt 1338 .replace(/"/g, '"') 1339 .replace(/</g, '<') 1340 .replace(/>/g, '>') 1341 .replace(/&/g, '&'); 1342 }; 1343 1344 var rgxFindMatchPos = function (str, left, right, flags) { 1345 'use strict'; 1346 var f = flags || '', 1347 g = f.indexOf('g') > -1, 1348 x = new RegExp(left + '|' + right, 'g' + f.replace(/g/g, '')), 1349 l = new RegExp(left, f.replace(/g/g, '')), 1350 pos = [], 1351 t, s, m, start, end; 1352 1353 do { 1354 t = 0; 1355 while ((m = x.exec(str))) { 1356 if (l.test(m[0])) { 1357 if (!(t++)) { 1358 s = x.lastIndex; 1359 start = s - m[0].length; 1360 } 1361 } else if (t) { 1362 if (!--t) { 1363 end = m.index + m[0].length; 1364 var obj = { 1365 left: {start: start, end: s}, 1366 match: {start: s, end: m.index}, 1367 right: {start: m.index, end: end}, 1368 wholeMatch: {start: start, end: end} 1369 }; 1370 pos.push(obj); 1371 if (!g) { 1372 return pos; 1373 } 1374 } 1375 } 1376 } 1377 } while (t && (x.lastIndex = s)); 1378 1379 return pos; 1380 }; 1381 1382 /** 1383 * matchRecursiveRegExp 1384 * 1385 * (c) 2007 Steven Levithan <stevenlevithan.com> 1386 * MIT License 1387 * 1388 * Accepts a string to search, a left and right format delimiter 1389 * as regex patterns, and optional regex flags. Returns an array 1390 * of matches, allowing nested instances of left/right delimiters. 1391 * Use the "g" flag to return all matches, otherwise only the 1392 * first is returned. Be careful to ensure that the left and 1393 * right format delimiters produce mutually exclusive matches. 1394 * Backreferences are not supported within the right delimiter 1395 * due to how it is internally combined with the left delimiter. 1396 * When matching strings whose format delimiters are unbalanced 1397 * to the left or right, the output is intentionally as a 1398 * conventional regex library with recursion support would 1399 * produce, e.g. "<<x>" and "<x>>" both produce ["x"] when using 1400 * "<" and ">" as the delimiters (both strings contain a single, 1401 * balanced instance of "<x>"). 1402 * 1403 * examples: 1404 * matchRecursiveRegExp("test", "\\(", "\\)") 1405 * returns: [] 1406 * matchRecursiveRegExp("<t<<e>><s>>t<>", "<", ">", "g") 1407 * returns: ["t<<e>><s>", ""] 1408 * matchRecursiveRegExp("<div id=\"x\">test</div>", "<div\\b[^>]*>", "</div>", "gi") 1409 * returns: ["test"] 1410 */ 1411 showdown.helper.matchRecursiveRegExp = function (str, left, right, flags) { 1412 'use strict'; 1413 1414 var matchPos = rgxFindMatchPos (str, left, right, flags), 1415 results = []; 1416 1417 for (var i = 0; i < matchPos.length; ++i) { 1418 results.push([ 1419 str.slice(matchPos[i].wholeMatch.start, matchPos[i].wholeMatch.end), 1420 str.slice(matchPos[i].match.start, matchPos[i].match.end), 1421 str.slice(matchPos[i].left.start, matchPos[i].left.end), 1422 str.slice(matchPos[i].right.start, matchPos[i].right.end) 1423 ]); 1424 } 1425 return results; 1426 }; 1427 1428 /** 1429 * 1430 * @param {string} str 1431 * @param {string|function} replacement 1432 * @param {string} left 1433 * @param {string} right 1434 * @param {string} flags 1435 * @returns {string} 1436 */ 1437 showdown.helper.replaceRecursiveRegExp = function (str, replacement, left, right, flags) { 1438 'use strict'; 1439 1440 if (!showdown.helper.isFunction(replacement)) { 1441 var repStr = replacement; 1442 replacement = function () { 1443 return repStr; 1444 }; 1445 } 1446 1447 var matchPos = rgxFindMatchPos(str, left, right, flags), 1448 finalStr = str, 1449 lng = matchPos.length; 1450 1451 if (lng > 0) { 1452 var bits = []; 1453 if (matchPos[0].wholeMatch.start !== 0) { 1454 bits.push(str.slice(0, matchPos[0].wholeMatch.start)); 1455 } 1456 for (var i = 0; i < lng; ++i) { 1457 bits.push( 1458 replacement( 1459 str.slice(matchPos[i].wholeMatch.start, matchPos[i].wholeMatch.end), 1460 str.slice(matchPos[i].match.start, matchPos[i].match.end), 1461 str.slice(matchPos[i].left.start, matchPos[i].left.end), 1462 str.slice(matchPos[i].right.start, matchPos[i].right.end) 1463 ) 1464 ); 1465 if (i < lng - 1) { 1466 bits.push(str.slice(matchPos[i].wholeMatch.end, matchPos[i + 1].wholeMatch.start)); 1467 } 1468 } 1469 if (matchPos[lng - 1].wholeMatch.end < str.length) { 1470 bits.push(str.slice(matchPos[lng - 1].wholeMatch.end)); 1471 } 1472 finalStr = bits.join(''); 1473 } 1474 return finalStr; 1475 }; 1476 1477 /** 1478 * Returns the index within the passed String object of the first occurrence of the specified regex, 1479 * starting the search at fromIndex. Returns -1 if the value is not found. 1480 * 1481 * @param {string} str string to search 1482 * @param {RegExp} regex Regular expression to search 1483 * @param {int} [fromIndex = 0] Index to start the search 1484 * @returns {Number} 1485 * @throws InvalidArgumentError 1486 */ 1487 showdown.helper.regexIndexOf = function (str, regex, fromIndex) { 1488 'use strict'; 1489 if (!showdown.helper.isString(str)) { 1490 throw 'InvalidArgumentError: first parameter of showdown.helper.regexIndexOf function must be a string'; 1491 } 1492 if (regex instanceof RegExp === false) { 1493 throw 'InvalidArgumentError: second parameter of showdown.helper.regexIndexOf function must be an instance of RegExp'; 1494 } 1495 var indexOf = str.substring(fromIndex || 0).search(regex); 1496 return (indexOf >= 0) ? (indexOf + (fromIndex || 0)) : indexOf; 1497 }; 1498 1499 /** 1500 * Splits the passed string object at the defined index, and returns an array composed of the two substrings 1501 * @param {string} str string to split 1502 * @param {int} index index to split string at 1503 * @returns {[string,string]} 1504 * @throws InvalidArgumentError 1505 */ 1506 showdown.helper.splitAtIndex = function (str, index) { 1507 'use strict'; 1508 if (!showdown.helper.isString(str)) { 1509 throw 'InvalidArgumentError: first parameter of showdown.helper.regexIndexOf function must be a string'; 1510 } 1511 return [str.substring(0, index), str.substring(index)]; 1512 }; 1513 1514 /** 1515 * Obfuscate an e-mail address through the use of Character Entities, 1516 * transforming ASCII characters into their equivalent decimal or hex entities. 1517 * 1518 * Since it has a random component, subsequent calls to this function produce different results 1519 * 1520 * @param {string} mail 1521 * @returns {string} 1522 */ 1523 showdown.helper.encodeEmailAddress = function (mail) { 1524 'use strict'; 1525 var encode = [ 1526 function (ch) { 1527 return '&#' + ch.charCodeAt(0) + ';'; 1528 }, 1529 function (ch) { 1530 return '&#x' + ch.charCodeAt(0).toString(16) + ';'; 1531 }, 1532 function (ch) { 1533 return ch; 1534 } 1535 ]; 1536 1537 mail = mail.replace(/./g, function (ch) { 1538 if (ch === '@') { 1539 // this *must* be encoded. I insist. 1540 ch = encode[Math.floor(Math.random() * 2)](ch); 1541 } else { 1542 var r = Math.random(); 1543 // roughly 10% raw, 45% hex, 45% dec 1544 ch = ( 1545 r > 0.9 ? encode[2](ch) : r > 0.45 ? encode[1](ch) : encode[0](ch) 1546 ); 1547 } 1548 return ch; 1549 }); 1550 1551 return mail; 1552 }; 1553 1554 /** 1555 * 1556 * @param str 1557 * @param targetLength 1558 * @param padString 1559 * @returns {string} 1560 */ 1561 showdown.helper.padEnd = function padEnd (str, targetLength, padString) { 1562 'use strict'; 1563 /*jshint bitwise: false*/ 1564 // eslint-disable-next-line space-infix-ops 1565 targetLength = targetLength>>0; //floor if number or convert non-number to 0; 1566 /*jshint bitwise: true*/ 1567 padString = String(padString || ' '); 1568 if (str.length > targetLength) { 1569 return String(str); 1570 } else { 1571 targetLength = targetLength - str.length; 1572 if (targetLength > padString.length) { 1573 padString += padString.repeat(targetLength / padString.length); //append to original to ensure we are longer than needed 1574 } 1575 return String(str) + padString.slice(0,targetLength); 1576 } 1577 }; 1578 1579 /** 1580 * POLYFILLS 1581 */ 1582 // use this instead of builtin is undefined for IE8 compatibility 1583 if (typeof console === 'undefined') { 1584 console = { 1585 warn: function (msg) { 1586 'use strict'; 1587 alert(msg); 1588 }, 1589 log: function (msg) { 1590 'use strict'; 1591 alert(msg); 1592 }, 1593 error: function (msg) { 1594 'use strict'; 1595 throw msg; 1596 } 1597 }; 1598 } 1599 1600 /** 1601 * Common regexes. 1602 * We declare some common regexes to improve performance 1603 */ 1604 showdown.helper.regexes = { 1605 asteriskDashAndColon: /([*_:~])/g 1606 }; 1607 1608 /** 1609 * EMOJIS LIST 1610 */ 1611 showdown.helper.emojis = { 1612 '+1':'\ud83d\udc4d', 1613 '-1':'\ud83d\udc4e', 1614 '100':'\ud83d\udcaf', 1615 '1234':'\ud83d\udd22', 1616 '1st_place_medal':'\ud83e\udd47', 1617 '2nd_place_medal':'\ud83e\udd48', 1618 '3rd_place_medal':'\ud83e\udd49', 1619 '8ball':'\ud83c\udfb1', 1620 'a':'\ud83c\udd70\ufe0f', 1621 'ab':'\ud83c\udd8e', 1622 'abc':'\ud83d\udd24', 1623 'abcd':'\ud83d\udd21', 1624 'accept':'\ud83c\ude51', 1625 'aerial_tramway':'\ud83d\udea1', 1626 'airplane':'\u2708\ufe0f', 1627 'alarm_clock':'\u23f0', 1628 'alembic':'\u2697\ufe0f', 1629 'alien':'\ud83d\udc7d', 1630 'ambulance':'\ud83d\ude91', 1631 'amphora':'\ud83c\udffa', 1632 'anchor':'\u2693\ufe0f', 1633 'angel':'\ud83d\udc7c', 1634 'anger':'\ud83d\udca2', 1635 'angry':'\ud83d\ude20', 1636 'anguished':'\ud83d\ude27', 1637 'ant':'\ud83d\udc1c', 1638 'apple':'\ud83c\udf4e', 1639 'aquarius':'\u2652\ufe0f', 1640 'aries':'\u2648\ufe0f', 1641 'arrow_backward':'\u25c0\ufe0f', 1642 'arrow_double_down':'\u23ec', 1643 'arrow_double_up':'\u23eb', 1644 'arrow_down':'\u2b07\ufe0f', 1645 'arrow_down_small':'\ud83d\udd3d', 1646 'arrow_forward':'\u25b6\ufe0f', 1647 'arrow_heading_down':'\u2935\ufe0f', 1648 'arrow_heading_up':'\u2934\ufe0f', 1649 'arrow_left':'\u2b05\ufe0f', 1650 'arrow_lower_left':'\u2199\ufe0f', 1651 'arrow_lower_right':'\u2198\ufe0f', 1652 'arrow_right':'\u27a1\ufe0f', 1653 'arrow_right_hook':'\u21aa\ufe0f', 1654 'arrow_up':'\u2b06\ufe0f', 1655 'arrow_up_down':'\u2195\ufe0f', 1656 'arrow_up_small':'\ud83d\udd3c', 1657 'arrow_upper_left':'\u2196\ufe0f', 1658 'arrow_upper_right':'\u2197\ufe0f', 1659 'arrows_clockwise':'\ud83d\udd03', 1660 'arrows_counterclockwise':'\ud83d\udd04', 1661 'art':'\ud83c\udfa8', 1662 'articulated_lorry':'\ud83d\ude9b', 1663 'artificial_satellite':'\ud83d\udef0', 1664 'astonished':'\ud83d\ude32', 1665 'athletic_shoe':'\ud83d\udc5f', 1666 'atm':'\ud83c\udfe7', 1667 'atom_symbol':'\u269b\ufe0f', 1668 'avocado':'\ud83e\udd51', 1669 'b':'\ud83c\udd71\ufe0f', 1670 'baby':'\ud83d\udc76', 1671 'baby_bottle':'\ud83c\udf7c', 1672 'baby_chick':'\ud83d\udc24', 1673 'baby_symbol':'\ud83d\udebc', 1674 'back':'\ud83d\udd19', 1675 'bacon':'\ud83e\udd53', 1676 'badminton':'\ud83c\udff8', 1677 'baggage_claim':'\ud83d\udec4', 1678 'baguette_bread':'\ud83e\udd56', 1679 'balance_scale':'\u2696\ufe0f', 1680 'balloon':'\ud83c\udf88', 1681 'ballot_box':'\ud83d\uddf3', 1682 'ballot_box_with_check':'\u2611\ufe0f', 1683 'bamboo':'\ud83c\udf8d', 1684 'banana':'\ud83c\udf4c', 1685 'bangbang':'\u203c\ufe0f', 1686 'bank':'\ud83c\udfe6', 1687 'bar_chart':'\ud83d\udcca', 1688 'barber':'\ud83d\udc88', 1689 'baseball':'\u26be\ufe0f', 1690 'basketball':'\ud83c\udfc0', 1691 'basketball_man':'\u26f9\ufe0f', 1692 'basketball_woman':'\u26f9\ufe0f‍\u2640\ufe0f', 1693 'bat':'\ud83e\udd87', 1694 'bath':'\ud83d\udec0', 1695 'bathtub':'\ud83d\udec1', 1696 'battery':'\ud83d\udd0b', 1697 'beach_umbrella':'\ud83c\udfd6', 1698 'bear':'\ud83d\udc3b', 1699 'bed':'\ud83d\udecf', 1700 'bee':'\ud83d\udc1d', 1701 'beer':'\ud83c\udf7a', 1702 'beers':'\ud83c\udf7b', 1703 'beetle':'\ud83d\udc1e', 1704 'beginner':'\ud83d\udd30', 1705 'bell':'\ud83d\udd14', 1706 'bellhop_bell':'\ud83d\udece', 1707 'bento':'\ud83c\udf71', 1708 'biking_man':'\ud83d\udeb4', 1709 'bike':'\ud83d\udeb2', 1710 'biking_woman':'\ud83d\udeb4‍\u2640\ufe0f', 1711 'bikini':'\ud83d\udc59', 1712 'biohazard':'\u2623\ufe0f', 1713 'bird':'\ud83d\udc26', 1714 'birthday':'\ud83c\udf82', 1715 'black_circle':'\u26ab\ufe0f', 1716 'black_flag':'\ud83c\udff4', 1717 'black_heart':'\ud83d\udda4', 1718 'black_joker':'\ud83c\udccf', 1719 'black_large_square':'\u2b1b\ufe0f', 1720 'black_medium_small_square':'\u25fe\ufe0f', 1721 'black_medium_square':'\u25fc\ufe0f', 1722 'black_nib':'\u2712\ufe0f', 1723 'black_small_square':'\u25aa\ufe0f', 1724 'black_square_button':'\ud83d\udd32', 1725 'blonde_man':'\ud83d\udc71', 1726 'blonde_woman':'\ud83d\udc71‍\u2640\ufe0f', 1727 'blossom':'\ud83c\udf3c', 1728 'blowfish':'\ud83d\udc21', 1729 'blue_book':'\ud83d\udcd8', 1730 'blue_car':'\ud83d\ude99', 1731 'blue_heart':'\ud83d\udc99', 1732 'blush':'\ud83d\ude0a', 1733 'boar':'\ud83d\udc17', 1734 'boat':'\u26f5\ufe0f', 1735 'bomb':'\ud83d\udca3', 1736 'book':'\ud83d\udcd6', 1737 'bookmark':'\ud83d\udd16', 1738 'bookmark_tabs':'\ud83d\udcd1', 1739 'books':'\ud83d\udcda', 1740 'boom':'\ud83d\udca5', 1741 'boot':'\ud83d\udc62', 1742 'bouquet':'\ud83d\udc90', 1743 'bowing_man':'\ud83d\ude47', 1744 'bow_and_arrow':'\ud83c\udff9', 1745 'bowing_woman':'\ud83d\ude47‍\u2640\ufe0f', 1746 'bowling':'\ud83c\udfb3', 1747 'boxing_glove':'\ud83e\udd4a', 1748 'boy':'\ud83d\udc66', 1749 'bread':'\ud83c\udf5e', 1750 'bride_with_veil':'\ud83d\udc70', 1751 'bridge_at_night':'\ud83c\udf09', 1752 'briefcase':'\ud83d\udcbc', 1753 'broken_heart':'\ud83d\udc94', 1754 'bug':'\ud83d\udc1b', 1755 'building_construction':'\ud83c\udfd7', 1756 'bulb':'\ud83d\udca1', 1757 'bullettrain_front':'\ud83d\ude85', 1758 'bullettrain_side':'\ud83d\ude84', 1759 'burrito':'\ud83c\udf2f', 1760 'bus':'\ud83d\ude8c', 1761 'business_suit_levitating':'\ud83d\udd74', 1762 'busstop':'\ud83d\ude8f', 1763 'bust_in_silhouette':'\ud83d\udc64', 1764 'busts_in_silhouette':'\ud83d\udc65', 1765 'butterfly':'\ud83e\udd8b', 1766 'cactus':'\ud83c\udf35', 1767 'cake':'\ud83c\udf70', 1768 'calendar':'\ud83d\udcc6', 1769 'call_me_hand':'\ud83e\udd19', 1770 'calling':'\ud83d\udcf2', 1771 'camel':'\ud83d\udc2b', 1772 'camera':'\ud83d\udcf7', 1773 'camera_flash':'\ud83d\udcf8', 1774 'camping':'\ud83c\udfd5', 1775 'cancer':'\u264b\ufe0f', 1776 'candle':'\ud83d\udd6f', 1777 'candy':'\ud83c\udf6c', 1778 'canoe':'\ud83d\udef6', 1779 'capital_abcd':'\ud83d\udd20', 1780 'capricorn':'\u2651\ufe0f', 1781 'car':'\ud83d\ude97', 1782 'card_file_box':'\ud83d\uddc3', 1783 'card_index':'\ud83d\udcc7', 1784 'card_index_dividers':'\ud83d\uddc2', 1785 'carousel_horse':'\ud83c\udfa0', 1786 'carrot':'\ud83e\udd55', 1787 'cat':'\ud83d\udc31', 1788 'cat2':'\ud83d\udc08', 1789 'cd':'\ud83d\udcbf', 1790 'chains':'\u26d3', 1791 'champagne':'\ud83c\udf7e', 1792 'chart':'\ud83d\udcb9', 1793 'chart_with_downwards_trend':'\ud83d\udcc9', 1794 'chart_with_upwards_trend':'\ud83d\udcc8', 1795 'checkered_flag':'\ud83c\udfc1', 1796 'cheese':'\ud83e\uddc0', 1797 'cherries':'\ud83c\udf52', 1798 'cherry_blossom':'\ud83c\udf38', 1799 'chestnut':'\ud83c\udf30', 1800 'chicken':'\ud83d\udc14', 1801 'children_crossing':'\ud83d\udeb8', 1802 'chipmunk':'\ud83d\udc3f', 1803 'chocolate_bar':'\ud83c\udf6b', 1804 'christmas_tree':'\ud83c\udf84', 1805 'church':'\u26ea\ufe0f', 1806 'cinema':'\ud83c\udfa6', 1807 'circus_tent':'\ud83c\udfaa', 1808 'city_sunrise':'\ud83c\udf07', 1809 'city_sunset':'\ud83c\udf06', 1810 'cityscape':'\ud83c\udfd9', 1811 'cl':'\ud83c\udd91', 1812 'clamp':'\ud83d\udddc', 1813 'clap':'\ud83d\udc4f', 1814 'clapper':'\ud83c\udfac', 1815 'classical_building':'\ud83c\udfdb', 1816 'clinking_glasses':'\ud83e\udd42', 1817 'clipboard':'\ud83d\udccb', 1818 'clock1':'\ud83d\udd50', 1819 'clock10':'\ud83d\udd59', 1820 'clock1030':'\ud83d\udd65', 1821 'clock11':'\ud83d\udd5a', 1822 'clock1130':'\ud83d\udd66', 1823 'clock12':'\ud83d\udd5b', 1824 'clock1230':'\ud83d\udd67', 1825 'clock130':'\ud83d\udd5c', 1826 'clock2':'\ud83d\udd51', 1827 'clock230':'\ud83d\udd5d', 1828 'clock3':'\ud83d\udd52', 1829 'clock330':'\ud83d\udd5e', 1830 'clock4':'\ud83d\udd53', 1831 'clock430':'\ud83d\udd5f', 1832 'clock5':'\ud83d\udd54', 1833 'clock530':'\ud83d\udd60', 1834 'clock6':'\ud83d\udd55', 1835 'clock630':'\ud83d\udd61', 1836 'clock7':'\ud83d\udd56', 1837 'clock730':'\ud83d\udd62', 1838 'clock8':'\ud83d\udd57', 1839 'clock830':'\ud83d\udd63', 1840 'clock9':'\ud83d\udd58', 1841 'clock930':'\ud83d\udd64', 1842 'closed_book':'\ud83d\udcd5', 1843 'closed_lock_with_key':'\ud83d\udd10', 1844 'closed_umbrella':'\ud83c\udf02', 1845 'cloud':'\u2601\ufe0f', 1846 'cloud_with_lightning':'\ud83c\udf29', 1847 'cloud_with_lightning_and_rain':'\u26c8', 1848 'cloud_with_rain':'\ud83c\udf27', 1849 'cloud_with_snow':'\ud83c\udf28', 1850 'clown_face':'\ud83e\udd21', 1851 'clubs':'\u2663\ufe0f', 1852 'cocktail':'\ud83c\udf78', 1853 'coffee':'\u2615\ufe0f', 1854 'coffin':'\u26b0\ufe0f', 1855 'cold_sweat':'\ud83d\ude30', 1856 'comet':'\u2604\ufe0f', 1857 'computer':'\ud83d\udcbb', 1858 'computer_mouse':'\ud83d\uddb1', 1859 'confetti_ball':'\ud83c\udf8a', 1860 'confounded':'\ud83d\ude16', 1861 'confused':'\ud83d\ude15', 1862 'congratulations':'\u3297\ufe0f', 1863 'construction':'\ud83d\udea7', 1864 'construction_worker_man':'\ud83d\udc77', 1865 'construction_worker_woman':'\ud83d\udc77‍\u2640\ufe0f', 1866 'control_knobs':'\ud83c\udf9b', 1867 'convenience_store':'\ud83c\udfea', 1868 'cookie':'\ud83c\udf6a', 1869 'cool':'\ud83c\udd92', 1870 'policeman':'\ud83d\udc6e', 1871 'copyright':'\u00a9\ufe0f', 1872 'corn':'\ud83c\udf3d', 1873 'couch_and_lamp':'\ud83d\udecb', 1874 'couple':'\ud83d\udc6b', 1875 'couple_with_heart_woman_man':'\ud83d\udc91', 1876 'couple_with_heart_man_man':'\ud83d\udc68‍\u2764\ufe0f‍\ud83d\udc68', 1877 'couple_with_heart_woman_woman':'\ud83d\udc69‍\u2764\ufe0f‍\ud83d\udc69', 1878 'couplekiss_man_man':'\ud83d\udc68‍\u2764\ufe0f‍\ud83d\udc8b‍\ud83d\udc68', 1879 'couplekiss_man_woman':'\ud83d\udc8f', 1880 'couplekiss_woman_woman':'\ud83d\udc69‍\u2764\ufe0f‍\ud83d\udc8b‍\ud83d\udc69', 1881 'cow':'\ud83d\udc2e', 1882 'cow2':'\ud83d\udc04', 1883 'cowboy_hat_face':'\ud83e\udd20', 1884 'crab':'\ud83e\udd80', 1885 'crayon':'\ud83d\udd8d', 1886 'credit_card':'\ud83d\udcb3', 1887 'crescent_moon':'\ud83c\udf19', 1888 'cricket':'\ud83c\udfcf', 1889 'crocodile':'\ud83d\udc0a', 1890 'croissant':'\ud83e\udd50', 1891 'crossed_fingers':'\ud83e\udd1e', 1892 'crossed_flags':'\ud83c\udf8c', 1893 'crossed_swords':'\u2694\ufe0f', 1894 'crown':'\ud83d\udc51', 1895 'cry':'\ud83d\ude22', 1896 'crying_cat_face':'\ud83d\ude3f', 1897 'crystal_ball':'\ud83d\udd2e', 1898 'cucumber':'\ud83e\udd52', 1899 'cupid':'\ud83d\udc98', 1900 'curly_loop':'\u27b0', 1901 'currency_exchange':'\ud83d\udcb1', 1902 'curry':'\ud83c\udf5b', 1903 'custard':'\ud83c\udf6e', 1904 'customs':'\ud83d\udec3', 1905 'cyclone':'\ud83c\udf00', 1906 'dagger':'\ud83d\udde1', 1907 'dancer':'\ud83d\udc83', 1908 'dancing_women':'\ud83d\udc6f', 1909 'dancing_men':'\ud83d\udc6f‍\u2642\ufe0f', 1910 'dango':'\ud83c\udf61', 1911 'dark_sunglasses':'\ud83d\udd76', 1912 'dart':'\ud83c\udfaf', 1913 'dash':'\ud83d\udca8', 1914 'date':'\ud83d\udcc5', 1915 'deciduous_tree':'\ud83c\udf33', 1916 'deer':'\ud83e\udd8c', 1917 'department_store':'\ud83c\udfec', 1918 'derelict_house':'\ud83c\udfda', 1919 'desert':'\ud83c\udfdc', 1920 'desert_island':'\ud83c\udfdd', 1921 'desktop_computer':'\ud83d\udda5', 1922 'male_detective':'\ud83d\udd75\ufe0f', 1923 'diamond_shape_with_a_dot_inside':'\ud83d\udca0', 1924 'diamonds':'\u2666\ufe0f', 1925 'disappointed':'\ud83d\ude1e', 1926 'disappointed_relieved':'\ud83d\ude25', 1927 'dizzy':'\ud83d\udcab', 1928 'dizzy_face':'\ud83d\ude35', 1929 'do_not_litter':'\ud83d\udeaf', 1930 'dog':'\ud83d\udc36', 1931 'dog2':'\ud83d\udc15', 1932 'dollar':'\ud83d\udcb5', 1933 'dolls':'\ud83c\udf8e', 1934 'dolphin':'\ud83d\udc2c', 1935 'door':'\ud83d\udeaa', 1936 'doughnut':'\ud83c\udf69', 1937 'dove':'\ud83d\udd4a', 1938 'dragon':'\ud83d\udc09', 1939 'dragon_face':'\ud83d\udc32', 1940 'dress':'\ud83d\udc57', 1941 'dromedary_camel':'\ud83d\udc2a', 1942 'drooling_face':'\ud83e\udd24', 1943 'droplet':'\ud83d\udca7', 1944 'drum':'\ud83e\udd41', 1945 'duck':'\ud83e\udd86', 1946 'dvd':'\ud83d\udcc0', 1947 'e-mail':'\ud83d\udce7', 1948 'eagle':'\ud83e\udd85', 1949 'ear':'\ud83d\udc42', 1950 'ear_of_rice':'\ud83c\udf3e', 1951 'earth_africa':'\ud83c\udf0d', 1952 'earth_americas':'\ud83c\udf0e', 1953 'earth_asia':'\ud83c\udf0f', 1954 'egg':'\ud83e\udd5a', 1955 'eggplant':'\ud83c\udf46', 1956 'eight_pointed_black_star':'\u2734\ufe0f', 1957 'eight_spoked_asterisk':'\u2733\ufe0f', 1958 'electric_plug':'\ud83d\udd0c', 1959 'elephant':'\ud83d\udc18', 1960 'email':'\u2709\ufe0f', 1961 'end':'\ud83d\udd1a', 1962 'envelope_with_arrow':'\ud83d\udce9', 1963 'euro':'\ud83d\udcb6', 1964 'european_castle':'\ud83c\udff0', 1965 'european_post_office':'\ud83c\udfe4', 1966 'evergreen_tree':'\ud83c\udf32', 1967 'exclamation':'\u2757\ufe0f', 1968 'expressionless':'\ud83d\ude11', 1969 'eye':'\ud83d\udc41', 1970 'eye_speech_bubble':'\ud83d\udc41‍\ud83d\udde8', 1971 'eyeglasses':'\ud83d\udc53', 1972 'eyes':'\ud83d\udc40', 1973 'face_with_head_bandage':'\ud83e\udd15', 1974 'face_with_thermometer':'\ud83e\udd12', 1975 'fist_oncoming':'\ud83d\udc4a', 1976 'factory':'\ud83c\udfed', 1977 'fallen_leaf':'\ud83c\udf42', 1978 'family_man_woman_boy':'\ud83d\udc6a', 1979 'family_man_boy':'\ud83d\udc68‍\ud83d\udc66', 1980 'family_man_boy_boy':'\ud83d\udc68‍\ud83d\udc66‍\ud83d\udc66', 1981 'family_man_girl':'\ud83d\udc68‍\ud83d\udc67', 1982 'family_man_girl_boy':'\ud83d\udc68‍\ud83d\udc67‍\ud83d\udc66', 1983 'family_man_girl_girl':'\ud83d\udc68‍\ud83d\udc67‍\ud83d\udc67', 1984 'family_man_man_boy':'\ud83d\udc68‍\ud83d\udc68‍\ud83d\udc66', 1985 'family_man_man_boy_boy':'\ud83d\udc68‍\ud83d\udc68‍\ud83d\udc66‍\ud83d\udc66', 1986 'family_man_man_girl':'\ud83d\udc68‍\ud83d\udc68‍\ud83d\udc67', 1987 'family_man_man_girl_boy':'\ud83d\udc68‍\ud83d\udc68‍\ud83d\udc67‍\ud83d\udc66', 1988 'family_man_man_girl_girl':'\ud83d\udc68‍\ud83d\udc68‍\ud83d\udc67‍\ud83d\udc67', 1989 'family_man_woman_boy_boy':'\ud83d\udc68‍\ud83d\udc69‍\ud83d\udc66‍\ud83d\udc66', 1990 'family_man_woman_girl':'\ud83d\udc68‍\ud83d\udc69‍\ud83d\udc67', 1991 'family_man_woman_girl_boy':'\ud83d\udc68‍\ud83d\udc69‍\ud83d\udc67‍\ud83d\udc66', 1992 'family_man_woman_girl_girl':'\ud83d\udc68‍\ud83d\udc69‍\ud83d\udc67‍\ud83d\udc67', 1993 'family_woman_boy':'\ud83d\udc69‍\ud83d\udc66', 1994 'family_woman_boy_boy':'\ud83d\udc69‍\ud83d\udc66‍\ud83d\udc66', 1995 'family_woman_girl':'\ud83d\udc69‍\ud83d\udc67', 1996 'family_woman_girl_boy':'\ud83d\udc69‍\ud83d\udc67‍\ud83d\udc66', 1997 'family_woman_girl_girl':'\ud83d\udc69‍\ud83d\udc67‍\ud83d\udc67', 1998 'family_woman_woman_boy':'\ud83d\udc69‍\ud83d\udc69‍\ud83d\udc66', 1999 'family_woman_woman_boy_boy':'\ud83d\udc69‍\ud83d\udc69‍\ud83d\udc66‍\ud83d\udc66', 2000 'family_woman_woman_girl':'\ud83d\udc69‍\ud83d\udc69‍\ud83d\udc67', 2001 'family_woman_woman_girl_boy':'\ud83d\udc69‍\ud83d\udc69‍\ud83d\udc67‍\ud83d\udc66', 2002 'family_woman_woman_girl_girl':'\ud83d\udc69‍\ud83d\udc69‍\ud83d\udc67‍\ud83d\udc67', 2003 'fast_forward':'\u23e9', 2004 'fax':'\ud83d\udce0', 2005 'fearful':'\ud83d\ude28', 2006 'feet':'\ud83d\udc3e', 2007 'female_detective':'\ud83d\udd75\ufe0f‍\u2640\ufe0f', 2008 'ferris_wheel':'\ud83c\udfa1', 2009 'ferry':'\u26f4', 2010 'field_hockey':'\ud83c\udfd1', 2011 'file_cabinet':'\ud83d\uddc4', 2012 'file_folder':'\ud83d\udcc1', 2013 'film_projector':'\ud83d\udcfd', 2014 'film_strip':'\ud83c\udf9e', 2015 'fire':'\ud83d\udd25', 2016 'fire_engine':'\ud83d\ude92', 2017 'fireworks':'\ud83c\udf86', 2018 'first_quarter_moon':'\ud83c\udf13', 2019 'first_quarter_moon_with_face':'\ud83c\udf1b', 2020 'fish':'\ud83d\udc1f', 2021 'fish_cake':'\ud83c\udf65', 2022 'fishing_pole_and_fish':'\ud83c\udfa3', 2023 'fist_raised':'\u270a', 2024 'fist_left':'\ud83e\udd1b', 2025 'fist_right':'\ud83e\udd1c', 2026 'flags':'\ud83c\udf8f', 2027 'flashlight':'\ud83d\udd26', 2028 'fleur_de_lis':'\u269c\ufe0f', 2029 'flight_arrival':'\ud83d\udeec', 2030 'flight_departure':'\ud83d\udeeb', 2031 'floppy_disk':'\ud83d\udcbe', 2032 'flower_playing_cards':'\ud83c\udfb4', 2033 'flushed':'\ud83d\ude33', 2034 'fog':'\ud83c\udf2b', 2035 'foggy':'\ud83c\udf01', 2036 'football':'\ud83c\udfc8', 2037 'footprints':'\ud83d\udc63', 2038 'fork_and_knife':'\ud83c\udf74', 2039 'fountain':'\u26f2\ufe0f', 2040 'fountain_pen':'\ud83d\udd8b', 2041 'four_leaf_clover':'\ud83c\udf40', 2042 'fox_face':'\ud83e\udd8a', 2043 'framed_picture':'\ud83d\uddbc', 2044 'free':'\ud83c\udd93', 2045 'fried_egg':'\ud83c\udf73', 2046 'fried_shrimp':'\ud83c\udf64', 2047 'fries':'\ud83c\udf5f', 2048 'frog':'\ud83d\udc38', 2049 'frowning':'\ud83d\ude26', 2050 'frowning_face':'\u2639\ufe0f', 2051 'frowning_man':'\ud83d\ude4d‍\u2642\ufe0f', 2052 'frowning_woman':'\ud83d\ude4d', 2053 'middle_finger':'\ud83d\udd95', 2054 'fuelpump':'\u26fd\ufe0f', 2055 'full_moon':'\ud83c\udf15', 2056 'full_moon_with_face':'\ud83c\udf1d', 2057 'funeral_urn':'\u26b1\ufe0f', 2058 'game_die':'\ud83c\udfb2', 2059 'gear':'\u2699\ufe0f', 2060 'gem':'\ud83d\udc8e', 2061 'gemini':'\u264a\ufe0f', 2062 'ghost':'\ud83d\udc7b', 2063 'gift':'\ud83c\udf81', 2064 'gift_heart':'\ud83d\udc9d', 2065 'girl':'\ud83d\udc67', 2066 'globe_with_meridians':'\ud83c\udf10', 2067 'goal_net':'\ud83e\udd45', 2068 'goat':'\ud83d\udc10', 2069 'golf':'\u26f3\ufe0f', 2070 'golfing_man':'\ud83c\udfcc\ufe0f', 2071 'golfing_woman':'\ud83c\udfcc\ufe0f‍\u2640\ufe0f', 2072 'gorilla':'\ud83e\udd8d', 2073 'grapes':'\ud83c\udf47', 2074 'green_apple':'\ud83c\udf4f', 2075 'green_book':'\ud83d\udcd7', 2076 'green_heart':'\ud83d\udc9a', 2077 'green_salad':'\ud83e\udd57', 2078 'grey_exclamation':'\u2755', 2079 'grey_question':'\u2754', 2080 'grimacing':'\ud83d\ude2c', 2081 'grin':'\ud83d\ude01', 2082 'grinning':'\ud83d\ude00', 2083 'guardsman':'\ud83d\udc82', 2084 'guardswoman':'\ud83d\udc82‍\u2640\ufe0f', 2085 'guitar':'\ud83c\udfb8', 2086 'gun':'\ud83d\udd2b', 2087 'haircut_woman':'\ud83d\udc87', 2088 'haircut_man':'\ud83d\udc87‍\u2642\ufe0f', 2089 'hamburger':'\ud83c\udf54', 2090 'hammer':'\ud83d\udd28', 2091 'hammer_and_pick':'\u2692', 2092 'hammer_and_wrench':'\ud83d\udee0', 2093 'hamster':'\ud83d\udc39', 2094 'hand':'\u270b', 2095 'handbag':'\ud83d\udc5c', 2096 'handshake':'\ud83e\udd1d', 2097 'hankey':'\ud83d\udca9', 2098 'hatched_chick':'\ud83d\udc25', 2099 'hatching_chick':'\ud83d\udc23', 2100 'headphones':'\ud83c\udfa7', 2101 'hear_no_evil':'\ud83d\ude49', 2102 'heart':'\u2764\ufe0f', 2103 'heart_decoration':'\ud83d\udc9f', 2104 'heart_eyes':'\ud83d\ude0d', 2105 'heart_eyes_cat':'\ud83d\ude3b', 2106 'heartbeat':'\ud83d\udc93', 2107 'heartpulse':'\ud83d\udc97', 2108 'hearts':'\u2665\ufe0f', 2109 'heavy_check_mark':'\u2714\ufe0f', 2110 'heavy_division_sign':'\u2797', 2111 'heavy_dollar_sign':'\ud83d\udcb2', 2112 'heavy_heart_exclamation':'\u2763\ufe0f', 2113 'heavy_minus_sign':'\u2796', 2114 'heavy_multiplication_x':'\u2716\ufe0f', 2115 'heavy_plus_sign':'\u2795', 2116 'helicopter':'\ud83d\ude81', 2117 'herb':'\ud83c\udf3f', 2118 'hibiscus':'\ud83c\udf3a', 2119 'high_brightness':'\ud83d\udd06', 2120 'high_heel':'\ud83d\udc60', 2121 'hocho':'\ud83d\udd2a', 2122 'hole':'\ud83d\udd73', 2123 'honey_pot':'\ud83c\udf6f', 2124 'horse':'\ud83d\udc34', 2125 'horse_racing':'\ud83c\udfc7', 2126 'hospital':'\ud83c\udfe5', 2127 'hot_pepper':'\ud83c\udf36', 2128 'hotdog':'\ud83c\udf2d', 2129 'hotel':'\ud83c\udfe8', 2130 'hotsprings':'\u2668\ufe0f', 2131 'hourglass':'\u231b\ufe0f', 2132 'hourglass_flowing_sand':'\u23f3', 2133 'house':'\ud83c\udfe0', 2134 'house_with_garden':'\ud83c\udfe1', 2135 'houses':'\ud83c\udfd8', 2136 'hugs':'\ud83e\udd17', 2137 'hushed':'\ud83d\ude2f', 2138 'ice_cream':'\ud83c\udf68', 2139 'ice_hockey':'\ud83c\udfd2', 2140 'ice_skate':'\u26f8', 2141 'icecream':'\ud83c\udf66', 2142 'id':'\ud83c\udd94', 2143 'ideograph_advantage':'\ud83c\ude50', 2144 'imp':'\ud83d\udc7f', 2145 'inbox_tray':'\ud83d\udce5', 2146 'incoming_envelope':'\ud83d\udce8', 2147 'tipping_hand_woman':'\ud83d\udc81', 2148 'information_source':'\u2139\ufe0f', 2149 'innocent':'\ud83d\ude07', 2150 'interrobang':'\u2049\ufe0f', 2151 'iphone':'\ud83d\udcf1', 2152 'izakaya_lantern':'\ud83c\udfee', 2153 'jack_o_lantern':'\ud83c\udf83', 2154 'japan':'\ud83d\uddfe', 2155 'japanese_castle':'\ud83c\udfef', 2156 'japanese_goblin':'\ud83d\udc7a', 2157 'japanese_ogre':'\ud83d\udc79', 2158 'jeans':'\ud83d\udc56', 2159 'joy':'\ud83d\ude02', 2160 'joy_cat':'\ud83d\ude39', 2161 'joystick':'\ud83d\udd79', 2162 'kaaba':'\ud83d\udd4b', 2163 'key':'\ud83d\udd11', 2164 'keyboard':'\u2328\ufe0f', 2165 'keycap_ten':'\ud83d\udd1f', 2166 'kick_scooter':'\ud83d\udef4', 2167 'kimono':'\ud83d\udc58', 2168 'kiss':'\ud83d\udc8b', 2169 'kissing':'\ud83d\ude17', 2170 'kissing_cat':'\ud83d\ude3d', 2171 'kissing_closed_eyes':'\ud83d\ude1a', 2172 'kissing_heart':'\ud83d\ude18', 2173 'kissing_smiling_eyes':'\ud83d\ude19', 2174 'kiwi_fruit':'\ud83e\udd5d', 2175 'koala':'\ud83d\udc28', 2176 'koko':'\ud83c\ude01', 2177 'label':'\ud83c\udff7', 2178 'large_blue_circle':'\ud83d\udd35', 2179 'large_blue_diamond':'\ud83d\udd37', 2180 'large_orange_diamond':'\ud83d\udd36', 2181 'last_quarter_moon':'\ud83c\udf17', 2182 'last_quarter_moon_with_face':'\ud83c\udf1c', 2183 'latin_cross':'\u271d\ufe0f', 2184 'laughing':'\ud83d\ude06', 2185 'leaves':'\ud83c\udf43', 2186 'ledger':'\ud83d\udcd2', 2187 'left_luggage':'\ud83d\udec5', 2188 'left_right_arrow':'\u2194\ufe0f', 2189 'leftwards_arrow_with_hook':'\u21a9\ufe0f', 2190 'lemon':'\ud83c\udf4b', 2191 'leo':'\u264c\ufe0f', 2192 'leopard':'\ud83d\udc06', 2193 'level_slider':'\ud83c\udf9a', 2194 'libra':'\u264e\ufe0f', 2195 'light_rail':'\ud83d\ude88', 2196 'link':'\ud83d\udd17', 2197 'lion':'\ud83e\udd81', 2198 'lips':'\ud83d\udc44', 2199 'lipstick':'\ud83d\udc84', 2200 'lizard':'\ud83e\udd8e', 2201 'lock':'\ud83d\udd12', 2202 'lock_with_ink_pen':'\ud83d\udd0f', 2203 'lollipop':'\ud83c\udf6d', 2204 'loop':'\u27bf', 2205 'loud_sound':'\ud83d\udd0a', 2206 'loudspeaker':'\ud83d\udce2', 2207 'love_hotel':'\ud83c\udfe9', 2208 'love_letter':'\ud83d\udc8c', 2209 'low_brightness':'\ud83d\udd05', 2210 'lying_face':'\ud83e\udd25', 2211 'm':'\u24c2\ufe0f', 2212 'mag':'\ud83d\udd0d', 2213 'mag_right':'\ud83d\udd0e', 2214 'mahjong':'\ud83c\udc04\ufe0f', 2215 'mailbox':'\ud83d\udceb', 2216 'mailbox_closed':'\ud83d\udcea', 2217 'mailbox_with_mail':'\ud83d\udcec', 2218 'mailbox_with_no_mail':'\ud83d\udced', 2219 'man':'\ud83d\udc68', 2220 'man_artist':'\ud83d\udc68‍\ud83c\udfa8', 2221 'man_astronaut':'\ud83d\udc68‍\ud83d\ude80', 2222 'man_cartwheeling':'\ud83e\udd38‍\u2642\ufe0f', 2223 'man_cook':'\ud83d\udc68‍\ud83c\udf73', 2224 'man_dancing':'\ud83d\udd7a', 2225 'man_facepalming':'\ud83e\udd26‍\u2642\ufe0f', 2226 'man_factory_worker':'\ud83d\udc68‍\ud83c\udfed', 2227 'man_farmer':'\ud83d\udc68‍\ud83c\udf3e', 2228 'man_firefighter':'\ud83d\udc68‍\ud83d\ude92', 2229 'man_health_worker':'\ud83d\udc68‍\u2695\ufe0f', 2230 'man_in_tuxedo':'\ud83e\udd35', 2231 'man_judge':'\ud83d\udc68‍\u2696\ufe0f', 2232 'man_juggling':'\ud83e\udd39‍\u2642\ufe0f', 2233 'man_mechanic':'\ud83d\udc68‍\ud83d\udd27', 2234 'man_office_worker':'\ud83d\udc68‍\ud83d\udcbc', 2235 'man_pilot':'\ud83d\udc68‍\u2708\ufe0f', 2236 'man_playing_handball':'\ud83e\udd3e‍\u2642\ufe0f', 2237 'man_playing_water_polo':'\ud83e\udd3d‍\u2642\ufe0f', 2238 'man_scientist':'\ud83d\udc68‍\ud83d\udd2c', 2239 'man_shrugging':'\ud83e\udd37‍\u2642\ufe0f', 2240 'man_singer':'\ud83d\udc68‍\ud83c\udfa4', 2241 'man_student':'\ud83d\udc68‍\ud83c\udf93', 2242 'man_teacher':'\ud83d\udc68‍\ud83c\udfeb', 2243 'man_technologist':'\ud83d\udc68‍\ud83d\udcbb', 2244 'man_with_gua_pi_mao':'\ud83d\udc72', 2245 'man_with_turban':'\ud83d\udc73', 2246 'tangerine':'\ud83c\udf4a', 2247 'mans_shoe':'\ud83d\udc5e', 2248 'mantelpiece_clock':'\ud83d\udd70', 2249 'maple_leaf':'\ud83c\udf41', 2250 'martial_arts_uniform':'\ud83e\udd4b', 2251 'mask':'\ud83d\ude37', 2252 'massage_woman':'\ud83d\udc86', 2253 'massage_man':'\ud83d\udc86‍\u2642\ufe0f', 2254 'meat_on_bone':'\ud83c\udf56', 2255 'medal_military':'\ud83c\udf96', 2256 'medal_sports':'\ud83c\udfc5', 2257 'mega':'\ud83d\udce3', 2258 'melon':'\ud83c\udf48', 2259 'memo':'\ud83d\udcdd', 2260 'men_wrestling':'\ud83e\udd3c‍\u2642\ufe0f', 2261 'menorah':'\ud83d\udd4e', 2262 'mens':'\ud83d\udeb9', 2263 'metal':'\ud83e\udd18', 2264 'metro':'\ud83d\ude87', 2265 'microphone':'\ud83c\udfa4', 2266 'microscope':'\ud83d\udd2c', 2267 'milk_glass':'\ud83e\udd5b', 2268 'milky_way':'\ud83c\udf0c', 2269 'minibus':'\ud83d\ude90', 2270 'minidisc':'\ud83d\udcbd', 2271 'mobile_phone_off':'\ud83d\udcf4', 2272 'money_mouth_face':'\ud83e\udd11', 2273 'money_with_wings':'\ud83d\udcb8', 2274 'moneybag':'\ud83d\udcb0', 2275 'monkey':'\ud83d\udc12', 2276 'monkey_face':'\ud83d\udc35', 2277 'monorail':'\ud83d\ude9d', 2278 'moon':'\ud83c\udf14', 2279 'mortar_board':'\ud83c\udf93', 2280 'mosque':'\ud83d\udd4c', 2281 'motor_boat':'\ud83d\udee5', 2282 'motor_scooter':'\ud83d\udef5', 2283 'motorcycle':'\ud83c\udfcd', 2284 'motorway':'\ud83d\udee3', 2285 'mount_fuji':'\ud83d\uddfb', 2286 'mountain':'\u26f0', 2287 'mountain_biking_man':'\ud83d\udeb5', 2288 'mountain_biking_woman':'\ud83d\udeb5‍\u2640\ufe0f', 2289 'mountain_cableway':'\ud83d\udea0', 2290 'mountain_railway':'\ud83d\ude9e', 2291 'mountain_snow':'\ud83c\udfd4', 2292 'mouse':'\ud83d\udc2d', 2293 'mouse2':'\ud83d\udc01', 2294 'movie_camera':'\ud83c\udfa5', 2295 'moyai':'\ud83d\uddff', 2296 'mrs_claus':'\ud83e\udd36', 2297 'muscle':'\ud83d\udcaa', 2298 'mushroom':'\ud83c\udf44', 2299 'musical_keyboard':'\ud83c\udfb9', 2300 'musical_note':'\ud83c\udfb5', 2301 'musical_score':'\ud83c\udfbc', 2302 'mute':'\ud83d\udd07', 2303 'nail_care':'\ud83d\udc85', 2304 'name_badge':'\ud83d\udcdb', 2305 'national_park':'\ud83c\udfde', 2306 'nauseated_face':'\ud83e\udd22', 2307 'necktie':'\ud83d\udc54', 2308 'negative_squared_cross_mark':'\u274e', 2309 'nerd_face':'\ud83e\udd13', 2310 'neutral_face':'\ud83d\ude10', 2311 'new':'\ud83c\udd95', 2312 'new_moon':'\ud83c\udf11', 2313 'new_moon_with_face':'\ud83c\udf1a', 2314 'newspaper':'\ud83d\udcf0', 2315 'newspaper_roll':'\ud83d\uddde', 2316 'next_track_button':'\u23ed', 2317 'ng':'\ud83c\udd96', 2318 'no_good_man':'\ud83d\ude45‍\u2642\ufe0f', 2319 'no_good_woman':'\ud83d\ude45', 2320 'night_with_stars':'\ud83c\udf03', 2321 'no_bell':'\ud83d\udd15', 2322 'no_bicycles':'\ud83d\udeb3', 2323 'no_entry':'\u26d4\ufe0f', 2324 'no_entry_sign':'\ud83d\udeab', 2325 'no_mobile_phones':'\ud83d\udcf5', 2326 'no_mouth':'\ud83d\ude36', 2327 'no_pedestrians':'\ud83d\udeb7', 2328 'no_smoking':'\ud83d\udead', 2329 'non-potable_water':'\ud83d\udeb1', 2330 'nose':'\ud83d\udc43', 2331 'notebook':'\ud83d\udcd3', 2332 'notebook_with_decorative_cover':'\ud83d\udcd4', 2333 'notes':'\ud83c\udfb6', 2334 'nut_and_bolt':'\ud83d\udd29', 2335 'o':'\u2b55\ufe0f', 2336 'o2':'\ud83c\udd7e\ufe0f', 2337 'ocean':'\ud83c\udf0a', 2338 'octopus':'\ud83d\udc19', 2339 'oden':'\ud83c\udf62', 2340 'office':'\ud83c\udfe2', 2341 'oil_drum':'\ud83d\udee2', 2342 'ok':'\ud83c\udd97', 2343 'ok_hand':'\ud83d\udc4c', 2344 'ok_man':'\ud83d\ude46‍\u2642\ufe0f', 2345 'ok_woman':'\ud83d\ude46', 2346 'old_key':'\ud83d\udddd', 2347 'older_man':'\ud83d\udc74', 2348 'older_woman':'\ud83d\udc75', 2349 'om':'\ud83d\udd49', 2350 'on':'\ud83d\udd1b', 2351 'oncoming_automobile':'\ud83d\ude98', 2352 'oncoming_bus':'\ud83d\ude8d', 2353 'oncoming_police_car':'\ud83d\ude94', 2354 'oncoming_taxi':'\ud83d\ude96', 2355 'open_file_folder':'\ud83d\udcc2', 2356 'open_hands':'\ud83d\udc50', 2357 'open_mouth':'\ud83d\ude2e', 2358 'open_umbrella':'\u2602\ufe0f', 2359 'ophiuchus':'\u26ce', 2360 'orange_book':'\ud83d\udcd9', 2361 'orthodox_cross':'\u2626\ufe0f', 2362 'outbox_tray':'\ud83d\udce4', 2363 'owl':'\ud83e\udd89', 2364 'ox':'\ud83d\udc02', 2365 'package':'\ud83d\udce6', 2366 'page_facing_up':'\ud83d\udcc4', 2367 'page_with_curl':'\ud83d\udcc3', 2368 'pager':'\ud83d\udcdf', 2369 'paintbrush':'\ud83d\udd8c', 2370 'palm_tree':'\ud83c\udf34', 2371 'pancakes':'\ud83e\udd5e', 2372 'panda_face':'\ud83d\udc3c', 2373 'paperclip':'\ud83d\udcce', 2374 'paperclips':'\ud83d\udd87', 2375 'parasol_on_ground':'\u26f1', 2376 'parking':'\ud83c\udd7f\ufe0f', 2377 'part_alternation_mark':'\u303d\ufe0f', 2378 'partly_sunny':'\u26c5\ufe0f', 2379 'passenger_ship':'\ud83d\udef3', 2380 'passport_control':'\ud83d\udec2', 2381 'pause_button':'\u23f8', 2382 'peace_symbol':'\u262e\ufe0f', 2383 'peach':'\ud83c\udf51', 2384 'peanuts':'\ud83e\udd5c', 2385 'pear':'\ud83c\udf50', 2386 'pen':'\ud83d\udd8a', 2387 'pencil2':'\u270f\ufe0f', 2388 'penguin':'\ud83d\udc27', 2389 'pensive':'\ud83d\ude14', 2390 'performing_arts':'\ud83c\udfad', 2391 'persevere':'\ud83d\ude23', 2392 'person_fencing':'\ud83e\udd3a', 2393 'pouting_woman':'\ud83d\ude4e', 2394 'phone':'\u260e\ufe0f', 2395 'pick':'\u26cf', 2396 'pig':'\ud83d\udc37', 2397 'pig2':'\ud83d\udc16', 2398 'pig_nose':'\ud83d\udc3d', 2399 'pill':'\ud83d\udc8a', 2400 'pineapple':'\ud83c\udf4d', 2401 'ping_pong':'\ud83c\udfd3', 2402 'pisces':'\u2653\ufe0f', 2403 'pizza':'\ud83c\udf55', 2404 'place_of_worship':'\ud83d\uded0', 2405 'plate_with_cutlery':'\ud83c\udf7d', 2406 'play_or_pause_button':'\u23ef', 2407 'point_down':'\ud83d\udc47', 2408 'point_left':'\ud83d\udc48', 2409 'point_right':'\ud83d\udc49', 2410 'point_up':'\u261d\ufe0f', 2411 'point_up_2':'\ud83d\udc46', 2412 'police_car':'\ud83d\ude93', 2413 'policewoman':'\ud83d\udc6e‍\u2640\ufe0f', 2414 'poodle':'\ud83d\udc29', 2415 'popcorn':'\ud83c\udf7f', 2416 'post_office':'\ud83c\udfe3', 2417 'postal_horn':'\ud83d\udcef', 2418 'postbox':'\ud83d\udcee', 2419 'potable_water':'\ud83d\udeb0', 2420 'potato':'\ud83e\udd54', 2421 'pouch':'\ud83d\udc5d', 2422 'poultry_leg':'\ud83c\udf57', 2423 'pound':'\ud83d\udcb7', 2424 'rage':'\ud83d\ude21', 2425 'pouting_cat':'\ud83d\ude3e', 2426 'pouting_man':'\ud83d\ude4e‍\u2642\ufe0f', 2427 'pray':'\ud83d\ude4f', 2428 'prayer_beads':'\ud83d\udcff', 2429 'pregnant_woman':'\ud83e\udd30', 2430 'previous_track_button':'\u23ee', 2431 'prince':'\ud83e\udd34', 2432 'princess':'\ud83d\udc78', 2433 'printer':'\ud83d\udda8', 2434 'purple_heart':'\ud83d\udc9c', 2435 'purse':'\ud83d\udc5b', 2436 'pushpin':'\ud83d\udccc', 2437 'put_litter_in_its_place':'\ud83d\udeae', 2438 'question':'\u2753', 2439 'rabbit':'\ud83d\udc30', 2440 'rabbit2':'\ud83d\udc07', 2441 'racehorse':'\ud83d\udc0e', 2442 'racing_car':'\ud83c\udfce', 2443 'radio':'\ud83d\udcfb', 2444 'radio_button':'\ud83d\udd18', 2445 'radioactive':'\u2622\ufe0f', 2446 'railway_car':'\ud83d\ude83', 2447 'railway_track':'\ud83d\udee4', 2448 'rainbow':'\ud83c\udf08', 2449 'rainbow_flag':'\ud83c\udff3\ufe0f‍\ud83c\udf08', 2450 'raised_back_of_hand':'\ud83e\udd1a', 2451 'raised_hand_with_fingers_splayed':'\ud83d\udd90', 2452 'raised_hands':'\ud83d\ude4c', 2453 'raising_hand_woman':'\ud83d\ude4b', 2454 'raising_hand_man':'\ud83d\ude4b‍\u2642\ufe0f', 2455 'ram':'\ud83d\udc0f', 2456 'ramen':'\ud83c\udf5c', 2457 'rat':'\ud83d\udc00', 2458 'record_button':'\u23fa', 2459 'recycle':'\u267b\ufe0f', 2460 'red_circle':'\ud83d\udd34', 2461 'registered':'\u00ae\ufe0f', 2462 'relaxed':'\u263a\ufe0f', 2463 'relieved':'\ud83d\ude0c', 2464 'reminder_ribbon':'\ud83c\udf97', 2465 'repeat':'\ud83d\udd01', 2466 'repeat_one':'\ud83d\udd02', 2467 'rescue_worker_helmet':'\u26d1', 2468 'restroom':'\ud83d\udebb', 2469 'revolving_hearts':'\ud83d\udc9e', 2470 'rewind':'\u23ea', 2471 'rhinoceros':'\ud83e\udd8f', 2472 'ribbon':'\ud83c\udf80', 2473 'rice':'\ud83c\udf5a', 2474 'rice_ball':'\ud83c\udf59', 2475 'rice_cracker':'\ud83c\udf58', 2476 'rice_scene':'\ud83c\udf91', 2477 'right_anger_bubble':'\ud83d\uddef', 2478 'ring':'\ud83d\udc8d', 2479 'robot':'\ud83e\udd16', 2480 'rocket':'\ud83d\ude80', 2481 'rofl':'\ud83e\udd23', 2482 'roll_eyes':'\ud83d\ude44', 2483 'roller_coaster':'\ud83c\udfa2', 2484 'rooster':'\ud83d\udc13', 2485 'rose':'\ud83c\udf39', 2486 'rosette':'\ud83c\udff5', 2487 'rotating_light':'\ud83d\udea8', 2488 'round_pushpin':'\ud83d\udccd', 2489 'rowing_man':'\ud83d\udea3', 2490 'rowing_woman':'\ud83d\udea3‍\u2640\ufe0f', 2491 'rugby_football':'\ud83c\udfc9', 2492 'running_man':'\ud83c\udfc3', 2493 'running_shirt_with_sash':'\ud83c\udfbd', 2494 'running_woman':'\ud83c\udfc3‍\u2640\ufe0f', 2495 'sa':'\ud83c\ude02\ufe0f', 2496 'sagittarius':'\u2650\ufe0f', 2497 'sake':'\ud83c\udf76', 2498 'sandal':'\ud83d\udc61', 2499 'santa':'\ud83c\udf85', 2500 'satellite':'\ud83d\udce1', 2501 'saxophone':'\ud83c\udfb7', 2502 'school':'\ud83c\udfeb', 2503 'school_satchel':'\ud83c\udf92', 2504 'scissors':'\u2702\ufe0f', 2505 'scorpion':'\ud83e\udd82', 2506 'scorpius':'\u264f\ufe0f', 2507 'scream':'\ud83d\ude31', 2508 'scream_cat':'\ud83d\ude40', 2509 'scroll':'\ud83d\udcdc', 2510 'seat':'\ud83d\udcba', 2511 'secret':'\u3299\ufe0f', 2512 'see_no_evil':'\ud83d\ude48', 2513 'seedling':'\ud83c\udf31', 2514 'selfie':'\ud83e\udd33', 2515 'shallow_pan_of_food':'\ud83e\udd58', 2516 'shamrock':'\u2618\ufe0f', 2517 'shark':'\ud83e\udd88', 2518 'shaved_ice':'\ud83c\udf67', 2519 'sheep':'\ud83d\udc11', 2520 'shell':'\ud83d\udc1a', 2521 'shield':'\ud83d\udee1', 2522 'shinto_shrine':'\u26e9', 2523 'ship':'\ud83d\udea2', 2524 'shirt':'\ud83d\udc55', 2525 'shopping':'\ud83d\udecd', 2526 'shopping_cart':'\ud83d\uded2', 2527 'shower':'\ud83d\udebf', 2528 'shrimp':'\ud83e\udd90', 2529 'signal_strength':'\ud83d\udcf6', 2530 'six_pointed_star':'\ud83d\udd2f', 2531 'ski':'\ud83c\udfbf', 2532 'skier':'\u26f7', 2533 'skull':'\ud83d\udc80', 2534 'skull_and_crossbones':'\u2620\ufe0f', 2535 'sleeping':'\ud83d\ude34', 2536 'sleeping_bed':'\ud83d\udecc', 2537 'sleepy':'\ud83d\ude2a', 2538 'slightly_frowning_face':'\ud83d\ude41', 2539 'slightly_smiling_face':'\ud83d\ude42', 2540 'slot_machine':'\ud83c\udfb0', 2541 'small_airplane':'\ud83d\udee9', 2542 'small_blue_diamond':'\ud83d\udd39', 2543 'small_orange_diamond':'\ud83d\udd38', 2544 'small_red_triangle':'\ud83d\udd3a', 2545 'small_red_triangle_down':'\ud83d\udd3b', 2546 'smile':'\ud83d\ude04', 2547 'smile_cat':'\ud83d\ude38', 2548 'smiley':'\ud83d\ude03', 2549 'smiley_cat':'\ud83d\ude3a', 2550 'smiling_imp':'\ud83d\ude08', 2551 'smirk':'\ud83d\ude0f', 2552 'smirk_cat':'\ud83d\ude3c', 2553 'smoking':'\ud83d\udeac', 2554 'snail':'\ud83d\udc0c', 2555 'snake':'\ud83d\udc0d', 2556 'sneezing_face':'\ud83e\udd27', 2557 'snowboarder':'\ud83c\udfc2', 2558 'snowflake':'\u2744\ufe0f', 2559 'snowman':'\u26c4\ufe0f', 2560 'snowman_with_snow':'\u2603\ufe0f', 2561 'sob':'\ud83d\ude2d', 2562 'soccer':'\u26bd\ufe0f', 2563 'soon':'\ud83d\udd1c', 2564 'sos':'\ud83c\udd98', 2565 'sound':'\ud83d\udd09', 2566 'space_invader':'\ud83d\udc7e', 2567 'spades':'\u2660\ufe0f', 2568 'spaghetti':'\ud83c\udf5d', 2569 'sparkle':'\u2747\ufe0f', 2570 'sparkler':'\ud83c\udf87', 2571 'sparkles':'\u2728', 2572 'sparkling_heart':'\ud83d\udc96', 2573 'speak_no_evil':'\ud83d\ude4a', 2574 'speaker':'\ud83d\udd08', 2575 'speaking_head':'\ud83d\udde3', 2576 'speech_balloon':'\ud83d\udcac', 2577 'speedboat':'\ud83d\udea4', 2578 'spider':'\ud83d\udd77', 2579 'spider_web':'\ud83d\udd78', 2580 'spiral_calendar':'\ud83d\uddd3', 2581 'spiral_notepad':'\ud83d\uddd2', 2582 'spoon':'\ud83e\udd44', 2583 'squid':'\ud83e\udd91', 2584 'stadium':'\ud83c\udfdf', 2585 'star':'\u2b50\ufe0f', 2586 'star2':'\ud83c\udf1f', 2587 'star_and_crescent':'\u262a\ufe0f', 2588 'star_of_david':'\u2721\ufe0f', 2589 'stars':'\ud83c\udf20', 2590 'station':'\ud83d\ude89', 2591 'statue_of_liberty':'\ud83d\uddfd', 2592 'steam_locomotive':'\ud83d\ude82', 2593 'stew':'\ud83c\udf72', 2594 'stop_button':'\u23f9', 2595 'stop_sign':'\ud83d\uded1', 2596 'stopwatch':'\u23f1', 2597 'straight_ruler':'\ud83d\udccf', 2598 'strawberry':'\ud83c\udf53', 2599 'stuck_out_tongue':'\ud83d\ude1b', 2600 'stuck_out_tongue_closed_eyes':'\ud83d\ude1d', 2601 'stuck_out_tongue_winking_eye':'\ud83d\ude1c', 2602 'studio_microphone':'\ud83c\udf99', 2603 'stuffed_flatbread':'\ud83e\udd59', 2604 'sun_behind_large_cloud':'\ud83c\udf25', 2605 'sun_behind_rain_cloud':'\ud83c\udf26', 2606 'sun_behind_small_cloud':'\ud83c\udf24', 2607 'sun_with_face':'\ud83c\udf1e', 2608 'sunflower':'\ud83c\udf3b', 2609 'sunglasses':'\ud83d\ude0e', 2610 'sunny':'\u2600\ufe0f', 2611 'sunrise':'\ud83c\udf05', 2612 'sunrise_over_mountains':'\ud83c\udf04', 2613 'surfing_man':'\ud83c\udfc4', 2614 'surfing_woman':'\ud83c\udfc4‍\u2640\ufe0f', 2615 'sushi':'\ud83c\udf63', 2616 'suspension_railway':'\ud83d\ude9f', 2617 'sweat':'\ud83d\ude13', 2618 'sweat_drops':'\ud83d\udca6', 2619 'sweat_smile':'\ud83d\ude05', 2620 'sweet_potato':'\ud83c\udf60', 2621 'swimming_man':'\ud83c\udfca', 2622 'swimming_woman':'\ud83c\udfca‍\u2640\ufe0f', 2623 'symbols':'\ud83d\udd23', 2624 'synagogue':'\ud83d\udd4d', 2625 'syringe':'\ud83d\udc89', 2626 'taco':'\ud83c\udf2e', 2627 'tada':'\ud83c\udf89', 2628 'tanabata_tree':'\ud83c\udf8b', 2629 'taurus':'\u2649\ufe0f', 2630 'taxi':'\ud83d\ude95', 2631 'tea':'\ud83c\udf75', 2632 'telephone_receiver':'\ud83d\udcde', 2633 'telescope':'\ud83d\udd2d', 2634 'tennis':'\ud83c\udfbe', 2635 'tent':'\u26fa\ufe0f', 2636 'thermometer':'\ud83c\udf21', 2637 'thinking':'\ud83e\udd14', 2638 'thought_balloon':'\ud83d\udcad', 2639 'ticket':'\ud83c\udfab', 2640 'tickets':'\ud83c\udf9f', 2641 'tiger':'\ud83d\udc2f', 2642 'tiger2':'\ud83d\udc05', 2643 'timer_clock':'\u23f2', 2644 'tipping_hand_man':'\ud83d\udc81‍\u2642\ufe0f', 2645 'tired_face':'\ud83d\ude2b', 2646 'tm':'\u2122\ufe0f', 2647 'toilet':'\ud83d\udebd', 2648 'tokyo_tower':'\ud83d\uddfc', 2649 'tomato':'\ud83c\udf45', 2650 'tongue':'\ud83d\udc45', 2651 'top':'\ud83d\udd1d', 2652 'tophat':'\ud83c\udfa9', 2653 'tornado':'\ud83c\udf2a', 2654 'trackball':'\ud83d\uddb2', 2655 'tractor':'\ud83d\ude9c', 2656 'traffic_light':'\ud83d\udea5', 2657 'train':'\ud83d\ude8b', 2658 'train2':'\ud83d\ude86', 2659 'tram':'\ud83d\ude8a', 2660 'triangular_flag_on_post':'\ud83d\udea9', 2661 'triangular_ruler':'\ud83d\udcd0', 2662 'trident':'\ud83d\udd31', 2663 'triumph':'\ud83d\ude24', 2664 'trolleybus':'\ud83d\ude8e', 2665 'trophy':'\ud83c\udfc6', 2666 'tropical_drink':'\ud83c\udf79', 2667 'tropical_fish':'\ud83d\udc20', 2668 'truck':'\ud83d\ude9a', 2669 'trumpet':'\ud83c\udfba', 2670 'tulip':'\ud83c\udf37', 2671 'tumbler_glass':'\ud83e\udd43', 2672 'turkey':'\ud83e\udd83', 2673 'turtle':'\ud83d\udc22', 2674 'tv':'\ud83d\udcfa', 2675 'twisted_rightwards_arrows':'\ud83d\udd00', 2676 'two_hearts':'\ud83d\udc95', 2677 'two_men_holding_hands':'\ud83d\udc6c', 2678 'two_women_holding_hands':'\ud83d\udc6d', 2679 'u5272':'\ud83c\ude39', 2680 'u5408':'\ud83c\ude34', 2681 'u55b6':'\ud83c\ude3a', 2682 'u6307':'\ud83c\ude2f\ufe0f', 2683 'u6708':'\ud83c\ude37\ufe0f', 2684 'u6709':'\ud83c\ude36', 2685 'u6e80':'\ud83c\ude35', 2686 'u7121':'\ud83c\ude1a\ufe0f', 2687 'u7533':'\ud83c\ude38', 2688 'u7981':'\ud83c\ude32', 2689 'u7a7a':'\ud83c\ude33', 2690 'umbrella':'\u2614\ufe0f', 2691 'unamused':'\ud83d\ude12', 2692 'underage':'\ud83d\udd1e', 2693 'unicorn':'\ud83e\udd84', 2694 'unlock':'\ud83d\udd13', 2695 'up':'\ud83c\udd99', 2696 'upside_down_face':'\ud83d\ude43', 2697 'v':'\u270c\ufe0f', 2698 'vertical_traffic_light':'\ud83d\udea6', 2699 'vhs':'\ud83d\udcfc', 2700 'vibration_mode':'\ud83d\udcf3', 2701 'video_camera':'\ud83d\udcf9', 2702 'video_game':'\ud83c\udfae', 2703 'violin':'\ud83c\udfbb', 2704 'virgo':'\u264d\ufe0f', 2705 'volcano':'\ud83c\udf0b', 2706 'volleyball':'\ud83c\udfd0', 2707 'vs':'\ud83c\udd9a', 2708 'vulcan_salute':'\ud83d\udd96', 2709 'walking_man':'\ud83d\udeb6', 2710 'walking_woman':'\ud83d\udeb6‍\u2640\ufe0f', 2711 'waning_crescent_moon':'\ud83c\udf18', 2712 'waning_gibbous_moon':'\ud83c\udf16', 2713 'warning':'\u26a0\ufe0f', 2714 'wastebasket':'\ud83d\uddd1', 2715 'watch':'\u231a\ufe0f', 2716 'water_buffalo':'\ud83d\udc03', 2717 'watermelon':'\ud83c\udf49', 2718 'wave':'\ud83d\udc4b', 2719 'wavy_dash':'\u3030\ufe0f', 2720 'waxing_crescent_moon':'\ud83c\udf12', 2721 'wc':'\ud83d\udebe', 2722 'weary':'\ud83d\ude29', 2723 'wedding':'\ud83d\udc92', 2724 'weight_lifting_man':'\ud83c\udfcb\ufe0f', 2725 'weight_lifting_woman':'\ud83c\udfcb\ufe0f‍\u2640\ufe0f', 2726 'whale':'\ud83d\udc33', 2727 'whale2':'\ud83d\udc0b', 2728 'wheel_of_dharma':'\u2638\ufe0f', 2729 'wheelchair':'\u267f\ufe0f', 2730 'white_check_mark':'\u2705', 2731 'white_circle':'\u26aa\ufe0f', 2732 'white_flag':'\ud83c\udff3\ufe0f', 2733 'white_flower':'\ud83d\udcae', 2734 'white_large_square':'\u2b1c\ufe0f', 2735 'white_medium_small_square':'\u25fd\ufe0f', 2736 'white_medium_square':'\u25fb\ufe0f', 2737 'white_small_square':'\u25ab\ufe0f', 2738 'white_square_button':'\ud83d\udd33', 2739 'wilted_flower':'\ud83e\udd40', 2740 'wind_chime':'\ud83c\udf90', 2741 'wind_face':'\ud83c\udf2c', 2742 'wine_glass':'\ud83c\udf77', 2743 'wink':'\ud83d\ude09', 2744 'wolf':'\ud83d\udc3a', 2745 'woman':'\ud83d\udc69', 2746 'woman_artist':'\ud83d\udc69‍\ud83c\udfa8', 2747 'woman_astronaut':'\ud83d\udc69‍\ud83d\ude80', 2748 'woman_cartwheeling':'\ud83e\udd38‍\u2640\ufe0f', 2749 'woman_cook':'\ud83d\udc69‍\ud83c\udf73', 2750 'woman_facepalming':'\ud83e\udd26‍\u2640\ufe0f', 2751 'woman_factory_worker':'\ud83d\udc69‍\ud83c\udfed', 2752 'woman_farmer':'\ud83d\udc69‍\ud83c\udf3e', 2753 'woman_firefighter':'\ud83d\udc69‍\ud83d\ude92', 2754 'woman_health_worker':'\ud83d\udc69‍\u2695\ufe0f', 2755 'woman_judge':'\ud83d\udc69‍\u2696\ufe0f', 2756 'woman_juggling':'\ud83e\udd39‍\u2640\ufe0f', 2757 'woman_mechanic':'\ud83d\udc69‍\ud83d\udd27', 2758 'woman_office_worker':'\ud83d\udc69‍\ud83d\udcbc', 2759 'woman_pilot':'\ud83d\udc69‍\u2708\ufe0f', 2760 'woman_playing_handball':'\ud83e\udd3e‍\u2640\ufe0f', 2761 'woman_playing_water_polo':'\ud83e\udd3d‍\u2640\ufe0f', 2762 'woman_scientist':'\ud83d\udc69‍\ud83d\udd2c', 2763 'woman_shrugging':'\ud83e\udd37‍\u2640\ufe0f', 2764 'woman_singer':'\ud83d\udc69‍\ud83c\udfa4', 2765 'woman_student':'\ud83d\udc69‍\ud83c\udf93', 2766 'woman_teacher':'\ud83d\udc69‍\ud83c\udfeb', 2767 'woman_technologist':'\ud83d\udc69‍\ud83d\udcbb', 2768 'woman_with_turban':'\ud83d\udc73‍\u2640\ufe0f', 2769 'womans_clothes':'\ud83d\udc5a', 2770 'womans_hat':'\ud83d\udc52', 2771 'women_wrestling':'\ud83e\udd3c‍\u2640\ufe0f', 2772 'womens':'\ud83d\udeba', 2773 'world_map':'\ud83d\uddfa', 2774 'worried':'\ud83d\ude1f', 2775 'wrench':'\ud83d\udd27', 2776 'writing_hand':'\u270d\ufe0f', 2777 'x':'\u274c', 2778 'yellow_heart':'\ud83d\udc9b', 2779 'yen':'\ud83d\udcb4', 2780 'yin_yang':'\u262f\ufe0f', 2781 'yum':'\ud83d\ude0b', 2782 'zap':'\u26a1\ufe0f', 2783 'zipper_mouth_face':'\ud83e\udd10', 2784 'zzz':'\ud83d\udca4', 2785 2786 /* special emojis :P */ 2787 'octocat': '<img alt=":octocat:" height="20" width="20" align="absmiddle" src="https://assets-cdn.github.com/images/icons/emoji/octocat.png">', 2788 'showdown': '<span style="font-family: \'Anonymous Pro\', monospace; text-decoration: underline; text-decoration-style: dashed; text-decoration-color: #3e8b8a;text-underline-position: under;">S</span>' 2789 }; 2790 2791 /** 2792 * Created by Estevao on 31-05-2015. 2793 */ 2794 2795 /** 2796 * Showdown Converter class 2797 * @class 2798 * @param {object} [converterOptions] 2799 * @returns {Converter} 2800 */ 2801 showdown.Converter = function (converterOptions) { 2802 'use strict'; 2803 2804 var 2805 /** 2806 * Options used by this converter 2807 * @private 2808 * @type {{}} 2809 */ 2810 options = {}, 2811 2812 /** 2813 * Language extensions used by this converter 2814 * @private 2815 * @type {Array} 2816 */ 2817 langExtensions = [], 2818 2819 /** 2820 * Output modifiers extensions used by this converter 2821 * @private 2822 * @type {Array} 2823 */ 2824 outputModifiers = [], 2825 2826 /** 2827 * Event listeners 2828 * @private 2829 * @type {{}} 2830 */ 2831 listeners = {}, 2832 2833 /** 2834 * The flavor set in this converter 2835 */ 2836 setConvFlavor = setFlavor, 2837 2838 /** 2839 * Metadata of the document 2840 * @type {{parsed: {}, raw: string, format: string}} 2841 */ 2842 metadata = { 2843 parsed: {}, 2844 raw: '', 2845 format: '' 2846 }; 2847 2848 _constructor(); 2849 2850 /** 2851 * Converter constructor 2852 * @private 2853 */ 2854 function _constructor () { 2855 converterOptions = converterOptions || {}; 2856 2857 for (var gOpt in globalOptions) { 2858 if (globalOptions.hasOwnProperty(gOpt)) { 2859 options[gOpt] = globalOptions[gOpt]; 2860 } 2861 } 2862 2863 // Merge options 2864 if (typeof converterOptions === 'object') { 2865 for (var opt in converterOptions) { 2866 if (converterOptions.hasOwnProperty(opt)) { 2867 options[opt] = converterOptions[opt]; 2868 } 2869 } 2870 } else { 2871 throw Error('Converter expects the passed parameter to be an object, but ' + typeof converterOptions + 2872 ' was passed instead.'); 2873 } 2874 2875 if (options.extensions) { 2876 showdown.helper.forEach(options.extensions, _parseExtension); 2877 } 2878 } 2879 2880 /** 2881 * Parse extension 2882 * @param {*} ext 2883 * @param {string} [name=''] 2884 * @private 2885 */ 2886 function _parseExtension (ext, name) { 2887 2888 name = name || null; 2889 // If it's a string, the extension was previously loaded 2890 if (showdown.helper.isString(ext)) { 2891 ext = showdown.helper.stdExtName(ext); 2892 name = ext; 2893 2894 // LEGACY_SUPPORT CODE 2895 if (showdown.extensions[ext]) { 2896 console.warn('DEPRECATION WARNING: ' + ext + ' is an old extension that uses a deprecated loading method.' + 2897 'Please inform the developer that the extension should be updated!'); 2898 legacyExtensionLoading(showdown.extensions[ext], ext); 2899 return; 2900 // END LEGACY SUPPORT CODE 2901 2902 } else if (!showdown.helper.isUndefined(extensions[ext])) { 2903 ext = extensions[ext]; 2904 2905 } else { 2906 throw Error('Extension "' + ext + '" could not be loaded. It was either not found or is not a valid extension.'); 2907 } 2908 } 2909 2910 if (typeof ext === 'function') { 2911 ext = ext(); 2912 } 2913 2914 if (!showdown.helper.isArray(ext)) { 2915 ext = [ext]; 2916 } 2917 2918 var validExt = validate(ext, name); 2919 if (!validExt.valid) { 2920 throw Error(validExt.error); 2921 } 2922 2923 for (var i = 0; i < ext.length; ++i) { 2924 switch (ext[i].type) { 2925 2926 case 'lang': 2927 langExtensions.push(ext[i]); 2928 break; 2929 2930 case 'output': 2931 outputModifiers.push(ext[i]); 2932 break; 2933 } 2934 if (ext[i].hasOwnProperty('listeners')) { 2935 for (var ln in ext[i].listeners) { 2936 if (ext[i].listeners.hasOwnProperty(ln)) { 2937 listen(ln, ext[i].listeners[ln]); 2938 } 2939 } 2940 } 2941 } 2942 2943 } 2944 2945 /** 2946 * LEGACY_SUPPORT 2947 * @param {*} ext 2948 * @param {string} name 2949 */ 2950 function legacyExtensionLoading (ext, name) { 2951 if (typeof ext === 'function') { 2952 ext = ext(new showdown.Converter()); 2953 } 2954 if (!showdown.helper.isArray(ext)) { 2955 ext = [ext]; 2956 } 2957 var valid = validate(ext, name); 2958 2959 if (!valid.valid) { 2960 throw Error(valid.error); 2961 } 2962 2963 for (var i = 0; i < ext.length; ++i) { 2964 switch (ext[i].type) { 2965 case 'lang': 2966 langExtensions.push(ext[i]); 2967 break; 2968 case 'output': 2969 outputModifiers.push(ext[i]); 2970 break; 2971 default:// should never reach here 2972 throw Error('Extension loader error: Type unrecognized!!!'); 2973 } 2974 } 2975 } 2976 2977 /** 2978 * Listen to an event 2979 * @param {string} name 2980 * @param {function} callback 2981 */ 2982 function listen (name, callback) { 2983 if (!showdown.helper.isString(name)) { 2984 throw Error('Invalid argument in converter.listen() method: name must be a string, but ' + typeof name + ' given'); 2985 } 2986 2987 if (typeof callback !== 'function') { 2988 throw Error('Invalid argument in converter.listen() method: callback must be a function, but ' + typeof callback + ' given'); 2989 } 2990 2991 if (!listeners.hasOwnProperty(name)) { 2992 listeners[name] = []; 2993 } 2994 listeners[name].push(callback); 2995 } 2996 2997 function rTrimInputText (text) { 2998 var rsp = text.match(/^\s*/)[0].length, 2999 rgx = new RegExp('^\\s{0,' + rsp + '}', 'gm'); 3000 return text.replace(rgx, ''); 3001 } 3002 3003 /** 3004 * Dispatch an event 3005 * @private 3006 * @param {string} evtName Event name 3007 * @param {string} text Text 3008 * @param {{}} options Converter Options 3009 * @param {{}} globals 3010 * @returns {string} 3011 */ 3012 this._dispatch = function dispatch (evtName, text, options, globals) { 3013 if (listeners.hasOwnProperty(evtName)) { 3014 for (var ei = 0; ei < listeners[evtName].length; ++ei) { 3015 var nText = listeners[evtName][ei](evtName, text, this, options, globals); 3016 if (nText && typeof nText !== 'undefined') { 3017 text = nText; 3018 } 3019 } 3020 } 3021 return text; 3022 }; 3023 3024 /** 3025 * Listen to an event 3026 * @param {string} name 3027 * @param {function} callback 3028 * @returns {showdown.Converter} 3029 */ 3030 this.listen = function (name, callback) { 3031 listen(name, callback); 3032 return this; 3033 }; 3034 3035 /** 3036 * Converts a markdown string into HTML 3037 * @param {string} text 3038 * @returns {*} 3039 */ 3040 this.makeHtml = function (text) { 3041 //check if text is not falsy 3042 if (!text) { 3043 return text; 3044 } 3045 3046 var globals = { 3047 gHtmlBlocks: [], 3048 gHtmlMdBlocks: [], 3049 gHtmlSpans: [], 3050 gUrls: {}, 3051 gTitles: {}, 3052 gDimensions: {}, 3053 gListLevel: 0, 3054 hashLinkCounts: {}, 3055 langExtensions: langExtensions, 3056 outputModifiers: outputModifiers, 3057 converter: this, 3058 ghCodeBlocks: [], 3059 metadata: { 3060 parsed: {}, 3061 raw: '', 3062 format: '' 3063 } 3064 }; 3065 3066 // This lets us use ¨ trema as an escape char to avoid md5 hashes 3067 // The choice of character is arbitrary; anything that isn't 3068 // magic in Markdown will work. 3069 text = text.replace(/¨/g, '¨T'); 3070 3071 // Replace $ with ¨D 3072 // RegExp interprets $ as a special character 3073 // when it's in a replacement string 3074 text = text.replace(/\$/g, '¨D'); 3075 3076 // Standardize line endings 3077 text = text.replace(/\r\n/g, '\n'); // DOS to Unix 3078 text = text.replace(/\r/g, '\n'); // Mac to Unix 3079 3080 // Stardardize line spaces 3081 text = text.replace(/\u00A0/g, ' '); 3082 3083 if (options.smartIndentationFix) { 3084 text = rTrimInputText(text); 3085 } 3086 3087 // Make sure text begins and ends with a couple of newlines: 3088 text = '\n\n' + text + '\n\n'; 3089 3090 // detab 3091 text = showdown.subParser('detab')(text, options, globals); 3092 3093 /** 3094 * Strip any lines consisting only of spaces and tabs. 3095 * This makes subsequent regexs easier to write, because we can 3096 * match consecutive blank lines with /\n+/ instead of something 3097 * contorted like /[ \t]*\n+/ 3098 */ 3099 text = text.replace(/^[ \t]+$/mg, ''); 3100 3101 //run languageExtensions 3102 showdown.helper.forEach(langExtensions, function (ext) { 3103 text = showdown.subParser('runExtension')(ext, text, options, globals); 3104 }); 3105 3106 // run the sub parsers 3107 text = showdown.subParser('metadata')(text, options, globals); 3108 text = showdown.subParser('hashPreCodeTags')(text, options, globals); 3109 text = showdown.subParser('githubCodeBlocks')(text, options, globals); 3110 text = showdown.subParser('hashHTMLBlocks')(text, options, globals); 3111 text = showdown.subParser('hashCodeTags')(text, options, globals); 3112 text = showdown.subParser('stripLinkDefinitions')(text, options, globals); 3113 text = showdown.subParser('blockGamut')(text, options, globals); 3114 text = showdown.subParser('unhashHTMLSpans')(text, options, globals); 3115 text = showdown.subParser('unescapeSpecialChars')(text, options, globals); 3116 3117 // attacklab: Restore dollar signs 3118 text = text.replace(/¨D/g, '$$'); 3119 3120 // attacklab: Restore tremas 3121 text = text.replace(/¨T/g, '¨'); 3122 3123 // render a complete html document instead of a partial if the option is enabled 3124 text = showdown.subParser('completeHTMLDocument')(text, options, globals); 3125 3126 // Run output modifiers 3127 showdown.helper.forEach(outputModifiers, function (ext) { 3128 text = showdown.subParser('runExtension')(ext, text, options, globals); 3129 }); 3130 3131 // update metadata 3132 metadata = globals.metadata; 3133 return text; 3134 }; 3135 3136 /** 3137 * Converts an HTML string into a markdown string 3138 * @param src 3139 * @param [HTMLParser] A WHATWG DOM and HTML parser, such as JSDOM. If none is supplied, window.document will be used. 3140 * @returns {string} 3141 */ 3142 this.makeMarkdown = this.makeMd = function (src, HTMLParser) { 3143 3144 // replace \r\n with \n 3145 src = src.replace(/\r\n/g, '\n'); 3146 src = src.replace(/\r/g, '\n'); // old macs 3147 3148 // due to an edge case, we need to find this: > < 3149 // to prevent removing of non silent white spaces 3150 // ex: <em>this is</em> <strong>sparta</strong> 3151 src = src.replace(/>[ \t]+</, '>¨NBSP;<'); 3152 3153 if (!HTMLParser) { 3154 if (window && window.document) { 3155 HTMLParser = window.document; 3156 } else { 3157 throw new Error('HTMLParser is undefined. If in a webworker or nodejs environment, you need to provide a WHATWG DOM and HTML such as JSDOM'); 3158 } 3159 } 3160 3161 var doc = HTMLParser.createElement('div'); 3162 doc.innerHTML = src; 3163 3164 var globals = { 3165 preList: substitutePreCodeTags(doc) 3166 }; 3167 3168 // remove all newlines and collapse spaces 3169 clean(doc); 3170 3171 // some stuff, like accidental reference links must now be escaped 3172 // TODO 3173 // doc.innerHTML = doc.innerHTML.replace(/\[[\S\t ]]/); 3174 3175 var nodes = doc.childNodes, 3176 mdDoc = ''; 3177 3178 for (var i = 0; i < nodes.length; i++) { 3179 mdDoc += showdown.subParser('makeMarkdown.node')(nodes[i], globals); 3180 } 3181 3182 function clean (node) { 3183 for (var n = 0; n < node.childNodes.length; ++n) { 3184 var child = node.childNodes[n]; 3185 if (child.nodeType === 3) { 3186 if (!/\S/.test(child.nodeValue)) { 3187 node.removeChild(child); 3188 --n; 3189 } else { 3190 child.nodeValue = child.nodeValue.split('\n').join(' '); 3191 child.nodeValue = child.nodeValue.replace(/(\s)+/g, '$1'); 3192 } 3193 } else if (child.nodeType === 1) { 3194 clean(child); 3195 } 3196 } 3197 } 3198 3199 // find all pre tags and replace contents with placeholder 3200 // we need this so that we can remove all indentation from html 3201 // to ease up parsing 3202 function substitutePreCodeTags (doc) { 3203 3204 var pres = doc.querySelectorAll('pre'), 3205 presPH = []; 3206 3207 for (var i = 0; i < pres.length; ++i) { 3208 3209 if (pres[i].childElementCount === 1 && pres[i].firstChild.tagName.toLowerCase() === 'code') { 3210 var content = pres[i].firstChild.innerHTML.trim(), 3211 language = pres[i].firstChild.getAttribute('data-language') || ''; 3212 3213 // if data-language attribute is not defined, then we look for class language-* 3214 if (language === '') { 3215 var classes = pres[i].firstChild.className.split(' '); 3216 for (var c = 0; c < classes.length; ++c) { 3217 var matches = classes[c].match(/^language-(.+)$/); 3218 if (matches !== null) { 3219 language = matches[1]; 3220 break; 3221 } 3222 } 3223 } 3224 3225 // unescape html entities in content 3226 content = showdown.helper.unescapeHTMLEntities(content); 3227 3228 presPH.push(content); 3229 pres[i].outerHTML = '<precode language="' + language + '" precodenum="' + i.toString() + '"></precode>'; 3230 } else { 3231 presPH.push(pres[i].innerHTML); 3232 pres[i].innerHTML = ''; 3233 pres[i].setAttribute('prenum', i.toString()); 3234 } 3235 } 3236 return presPH; 3237 } 3238 3239 return mdDoc; 3240 }; 3241 3242 /** 3243 * Set an option of this Converter instance 3244 * @param {string} key 3245 * @param {*} value 3246 */ 3247 this.setOption = function (key, value) { 3248 options[key] = value; 3249 }; 3250 3251 /** 3252 * Get the option of this Converter instance 3253 * @param {string} key 3254 * @returns {*} 3255 */ 3256 this.getOption = function (key) { 3257 return options[key]; 3258 }; 3259 3260 /** 3261 * Get the options of this Converter instance 3262 * @returns {{}} 3263 */ 3264 this.getOptions = function () { 3265 return options; 3266 }; 3267 3268 /** 3269 * Add extension to THIS converter 3270 * @param {{}} extension 3271 * @param {string} [name=null] 3272 */ 3273 this.addExtension = function (extension, name) { 3274 name = name || null; 3275 _parseExtension(extension, name); 3276 }; 3277 3278 /** 3279 * Use a global registered extension with THIS converter 3280 * @param {string} extensionName Name of the previously registered extension 3281 */ 3282 this.useExtension = function (extensionName) { 3283 _parseExtension(extensionName); 3284 }; 3285 3286 /** 3287 * Set the flavor THIS converter should use 3288 * @param {string} name 3289 */ 3290 this.setFlavor = function (name) { 3291 if (!flavor.hasOwnProperty(name)) { 3292 throw Error(name + ' flavor was not found'); 3293 } 3294 var preset = flavor[name]; 3295 setConvFlavor = name; 3296 for (var option in preset) { 3297 if (preset.hasOwnProperty(option)) { 3298 options[option] = preset[option]; 3299 } 3300 } 3301 }; 3302 3303 /** 3304 * Get the currently set flavor of this converter 3305 * @returns {string} 3306 */ 3307 this.getFlavor = function () { 3308 return setConvFlavor; 3309 }; 3310 3311 /** 3312 * Remove an extension from THIS converter. 3313 * Note: This is a costly operation. It's better to initialize a new converter 3314 * and specify the extensions you wish to use 3315 * @param {Array} extension 3316 */ 3317 this.removeExtension = function (extension) { 3318 if (!showdown.helper.isArray(extension)) { 3319 extension = [extension]; 3320 } 3321 for (var a = 0; a < extension.length; ++a) { 3322 var ext = extension[a]; 3323 for (var i = 0; i < langExtensions.length; ++i) { 3324 if (langExtensions[i] === ext) { 3325 langExtensions[i].splice(i, 1); 3326 } 3327 } 3328 for (var ii = 0; ii < outputModifiers.length; ++i) { 3329 if (outputModifiers[ii] === ext) { 3330 outputModifiers[ii].splice(i, 1); 3331 } 3332 } 3333 } 3334 }; 3335 3336 /** 3337 * Get all extension of THIS converter 3338 * @returns {{language: Array, output: Array}} 3339 */ 3340 this.getAllExtensions = function () { 3341 return { 3342 language: langExtensions, 3343 output: outputModifiers 3344 }; 3345 }; 3346 3347 /** 3348 * Get the metadata of the previously parsed document 3349 * @param raw 3350 * @returns {string|{}} 3351 */ 3352 this.getMetadata = function (raw) { 3353 if (raw) { 3354 return metadata.raw; 3355 } else { 3356 return metadata.parsed; 3357 } 3358 }; 3359 3360 /** 3361 * Get the metadata format of the previously parsed document 3362 * @returns {string} 3363 */ 3364 this.getMetadataFormat = function () { 3365 return metadata.format; 3366 }; 3367 3368 /** 3369 * Private: set a single key, value metadata pair 3370 * @param {string} key 3371 * @param {string} value 3372 */ 3373 this._setMetadataPair = function (key, value) { 3374 metadata.parsed[key] = value; 3375 }; 3376 3377 /** 3378 * Private: set metadata format 3379 * @param {string} format 3380 */ 3381 this._setMetadataFormat = function (format) { 3382 metadata.format = format; 3383 }; 3384 3385 /** 3386 * Private: set metadata raw text 3387 * @param {string} raw 3388 */ 3389 this._setMetadataRaw = function (raw) { 3390 metadata.raw = raw; 3391 }; 3392 }; 3393 3394 /** 3395 * Turn Markdown link shortcuts into XHTML <a> tags. 3396 */ 3397 showdown.subParser('anchors', function (text, options, globals) { 3398 'use strict'; 3399 3400 text = globals.converter._dispatch('anchors.before', text, options, globals); 3401 3402 var writeAnchorTag = function (wholeMatch, linkText, linkId, url, m5, m6, title) { 3403 if (showdown.helper.isUndefined(title)) { 3404 title = ''; 3405 } 3406 linkId = linkId.toLowerCase(); 3407 3408 // Special case for explicit empty url 3409 if (wholeMatch.search(/\(<?\s*>? ?(['"].*['"])?\)$/m) > -1) { 3410 url = ''; 3411 } else if (!url) { 3412 if (!linkId) { 3413 // lower-case and turn embedded newlines into spaces 3414 linkId = linkText.toLowerCase().replace(/ ?\n/g, ' '); 3415 } 3416 url = '#' + linkId; 3417 3418 if (!showdown.helper.isUndefined(globals.gUrls[linkId])) { 3419 url = globals.gUrls[linkId]; 3420 if (!showdown.helper.isUndefined(globals.gTitles[linkId])) { 3421 title = globals.gTitles[linkId]; 3422 } 3423 } else { 3424 return wholeMatch; 3425 } 3426 } 3427 3428 //url = showdown.helper.escapeCharacters(url, '*_', false); // replaced line to improve performance 3429 url = url.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback); 3430 3431 var result = '<a href="' + url + '"'; 3432 3433 if (title !== '' && title !== null) { 3434 title = title.replace(/"/g, '"'); 3435 //title = showdown.helper.escapeCharacters(title, '*_', false); // replaced line to improve performance 3436 title = title.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback); 3437 result += ' title="' + title + '"'; 3438 } 3439 3440 // optionLinksInNewWindow only applies 3441 // to external links. Hash links (#) open in same page 3442 if (options.openLinksInNewWindow && !/^#/.test(url)) { 3443 // escaped _ 3444 result += ' rel="noopener noreferrer" target="¨E95Eblank"'; 3445 } 3446 3447 result += '>' + linkText + '</a>'; 3448 3449 return result; 3450 }; 3451 3452 // First, handle reference-style links: [link text] [id] 3453 text = text.replace(/\[((?:\[[^\]]*]|[^\[\]])*)] ?(?:\n *)?\[(.*?)]()()()()/g, writeAnchorTag); 3454 3455 // Next, inline-style links: [link text](url "optional title") 3456 // cases with crazy urls like ./image/cat1).png 3457 text = text.replace(/\[((?:\[[^\]]*]|[^\[\]])*)]()[ \t]*\([ \t]?<([^>]*)>(?:[ \t]*((["'])([^"]*?)\5))?[ \t]?\)/g, 3458 writeAnchorTag); 3459 3460 // normal cases 3461 text = text.replace(/\[((?:\[[^\]]*]|[^\[\]])*)]()[ \t]*\([ \t]?<?([\S]+?(?:\([\S]*?\)[\S]*?)?)>?(?:[ \t]*((["'])([^"]*?)\5))?[ \t]?\)/g, 3462 writeAnchorTag); 3463 3464 // handle reference-style shortcuts: [link text] 3465 // These must come last in case you've also got [link test][1] 3466 // or [link test](/foo) 3467 text = text.replace(/\[([^\[\]]+)]()()()()()/g, writeAnchorTag); 3468 3469 // Lastly handle GithubMentions if option is enabled 3470 if (options.ghMentions) { 3471 text = text.replace(/(^|\s)(\\)?(@([a-z\d]+(?:[a-z\d.-]+?[a-z\d]+)*))/gmi, function (wm, st, escape, mentions, username) { 3472 if (escape === '\\') { 3473 return st + mentions; 3474 } 3475 3476 //check if options.ghMentionsLink is a string 3477 if (!showdown.helper.isString(options.ghMentionsLink)) { 3478 throw new Error('ghMentionsLink option must be a string'); 3479 } 3480 var lnk = options.ghMentionsLink.replace(/\{u}/g, username), 3481 target = ''; 3482 if (options.openLinksInNewWindow) { 3483 target = ' rel="noopener noreferrer" target="¨E95Eblank"'; 3484 } 3485 return st + '<a href="' + lnk + '"' + target + '>' + mentions + '</a>'; 3486 }); 3487 } 3488 3489 text = globals.converter._dispatch('anchors.after', text, options, globals); 3490 return text; 3491 }); 3492 3493 // url allowed chars [a-z\d_.~:/?#[]@!$&'()*+,;=-] 3494 3495 var simpleURLRegex = /([*~_]+|\b)(((https?|ftp|dict):\/\/|www\.)[^'">\s]+?\.[^'">\s]+?)()(\1)?(?=\s|$)(?!["<>])/gi, 3496 simpleURLRegex2 = /([*~_]+|\b)(((https?|ftp|dict):\/\/|www\.)[^'">\s]+\.[^'">\s]+?)([.!?,()\[\]])?(\1)?(?=\s|$)(?!["<>])/gi, 3497 delimUrlRegex = /()<(((https?|ftp|dict):\/\/|www\.)[^'">\s]+)()>()/gi, 3498 simpleMailRegex = /(^|\s)(?:mailto:)?([A-Za-z0-9!#$%&'*+-/=?^_`{|}~.]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)(?=$|\s)/gmi, 3499 delimMailRegex = /<()(?:mailto:)?([-.\w]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi, 3500 3501 replaceLink = function (options) { 3502 'use strict'; 3503 return function (wm, leadingMagicChars, link, m2, m3, trailingPunctuation, trailingMagicChars) { 3504 link = link.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback); 3505 var lnkTxt = link, 3506 append = '', 3507 target = '', 3508 lmc = leadingMagicChars || '', 3509 tmc = trailingMagicChars || ''; 3510 if (/^www\./i.test(link)) { 3511 link = link.replace(/^www\./i, 'http://www.'); 3512 } 3513 if (options.excludeTrailingPunctuationFromURLs && trailingPunctuation) { 3514 append = trailingPunctuation; 3515 } 3516 if (options.openLinksInNewWindow) { 3517 target = ' rel="noopener noreferrer" target="¨E95Eblank"'; 3518 } 3519 return lmc + '<a href="' + link + '"' + target + '>' + lnkTxt + '</a>' + append + tmc; 3520 }; 3521 }, 3522 3523 replaceMail = function (options, globals) { 3524 'use strict'; 3525 return function (wholeMatch, b, mail) { 3526 var href = 'mailto:'; 3527 b = b || ''; 3528 mail = showdown.subParser('unescapeSpecialChars')(mail, options, globals); 3529 if (options.encodeEmails) { 3530 href = showdown.helper.encodeEmailAddress(href + mail); 3531 mail = showdown.helper.encodeEmailAddress(mail); 3532 } else { 3533 href = href + mail; 3534 } 3535 return b + '<a href="' + href + '">' + mail + '</a>'; 3536 }; 3537 }; 3538 3539 showdown.subParser('autoLinks', function (text, options, globals) { 3540 'use strict'; 3541 3542 text = globals.converter._dispatch('autoLinks.before', text, options, globals); 3543 3544 text = text.replace(delimUrlRegex, replaceLink(options)); 3545 text = text.replace(delimMailRegex, replaceMail(options, globals)); 3546 3547 text = globals.converter._dispatch('autoLinks.after', text, options, globals); 3548 3549 return text; 3550 }); 3551 3552 showdown.subParser('simplifiedAutoLinks', function (text, options, globals) { 3553 'use strict'; 3554 3555 if (!options.simplifiedAutoLink) { 3556 return text; 3557 } 3558 3559 text = globals.converter._dispatch('simplifiedAutoLinks.before', text, options, globals); 3560 3561 if (options.excludeTrailingPunctuationFromURLs) { 3562 text = text.replace(simpleURLRegex2, replaceLink(options)); 3563 } else { 3564 text = text.replace(simpleURLRegex, replaceLink(options)); 3565 } 3566 text = text.replace(simpleMailRegex, replaceMail(options, globals)); 3567 3568 text = globals.converter._dispatch('simplifiedAutoLinks.after', text, options, globals); 3569 3570 return text; 3571 }); 3572 3573 /** 3574 * These are all the transformations that form block-level 3575 * tags like paragraphs, headers, and list items. 3576 */ 3577 showdown.subParser('blockGamut', function (text, options, globals) { 3578 'use strict'; 3579 3580 text = globals.converter._dispatch('blockGamut.before', text, options, globals); 3581 3582 // we parse blockquotes first so that we can have headings and hrs 3583 // inside blockquotes 3584 text = showdown.subParser('blockQuotes')(text, options, globals); 3585 text = showdown.subParser('headers')(text, options, globals); 3586 3587 // Do Horizontal Rules: 3588 text = showdown.subParser('horizontalRule')(text, options, globals); 3589 3590 text = showdown.subParser('lists')(text, options, globals); 3591 text = showdown.subParser('codeBlocks')(text, options, globals); 3592 text = showdown.subParser('tables')(text, options, globals); 3593 3594 // We already ran _HashHTMLBlocks() before, in Markdown(), but that 3595 // was to escape raw HTML in the original Markdown source. This time, 3596 // we're escaping the markup we've just created, so that we don't wrap 3597 // <p> tags around block-level tags. 3598 text = showdown.subParser('hashHTMLBlocks')(text, options, globals); 3599 text = showdown.subParser('paragraphs')(text, options, globals); 3600 3601 text = globals.converter._dispatch('blockGamut.after', text, options, globals); 3602 3603 return text; 3604 }); 3605 3606 showdown.subParser('blockQuotes', function (text, options, globals) { 3607 'use strict'; 3608 3609 text = globals.converter._dispatch('blockQuotes.before', text, options, globals); 3610 3611 // add a couple extra lines after the text and endtext mark 3612 text = text + '\n\n'; 3613 3614 var rgx = /(^ {0,3}>[ \t]?.+\n(.+\n)*\n*)+/gm; 3615 3616 if (options.splitAdjacentBlockquotes) { 3617 rgx = /^ {0,3}>[\s\S]*?(?:\n\n)/gm; 3618 } 3619 3620 text = text.replace(rgx, function (bq) { 3621 // attacklab: hack around Konqueror 3.5.4 bug: 3622 // "----------bug".replace(/^-/g,"") == "bug" 3623 bq = bq.replace(/^[ \t]*>[ \t]?/gm, ''); // trim one level of quoting 3624 3625 // attacklab: clean up hack 3626 bq = bq.replace(/¨0/g, ''); 3627 3628 bq = bq.replace(/^[ \t]+$/gm, ''); // trim whitespace-only lines 3629 bq = showdown.subParser('githubCodeBlocks')(bq, options, globals); 3630 bq = showdown.subParser('blockGamut')(bq, options, globals); // recurse 3631 3632 bq = bq.replace(/(^|\n)/g, '$1 '); 3633 // These leading spaces screw with <pre> content, so we need to fix that: 3634 bq = bq.replace(/(\s*<pre>[^\r]+?<\/pre>)/gm, function (wholeMatch, m1) { 3635 var pre = m1; 3636 // attacklab: hack around Konqueror 3.5.4 bug: 3637 pre = pre.replace(/^ /mg, '¨0'); 3638 pre = pre.replace(/¨0/g, ''); 3639 return pre; 3640 }); 3641 3642 return showdown.subParser('hashBlock')('<blockquote>\n' + bq + '\n</blockquote>', options, globals); 3643 }); 3644 3645 text = globals.converter._dispatch('blockQuotes.after', text, options, globals); 3646 return text; 3647 }); 3648 3649 /** 3650 * Process Markdown `<pre><code>` blocks. 3651 */ 3652 showdown.subParser('codeBlocks', function (text, options, globals) { 3653 'use strict'; 3654 3655 text = globals.converter._dispatch('codeBlocks.before', text, options, globals); 3656 3657 // sentinel workarounds for lack of \A and \Z, safari\khtml bug 3658 text += '¨0'; 3659 3660 var pattern = /(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=¨0))/g; 3661 text = text.replace(pattern, function (wholeMatch, m1, m2) { 3662 var codeblock = m1, 3663 nextChar = m2, 3664 end = '\n'; 3665 3666 codeblock = showdown.subParser('outdent')(codeblock, options, globals); 3667 codeblock = showdown.subParser('encodeCode')(codeblock, options, globals); 3668 codeblock = showdown.subParser('detab')(codeblock, options, globals); 3669 codeblock = codeblock.replace(/^\n+/g, ''); // trim leading newlines 3670 codeblock = codeblock.replace(/\n+$/g, ''); // trim trailing newlines 3671 3672 if (options.omitExtraWLInCodeBlocks) { 3673 end = ''; 3674 } 3675 3676 codeblock = '<pre><code>' + codeblock + end + '</code></pre>'; 3677 3678 return showdown.subParser('hashBlock')(codeblock, options, globals) + nextChar; 3679 }); 3680 3681 // strip sentinel 3682 text = text.replace(/¨0/, ''); 3683 3684 text = globals.converter._dispatch('codeBlocks.after', text, options, globals); 3685 return text; 3686 }); 3687 3688 /** 3689 * 3690 * * Backtick quotes are used for <code></code> spans. 3691 * 3692 * * You can use multiple backticks as the delimiters if you want to 3693 * include literal backticks in the code span. So, this input: 3694 * 3695 * Just type ``foo `bar` baz`` at the prompt. 3696 * 3697 * Will translate to: 3698 * 3699 * <p>Just type <code>foo `bar` baz</code> at the prompt.</p> 3700 * 3701 * There's no arbitrary limit to the number of backticks you 3702 * can use as delimters. If you need three consecutive backticks 3703 * in your code, use four for delimiters, etc. 3704 * 3705 * * You can use spaces to get literal backticks at the edges: 3706 * 3707 * ... type `` `bar` `` ... 3708 * 3709 * Turns to: 3710 * 3711 * ... type <code>`bar`</code> ... 3712 */ 3713 showdown.subParser('codeSpans', function (text, options, globals) { 3714 'use strict'; 3715 3716 text = globals.converter._dispatch('codeSpans.before', text, options, globals); 3717 3718 if (typeof text === 'undefined') { 3719 text = ''; 3720 } 3721 text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm, 3722 function (wholeMatch, m1, m2, m3) { 3723 var c = m3; 3724 c = c.replace(/^([ \t]*)/g, ''); // leading whitespace 3725 c = c.replace(/[ \t]*$/g, ''); // trailing whitespace 3726 c = showdown.subParser('encodeCode')(c, options, globals); 3727 c = m1 + '<code>' + c + '</code>'; 3728 c = showdown.subParser('hashHTMLSpans')(c, options, globals); 3729 return c; 3730 } 3731 ); 3732 3733 text = globals.converter._dispatch('codeSpans.after', text, options, globals); 3734 return text; 3735 }); 3736 3737 /** 3738 * Create a full HTML document from the processed markdown 3739 */ 3740 showdown.subParser('completeHTMLDocument', function (text, options, globals) { 3741 'use strict'; 3742 3743 if (!options.completeHTMLDocument) { 3744 return text; 3745 } 3746 3747 text = globals.converter._dispatch('completeHTMLDocument.before', text, options, globals); 3748 3749 var doctype = 'html', 3750 doctypeParsed = '<!DOCTYPE HTML>\n', 3751 title = '', 3752 charset = '<meta charset="utf-8">\n', 3753 lang = '', 3754 metadata = ''; 3755 3756 if (typeof globals.metadata.parsed.doctype !== 'undefined') { 3757 doctypeParsed = '<!DOCTYPE ' + globals.metadata.parsed.doctype + '>\n'; 3758 doctype = globals.metadata.parsed.doctype.toString().toLowerCase(); 3759 if (doctype === 'html' || doctype === 'html5') { 3760 charset = '<meta charset="utf-8">'; 3761 } 3762 } 3763 3764 for (var meta in globals.metadata.parsed) { 3765 if (globals.metadata.parsed.hasOwnProperty(meta)) { 3766 switch (meta.toLowerCase()) { 3767 case 'doctype': 3768 break; 3769 3770 case 'title': 3771 title = '<title>' + globals.metadata.parsed.title + '</title>\n'; 3772 break; 3773 3774 case 'charset': 3775 if (doctype === 'html' || doctype === 'html5') { 3776 charset = '<meta charset="' + globals.metadata.parsed.charset + '">\n'; 3777 } else { 3778 charset = '<meta name="charset" content="' + globals.metadata.parsed.charset + '">\n'; 3779 } 3780 break; 3781 3782 case 'language': 3783 case 'lang': 3784 lang = ' lang="' + globals.metadata.parsed[meta] + '"'; 3785 metadata += '<meta name="' + meta + '" content="' + globals.metadata.parsed[meta] + '">\n'; 3786 break; 3787 3788 default: 3789 metadata += '<meta name="' + meta + '" content="' + globals.metadata.parsed[meta] + '">\n'; 3790 } 3791 } 3792 } 3793 3794 text = doctypeParsed + '<html' + lang + '>\n<head>\n' + title + charset + metadata + '</head>\n<body>\n' + text.trim() + '\n</body>\n</html>'; 3795 3796 text = globals.converter._dispatch('completeHTMLDocument.after', text, options, globals); 3797 return text; 3798 }); 3799 3800 /** 3801 * Convert all tabs to spaces 3802 */ 3803 showdown.subParser('detab', function (text, options, globals) { 3804 'use strict'; 3805 text = globals.converter._dispatch('detab.before', text, options, globals); 3806 3807 // expand first n-1 tabs 3808 text = text.replace(/\t(?=\t)/g, ' '); // g_tab_width 3809 3810 // replace the nth with two sentinels 3811 text = text.replace(/\t/g, '¨A¨B'); 3812 3813 // use the sentinel to anchor our regex so it doesn't explode 3814 text = text.replace(/¨B(.+?)¨A/g, function (wholeMatch, m1) { 3815 var leadingText = m1, 3816 numSpaces = 4 - leadingText.length % 4; // g_tab_width 3817 3818 // there *must* be a better way to do this: 3819 for (var i = 0; i < numSpaces; i++) { 3820 leadingText += ' '; 3821 } 3822 3823 return leadingText; 3824 }); 3825 3826 // clean up sentinels 3827 text = text.replace(/¨A/g, ' '); // g_tab_width 3828 text = text.replace(/¨B/g, ''); 3829 3830 text = globals.converter._dispatch('detab.after', text, options, globals); 3831 return text; 3832 }); 3833 3834 showdown.subParser('ellipsis', function (text, options, globals) { 3835 'use strict'; 3836 3837 text = globals.converter._dispatch('ellipsis.before', text, options, globals); 3838 3839 text = text.replace(/\.\.\./g, '…'); 3840 3841 text = globals.converter._dispatch('ellipsis.after', text, options, globals); 3842 3843 return text; 3844 }); 3845 3846 /** 3847 * Turn emoji codes into emojis 3848 * 3849 * List of supported emojis: https://github.com/showdownjs/showdown/wiki/Emojis 3850 */ 3851 showdown.subParser('emoji', function (text, options, globals) { 3852 'use strict'; 3853 3854 if (!options.emoji) { 3855 return text; 3856 } 3857 3858 text = globals.converter._dispatch('emoji.before', text, options, globals); 3859 3860 var emojiRgx = /:([\S]+?):/g; 3861 3862 text = text.replace(emojiRgx, function (wm, emojiCode) { 3863 if (showdown.helper.emojis.hasOwnProperty(emojiCode)) { 3864 return showdown.helper.emojis[emojiCode]; 3865 } 3866 return wm; 3867 }); 3868 3869 text = globals.converter._dispatch('emoji.after', text, options, globals); 3870 3871 return text; 3872 }); 3873 3874 /** 3875 * Smart processing for ampersands and angle brackets that need to be encoded. 3876 */ 3877 showdown.subParser('encodeAmpsAndAngles', function (text, options, globals) { 3878 'use strict'; 3879 text = globals.converter._dispatch('encodeAmpsAndAngles.before', text, options, globals); 3880 3881 // Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin: 3882 // http://bumppo.net/projects/amputator/ 3883 text = text.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g, '&'); 3884 3885 // Encode naked <'s 3886 text = text.replace(/<(?![a-z\/?$!])/gi, '<'); 3887 3888 // Encode < 3889 text = text.replace(/</g, '<'); 3890 3891 // Encode > 3892 text = text.replace(/>/g, '>'); 3893 3894 text = globals.converter._dispatch('encodeAmpsAndAngles.after', text, options, globals); 3895 return text; 3896 }); 3897 3898 /** 3899 * Returns the string, with after processing the following backslash escape sequences. 3900 * 3901 * attacklab: The polite way to do this is with the new escapeCharacters() function: 3902 * 3903 * text = escapeCharacters(text,"\\",true); 3904 * text = escapeCharacters(text,"`*_{}[]()>#+-.!",true); 3905 * 3906 * ...but we're sidestepping its use of the (slow) RegExp constructor 3907 * as an optimization for Firefox. This function gets called a LOT. 3908 */ 3909 showdown.subParser('encodeBackslashEscapes', function (text, options, globals) { 3910 'use strict'; 3911 text = globals.converter._dispatch('encodeBackslashEscapes.before', text, options, globals); 3912 3913 text = text.replace(/\\(\\)/g, showdown.helper.escapeCharactersCallback); 3914 text = text.replace(/\\([`*_{}\[\]()>#+.!~=|-])/g, showdown.helper.escapeCharactersCallback); 3915 3916 text = globals.converter._dispatch('encodeBackslashEscapes.after', text, options, globals); 3917 return text; 3918 }); 3919 3920 /** 3921 * Encode/escape certain characters inside Markdown code runs. 3922 * The point is that in code, these characters are literals, 3923 * and lose their special Markdown meanings. 3924 */ 3925 showdown.subParser('encodeCode', function (text, options, globals) { 3926 'use strict'; 3927 3928 text = globals.converter._dispatch('encodeCode.before', text, options, globals); 3929 3930 // Encode all ampersands; HTML entities are not 3931 // entities within a Markdown code span. 3932 text = text 3933 .replace(/&/g, '&') 3934 // Do the angle bracket song and dance: 3935 .replace(/</g, '<') 3936 .replace(/>/g, '>') 3937 // Now, escape characters that are magic in Markdown: 3938 .replace(/([*_{}\[\]\\=~-])/g, showdown.helper.escapeCharactersCallback); 3939 3940 text = globals.converter._dispatch('encodeCode.after', text, options, globals); 3941 return text; 3942 }); 3943 3944 /** 3945 * Within tags -- meaning between < and > -- encode [\ ` * _ ~ =] so they 3946 * don't conflict with their use in Markdown for code, italics and strong. 3947 */ 3948 showdown.subParser('escapeSpecialCharsWithinTagAttributes', function (text, options, globals) { 3949 'use strict'; 3950 text = globals.converter._dispatch('escapeSpecialCharsWithinTagAttributes.before', text, options, globals); 3951 3952 // Build a regex to find HTML tags. 3953 var tags = /<\/?[a-z\d_:-]+(?:[\s]+[\s\S]+?)?>/gi, 3954 comments = /<!(--(?:(?:[^>-]|-[^>])(?:[^-]|-[^-])*)--)>/gi; 3955 3956 text = text.replace(tags, function (wholeMatch) { 3957 return wholeMatch 3958 .replace(/(.)<\/?code>(?=.)/g, '$1`') 3959 .replace(/([\\`*_~=|])/g, showdown.helper.escapeCharactersCallback); 3960 }); 3961 3962 text = text.replace(comments, function (wholeMatch) { 3963 return wholeMatch 3964 .replace(/([\\`*_~=|])/g, showdown.helper.escapeCharactersCallback); 3965 }); 3966 3967 text = globals.converter._dispatch('escapeSpecialCharsWithinTagAttributes.after', text, options, globals); 3968 return text; 3969 }); 3970 3971 /** 3972 * Handle github codeblocks prior to running HashHTML so that 3973 * HTML contained within the codeblock gets escaped properly 3974 * Example: 3975 * ```ruby 3976 * def hello_world(x) 3977 * puts "Hello, #{x}" 3978 * end 3979 * ``` 3980 */ 3981 showdown.subParser('githubCodeBlocks', function (text, options, globals) { 3982 'use strict'; 3983 3984 // early exit if option is not enabled 3985 if (!options.ghCodeBlocks) { 3986 return text; 3987 } 3988 3989 text = globals.converter._dispatch('githubCodeBlocks.before', text, options, globals); 3990 3991 text += '¨0'; 3992 3993 text = text.replace(/(?:^|\n)(?: {0,3})(```+|~~~+)(?: *)([^\s`~]*)\n([\s\S]*?)\n(?: {0,3})\1/g, function (wholeMatch, delim, language, codeblock) { 3994 var end = (options.omitExtraWLInCodeBlocks) ? '' : '\n'; 3995 3996 // First parse the github code block 3997 codeblock = showdown.subParser('encodeCode')(codeblock, options, globals); 3998 codeblock = showdown.subParser('detab')(codeblock, options, globals); 3999 codeblock = codeblock.replace(/^\n+/g, ''); // trim leading newlines 4000 codeblock = codeblock.replace(/\n+$/g, ''); // trim trailing whitespace 4001 4002 codeblock = '<pre><code' + (language ? ' class="' + language + ' language-' + language + '"' : '') + '>' + codeblock + end + '</code></pre>'; 4003 4004 codeblock = showdown.subParser('hashBlock')(codeblock, options, globals); 4005 4006 // Since GHCodeblocks can be false positives, we need to 4007 // store the primitive text and the parsed text in a global var, 4008 // and then return a token 4009 return '\n\n¨G' + (globals.ghCodeBlocks.push({text: wholeMatch, codeblock: codeblock}) - 1) + 'G\n\n'; 4010 }); 4011 4012 // attacklab: strip sentinel 4013 text = text.replace(/¨0/, ''); 4014 4015 return globals.converter._dispatch('githubCodeBlocks.after', text, options, globals); 4016 }); 4017 4018 showdown.subParser('hashBlock', function (text, options, globals) { 4019 'use strict'; 4020 text = globals.converter._dispatch('hashBlock.before', text, options, globals); 4021 text = text.replace(/(^\n+|\n+$)/g, ''); 4022 text = '\n\n¨K' + (globals.gHtmlBlocks.push(text) - 1) + 'K\n\n'; 4023 text = globals.converter._dispatch('hashBlock.after', text, options, globals); 4024 return text; 4025 }); 4026 4027 /** 4028 * Hash and escape <code> elements that should not be parsed as markdown 4029 */ 4030 showdown.subParser('hashCodeTags', function (text, options, globals) { 4031 'use strict'; 4032 text = globals.converter._dispatch('hashCodeTags.before', text, options, globals); 4033 4034 var repFunc = function (wholeMatch, match, left, right) { 4035 var codeblock = left + showdown.subParser('encodeCode')(match, options, globals) + right; 4036 return '¨C' + (globals.gHtmlSpans.push(codeblock) - 1) + 'C'; 4037 }; 4038 4039 // Hash naked <code> 4040 text = showdown.helper.replaceRecursiveRegExp(text, repFunc, '<code\\b[^>]*>', '</code>', 'gim'); 4041 4042 text = globals.converter._dispatch('hashCodeTags.after', text, options, globals); 4043 return text; 4044 }); 4045 4046 showdown.subParser('hashElement', function (text, options, globals) { 4047 'use strict'; 4048 4049 return function (wholeMatch, m1) { 4050 var blockText = m1; 4051 4052 // Undo double lines 4053 blockText = blockText.replace(/\n\n/g, '\n'); 4054 blockText = blockText.replace(/^\n/, ''); 4055 4056 // strip trailing blank lines 4057 blockText = blockText.replace(/\n+$/g, ''); 4058 4059 // Replace the element text with a marker ("¨KxK" where x is its key) 4060 blockText = '\n\n¨K' + (globals.gHtmlBlocks.push(blockText) - 1) + 'K\n\n'; 4061 4062 return blockText; 4063 }; 4064 }); 4065 4066 showdown.subParser('hashHTMLBlocks', function (text, options, globals) { 4067 'use strict'; 4068 text = globals.converter._dispatch('hashHTMLBlocks.before', text, options, globals); 4069 4070 var blockTags = [ 4071 'pre', 4072 'div', 4073 'h1', 4074 'h2', 4075 'h3', 4076 'h4', 4077 'h5', 4078 'h6', 4079 'blockquote', 4080 'table', 4081 'dl', 4082 'ol', 4083 'ul', 4084 'script', 4085 'noscript', 4086 'form', 4087 'fieldset', 4088 'iframe', 4089 'math', 4090 'style', 4091 'section', 4092 'header', 4093 'footer', 4094 'nav', 4095 'article', 4096 'aside', 4097 'address', 4098 'audio', 4099 'canvas', 4100 'figure', 4101 'hgroup', 4102 'output', 4103 'video', 4104 'p' 4105 ], 4106 repFunc = function (wholeMatch, match, left, right) { 4107 var txt = wholeMatch; 4108 // check if this html element is marked as markdown 4109 // if so, it's contents should be parsed as markdown 4110 if (left.search(/\bmarkdown\b/) !== -1) { 4111 txt = left + globals.converter.makeHtml(match) + right; 4112 } 4113 return '\n\n¨K' + (globals.gHtmlBlocks.push(txt) - 1) + 'K\n\n'; 4114 }; 4115 4116 if (options.backslashEscapesHTMLTags) { 4117 // encode backslash escaped HTML tags 4118 text = text.replace(/\\<(\/?[^>]+?)>/g, function (wm, inside) { 4119 return '<' + inside + '>'; 4120 }); 4121 } 4122 4123 // hash HTML Blocks 4124 for (var i = 0; i < blockTags.length; ++i) { 4125 4126 var opTagPos, 4127 rgx1 = new RegExp('^ {0,3}(<' + blockTags[i] + '\\b[^>]*>)', 'im'), 4128 patLeft = '<' + blockTags[i] + '\\b[^>]*>', 4129 patRight = '</' + blockTags[i] + '>'; 4130 // 1. Look for the first position of the first opening HTML tag in the text 4131 while ((opTagPos = showdown.helper.regexIndexOf(text, rgx1)) !== -1) { 4132 4133 // if the HTML tag is \ escaped, we need to escape it and break 4134 4135 4136 //2. Split the text in that position 4137 var subTexts = showdown.helper.splitAtIndex(text, opTagPos), 4138 //3. Match recursively 4139 newSubText1 = showdown.helper.replaceRecursiveRegExp(subTexts[1], repFunc, patLeft, patRight, 'im'); 4140 4141 // prevent an infinite loop 4142 if (newSubText1 === subTexts[1]) { 4143 break; 4144 } 4145 text = subTexts[0].concat(newSubText1); 4146 } 4147 } 4148 // HR SPECIAL CASE 4149 text = text.replace(/(\n {0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g, 4150 showdown.subParser('hashElement')(text, options, globals)); 4151 4152 // Special case for standalone HTML comments 4153 text = showdown.helper.replaceRecursiveRegExp(text, function (txt) { 4154 return '\n\n¨K' + (globals.gHtmlBlocks.push(txt) - 1) + 'K\n\n'; 4155 }, '^ {0,3}<!--', '-->', 'gm'); 4156 4157 // PHP and ASP-style processor instructions (<?...?> and <%...%>) 4158 text = text.replace(/(?:\n\n)( {0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g, 4159 showdown.subParser('hashElement')(text, options, globals)); 4160 4161 text = globals.converter._dispatch('hashHTMLBlocks.after', text, options, globals); 4162 return text; 4163 }); 4164 4165 /** 4166 * Hash span elements that should not be parsed as markdown 4167 */ 4168 showdown.subParser('hashHTMLSpans', function (text, options, globals) { 4169 'use strict'; 4170 text = globals.converter._dispatch('hashHTMLSpans.before', text, options, globals); 4171 4172 function hashHTMLSpan (html) { 4173 return '¨C' + (globals.gHtmlSpans.push(html) - 1) + 'C'; 4174 } 4175 4176 // Hash Self Closing tags 4177 text = text.replace(/<[^>]+?\/>/gi, function (wm) { 4178 return hashHTMLSpan(wm); 4179 }); 4180 4181 // Hash tags without properties 4182 text = text.replace(/<([^>]+?)>[\s\S]*?<\/\1>/g, function (wm) { 4183 return hashHTMLSpan(wm); 4184 }); 4185 4186 // Hash tags with properties 4187 text = text.replace(/<([^>]+?)\s[^>]+?>[\s\S]*?<\/\1>/g, function (wm) { 4188 return hashHTMLSpan(wm); 4189 }); 4190 4191 // Hash self closing tags without /> 4192 text = text.replace(/<[^>]+?>/gi, function (wm) { 4193 return hashHTMLSpan(wm); 4194 }); 4195 4196 /*showdown.helper.matchRecursiveRegExp(text, '<code\\b[^>]*>', '</code>', 'gi');*/ 4197 4198 text = globals.converter._dispatch('hashHTMLSpans.after', text, options, globals); 4199 return text; 4200 }); 4201 4202 /** 4203 * Unhash HTML spans 4204 */ 4205 showdown.subParser('unhashHTMLSpans', function (text, options, globals) { 4206 'use strict'; 4207 text = globals.converter._dispatch('unhashHTMLSpans.before', text, options, globals); 4208 4209 for (var i = 0; i < globals.gHtmlSpans.length; ++i) { 4210 var repText = globals.gHtmlSpans[i], 4211 // limiter to prevent infinite loop (assume 10 as limit for recurse) 4212 limit = 0; 4213 4214 while (/¨C(\d+)C/.test(repText)) { 4215 var num = RegExp.$1; 4216 repText = repText.replace('¨C' + num + 'C', globals.gHtmlSpans[num]); 4217 if (limit === 10) { 4218 console.error('maximum nesting of 10 spans reached!!!'); 4219 break; 4220 } 4221 ++limit; 4222 } 4223 text = text.replace('¨C' + i + 'C', repText); 4224 } 4225 4226 text = globals.converter._dispatch('unhashHTMLSpans.after', text, options, globals); 4227 return text; 4228 }); 4229 4230 /** 4231 * Hash and escape <pre><code> elements that should not be parsed as markdown 4232 */ 4233 showdown.subParser('hashPreCodeTags', function (text, options, globals) { 4234 'use strict'; 4235 text = globals.converter._dispatch('hashPreCodeTags.before', text, options, globals); 4236 4237 var repFunc = function (wholeMatch, match, left, right) { 4238 // encode html entities 4239 var codeblock = left + showdown.subParser('encodeCode')(match, options, globals) + right; 4240 return '\n\n¨G' + (globals.ghCodeBlocks.push({text: wholeMatch, codeblock: codeblock}) - 1) + 'G\n\n'; 4241 }; 4242 4243 // Hash <pre><code> 4244 text = showdown.helper.replaceRecursiveRegExp(text, repFunc, '^ {0,3}<pre\\b[^>]*>\\s*<code\\b[^>]*>', '^ {0,3}</code>\\s*</pre>', 'gim'); 4245 4246 text = globals.converter._dispatch('hashPreCodeTags.after', text, options, globals); 4247 return text; 4248 }); 4249 4250 showdown.subParser('headers', function (text, options, globals) { 4251 'use strict'; 4252 4253 text = globals.converter._dispatch('headers.before', text, options, globals); 4254 4255 var headerLevelStart = (isNaN(parseInt(options.headerLevelStart))) ? 1 : parseInt(options.headerLevelStart), 4256 4257 // Set text-style headers: 4258 // Header 1 4259 // ======== 4260 // 4261 // Header 2 4262 // -------- 4263 // 4264 setextRegexH1 = (options.smoothLivePreview) ? /^(.+)[ \t]*\n={2,}[ \t]*\n+/gm : /^(.+)[ \t]*\n=+[ \t]*\n+/gm, 4265 setextRegexH2 = (options.smoothLivePreview) ? /^(.+)[ \t]*\n-{2,}[ \t]*\n+/gm : /^(.+)[ \t]*\n-+[ \t]*\n+/gm; 4266 4267 text = text.replace(setextRegexH1, function (wholeMatch, m1) { 4268 4269 var spanGamut = showdown.subParser('spanGamut')(m1, options, globals), 4270 hID = (options.noHeaderId) ? '' : ' id="' + headerId(m1) + '"', 4271 hLevel = headerLevelStart, 4272 hashBlock = '<h' + hLevel + hID + '>' + spanGamut + '</h' + hLevel + '>'; 4273 return showdown.subParser('hashBlock')(hashBlock, options, globals); 4274 }); 4275 4276 text = text.replace(setextRegexH2, function (matchFound, m1) { 4277 var spanGamut = showdown.subParser('spanGamut')(m1, options, globals), 4278 hID = (options.noHeaderId) ? '' : ' id="' + headerId(m1) + '"', 4279 hLevel = headerLevelStart + 1, 4280 hashBlock = '<h' + hLevel + hID + '>' + spanGamut + '</h' + hLevel + '>'; 4281 return showdown.subParser('hashBlock')(hashBlock, options, globals); 4282 }); 4283 4284 // atx-style headers: 4285 // # Header 1 4286 // ## Header 2 4287 // ## Header 2 with closing hashes ## 4288 // ... 4289 // ###### Header 6 4290 // 4291 var atxStyle = (options.requireSpaceBeforeHeadingText) ? /^(#{1,6})[ \t]+(.+?)[ \t]*#*\n+/gm : /^(#{1,6})[ \t]*(.+?)[ \t]*#*\n+/gm; 4292 4293 text = text.replace(atxStyle, function (wholeMatch, m1, m2) { 4294 var hText = m2; 4295 if (options.customizedHeaderId) { 4296 hText = m2.replace(/\s?\{([^{]+?)}\s*$/, ''); 4297 } 4298 4299 var span = showdown.subParser('spanGamut')(hText, options, globals), 4300 hID = (options.noHeaderId) ? '' : ' id="' + headerId(m2) + '"', 4301 hLevel = headerLevelStart - 1 + m1.length, 4302 header = '<h' + hLevel + hID + '>' + span + '</h' + hLevel + '>'; 4303 4304 return showdown.subParser('hashBlock')(header, options, globals); 4305 }); 4306 4307 function headerId (m) { 4308 var title, 4309 prefix; 4310 4311 // It is separate from other options to allow combining prefix and customized 4312 if (options.customizedHeaderId) { 4313 var match = m.match(/\{([^{]+?)}\s*$/); 4314 if (match && match[1]) { 4315 m = match[1]; 4316 } 4317 } 4318 4319 title = m; 4320 4321 // Prefix id to prevent causing inadvertent pre-existing style matches. 4322 if (showdown.helper.isString(options.prefixHeaderId)) { 4323 prefix = options.prefixHeaderId; 4324 } else if (options.prefixHeaderId === true) { 4325 prefix = 'section-'; 4326 } else { 4327 prefix = ''; 4328 } 4329 4330 if (!options.rawPrefixHeaderId) { 4331 title = prefix + title; 4332 } 4333 4334 if (options.ghCompatibleHeaderId) { 4335 title = title 4336 .replace(/ /g, '-') 4337 // replace previously escaped chars (&, ¨ and $) 4338 .replace(/&/g, '') 4339 .replace(/¨T/g, '') 4340 .replace(/¨D/g, '') 4341 // replace rest of the chars (&~$ are repeated as they might have been escaped) 4342 // borrowed from github's redcarpet (some they should produce similar results) 4343 .replace(/[&+$,\/:;=?@"#{}|^¨~\[\]`\\*)(%.!'<>]/g, '') 4344 .toLowerCase(); 4345 } else if (options.rawHeaderId) { 4346 title = title 4347 .replace(/ /g, '-') 4348 // replace previously escaped chars (&, ¨ and $) 4349 .replace(/&/g, '&') 4350 .replace(/¨T/g, '¨') 4351 .replace(/¨D/g, '$') 4352 // replace " and ' 4353 .replace(/["']/g, '-') 4354 .toLowerCase(); 4355 } else { 4356 title = title 4357 .replace(/[^\w]/g, '') 4358 .toLowerCase(); 4359 } 4360 4361 if (options.rawPrefixHeaderId) { 4362 title = prefix + title; 4363 } 4364 4365 if (globals.hashLinkCounts[title]) { 4366 title = title + '-' + (globals.hashLinkCounts[title]++); 4367 } else { 4368 globals.hashLinkCounts[title] = 1; 4369 } 4370 return title; 4371 } 4372 4373 text = globals.converter._dispatch('headers.after', text, options, globals); 4374 return text; 4375 }); 4376 4377 /** 4378 * Turn Markdown link shortcuts into XHTML <a> tags. 4379 */ 4380 showdown.subParser('horizontalRule', function (text, options, globals) { 4381 'use strict'; 4382 text = globals.converter._dispatch('horizontalRule.before', text, options, globals); 4383 4384 var key = showdown.subParser('hashBlock')('<hr />', options, globals); 4385 text = text.replace(/^ {0,2}( ?-){3,}[ \t]*$/gm, key); 4386 text = text.replace(/^ {0,2}( ?\*){3,}[ \t]*$/gm, key); 4387 text = text.replace(/^ {0,2}( ?_){3,}[ \t]*$/gm, key); 4388 4389 text = globals.converter._dispatch('horizontalRule.after', text, options, globals); 4390 return text; 4391 }); 4392 4393 /** 4394 * Turn Markdown image shortcuts into <img> tags. 4395 */ 4396 showdown.subParser('images', function (text, options, globals) { 4397 'use strict'; 4398 4399 text = globals.converter._dispatch('images.before', text, options, globals); 4400 4401 var inlineRegExp = /!\[([^\]]*?)][ \t]*()\([ \t]?<?([\S]+?(?:\([\S]*?\)[\S]*?)?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(["'])([^"]*?)\6)?[ \t]?\)/g, 4402 crazyRegExp = /!\[([^\]]*?)][ \t]*()\([ \t]?<([^>]*)>(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(?:(["'])([^"]*?)\6))?[ \t]?\)/g, 4403 base64RegExp = /!\[([^\]]*?)][ \t]*()\([ \t]?<?(data:.+?\/.+?;base64,[A-Za-z0-9+/=\n]+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(["'])([^"]*?)\6)?[ \t]?\)/g, 4404 referenceRegExp = /!\[([^\]]*?)] ?(?:\n *)?\[([\s\S]*?)]()()()()()/g, 4405 refShortcutRegExp = /!\[([^\[\]]+)]()()()()()/g; 4406 4407 function writeImageTagBase64 (wholeMatch, altText, linkId, url, width, height, m5, title) { 4408 url = url.replace(/\s/g, ''); 4409 return writeImageTag (wholeMatch, altText, linkId, url, width, height, m5, title); 4410 } 4411 4412 function writeImageTag (wholeMatch, altText, linkId, url, width, height, m5, title) { 4413 4414 var gUrls = globals.gUrls, 4415 gTitles = globals.gTitles, 4416 gDims = globals.gDimensions; 4417 4418 linkId = linkId.toLowerCase(); 4419 4420 if (!title) { 4421 title = ''; 4422 } 4423 // Special case for explicit empty url 4424 if (wholeMatch.search(/\(<?\s*>? ?(['"].*['"])?\)$/m) > -1) { 4425 url = ''; 4426 4427 } else if (url === '' || url === null) { 4428 if (linkId === '' || linkId === null) { 4429 // lower-case and turn embedded newlines into spaces 4430 linkId = altText.toLowerCase().replace(/ ?\n/g, ' '); 4431 } 4432 url = '#' + linkId; 4433 4434 if (!showdown.helper.isUndefined(gUrls[linkId])) { 4435 url = gUrls[linkId]; 4436 if (!showdown.helper.isUndefined(gTitles[linkId])) { 4437 title = gTitles[linkId]; 4438 } 4439 if (!showdown.helper.isUndefined(gDims[linkId])) { 4440 width = gDims[linkId].width; 4441 height = gDims[linkId].height; 4442 } 4443 } else { 4444 return wholeMatch; 4445 } 4446 } 4447 4448 altText = altText 4449 .replace(/"/g, '"') 4450 //altText = showdown.helper.escapeCharacters(altText, '*_', false); 4451 .replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback); 4452 //url = showdown.helper.escapeCharacters(url, '*_', false); 4453 url = url.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback); 4454 var result = '<img src="' + url + '" alt="' + altText + '"'; 4455 4456 if (title && showdown.helper.isString(title)) { 4457 title = title 4458 .replace(/"/g, '"') 4459 //title = showdown.helper.escapeCharacters(title, '*_', false); 4460 .replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback); 4461 result += ' title="' + title + '"'; 4462 } 4463 4464 if (width && height) { 4465 width = (width === '*') ? 'auto' : width; 4466 height = (height === '*') ? 'auto' : height; 4467 4468 result += ' width="' + width + '"'; 4469 result += ' height="' + height + '"'; 4470 } 4471 4472 result += ' />'; 4473 4474 return result; 4475 } 4476 4477 // First, handle reference-style labeled images: ![alt text][id] 4478 text = text.replace(referenceRegExp, writeImageTag); 4479 4480 // Next, handle inline images: ![alt text](url =<width>x<height> "optional title") 4481 4482 // base64 encoded images 4483 text = text.replace(base64RegExp, writeImageTagBase64); 4484 4485 // cases with crazy urls like ./image/cat1).png 4486 text = text.replace(crazyRegExp, writeImageTag); 4487 4488 // normal cases 4489 text = text.replace(inlineRegExp, writeImageTag); 4490 4491 // handle reference-style shortcuts: ![img text] 4492 text = text.replace(refShortcutRegExp, writeImageTag); 4493 4494 text = globals.converter._dispatch('images.after', text, options, globals); 4495 return text; 4496 }); 4497 4498 showdown.subParser('italicsAndBold', function (text, options, globals) { 4499 'use strict'; 4500 4501 text = globals.converter._dispatch('italicsAndBold.before', text, options, globals); 4502 4503 // it's faster to have 3 separate regexes for each case than have just one 4504 // because of backtracing, in some cases, it could lead to an exponential effect 4505 // called "catastrophic backtrace". Ominous! 4506 4507 function parseInside (txt, left, right) { 4508 /* 4509 if (options.simplifiedAutoLink) { 4510 txt = showdown.subParser('simplifiedAutoLinks')(txt, options, globals); 4511 } 4512 */ 4513 return left + txt + right; 4514 } 4515 4516 // Parse underscores 4517 if (options.literalMidWordUnderscores) { 4518 text = text.replace(/\b___(\S[\s\S]*?)___\b/g, function (wm, txt) { 4519 return parseInside (txt, '<strong><em>', '</em></strong>'); 4520 }); 4521 text = text.replace(/\b__(\S[\s\S]*?)__\b/g, function (wm, txt) { 4522 return parseInside (txt, '<strong>', '</strong>'); 4523 }); 4524 text = text.replace(/\b_(\S[\s\S]*?)_\b/g, function (wm, txt) { 4525 return parseInside (txt, '<em>', '</em>'); 4526 }); 4527 } else { 4528 text = text.replace(/___(\S[\s\S]*?)___/g, function (wm, m) { 4529 return (/\S$/.test(m)) ? parseInside (m, '<strong><em>', '</em></strong>') : wm; 4530 }); 4531 text = text.replace(/__(\S[\s\S]*?)__/g, function (wm, m) { 4532 return (/\S$/.test(m)) ? parseInside (m, '<strong>', '</strong>') : wm; 4533 }); 4534 text = text.replace(/_([^\s_][\s\S]*?)_/g, function (wm, m) { 4535 // !/^_[^_]/.test(m) - test if it doesn't start with __ (since it seems redundant, we removed it) 4536 return (/\S$/.test(m)) ? parseInside (m, '<em>', '</em>') : wm; 4537 }); 4538 } 4539 4540 // Now parse asterisks 4541 if (options.literalMidWordAsterisks) { 4542 text = text.replace(/([^*]|^)\B\*\*\*(\S[\s\S]*?)\*\*\*\B(?!\*)/g, function (wm, lead, txt) { 4543 return parseInside (txt, lead + '<strong><em>', '</em></strong>'); 4544 }); 4545 text = text.replace(/([^*]|^)\B\*\*(\S[\s\S]*?)\*\*\B(?!\*)/g, function (wm, lead, txt) { 4546 return parseInside (txt, lead + '<strong>', '</strong>'); 4547 }); 4548 text = text.replace(/([^*]|^)\B\*(\S[\s\S]*?)\*\B(?!\*)/g, function (wm, lead, txt) { 4549 return parseInside (txt, lead + '<em>', '</em>'); 4550 }); 4551 } else { 4552 text = text.replace(/\*\*\*(\S[\s\S]*?)\*\*\*/g, function (wm, m) { 4553 return (/\S$/.test(m)) ? parseInside (m, '<strong><em>', '</em></strong>') : wm; 4554 }); 4555 text = text.replace(/\*\*(\S[\s\S]*?)\*\*/g, function (wm, m) { 4556 return (/\S$/.test(m)) ? parseInside (m, '<strong>', '</strong>') : wm; 4557 }); 4558 text = text.replace(/\*([^\s*][\s\S]*?)\*/g, function (wm, m) { 4559 // !/^\*[^*]/.test(m) - test if it doesn't start with ** (since it seems redundant, we removed it) 4560 return (/\S$/.test(m)) ? parseInside (m, '<em>', '</em>') : wm; 4561 }); 4562 } 4563 4564 4565 text = globals.converter._dispatch('italicsAndBold.after', text, options, globals); 4566 return text; 4567 }); 4568 4569 /** 4570 * Form HTML ordered (numbered) and unordered (bulleted) lists. 4571 */ 4572 showdown.subParser('lists', function (text, options, globals) { 4573 'use strict'; 4574 4575 /** 4576 * Process the contents of a single ordered or unordered list, splitting it 4577 * into individual list items. 4578 * @param {string} listStr 4579 * @param {boolean} trimTrailing 4580 * @returns {string} 4581 */ 4582 function processListItems (listStr, trimTrailing) { 4583 // The $g_list_level global keeps track of when we're inside a list. 4584 // Each time we enter a list, we increment it; when we leave a list, 4585 // we decrement. If it's zero, we're not in a list anymore. 4586 // 4587 // We do this because when we're not inside a list, we want to treat 4588 // something like this: 4589 // 4590 // I recommend upgrading to version 4591 // 8. Oops, now this line is treated 4592 // as a sub-list. 4593 // 4594 // As a single paragraph, despite the fact that the second line starts 4595 // with a digit-period-space sequence. 4596 // 4597 // Whereas when we're inside a list (or sub-list), that line will be 4598 // treated as the start of a sub-list. What a kludge, huh? This is 4599 // an aspect of Markdown's syntax that's hard to parse perfectly 4600 // without resorting to mind-reading. Perhaps the solution is to 4601 // change the syntax rules such that sub-lists must start with a 4602 // starting cardinal number; e.g. "1." or "a.". 4603 globals.gListLevel++; 4604 4605 // trim trailing blank lines: 4606 listStr = listStr.replace(/\n{2,}$/, '\n'); 4607 4608 // attacklab: add sentinel to emulate \z 4609 listStr += '¨0'; 4610 4611 var rgx = /(\n)?(^ {0,3})([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(¨0| {0,3}([*+-]|\d+[.])[ \t]+))/gm, 4612 isParagraphed = (/\n[ \t]*\n(?!¨0)/.test(listStr)); 4613 4614 // Since version 1.5, nesting sublists requires 4 spaces (or 1 tab) indentation, 4615 // which is a syntax breaking change 4616 // activating this option reverts to old behavior 4617 if (options.disableForced4SpacesIndentedSublists) { 4618 rgx = /(\n)?(^ {0,3})([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(¨0|\2([*+-]|\d+[.])[ \t]+))/gm; 4619 } 4620 4621 listStr = listStr.replace(rgx, function (wholeMatch, m1, m2, m3, m4, taskbtn, checked) { 4622 checked = (checked && checked.trim() !== ''); 4623 4624 var item = showdown.subParser('outdent')(m4, options, globals), 4625 bulletStyle = ''; 4626 4627 // Support for github tasklists 4628 if (taskbtn && options.tasklists) { 4629 bulletStyle = ' class="task-list-item" style="list-style-type: none;"'; 4630 item = item.replace(/^[ \t]*\[(x|X| )?]/m, function () { 4631 var otp = '<input type="checkbox" disabled style="margin: 0px 0.35em 0.25em -1.6em; vertical-align: middle;"'; 4632 if (checked) { 4633 otp += ' checked'; 4634 } 4635 otp += '>'; 4636 return otp; 4637 }); 4638 } 4639 4640 // ISSUE #312 4641 // This input: - - - a 4642 // causes trouble to the parser, since it interprets it as: 4643 // <ul><li><li><li>a</li></li></li></ul> 4644 // instead of: 4645 // <ul><li>- - a</li></ul> 4646 // So, to prevent it, we will put a marker (¨A)in the beginning of the line 4647 // Kind of hackish/monkey patching, but seems more effective than overcomplicating the list parser 4648 item = item.replace(/^([-*+]|\d\.)[ \t]+[\S\n ]*/g, function (wm2) { 4649 return '¨A' + wm2; 4650 }); 4651 4652 // m1 - Leading line or 4653 // Has a double return (multi paragraph) or 4654 // Has sublist 4655 if (m1 || (item.search(/\n{2,}/) > -1)) { 4656 item = showdown.subParser('githubCodeBlocks')(item, options, globals); 4657 item = showdown.subParser('blockGamut')(item, options, globals); 4658 } else { 4659 // Recursion for sub-lists: 4660 item = showdown.subParser('lists')(item, options, globals); 4661 item = item.replace(/\n$/, ''); // chomp(item) 4662 item = showdown.subParser('hashHTMLBlocks')(item, options, globals); 4663 4664 // Colapse double linebreaks 4665 item = item.replace(/\n\n+/g, '\n\n'); 4666 if (isParagraphed) { 4667 item = showdown.subParser('paragraphs')(item, options, globals); 4668 } else { 4669 item = showdown.subParser('spanGamut')(item, options, globals); 4670 } 4671 } 4672 4673 // now we need to remove the marker (¨A) 4674 item = item.replace('¨A', ''); 4675 // we can finally wrap the line in list item tags 4676 item = '<li' + bulletStyle + '>' + item + '</li>\n'; 4677 4678 return item; 4679 }); 4680 4681 // attacklab: strip sentinel 4682 listStr = listStr.replace(/¨0/g, ''); 4683 4684 globals.gListLevel--; 4685 4686 if (trimTrailing) { 4687 listStr = listStr.replace(/\s+$/, ''); 4688 } 4689 4690 return listStr; 4691 } 4692 4693 function styleStartNumber (list, listType) { 4694 // check if ol and starts by a number different than 1 4695 if (listType === 'ol') { 4696 var res = list.match(/^ *(\d+)\./); 4697 if (res && res[1] !== '1') { 4698 return ' start="' + res[1] + '"'; 4699 } 4700 } 4701 return ''; 4702 } 4703 4704 /** 4705 * Check and parse consecutive lists (better fix for issue #142) 4706 * @param {string} list 4707 * @param {string} listType 4708 * @param {boolean} trimTrailing 4709 * @returns {string} 4710 */ 4711 function parseConsecutiveLists (list, listType, trimTrailing) { 4712 // check if we caught 2 or more consecutive lists by mistake 4713 // we use the counterRgx, meaning if listType is UL we look for OL and vice versa 4714 var olRgx = (options.disableForced4SpacesIndentedSublists) ? /^ ?\d+\.[ \t]/gm : /^ {0,3}\d+\.[ \t]/gm, 4715 ulRgx = (options.disableForced4SpacesIndentedSublists) ? /^ ?[*+-][ \t]/gm : /^ {0,3}[*+-][ \t]/gm, 4716 counterRxg = (listType === 'ul') ? olRgx : ulRgx, 4717 result = ''; 4718 4719 if (list.search(counterRxg) !== -1) { 4720 (function parseCL (txt) { 4721 var pos = txt.search(counterRxg), 4722 style = styleStartNumber(list, listType); 4723 if (pos !== -1) { 4724 // slice 4725 result += '\n\n<' + listType + style + '>\n' + processListItems(txt.slice(0, pos), !!trimTrailing) + '</' + listType + '>\n'; 4726 4727 // invert counterType and listType 4728 listType = (listType === 'ul') ? 'ol' : 'ul'; 4729 counterRxg = (listType === 'ul') ? olRgx : ulRgx; 4730 4731 //recurse 4732 parseCL(txt.slice(pos)); 4733 } else { 4734 result += '\n\n<' + listType + style + '>\n' + processListItems(txt, !!trimTrailing) + '</' + listType + '>\n'; 4735 } 4736 })(list); 4737 } else { 4738 var style = styleStartNumber(list, listType); 4739 result = '\n\n<' + listType + style + '>\n' + processListItems(list, !!trimTrailing) + '</' + listType + '>\n'; 4740 } 4741 4742 return result; 4743 } 4744 4745 /** Start of list parsing **/ 4746 text = globals.converter._dispatch('lists.before', text, options, globals); 4747 // add sentinel to hack around khtml/safari bug: 4748 // http://bugs.webkit.org/show_bug.cgi?id=11231 4749 text += '¨0'; 4750 4751 if (globals.gListLevel) { 4752 text = text.replace(/^(( {0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(¨0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm, 4753 function (wholeMatch, list, m2) { 4754 var listType = (m2.search(/[*+-]/g) > -1) ? 'ul' : 'ol'; 4755 return parseConsecutiveLists(list, listType, true); 4756 } 4757 ); 4758 } else { 4759 text = text.replace(/(\n\n|^\n?)(( {0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(¨0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm, 4760 function (wholeMatch, m1, list, m3) { 4761 var listType = (m3.search(/[*+-]/g) > -1) ? 'ul' : 'ol'; 4762 return parseConsecutiveLists(list, listType, false); 4763 } 4764 ); 4765 } 4766 4767 // strip sentinel 4768 text = text.replace(/¨0/, ''); 4769 text = globals.converter._dispatch('lists.after', text, options, globals); 4770 return text; 4771 }); 4772 4773 /** 4774 * Parse metadata at the top of the document 4775 */ 4776 showdown.subParser('metadata', function (text, options, globals) { 4777 'use strict'; 4778 4779 if (!options.metadata) { 4780 return text; 4781 } 4782 4783 text = globals.converter._dispatch('metadata.before', text, options, globals); 4784 4785 function parseMetadataContents (content) { 4786 // raw is raw so it's not changed in any way 4787 globals.metadata.raw = content; 4788 4789 // escape chars forbidden in html attributes 4790 // double quotes 4791 content = content 4792 // ampersand first 4793 .replace(/&/g, '&') 4794 // double quotes 4795 .replace(/"/g, '"'); 4796 4797 content = content.replace(/\n {4}/g, ' '); 4798 content.replace(/^([\S ]+): +([\s\S]+?)$/gm, function (wm, key, value) { 4799 globals.metadata.parsed[key] = value; 4800 return ''; 4801 }); 4802 } 4803 4804 text = text.replace(/^\s*«««+(\S*?)\n([\s\S]+?)\n»»»+\n/, function (wholematch, format, content) { 4805 parseMetadataContents(content); 4806 return '¨M'; 4807 }); 4808 4809 text = text.replace(/^\s*---+(\S*?)\n([\s\S]+?)\n---+\n/, function (wholematch, format, content) { 4810 if (format) { 4811 globals.metadata.format = format; 4812 } 4813 parseMetadataContents(content); 4814 return '¨M'; 4815 }); 4816 4817 text = text.replace(/¨M/g, ''); 4818 4819 text = globals.converter._dispatch('metadata.after', text, options, globals); 4820 return text; 4821 }); 4822 4823 /** 4824 * Remove one level of line-leading tabs or spaces 4825 */ 4826 showdown.subParser('outdent', function (text, options, globals) { 4827 'use strict'; 4828 text = globals.converter._dispatch('outdent.before', text, options, globals); 4829 4830 // attacklab: hack around Konqueror 3.5.4 bug: 4831 // "----------bug".replace(/^-/g,"") == "bug" 4832 text = text.replace(/^(\t|[ ]{1,4})/gm, '¨0'); // attacklab: g_tab_width 4833 4834 // attacklab: clean up hack 4835 text = text.replace(/¨0/g, ''); 4836 4837 text = globals.converter._dispatch('outdent.after', text, options, globals); 4838 return text; 4839 }); 4840 4841 /** 4842 * 4843 */ 4844 showdown.subParser('paragraphs', function (text, options, globals) { 4845 'use strict'; 4846 4847 text = globals.converter._dispatch('paragraphs.before', text, options, globals); 4848 // Strip leading and trailing lines: 4849 text = text.replace(/^\n+/g, ''); 4850 text = text.replace(/\n+$/g, ''); 4851 4852 var grafs = text.split(/\n{2,}/g), 4853 grafsOut = [], 4854 end = grafs.length; // Wrap <p> tags 4855 4856 for (var i = 0; i < end; i++) { 4857 var str = grafs[i]; 4858 // if this is an HTML marker, copy it 4859 if (str.search(/¨(K|G)(\d+)\1/g) >= 0) { 4860 grafsOut.push(str); 4861 4862 // test for presence of characters to prevent empty lines being parsed 4863 // as paragraphs (resulting in undesired extra empty paragraphs) 4864 } else if (str.search(/\S/) >= 0) { 4865 str = showdown.subParser('spanGamut')(str, options, globals); 4866 str = str.replace(/^([ \t]*)/g, '<p>'); 4867 str += '</p>'; 4868 grafsOut.push(str); 4869 } 4870 } 4871 4872 /** Unhashify HTML blocks */ 4873 end = grafsOut.length; 4874 for (i = 0; i < end; i++) { 4875 var blockText = '', 4876 grafsOutIt = grafsOut[i], 4877 codeFlag = false; 4878 // if this is a marker for an html block... 4879 // use RegExp.test instead of string.search because of QML bug 4880 while (/¨(K|G)(\d+)\1/.test(grafsOutIt)) { 4881 var delim = RegExp.$1, 4882 num = RegExp.$2; 4883 4884 if (delim === 'K') { 4885 blockText = globals.gHtmlBlocks[num]; 4886 } else { 4887 // we need to check if ghBlock is a false positive 4888 if (codeFlag) { 4889 // use encoded version of all text 4890 blockText = showdown.subParser('encodeCode')(globals.ghCodeBlocks[num].text, options, globals); 4891 } else { 4892 blockText = globals.ghCodeBlocks[num].codeblock; 4893 } 4894 } 4895 blockText = blockText.replace(/\$/g, '$$$$'); // Escape any dollar signs 4896 4897 grafsOutIt = grafsOutIt.replace(/(\n\n)?¨(K|G)\d+\2(\n\n)?/, blockText); 4898 // Check if grafsOutIt is a pre->code 4899 if (/^<pre\b[^>]*>\s*<code\b[^>]*>/.test(grafsOutIt)) { 4900 codeFlag = true; 4901 } 4902 } 4903 grafsOut[i] = grafsOutIt; 4904 } 4905 text = grafsOut.join('\n'); 4906 // Strip leading and trailing lines: 4907 text = text.replace(/^\n+/g, ''); 4908 text = text.replace(/\n+$/g, ''); 4909 return globals.converter._dispatch('paragraphs.after', text, options, globals); 4910 }); 4911 4912 /** 4913 * Run extension 4914 */ 4915 showdown.subParser('runExtension', function (ext, text, options, globals) { 4916 'use strict'; 4917 4918 if (ext.filter) { 4919 text = ext.filter(text, globals.converter, options); 4920 4921 } else if (ext.regex) { 4922 // TODO remove this when old extension loading mechanism is deprecated 4923 var re = ext.regex; 4924 if (!(re instanceof RegExp)) { 4925 re = new RegExp(re, 'g'); 4926 } 4927 text = text.replace(re, ext.replace); 4928 } 4929 4930 return text; 4931 }); 4932 4933 /** 4934 * These are all the transformations that occur *within* block-level 4935 * tags like paragraphs, headers, and list items. 4936 */ 4937 showdown.subParser('spanGamut', function (text, options, globals) { 4938 'use strict'; 4939 4940 text = globals.converter._dispatch('spanGamut.before', text, options, globals); 4941 text = showdown.subParser('codeSpans')(text, options, globals); 4942 text = showdown.subParser('escapeSpecialCharsWithinTagAttributes')(text, options, globals); 4943 text = showdown.subParser('encodeBackslashEscapes')(text, options, globals); 4944 4945 // Process anchor and image tags. Images must come first, 4946 // because ![foo][f] looks like an anchor. 4947 text = showdown.subParser('images')(text, options, globals); 4948 text = showdown.subParser('anchors')(text, options, globals); 4949 4950 // Make links out of things like `<http://example.com/>` 4951 // Must come after anchors, because you can use < and > 4952 // delimiters in inline links like [this](<url>). 4953 text = showdown.subParser('autoLinks')(text, options, globals); 4954 text = showdown.subParser('simplifiedAutoLinks')(text, options, globals); 4955 text = showdown.subParser('emoji')(text, options, globals); 4956 text = showdown.subParser('underline')(text, options, globals); 4957 text = showdown.subParser('italicsAndBold')(text, options, globals); 4958 text = showdown.subParser('strikethrough')(text, options, globals); 4959 text = showdown.subParser('ellipsis')(text, options, globals); 4960 4961 // we need to hash HTML tags inside spans 4962 text = showdown.subParser('hashHTMLSpans')(text, options, globals); 4963 4964 // now we encode amps and angles 4965 text = showdown.subParser('encodeAmpsAndAngles')(text, options, globals); 4966 4967 // Do hard breaks 4968 if (options.simpleLineBreaks) { 4969 // GFM style hard breaks 4970 // only add line breaks if the text does not contain a block (special case for lists) 4971 if (!/\n\n¨K/.test(text)) { 4972 text = text.replace(/\n+/g, '<br />\n'); 4973 } 4974 } else { 4975 // Vanilla hard breaks 4976 text = text.replace(/ +\n/g, '<br />\n'); 4977 } 4978 4979 text = globals.converter._dispatch('spanGamut.after', text, options, globals); 4980 return text; 4981 }); 4982 4983 showdown.subParser('strikethrough', function (text, options, globals) { 4984 'use strict'; 4985 4986 function parseInside (txt) { 4987 if (options.simplifiedAutoLink) { 4988 txt = showdown.subParser('simplifiedAutoLinks')(txt, options, globals); 4989 } 4990 return '<del>' + txt + '</del>'; 4991 } 4992 4993 if (options.strikethrough) { 4994 text = globals.converter._dispatch('strikethrough.before', text, options, globals); 4995 text = text.replace(/(?:~){2}([\s\S]+?)(?:~){2}/g, function (wm, txt) { return parseInside(txt); }); 4996 text = globals.converter._dispatch('strikethrough.after', text, options, globals); 4997 } 4998 4999 return text; 5000 }); 5001 5002 /** 5003 * Strips link definitions from text, stores the URLs and titles in 5004 * hash references. 5005 * Link defs are in the form: ^[id]: url "optional title" 5006 */ 5007 showdown.subParser('stripLinkDefinitions', function (text, options, globals) { 5008 'use strict'; 5009 5010 var regex = /^ {0,3}\[(.+)]:[ \t]*\n?[ \t]*<?([^>\s]+)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n+|(?=¨0))/gm, 5011 base64Regex = /^ {0,3}\[(.+)]:[ \t]*\n?[ \t]*<?(data:.+?\/.+?;base64,[A-Za-z0-9+/=\n]+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n\n|(?=¨0)|(?=\n\[))/gm; 5012 5013 // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug 5014 text += '¨0'; 5015 5016 var replaceFunc = function (wholeMatch, linkId, url, width, height, blankLines, title) { 5017 linkId = linkId.toLowerCase(); 5018 if (url.match(/^data:.+?\/.+?;base64,/)) { 5019 // remove newlines 5020 globals.gUrls[linkId] = url.replace(/\s/g, ''); 5021 } else { 5022 globals.gUrls[linkId] = showdown.subParser('encodeAmpsAndAngles')(url, options, globals); // Link IDs are case-insensitive 5023 } 5024 5025 if (blankLines) { 5026 // Oops, found blank lines, so it's not a title. 5027 // Put back the parenthetical statement we stole. 5028 return blankLines + title; 5029 5030 } else { 5031 if (title) { 5032 globals.gTitles[linkId] = title.replace(/"|'/g, '"'); 5033 } 5034 if (options.parseImgDimensions && width && height) { 5035 globals.gDimensions[linkId] = { 5036 width: width, 5037 height: height 5038 }; 5039 } 5040 } 5041 // Completely remove the definition from the text 5042 return ''; 5043 }; 5044 5045 // first we try to find base64 link references 5046 text = text.replace(base64Regex, replaceFunc); 5047 5048 text = text.replace(regex, replaceFunc); 5049 5050 // attacklab: strip sentinel 5051 text = text.replace(/¨0/, ''); 5052 5053 return text; 5054 }); 5055 5056 showdown.subParser('tables', function (text, options, globals) { 5057 'use strict'; 5058 5059 if (!options.tables) { 5060 return text; 5061 } 5062 5063 var tableRgx = /^ {0,3}\|?.+\|.+\n {0,3}\|?[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*:?[ \t]*(?:[-=]){2,}[\s\S]+?(?:\n\n|¨0)/gm, 5064 //singeColTblRgx = /^ {0,3}\|.+\|\n {0,3}\|[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*\n(?: {0,3}\|.+\|\n)+(?:\n\n|¨0)/gm; 5065 singeColTblRgx = /^ {0,3}\|.+\|[ \t]*\n {0,3}\|[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*\n( {0,3}\|.+\|[ \t]*\n)*(?:\n|¨0)/gm; 5066 5067 function parseStyles (sLine) { 5068 if (/^:[ \t]*--*$/.test(sLine)) { 5069 return ' style="text-align:left;"'; 5070 } else if (/^--*[ \t]*:[ \t]*$/.test(sLine)) { 5071 return ' style="text-align:right;"'; 5072 } else if (/^:[ \t]*--*[ \t]*:$/.test(sLine)) { 5073 return ' style="text-align:center;"'; 5074 } else { 5075 return ''; 5076 } 5077 } 5078 5079 function parseHeaders (header, style) { 5080 var id = ''; 5081 header = header.trim(); 5082 // support both tablesHeaderId and tableHeaderId due to error in documentation so we don't break backwards compatibility 5083 if (options.tablesHeaderId || options.tableHeaderId) { 5084 id = ' id="' + header.replace(/ /g, '_').toLowerCase() + '"'; 5085 } 5086 header = showdown.subParser('spanGamut')(header, options, globals); 5087 5088 return '<th' + id + style + '>' + header + '</th>\n'; 5089 } 5090 5091 function parseCells (cell, style) { 5092 var subText = showdown.subParser('spanGamut')(cell, options, globals); 5093 return '<td' + style + '>' + subText + '</td>\n'; 5094 } 5095 5096 function buildTable (headers, cells) { 5097 var tb = '<table>\n<thead>\n<tr>\n', 5098 tblLgn = headers.length; 5099 5100 for (var i = 0; i < tblLgn; ++i) { 5101 tb += headers[i]; 5102 } 5103 tb += '</tr>\n</thead>\n<tbody>\n'; 5104 5105 for (i = 0; i < cells.length; ++i) { 5106 tb += '<tr>\n'; 5107 for (var ii = 0; ii < tblLgn; ++ii) { 5108 tb += cells[i][ii]; 5109 } 5110 tb += '</tr>\n'; 5111 } 5112 tb += '</tbody>\n</table>\n'; 5113 return tb; 5114 } 5115 5116 function parseTable (rawTable) { 5117 var i, tableLines = rawTable.split('\n'); 5118 5119 for (i = 0; i < tableLines.length; ++i) { 5120 // strip wrong first and last column if wrapped tables are used 5121 if (/^ {0,3}\|/.test(tableLines[i])) { 5122 tableLines[i] = tableLines[i].replace(/^ {0,3}\|/, ''); 5123 } 5124 if (/\|[ \t]*$/.test(tableLines[i])) { 5125 tableLines[i] = tableLines[i].replace(/\|[ \t]*$/, ''); 5126 } 5127 // parse code spans first, but we only support one line code spans 5128 tableLines[i] = showdown.subParser('codeSpans')(tableLines[i], options, globals); 5129 } 5130 5131 var rawHeaders = tableLines[0].split('|').map(function (s) { return s.trim();}), 5132 rawStyles = tableLines[1].split('|').map(function (s) { return s.trim();}), 5133 rawCells = [], 5134 headers = [], 5135 styles = [], 5136 cells = []; 5137 5138 tableLines.shift(); 5139 tableLines.shift(); 5140 5141 for (i = 0; i < tableLines.length; ++i) { 5142 if (tableLines[i].trim() === '') { 5143 continue; 5144 } 5145 rawCells.push( 5146 tableLines[i] 5147 .split('|') 5148 .map(function (s) { 5149 return s.trim(); 5150 }) 5151 ); 5152 } 5153 5154 if (rawHeaders.length < rawStyles.length) { 5155 return rawTable; 5156 } 5157 5158 for (i = 0; i < rawStyles.length; ++i) { 5159 styles.push(parseStyles(rawStyles[i])); 5160 } 5161 5162 for (i = 0; i < rawHeaders.length; ++i) { 5163 if (showdown.helper.isUndefined(styles[i])) { 5164 styles[i] = ''; 5165 } 5166 headers.push(parseHeaders(rawHeaders[i], styles[i])); 5167 } 5168 5169 for (i = 0; i < rawCells.length; ++i) { 5170 var row = []; 5171 for (var ii = 0; ii < headers.length; ++ii) { 5172 if (showdown.helper.isUndefined(rawCells[i][ii])) { 5173 5174 } 5175 row.push(parseCells(rawCells[i][ii], styles[ii])); 5176 } 5177 cells.push(row); 5178 } 5179 5180 return buildTable(headers, cells); 5181 } 5182 5183 text = globals.converter._dispatch('tables.before', text, options, globals); 5184 5185 // find escaped pipe characters 5186 text = text.replace(/\\(\|)/g, showdown.helper.escapeCharactersCallback); 5187 5188 // parse multi column tables 5189 text = text.replace(tableRgx, parseTable); 5190 5191 // parse one column tables 5192 text = text.replace(singeColTblRgx, parseTable); 5193 5194 text = globals.converter._dispatch('tables.after', text, options, globals); 5195 5196 return text; 5197 }); 5198 5199 showdown.subParser('underline', function (text, options, globals) { 5200 'use strict'; 5201 5202 if (!options.underline) { 5203 return text; 5204 } 5205 5206 text = globals.converter._dispatch('underline.before', text, options, globals); 5207 5208 if (options.literalMidWordUnderscores) { 5209 text = text.replace(/\b___(\S[\s\S]*?)___\b/g, function (wm, txt) { 5210 return '<u>' + txt + '</u>'; 5211 }); 5212 text = text.replace(/\b__(\S[\s\S]*?)__\b/g, function (wm, txt) { 5213 return '<u>' + txt + '</u>'; 5214 }); 5215 } else { 5216 text = text.replace(/___(\S[\s\S]*?)___/g, function (wm, m) { 5217 return (/\S$/.test(m)) ? '<u>' + m + '</u>' : wm; 5218 }); 5219 text = text.replace(/__(\S[\s\S]*?)__/g, function (wm, m) { 5220 return (/\S$/.test(m)) ? '<u>' + m + '</u>' : wm; 5221 }); 5222 } 5223 5224 // escape remaining underscores to prevent them being parsed by italic and bold 5225 text = text.replace(/(_)/g, showdown.helper.escapeCharactersCallback); 5226 5227 text = globals.converter._dispatch('underline.after', text, options, globals); 5228 5229 return text; 5230 }); 5231 5232 /** 5233 * Swap back in all the special characters we've hidden. 5234 */ 5235 showdown.subParser('unescapeSpecialChars', function (text, options, globals) { 5236 'use strict'; 5237 text = globals.converter._dispatch('unescapeSpecialChars.before', text, options, globals); 5238 5239 text = text.replace(/¨E(\d+)E/g, function (wholeMatch, m1) { 5240 var charCodeToReplace = parseInt(m1); 5241 return String.fromCharCode(charCodeToReplace); 5242 }); 5243 5244 text = globals.converter._dispatch('unescapeSpecialChars.after', text, options, globals); 5245 return text; 5246 }); 5247 5248 showdown.subParser('makeMarkdown.blockquote', function (node, globals) { 5249 'use strict'; 5250 5251 var txt = ''; 5252 if (node.hasChildNodes()) { 5253 var children = node.childNodes, 5254 childrenLength = children.length; 5255 5256 for (var i = 0; i < childrenLength; ++i) { 5257 var innerTxt = showdown.subParser('makeMarkdown.node')(children[i], globals); 5258 5259 if (innerTxt === '') { 5260 continue; 5261 } 5262 txt += innerTxt; 5263 } 5264 } 5265 // cleanup 5266 txt = txt.trim(); 5267 txt = '> ' + txt.split('\n').join('\n> '); 5268 return txt; 5269 }); 5270 5271 showdown.subParser('makeMarkdown.codeBlock', function (node, globals) { 5272 'use strict'; 5273 5274 var lang = node.getAttribute('language'), 5275 num = node.getAttribute('precodenum'); 5276 return '```' + lang + '\n' + globals.preList[num] + '\n```'; 5277 }); 5278 5279 showdown.subParser('makeMarkdown.codeSpan', function (node) { 5280 'use strict'; 5281 5282 return '`' + node.innerHTML + '`'; 5283 }); 5284 5285 showdown.subParser('makeMarkdown.emphasis', function (node, globals) { 5286 'use strict'; 5287 5288 var txt = ''; 5289 if (node.hasChildNodes()) { 5290 txt += '*'; 5291 var children = node.childNodes, 5292 childrenLength = children.length; 5293 for (var i = 0; i < childrenLength; ++i) { 5294 txt += showdown.subParser('makeMarkdown.node')(children[i], globals); 5295 } 5296 txt += '*'; 5297 } 5298 return txt; 5299 }); 5300 5301 showdown.subParser('makeMarkdown.header', function (node, globals, headerLevel) { 5302 'use strict'; 5303 5304 var headerMark = new Array(headerLevel + 1).join('#'), 5305 txt = ''; 5306 5307 if (node.hasChildNodes()) { 5308 txt = headerMark + ' '; 5309 var children = node.childNodes, 5310 childrenLength = children.length; 5311 5312 for (var i = 0; i < childrenLength; ++i) { 5313 txt += showdown.subParser('makeMarkdown.node')(children[i], globals); 5314 } 5315 } 5316 return txt; 5317 }); 5318 5319 showdown.subParser('makeMarkdown.hr', function () { 5320 'use strict'; 5321 5322 return '---'; 5323 }); 5324 5325 showdown.subParser('makeMarkdown.image', function (node) { 5326 'use strict'; 5327 5328 var txt = ''; 5329 if (node.hasAttribute('src')) { 5330 txt += '![' + node.getAttribute('alt') + ']('; 5331 txt += '<' + node.getAttribute('src') + '>'; 5332 if (node.hasAttribute('width') && node.hasAttribute('height')) { 5333 txt += ' =' + node.getAttribute('width') + 'x' + node.getAttribute('height'); 5334 } 5335 5336 if (node.hasAttribute('title')) { 5337 txt += ' "' + node.getAttribute('title') + '"'; 5338 } 5339 txt += ')'; 5340 } 5341 return txt; 5342 }); 5343 5344 showdown.subParser('makeMarkdown.links', function (node, globals) { 5345 'use strict'; 5346 5347 var txt = ''; 5348 if (node.hasChildNodes() && node.hasAttribute('href')) { 5349 var children = node.childNodes, 5350 childrenLength = children.length; 5351 txt = '['; 5352 for (var i = 0; i < childrenLength; ++i) { 5353 txt += showdown.subParser('makeMarkdown.node')(children[i], globals); 5354 } 5355 txt += ']('; 5356 txt += '<' + node.getAttribute('href') + '>'; 5357 if (node.hasAttribute('title')) { 5358 txt += ' "' + node.getAttribute('title') + '"'; 5359 } 5360 txt += ')'; 5361 } 5362 return txt; 5363 }); 5364 5365 showdown.subParser('makeMarkdown.list', function (node, globals, type) { 5366 'use strict'; 5367 5368 var txt = ''; 5369 if (!node.hasChildNodes()) { 5370 return ''; 5371 } 5372 var listItems = node.childNodes, 5373 listItemsLenght = listItems.length, 5374 listNum = node.getAttribute('start') || 1; 5375 5376 for (var i = 0; i < listItemsLenght; ++i) { 5377 if (typeof listItems[i].tagName === 'undefined' || listItems[i].tagName.toLowerCase() !== 'li') { 5378 continue; 5379 } 5380 5381 // define the bullet to use in list 5382 var bullet = ''; 5383 if (type === 'ol') { 5384 bullet = listNum.toString() + '. '; 5385 } else { 5386 bullet = '- '; 5387 } 5388 5389 // parse list item 5390 txt += bullet + showdown.subParser('makeMarkdown.listItem')(listItems[i], globals); 5391 ++listNum; 5392 } 5393 5394 // add comment at the end to prevent consecutive lists to be parsed as one 5395 txt += '\n<!-- -->\n'; 5396 return txt.trim(); 5397 }); 5398 5399 showdown.subParser('makeMarkdown.listItem', function (node, globals) { 5400 'use strict'; 5401 5402 var listItemTxt = ''; 5403 5404 var children = node.childNodes, 5405 childrenLenght = children.length; 5406 5407 for (var i = 0; i < childrenLenght; ++i) { 5408 listItemTxt += showdown.subParser('makeMarkdown.node')(children[i], globals); 5409 } 5410 // if it's only one liner, we need to add a newline at the end 5411 if (!/\n$/.test(listItemTxt)) { 5412 listItemTxt += '\n'; 5413 } else { 5414 // it's multiparagraph, so we need to indent 5415 listItemTxt = listItemTxt 5416 .split('\n') 5417 .join('\n ') 5418 .replace(/^ {4}$/gm, '') 5419 .replace(/\n\n+/g, '\n\n'); 5420 } 5421 5422 return listItemTxt; 5423 }); 5424 5425 5426 5427 showdown.subParser('makeMarkdown.node', function (node, globals, spansOnly) { 5428 'use strict'; 5429 5430 spansOnly = spansOnly || false; 5431 5432 var txt = ''; 5433 5434 // edge case of text without wrapper paragraph 5435 if (node.nodeType === 3) { 5436 return showdown.subParser('makeMarkdown.txt')(node, globals); 5437 } 5438 5439 // HTML comment 5440 if (node.nodeType === 8) { 5441 return '<!--' + node.data + '-->\n\n'; 5442 } 5443 5444 // process only node elements 5445 if (node.nodeType !== 1) { 5446 return ''; 5447 } 5448 5449 var tagName = node.tagName.toLowerCase(); 5450 5451 switch (tagName) { 5452 5453 // 5454 // BLOCKS 5455 // 5456 case 'h1': 5457 if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 1) + '\n\n'; } 5458 break; 5459 case 'h2': 5460 if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 2) + '\n\n'; } 5461 break; 5462 case 'h3': 5463 if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 3) + '\n\n'; } 5464 break; 5465 case 'h4': 5466 if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 4) + '\n\n'; } 5467 break; 5468 case 'h5': 5469 if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 5) + '\n\n'; } 5470 break; 5471 case 'h6': 5472 if (!spansOnly) { txt = showdown.subParser('makeMarkdown.header')(node, globals, 6) + '\n\n'; } 5473 break; 5474 5475 case 'p': 5476 if (!spansOnly) { txt = showdown.subParser('makeMarkdown.paragraph')(node, globals) + '\n\n'; } 5477 break; 5478 5479 case 'blockquote': 5480 if (!spansOnly) { txt = showdown.subParser('makeMarkdown.blockquote')(node, globals) + '\n\n'; } 5481 break; 5482 5483 case 'hr': 5484 if (!spansOnly) { txt = showdown.subParser('makeMarkdown.hr')(node, globals) + '\n\n'; } 5485 break; 5486 5487 case 'ol': 5488 if (!spansOnly) { txt = showdown.subParser('makeMarkdown.list')(node, globals, 'ol') + '\n\n'; } 5489 break; 5490 5491 case 'ul': 5492 if (!spansOnly) { txt = showdown.subParser('makeMarkdown.list')(node, globals, 'ul') + '\n\n'; } 5493 break; 5494 5495 case 'precode': 5496 if (!spansOnly) { txt = showdown.subParser('makeMarkdown.codeBlock')(node, globals) + '\n\n'; } 5497 break; 5498 5499 case 'pre': 5500 if (!spansOnly) { txt = showdown.subParser('makeMarkdown.pre')(node, globals) + '\n\n'; } 5501 break; 5502 5503 case 'table': 5504 if (!spansOnly) { txt = showdown.subParser('makeMarkdown.table')(node, globals) + '\n\n'; } 5505 break; 5506 5507 // 5508 // SPANS 5509 // 5510 case 'code': 5511 txt = showdown.subParser('makeMarkdown.codeSpan')(node, globals); 5512 break; 5513 5514 case 'em': 5515 case 'i': 5516 txt = showdown.subParser('makeMarkdown.emphasis')(node, globals); 5517 break; 5518 5519 case 'strong': 5520 case 'b': 5521 txt = showdown.subParser('makeMarkdown.strong')(node, globals); 5522 break; 5523 5524 case 'del': 5525 txt = showdown.subParser('makeMarkdown.strikethrough')(node, globals); 5526 break; 5527 5528 case 'a': 5529 txt = showdown.subParser('makeMarkdown.links')(node, globals); 5530 break; 5531 5532 case 'img': 5533 txt = showdown.subParser('makeMarkdown.image')(node, globals); 5534 break; 5535 5536 default: 5537 txt = node.outerHTML + '\n\n'; 5538 } 5539 5540 // common normalization 5541 // TODO eventually 5542 5543 return txt; 5544 }); 5545 5546 showdown.subParser('makeMarkdown.paragraph', function (node, globals) { 5547 'use strict'; 5548 5549 var txt = ''; 5550 if (node.hasChildNodes()) { 5551 var children = node.childNodes, 5552 childrenLength = children.length; 5553 for (var i = 0; i < childrenLength; ++i) { 5554 txt += showdown.subParser('makeMarkdown.node')(children[i], globals); 5555 } 5556 } 5557 5558 // some text normalization 5559 txt = txt.trim(); 5560 5561 return txt; 5562 }); 5563 5564 showdown.subParser('makeMarkdown.pre', function (node, globals) { 5565 'use strict'; 5566 5567 var num = node.getAttribute('prenum'); 5568 return '<pre>' + globals.preList[num] + '</pre>'; 5569 }); 5570 5571 showdown.subParser('makeMarkdown.strikethrough', function (node, globals) { 5572 'use strict'; 5573 5574 var txt = ''; 5575 if (node.hasChildNodes()) { 5576 txt += '~~'; 5577 var children = node.childNodes, 5578 childrenLength = children.length; 5579 for (var i = 0; i < childrenLength; ++i) { 5580 txt += showdown.subParser('makeMarkdown.node')(children[i], globals); 5581 } 5582 txt += '~~'; 5583 } 5584 return txt; 5585 }); 5586 5587 showdown.subParser('makeMarkdown.strong', function (node, globals) { 5588 'use strict'; 5589 5590 var txt = ''; 5591 if (node.hasChildNodes()) { 5592 txt += '**'; 5593 var children = node.childNodes, 5594 childrenLength = children.length; 5595 for (var i = 0; i < childrenLength; ++i) { 5596 txt += showdown.subParser('makeMarkdown.node')(children[i], globals); 5597 } 5598 txt += '**'; 5599 } 5600 return txt; 5601 }); 5602 5603 showdown.subParser('makeMarkdown.table', function (node, globals) { 5604 'use strict'; 5605 5606 var txt = '', 5607 tableArray = [[], []], 5608 headings = node.querySelectorAll('thead>tr>th'), 5609 rows = node.querySelectorAll('tbody>tr'), 5610 i, ii; 5611 for (i = 0; i < headings.length; ++i) { 5612 var headContent = showdown.subParser('makeMarkdown.tableCell')(headings[i], globals), 5613 allign = '---'; 5614 5615 if (headings[i].hasAttribute('style')) { 5616 var style = headings[i].getAttribute('style').toLowerCase().replace(/\s/g, ''); 5617 switch (style) { 5618 case 'text-align:left;': 5619 allign = ':---'; 5620 break; 5621 case 'text-align:right;': 5622 allign = '---:'; 5623 break; 5624 case 'text-align:center;': 5625 allign = ':---:'; 5626 break; 5627 } 5628 } 5629 tableArray[0][i] = headContent.trim(); 5630 tableArray[1][i] = allign; 5631 } 5632 5633 for (i = 0; i < rows.length; ++i) { 5634 var r = tableArray.push([]) - 1, 5635 cols = rows[i].getElementsByTagName('td'); 5636 5637 for (ii = 0; ii < headings.length; ++ii) { 5638 var cellContent = ' '; 5639 if (typeof cols[ii] !== 'undefined') { 5640 cellContent = showdown.subParser('makeMarkdown.tableCell')(cols[ii], globals); 5641 } 5642 tableArray[r].push(cellContent); 5643 } 5644 } 5645 5646 var cellSpacesCount = 3; 5647 for (i = 0; i < tableArray.length; ++i) { 5648 for (ii = 0; ii < tableArray[i].length; ++ii) { 5649 var strLen = tableArray[i][ii].length; 5650 if (strLen > cellSpacesCount) { 5651 cellSpacesCount = strLen; 5652 } 5653 } 5654 } 5655 5656 for (i = 0; i < tableArray.length; ++i) { 5657 for (ii = 0; ii < tableArray[i].length; ++ii) { 5658 if (i === 1) { 5659 if (tableArray[i][ii].slice(-1) === ':') { 5660 tableArray[i][ii] = showdown.helper.padEnd(tableArray[i][ii].slice(-1), cellSpacesCount - 1, '-') + ':'; 5661 } else { 5662 tableArray[i][ii] = showdown.helper.padEnd(tableArray[i][ii], cellSpacesCount, '-'); 5663 } 5664 } else { 5665 tableArray[i][ii] = showdown.helper.padEnd(tableArray[i][ii], cellSpacesCount); 5666 } 5667 } 5668 txt += '| ' + tableArray[i].join(' | ') + ' |\n'; 5669 } 5670 5671 return txt.trim(); 5672 }); 5673 5674 showdown.subParser('makeMarkdown.tableCell', function (node, globals) { 5675 'use strict'; 5676 5677 var txt = ''; 5678 if (!node.hasChildNodes()) { 5679 return ''; 5680 } 5681 var children = node.childNodes, 5682 childrenLength = children.length; 5683 5684 for (var i = 0; i < childrenLength; ++i) { 5685 txt += showdown.subParser('makeMarkdown.node')(children[i], globals, true); 5686 } 5687 return txt.trim(); 5688 }); 5689 5690 showdown.subParser('makeMarkdown.txt', function (node) { 5691 'use strict'; 5692 5693 var txt = node.nodeValue; 5694 5695 // multiple spaces are collapsed 5696 txt = txt.replace(/ +/g, ' '); 5697 5698 // replace the custom ¨NBSP; with a space 5699 txt = txt.replace(/¨NBSP;/g, ' '); 5700 5701 // ", <, > and & should replace escaped html entities 5702 txt = showdown.helper.unescapeHTMLEntities(txt); 5703 5704 // escape markdown magic characters 5705 // emphasis, strong and strikethrough - can appear everywhere 5706 // we also escape pipe (|) because of tables 5707 // and escape ` because of code blocks and spans 5708 txt = txt.replace(/([*_~|`])/g, '\\$1'); 5709 5710 // escape > because of blockquotes 5711 txt = txt.replace(/^(\s*)>/g, '\\$1>'); 5712 5713 // hash character, only troublesome at the beginning of a line because of headers 5714 txt = txt.replace(/^#/gm, '\\#'); 5715 5716 // horizontal rules 5717 txt = txt.replace(/^(\s*)([-=]{3,})(\s*)$/, '$1\\$2$3'); 5718 5719 // dot, because of ordered lists, only troublesome at the beginning of a line when preceded by an integer 5720 txt = txt.replace(/^( {0,3}\d+)\./gm, '$1\\.'); 5721 5722 // +, * and -, at the beginning of a line becomes a list, so we need to escape them also (asterisk was already escaped) 5723 txt = txt.replace(/^( {0,3})([+-])/gm, '$1\\$2'); 5724 5725 // images and links, ] followed by ( is problematic, so we escape it 5726 txt = txt.replace(/]([\s]*)\(/g, '\\]$1\\('); 5727 5728 // reference URIs must also be escaped 5729 txt = txt.replace(/^ {0,3}\[([\S \t]*?)]:/gm, '\\[$1]:'); 5730 5731 return txt; 5732 }); 5733 5734 var root = this; 5735 5736 // AMD Loader 5737 if (true) { 5738 !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () { 5739 'use strict'; 5740 return showdown; 5741 }).call(exports, __webpack_require__, exports, module), 5742 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 5743 5744 // CommonJS/nodeJS Loader 5745 } else {} 5746 }).call(this); 5747 5748 5749 5750 5751 /***/ }) 5752 5753 /******/ }); 5754 /************************************************************************/ 5755 /******/ // The module cache 5756 /******/ var __webpack_module_cache__ = {}; 5757 /******/ 5758 /******/ // The require function 5759 /******/ function __webpack_require__(moduleId) { 5760 /******/ // Check if module is in cache 5761 /******/ var cachedModule = __webpack_module_cache__[moduleId]; 5762 /******/ if (cachedModule !== undefined) { 5763 /******/ return cachedModule.exports; 5764 /******/ } 5765 /******/ // Create a new module (and put it into the cache) 5766 /******/ var module = __webpack_module_cache__[moduleId] = { 5767 /******/ // no module.id needed 5768 /******/ // no module.loaded needed 5769 /******/ exports: {} 5770 /******/ }; 5771 /******/ 5772 /******/ // Execute the module function 5773 /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); 5774 /******/ 5775 /******/ // Return the exports of the module 5776 /******/ return module.exports; 5777 /******/ } 5778 /******/ 5779 /************************************************************************/ 5780 /******/ /* webpack/runtime/compat get default export */ 5781 /******/ (() => { 5782 /******/ // getDefaultExport function for compatibility with non-harmony modules 5783 /******/ __webpack_require__.n = (module) => { 5784 /******/ var getter = module && module.__esModule ? 5785 /******/ () => (module['default']) : 5786 /******/ () => (module); 5787 /******/ __webpack_require__.d(getter, { a: getter }); 5788 /******/ return getter; 5789 /******/ }; 5790 /******/ })(); 5791 /******/ 5792 /******/ /* webpack/runtime/define property getters */ 5793 /******/ (() => { 5794 /******/ // define getter functions for harmony exports 5795 /******/ __webpack_require__.d = (exports, definition) => { 5796 /******/ for(var key in definition) { 5797 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 5798 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 5799 /******/ } 5800 /******/ } 5801 /******/ }; 5802 /******/ })(); 5803 /******/ 5804 /******/ /* webpack/runtime/hasOwnProperty shorthand */ 5805 /******/ (() => { 5806 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) 5807 /******/ })(); 5808 /******/ 5809 /******/ /* webpack/runtime/make namespace object */ 5810 /******/ (() => { 5811 /******/ // define __esModule on exports 5812 /******/ __webpack_require__.r = (exports) => { 5813 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 5814 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 5815 /******/ } 5816 /******/ Object.defineProperty(exports, '__esModule', { value: true }); 5817 /******/ }; 5818 /******/ })(); 5819 /******/ 5820 /************************************************************************/ 5821 var __webpack_exports__ = {}; 5822 // This entry need to be wrapped in an IIFE because it need to be in strict mode. 5823 (() => { 5824 "use strict"; 5825 // ESM COMPAT FLAG 5826 __webpack_require__.r(__webpack_exports__); 5827 5828 // EXPORTS 5829 __webpack_require__.d(__webpack_exports__, { 5830 __EXPERIMENTAL_ELEMENTS: () => (/* reexport */ __EXPERIMENTAL_ELEMENTS), 5831 __EXPERIMENTAL_PATHS_WITH_OVERRIDE: () => (/* reexport */ __EXPERIMENTAL_PATHS_WITH_OVERRIDE), 5832 __EXPERIMENTAL_STYLE_PROPERTY: () => (/* reexport */ __EXPERIMENTAL_STYLE_PROPERTY), 5833 __experimentalCloneSanitizedBlock: () => (/* reexport */ __experimentalCloneSanitizedBlock), 5834 __experimentalGetAccessibleBlockLabel: () => (/* reexport */ getAccessibleBlockLabel), 5835 __experimentalGetBlockAttributesNamesByRole: () => (/* reexport */ __experimentalGetBlockAttributesNamesByRole), 5836 __experimentalGetBlockLabel: () => (/* reexport */ getBlockLabel), 5837 __experimentalSanitizeBlockAttributes: () => (/* reexport */ __experimentalSanitizeBlockAttributes), 5838 __unstableGetBlockProps: () => (/* reexport */ getBlockProps), 5839 __unstableGetInnerBlocksProps: () => (/* reexport */ getInnerBlocksProps), 5840 __unstableSerializeAndClean: () => (/* reexport */ __unstableSerializeAndClean), 5841 children: () => (/* reexport */ children), 5842 cloneBlock: () => (/* reexport */ cloneBlock), 5843 createBlock: () => (/* reexport */ createBlock), 5844 createBlocksFromInnerBlocksTemplate: () => (/* reexport */ createBlocksFromInnerBlocksTemplate), 5845 doBlocksMatchTemplate: () => (/* reexport */ doBlocksMatchTemplate), 5846 findTransform: () => (/* reexport */ findTransform), 5847 getBlockAttributes: () => (/* reexport */ getBlockAttributes), 5848 getBlockContent: () => (/* reexport */ getBlockInnerHTML), 5849 getBlockDefaultClassName: () => (/* reexport */ getBlockDefaultClassName), 5850 getBlockFromExample: () => (/* reexport */ getBlockFromExample), 5851 getBlockMenuDefaultClassName: () => (/* reexport */ getBlockMenuDefaultClassName), 5852 getBlockSupport: () => (/* reexport */ getBlockSupport), 5853 getBlockTransforms: () => (/* reexport */ getBlockTransforms), 5854 getBlockType: () => (/* reexport */ getBlockType), 5855 getBlockTypes: () => (/* reexport */ getBlockTypes), 5856 getBlockVariations: () => (/* reexport */ getBlockVariations), 5857 getCategories: () => (/* reexport */ categories_getCategories), 5858 getChildBlockNames: () => (/* reexport */ getChildBlockNames), 5859 getDefaultBlockName: () => (/* reexport */ getDefaultBlockName), 5860 getFreeformContentHandlerName: () => (/* reexport */ getFreeformContentHandlerName), 5861 getGroupingBlockName: () => (/* reexport */ getGroupingBlockName), 5862 getPhrasingContentSchema: () => (/* reexport */ deprecatedGetPhrasingContentSchema), 5863 getPossibleBlockTransformations: () => (/* reexport */ getPossibleBlockTransformations), 5864 getSaveContent: () => (/* reexport */ getSaveContent), 5865 getSaveElement: () => (/* reexport */ getSaveElement), 5866 getUnregisteredTypeHandlerName: () => (/* reexport */ getUnregisteredTypeHandlerName), 5867 hasBlockSupport: () => (/* reexport */ hasBlockSupport), 5868 hasChildBlocks: () => (/* reexport */ hasChildBlocks), 5869 hasChildBlocksWithInserterSupport: () => (/* reexport */ hasChildBlocksWithInserterSupport), 5870 isReusableBlock: () => (/* reexport */ isReusableBlock), 5871 isTemplatePart: () => (/* reexport */ isTemplatePart), 5872 isUnmodifiedBlock: () => (/* reexport */ isUnmodifiedBlock), 5873 isUnmodifiedDefaultBlock: () => (/* reexport */ isUnmodifiedDefaultBlock), 5874 isValidBlockContent: () => (/* reexport */ isValidBlockContent), 5875 isValidIcon: () => (/* reexport */ isValidIcon), 5876 node: () => (/* reexport */ node), 5877 normalizeIconObject: () => (/* reexport */ normalizeIconObject), 5878 parse: () => (/* reexport */ parser_parse), 5879 parseWithAttributeSchema: () => (/* reexport */ parseWithAttributeSchema), 5880 pasteHandler: () => (/* reexport */ pasteHandler), 5881 rawHandler: () => (/* reexport */ rawHandler), 5882 registerBlockCollection: () => (/* reexport */ registerBlockCollection), 5883 registerBlockStyle: () => (/* reexport */ registerBlockStyle), 5884 registerBlockType: () => (/* reexport */ registerBlockType), 5885 registerBlockVariation: () => (/* reexport */ registerBlockVariation), 5886 serialize: () => (/* reexport */ serialize), 5887 serializeRawBlock: () => (/* reexport */ serializeRawBlock), 5888 setCategories: () => (/* reexport */ categories_setCategories), 5889 setDefaultBlockName: () => (/* reexport */ setDefaultBlockName), 5890 setFreeformContentHandlerName: () => (/* reexport */ setFreeformContentHandlerName), 5891 setGroupingBlockName: () => (/* reexport */ setGroupingBlockName), 5892 setUnregisteredTypeHandlerName: () => (/* reexport */ setUnregisteredTypeHandlerName), 5893 store: () => (/* reexport */ store), 5894 switchToBlockType: () => (/* reexport */ switchToBlockType), 5895 synchronizeBlocksWithTemplate: () => (/* reexport */ synchronizeBlocksWithTemplate), 5896 unregisterBlockStyle: () => (/* reexport */ unregisterBlockStyle), 5897 unregisterBlockType: () => (/* reexport */ unregisterBlockType), 5898 unregisterBlockVariation: () => (/* reexport */ unregisterBlockVariation), 5899 unstable__bootstrapServerSideBlockDefinitions: () => (/* reexport */ unstable__bootstrapServerSideBlockDefinitions), 5900 updateCategory: () => (/* reexport */ categories_updateCategory), 5901 validateBlock: () => (/* reexport */ validateBlock), 5902 withBlockContentContext: () => (/* reexport */ withBlockContentContext) 5903 }); 5904 5905 // NAMESPACE OBJECT: ./node_modules/@wordpress/blocks/build-module/store/selectors.js 5906 var selectors_namespaceObject = {}; 5907 __webpack_require__.r(selectors_namespaceObject); 5908 __webpack_require__.d(selectors_namespaceObject, { 5909 __experimentalHasContentRoleAttribute: () => (__experimentalHasContentRoleAttribute), 5910 getActiveBlockVariation: () => (getActiveBlockVariation), 5911 getBlockStyles: () => (getBlockStyles), 5912 getBlockSupport: () => (selectors_getBlockSupport), 5913 getBlockType: () => (selectors_getBlockType), 5914 getBlockTypes: () => (selectors_getBlockTypes), 5915 getBlockVariations: () => (selectors_getBlockVariations), 5916 getCategories: () => (getCategories), 5917 getChildBlockNames: () => (selectors_getChildBlockNames), 5918 getCollections: () => (getCollections), 5919 getDefaultBlockName: () => (selectors_getDefaultBlockName), 5920 getDefaultBlockVariation: () => (getDefaultBlockVariation), 5921 getFreeformFallbackBlockName: () => (getFreeformFallbackBlockName), 5922 getGroupingBlockName: () => (selectors_getGroupingBlockName), 5923 getUnregisteredFallbackBlockName: () => (getUnregisteredFallbackBlockName), 5924 hasBlockSupport: () => (selectors_hasBlockSupport), 5925 hasChildBlocks: () => (selectors_hasChildBlocks), 5926 hasChildBlocksWithInserterSupport: () => (selectors_hasChildBlocksWithInserterSupport), 5927 isMatchingSearchTerm: () => (isMatchingSearchTerm) 5928 }); 5929 5930 // NAMESPACE OBJECT: ./node_modules/@wordpress/blocks/build-module/store/private-selectors.js 5931 var private_selectors_namespaceObject = {}; 5932 __webpack_require__.r(private_selectors_namespaceObject); 5933 __webpack_require__.d(private_selectors_namespaceObject, { 5934 getAllBlockBindingsSources: () => (getAllBlockBindingsSources), 5935 getBlockBindingsSource: () => (getBlockBindingsSource), 5936 getBootstrappedBlockType: () => (getBootstrappedBlockType), 5937 getSupportedStyles: () => (getSupportedStyles), 5938 getUnprocessedBlockTypes: () => (getUnprocessedBlockTypes) 5939 }); 5940 5941 // NAMESPACE OBJECT: ./node_modules/@wordpress/blocks/build-module/store/actions.js 5942 var actions_namespaceObject = {}; 5943 __webpack_require__.r(actions_namespaceObject); 5944 __webpack_require__.d(actions_namespaceObject, { 5945 __experimentalReapplyBlockFilters: () => (__experimentalReapplyBlockFilters), 5946 addBlockCollection: () => (addBlockCollection), 5947 addBlockStyles: () => (addBlockStyles), 5948 addBlockTypes: () => (addBlockTypes), 5949 addBlockVariations: () => (addBlockVariations), 5950 reapplyBlockTypeFilters: () => (reapplyBlockTypeFilters), 5951 removeBlockCollection: () => (removeBlockCollection), 5952 removeBlockStyles: () => (removeBlockStyles), 5953 removeBlockTypes: () => (removeBlockTypes), 5954 removeBlockVariations: () => (removeBlockVariations), 5955 setCategories: () => (setCategories), 5956 setDefaultBlockName: () => (actions_setDefaultBlockName), 5957 setFreeformFallbackBlockName: () => (setFreeformFallbackBlockName), 5958 setGroupingBlockName: () => (actions_setGroupingBlockName), 5959 setUnregisteredFallbackBlockName: () => (setUnregisteredFallbackBlockName), 5960 updateCategory: () => (updateCategory) 5961 }); 5962 5963 // NAMESPACE OBJECT: ./node_modules/@wordpress/blocks/build-module/store/private-actions.js 5964 var private_actions_namespaceObject = {}; 5965 __webpack_require__.r(private_actions_namespaceObject); 5966 __webpack_require__.d(private_actions_namespaceObject, { 5967 addBootstrappedBlockType: () => (addBootstrappedBlockType), 5968 addUnprocessedBlockType: () => (addUnprocessedBlockType), 5969 registerBlockBindingsSource: () => (registerBlockBindingsSource) 5970 }); 5971 5972 ;// CONCATENATED MODULE: external ["wp","data"] 5973 const external_wp_data_namespaceObject = window["wp"]["data"]; 5974 ;// CONCATENATED MODULE: ./node_modules/tslib/tslib.es6.mjs 5975 /****************************************************************************** 5976 Copyright (c) Microsoft Corporation. 5977 5978 Permission to use, copy, modify, and/or distribute this software for any 5979 purpose with or without fee is hereby granted. 5980 5981 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 5982 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 5983 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 5984 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 5985 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 5986 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 5987 PERFORMANCE OF THIS SOFTWARE. 5988 ***************************************************************************** */ 5989 /* global Reflect, Promise, SuppressedError, Symbol */ 5990 5991 var extendStatics = function(d, b) { 5992 extendStatics = Object.setPrototypeOf || 5993 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 5994 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; 5995 return extendStatics(d, b); 5996 }; 5997 5998 function __extends(d, b) { 5999 if (typeof b !== "function" && b !== null) 6000 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); 6001 extendStatics(d, b); 6002 function __() { this.constructor = d; } 6003 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 6004 } 6005 6006 var __assign = function() { 6007 __assign = Object.assign || function __assign(t) { 6008 for (var s, i = 1, n = arguments.length; i < n; i++) { 6009 s = arguments[i]; 6010 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; 6011 } 6012 return t; 6013 } 6014 return __assign.apply(this, arguments); 6015 } 6016 6017 function __rest(s, e) { 6018 var t = {}; 6019 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) 6020 t[p] = s[p]; 6021 if (s != null && typeof Object.getOwnPropertySymbols === "function") 6022 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { 6023 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) 6024 t[p[i]] = s[p[i]]; 6025 } 6026 return t; 6027 } 6028 6029 function __decorate(decorators, target, key, desc) { 6030 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 6031 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 6032 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6033 return c > 3 && r && Object.defineProperty(target, key, r), r; 6034 } 6035 6036 function __param(paramIndex, decorator) { 6037 return function (target, key) { decorator(target, key, paramIndex); } 6038 } 6039 6040 function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { 6041 function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } 6042 var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; 6043 var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; 6044 var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); 6045 var _, done = false; 6046 for (var i = decorators.length - 1; i >= 0; i--) { 6047 var context = {}; 6048 for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p]; 6049 for (var p in contextIn.access) context.access[p] = contextIn.access[p]; 6050 context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); }; 6051 var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); 6052 if (kind === "accessor") { 6053 if (result === void 0) continue; 6054 if (result === null || typeof result !== "object") throw new TypeError("Object expected"); 6055 if (_ = accept(result.get)) descriptor.get = _; 6056 if (_ = accept(result.set)) descriptor.set = _; 6057 if (_ = accept(result.init)) initializers.unshift(_); 6058 } 6059 else if (_ = accept(result)) { 6060 if (kind === "field") initializers.unshift(_); 6061 else descriptor[key] = _; 6062 } 6063 } 6064 if (target) Object.defineProperty(target, contextIn.name, descriptor); 6065 done = true; 6066 }; 6067 6068 function __runInitializers(thisArg, initializers, value) { 6069 var useValue = arguments.length > 2; 6070 for (var i = 0; i < initializers.length; i++) { 6071 value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); 6072 } 6073 return useValue ? value : void 0; 6074 }; 6075 6076 function __propKey(x) { 6077 return typeof x === "symbol" ? x : "".concat(x); 6078 }; 6079 6080 function __setFunctionName(f, name, prefix) { 6081 if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; 6082 return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); 6083 }; 6084 6085 function __metadata(metadataKey, metadataValue) { 6086 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); 6087 } 6088 6089 function __awaiter(thisArg, _arguments, P, generator) { 6090 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 6091 return new (P || (P = Promise))(function (resolve, reject) { 6092 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6093 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 6094 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 6095 step((generator = generator.apply(thisArg, _arguments || [])).next()); 6096 }); 6097 } 6098 6099 function __generator(thisArg, body) { 6100 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; 6101 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; 6102 function verb(n) { return function (v) { return step([n, v]); }; } 6103 function step(op) { 6104 if (f) throw new TypeError("Generator is already executing."); 6105 while (g && (g = 0, op[0] && (_ = 0)), _) try { 6106 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; 6107 if (y = 0, t) op = [op[0] & 2, t.value]; 6108 switch (op[0]) { 6109 case 0: case 1: t = op; break; 6110 case 4: _.label++; return { value: op[1], done: false }; 6111 case 5: _.label++; y = op[1]; op = [0]; continue; 6112 case 7: op = _.ops.pop(); _.trys.pop(); continue; 6113 default: 6114 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } 6115 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } 6116 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } 6117 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } 6118 if (t[2]) _.ops.pop(); 6119 _.trys.pop(); continue; 6120 } 6121 op = body.call(thisArg, _); 6122 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } 6123 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; 6124 } 6125 } 6126 6127 var __createBinding = Object.create ? (function(o, m, k, k2) { 6128 if (k2 === undefined) k2 = k; 6129 var desc = Object.getOwnPropertyDescriptor(m, k); 6130 if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6131 desc = { enumerable: true, get: function() { return m[k]; } }; 6132 } 6133 Object.defineProperty(o, k2, desc); 6134 }) : (function(o, m, k, k2) { 6135 if (k2 === undefined) k2 = k; 6136 o[k2] = m[k]; 6137 }); 6138 6139 function __exportStar(m, o) { 6140 for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); 6141 } 6142 6143 function __values(o) { 6144 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; 6145 if (m) return m.call(o); 6146 if (o && typeof o.length === "number") return { 6147 next: function () { 6148 if (o && i >= o.length) o = void 0; 6149 return { value: o && o[i++], done: !o }; 6150 } 6151 }; 6152 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); 6153 } 6154 6155 function __read(o, n) { 6156 var m = typeof Symbol === "function" && o[Symbol.iterator]; 6157 if (!m) return o; 6158 var i = m.call(o), r, ar = [], e; 6159 try { 6160 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); 6161 } 6162 catch (error) { e = { error: error }; } 6163 finally { 6164 try { 6165 if (r && !r.done && (m = i["return"])) m.call(i); 6166 } 6167 finally { if (e) throw e.error; } 6168 } 6169 return ar; 6170 } 6171 6172 /** @deprecated */ 6173 function __spread() { 6174 for (var ar = [], i = 0; i < arguments.length; i++) 6175 ar = ar.concat(__read(arguments[i])); 6176 return ar; 6177 } 6178 6179 /** @deprecated */ 6180 function __spreadArrays() { 6181 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; 6182 for (var r = Array(s), k = 0, i = 0; i < il; i++) 6183 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) 6184 r[k] = a[j]; 6185 return r; 6186 } 6187 6188 function __spreadArray(to, from, pack) { 6189 if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { 6190 if (ar || !(i in from)) { 6191 if (!ar) ar = Array.prototype.slice.call(from, 0, i); 6192 ar[i] = from[i]; 6193 } 6194 } 6195 return to.concat(ar || Array.prototype.slice.call(from)); 6196 } 6197 6198 function __await(v) { 6199 return this instanceof __await ? (this.v = v, this) : new __await(v); 6200 } 6201 6202 function __asyncGenerator(thisArg, _arguments, generator) { 6203 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); 6204 var g = generator.apply(thisArg, _arguments || []), i, q = []; 6205 return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; 6206 function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } 6207 function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } 6208 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } 6209 function fulfill(value) { resume("next", value); } 6210 function reject(value) { resume("throw", value); } 6211 function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } 6212 } 6213 6214 function __asyncDelegator(o) { 6215 var i, p; 6216 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; 6217 function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; } 6218 } 6219 6220 function __asyncValues(o) { 6221 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); 6222 var m = o[Symbol.asyncIterator], i; 6223 return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); 6224 function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } 6225 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } 6226 } 6227 6228 function __makeTemplateObject(cooked, raw) { 6229 if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } 6230 return cooked; 6231 }; 6232 6233 var __setModuleDefault = Object.create ? (function(o, v) { 6234 Object.defineProperty(o, "default", { enumerable: true, value: v }); 6235 }) : function(o, v) { 6236 o["default"] = v; 6237 }; 6238 6239 function __importStar(mod) { 6240 if (mod && mod.__esModule) return mod; 6241 var result = {}; 6242 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); 6243 __setModuleDefault(result, mod); 6244 return result; 6245 } 6246 6247 function __importDefault(mod) { 6248 return (mod && mod.__esModule) ? mod : { default: mod }; 6249 } 6250 6251 function __classPrivateFieldGet(receiver, state, kind, f) { 6252 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); 6253 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); 6254 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); 6255 } 6256 6257 function __classPrivateFieldSet(receiver, state, value, kind, f) { 6258 if (kind === "m") throw new TypeError("Private method is not writable"); 6259 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); 6260 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); 6261 return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; 6262 } 6263 6264 function __classPrivateFieldIn(state, receiver) { 6265 if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object"); 6266 return typeof state === "function" ? receiver === state : state.has(receiver); 6267 } 6268 6269 function __addDisposableResource(env, value, async) { 6270 if (value !== null && value !== void 0) { 6271 if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected."); 6272 var dispose; 6273 if (async) { 6274 if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); 6275 dispose = value[Symbol.asyncDispose]; 6276 } 6277 if (dispose === void 0) { 6278 if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); 6279 dispose = value[Symbol.dispose]; 6280 } 6281 if (typeof dispose !== "function") throw new TypeError("Object not disposable."); 6282 env.stack.push({ value: value, dispose: dispose, async: async }); 6283 } 6284 else if (async) { 6285 env.stack.push({ async: true }); 6286 } 6287 return value; 6288 } 6289 6290 var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { 6291 var e = new Error(message); 6292 return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; 6293 }; 6294 6295 function __disposeResources(env) { 6296 function fail(e) { 6297 env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; 6298 env.hasError = true; 6299 } 6300 function next() { 6301 while (env.stack.length) { 6302 var rec = env.stack.pop(); 6303 try { 6304 var result = rec.dispose && rec.dispose.call(rec.value); 6305 if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); 6306 } 6307 catch (e) { 6308 fail(e); 6309 } 6310 } 6311 if (env.hasError) throw env.error; 6312 } 6313 return next(); 6314 } 6315 6316 /* harmony default export */ const tslib_es6 = ({ 6317 __extends, 6318 __assign, 6319 __rest, 6320 __decorate, 6321 __param, 6322 __metadata, 6323 __awaiter, 6324 __generator, 6325 __createBinding, 6326 __exportStar, 6327 __values, 6328 __read, 6329 __spread, 6330 __spreadArrays, 6331 __spreadArray, 6332 __await, 6333 __asyncGenerator, 6334 __asyncDelegator, 6335 __asyncValues, 6336 __makeTemplateObject, 6337 __importStar, 6338 __importDefault, 6339 __classPrivateFieldGet, 6340 __classPrivateFieldSet, 6341 __classPrivateFieldIn, 6342 __addDisposableResource, 6343 __disposeResources, 6344 }); 6345 6346 ;// CONCATENATED MODULE: ./node_modules/lower-case/dist.es2015/index.js 6347 /** 6348 * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt 6349 */ 6350 var SUPPORTED_LOCALE = { 6351 tr: { 6352 regexp: /\u0130|\u0049|\u0049\u0307/g, 6353 map: { 6354 İ: "\u0069", 6355 I: "\u0131", 6356 İ: "\u0069", 6357 }, 6358 }, 6359 az: { 6360 regexp: /\u0130/g, 6361 map: { 6362 İ: "\u0069", 6363 I: "\u0131", 6364 İ: "\u0069", 6365 }, 6366 }, 6367 lt: { 6368 regexp: /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g, 6369 map: { 6370 I: "\u0069\u0307", 6371 J: "\u006A\u0307", 6372 Į: "\u012F\u0307", 6373 Ì: "\u0069\u0307\u0300", 6374 Í: "\u0069\u0307\u0301", 6375 Ĩ: "\u0069\u0307\u0303", 6376 }, 6377 }, 6378 }; 6379 /** 6380 * Localized lower case. 6381 */ 6382 function localeLowerCase(str, locale) { 6383 var lang = SUPPORTED_LOCALE[locale.toLowerCase()]; 6384 if (lang) 6385 return lowerCase(str.replace(lang.regexp, function (m) { return lang.map[m]; })); 6386 return lowerCase(str); 6387 } 6388 /** 6389 * Lower case as a function. 6390 */ 6391 function lowerCase(str) { 6392 return str.toLowerCase(); 6393 } 6394 6395 ;// CONCATENATED MODULE: ./node_modules/no-case/dist.es2015/index.js 6396 6397 // Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case"). 6398 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g]; 6399 // Remove all non-word characters. 6400 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi; 6401 /** 6402 * Normalize the string into something other libraries can manipulate easier. 6403 */ 6404 function noCase(input, options) { 6405 if (options === void 0) { options = {}; } 6406 var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d; 6407 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0"); 6408 var start = 0; 6409 var end = result.length; 6410 // Trim the delimiter from around the output string. 6411 while (result.charAt(start) === "\0") 6412 start++; 6413 while (result.charAt(end - 1) === "\0") 6414 end--; 6415 // Transform each token independently. 6416 return result.slice(start, end).split("\0").map(transform).join(delimiter); 6417 } 6418 /** 6419 * Replace `re` in the input string with the replacement value. 6420 */ 6421 function replace(input, re, value) { 6422 if (re instanceof RegExp) 6423 return input.replace(re, value); 6424 return re.reduce(function (input, re) { return input.replace(re, value); }, input); 6425 } 6426 6427 ;// CONCATENATED MODULE: ./node_modules/pascal-case/dist.es2015/index.js 6428 6429 6430 function pascalCaseTransform(input, index) { 6431 var firstChar = input.charAt(0); 6432 var lowerChars = input.substr(1).toLowerCase(); 6433 if (index > 0 && firstChar >= "0" && firstChar <= "9") { 6434 return "_" + firstChar + lowerChars; 6435 } 6436 return "" + firstChar.toUpperCase() + lowerChars; 6437 } 6438 function dist_es2015_pascalCaseTransformMerge(input) { 6439 return input.charAt(0).toUpperCase() + input.slice(1).toLowerCase(); 6440 } 6441 function pascalCase(input, options) { 6442 if (options === void 0) { options = {}; } 6443 return noCase(input, __assign({ delimiter: "", transform: pascalCaseTransform }, options)); 6444 } 6445 6446 ;// CONCATENATED MODULE: ./node_modules/camel-case/dist.es2015/index.js 6447 6448 6449 function camelCaseTransform(input, index) { 6450 if (index === 0) 6451 return input.toLowerCase(); 6452 return pascalCaseTransform(input, index); 6453 } 6454 function camelCaseTransformMerge(input, index) { 6455 if (index === 0) 6456 return input.toLowerCase(); 6457 return pascalCaseTransformMerge(input); 6458 } 6459 function camelCase(input, options) { 6460 if (options === void 0) { options = {}; } 6461 return pascalCase(input, __assign({ transform: camelCaseTransform }, options)); 6462 } 6463 6464 ;// CONCATENATED MODULE: external ["wp","i18n"] 6465 const external_wp_i18n_namespaceObject = window["wp"]["i18n"]; 6466 ;// CONCATENATED MODULE: ./node_modules/colord/index.mjs 6467 var r={grad:.9,turn:360,rad:360/(2*Math.PI)},t=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},n=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=Math.pow(10,t)),Math.round(n*r)/n+0},e=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),r>n?n:r>t?r:t},u=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},a=function(r){return{r:e(r.r,0,255),g:e(r.g,0,255),b:e(r.b,0,255),a:e(r.a)}},o=function(r){return{r:n(r.r),g:n(r.g),b:n(r.b),a:n(r.a,3)}},i=/^#([0-9a-f]{3,8})$/i,s=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},h=function(r){var t=r.r,n=r.g,e=r.b,u=r.a,a=Math.max(t,n,e),o=a-Math.min(t,n,e),i=o?a===t?(n-e)/o:a===n?2+(e-t)/o:4+(t-n)/o:0;return{h:60*(i<0?i+6:i),s:a?o/a*100:0,v:a/255*100,a:u}},b=function(r){var t=r.h,n=r.s,e=r.v,u=r.a;t=t/360*6,n/=100,e/=100;var a=Math.floor(t),o=e*(1-n),i=e*(1-(t-a)*n),s=e*(1-(1-t+a)*n),h=a%6;return{r:255*[e,i,o,o,s,e][h],g:255*[s,e,e,i,o,o][h],b:255*[o,o,s,e,e,i][h],a:u}},g=function(r){return{h:u(r.h),s:e(r.s,0,100),l:e(r.l,0,100),a:e(r.a)}},d=function(r){return{h:n(r.h),s:n(r.s),l:n(r.l),a:n(r.a,3)}},f=function(r){return b((n=(t=r).s,{h:t.h,s:(n*=((e=t.l)<50?e:100-e)/100)>0?2*n/(e+n)*100:0,v:e+n,a:t.a}));var t,n,e},c=function(r){return{h:(t=h(r)).h,s:(u=(200-(n=t.s))*(e=t.v)/100)>0&&u<200?n*e/100/(u<=100?u:200-u)*100:0,l:u/2,a:t.a};var t,n,e,u},l=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,p=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,v=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,m=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,y={string:[[function(r){var t=i.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:4===r.length?n(parseInt(r[3]+r[3],16)/255,2):1}:6===r.length||8===r.length?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:8===r.length?n(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=v.exec(r)||m.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:a({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:void 0===t[7]?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(t){var n=l.exec(t)||p.exec(t);if(!n)return null;var e,u,a=g({h:(e=n[1],u=n[2],void 0===u&&(u="deg"),Number(e)*(r[u]||1)),s:Number(n[3]),l:Number(n[4]),a:void 0===n[5]?1:Number(n[5])/(n[6]?100:1)});return f(a)},"hsl"]],object:[[function(r){var n=r.r,e=r.g,u=r.b,o=r.a,i=void 0===o?1:o;return t(n)&&t(e)&&t(u)?a({r:Number(n),g:Number(e),b:Number(u),a:Number(i)}):null},"rgb"],[function(r){var n=r.h,e=r.s,u=r.l,a=r.a,o=void 0===a?1:a;if(!t(n)||!t(e)||!t(u))return null;var i=g({h:Number(n),s:Number(e),l:Number(u),a:Number(o)});return f(i)},"hsl"],[function(r){var n=r.h,a=r.s,o=r.v,i=r.a,s=void 0===i?1:i;if(!t(n)||!t(a)||!t(o))return null;var h=function(r){return{h:u(r.h),s:e(r.s,0,100),v:e(r.v,0,100),a:e(r.a)}}({h:Number(n),s:Number(a),v:Number(o),a:Number(s)});return b(h)},"hsv"]]},N=function(r,t){for(var n=0;n<t.length;n++){var e=t[n][0](r);if(e)return[e,t[n][1]]}return[null,void 0]},x=function(r){return"string"==typeof r?N(r.trim(),y.string):"object"==typeof r&&null!==r?N(r,y.object):[null,void 0]},I=function(r){return x(r)[1]},M=function(r,t){var n=c(r);return{h:n.h,s:e(n.s+100*t,0,100),l:n.l,a:n.a}},H=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},$=function(r,t){var n=c(r);return{h:n.h,s:n.s,l:e(n.l+100*t,0,100),a:n.a}},j=function(){function r(r){this.parsed=x(r)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return null!==this.parsed},r.prototype.brightness=function(){return n(H(this.rgba),2)},r.prototype.isDark=function(){return H(this.rgba)<.5},r.prototype.isLight=function(){return H(this.rgba)>=.5},r.prototype.toHex=function(){return r=o(this.rgba),t=r.r,e=r.g,u=r.b,i=(a=r.a)<1?s(n(255*a)):"","#"+s(t)+s(e)+s(u)+i;var r,t,e,u,a,i},r.prototype.toRgb=function(){return o(this.rgba)},r.prototype.toRgbString=function(){return r=o(this.rgba),t=r.r,n=r.g,e=r.b,(u=r.a)<1?"rgba("+t+", "+n+", "+e+", "+u+")":"rgb("+t+", "+n+", "+e+")";var r,t,n,e,u},r.prototype.toHsl=function(){return d(c(this.rgba))},r.prototype.toHslString=function(){return r=d(c(this.rgba)),t=r.h,n=r.s,e=r.l,(u=r.a)<1?"hsla("+t+", "+n+"%, "+e+"%, "+u+")":"hsl("+t+", "+n+"%, "+e+"%)";var r,t,n,e,u},r.prototype.toHsv=function(){return r=h(this.rgba),{h:n(r.h),s:n(r.s),v:n(r.v),a:n(r.a,3)};var r},r.prototype.invert=function(){return w({r:255-(r=this.rgba).r,g:255-r.g,b:255-r.b,a:r.a});var r},r.prototype.saturate=function(r){return void 0===r&&(r=.1),w(M(this.rgba,r))},r.prototype.desaturate=function(r){return void 0===r&&(r=.1),w(M(this.rgba,-r))},r.prototype.grayscale=function(){return w(M(this.rgba,-1))},r.prototype.lighten=function(r){return void 0===r&&(r=.1),w($(this.rgba,r))},r.prototype.darken=function(r){return void 0===r&&(r=.1),w($(this.rgba,-r))},r.prototype.rotate=function(r){return void 0===r&&(r=15),this.hue(this.hue()+r)},r.prototype.alpha=function(r){return"number"==typeof r?w({r:(t=this.rgba).r,g:t.g,b:t.b,a:r}):n(this.rgba.a,3);var t},r.prototype.hue=function(r){var t=c(this.rgba);return"number"==typeof r?w({h:r,s:t.s,l:t.l,a:t.a}):n(t.h)},r.prototype.isEqual=function(r){return this.toHex()===w(r).toHex()},r}(),w=function(r){return r instanceof j?r:new j(r)},S=[],k=function(r){r.forEach(function(r){S.indexOf(r)<0&&(r(j,y),S.push(r))})},E=function(){return new j({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})}; 6468 6469 ;// CONCATENATED MODULE: ./node_modules/colord/plugins/names.mjs 6470 /* harmony default export */ function names(e,f){var a={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},r={};for(var d in a)r[a[d]]=d;var l={};e.prototype.toName=function(f){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var d,i,n=r[this.toHex()];if(n)return n;if(null==f?void 0:f.closest){var o=this.toRgb(),t=1/0,b="black";if(!l.length)for(var c in a)l[c]=new e(a[c]).toRgb();for(var g in a){var u=(d=o,i=l[g],Math.pow(d.r-i.r,2)+Math.pow(d.g-i.g,2)+Math.pow(d.b-i.b,2));u<t&&(t=u,b=g)}return b}};f.string.push([function(f){var r=f.toLowerCase(),d="transparent"===r?"#0000":a[r];return d?new e(d).toRgb():null},"name"])} 6471 6472 ;// CONCATENATED MODULE: ./node_modules/colord/plugins/a11y.mjs 6473 var a11y_o=function(o){var t=o/255;return t<.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)},a11y_t=function(t){return.2126*a11y_o(t.r)+.7152*a11y_o(t.g)+.0722*a11y_o(t.b)};/* harmony default export */ function a11y(o){o.prototype.luminance=function(){return o=a11y_t(this.rgba),void 0===(r=2)&&(r=0),void 0===n&&(n=Math.pow(10,r)),Math.round(n*o)/n+0;var o,r,n},o.prototype.contrast=function(r){void 0===r&&(r="#FFF");var n,a,i,e,v,u,d,c=r instanceof o?r:new o(r);return e=this.rgba,v=c.toRgb(),u=a11y_t(e),d=a11y_t(v),n=u>d?(u+.05)/(d+.05):(d+.05)/(u+.05),void 0===(a=2)&&(a=0),void 0===i&&(i=Math.pow(10,a)),Math.floor(i*n)/i+0},o.prototype.isReadable=function(o,t){return void 0===o&&(o="#FFF"),void 0===t&&(t={}),this.contrast(o)>=(e=void 0===(i=(r=t).size)?"normal":i,"AAA"===(a=void 0===(n=r.level)?"AA":n)&&"normal"===e?7:"AA"===a&&"large"===e?3:4.5);var r,n,a,i,e}} 6474 6475 ;// CONCATENATED MODULE: external ["wp","element"] 6476 const external_wp_element_namespaceObject = window["wp"]["element"]; 6477 ;// CONCATENATED MODULE: external ["wp","dom"] 6478 const external_wp_dom_namespaceObject = window["wp"]["dom"]; 6479 ;// CONCATENATED MODULE: external ["wp","richText"] 6480 const external_wp_richText_namespaceObject = window["wp"]["richText"]; 6481 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/constants.js 6482 const BLOCK_ICON_DEFAULT = 'block-default'; 6483 6484 /** 6485 * Array of valid keys in a block type settings deprecation object. 6486 * 6487 * @type {string[]} 6488 */ 6489 const DEPRECATED_ENTRY_KEYS = ['attributes', 'supports', 'save', 'migrate', 'isEligible', 'apiVersion']; 6490 const __EXPERIMENTAL_STYLE_PROPERTY = { 6491 // Kept for back-compatibility purposes. 6492 '--wp--style--color--link': { 6493 value: ['color', 'link'], 6494 support: ['color', 'link'] 6495 }, 6496 aspectRatio: { 6497 value: ['dimensions', 'aspectRatio'], 6498 support: ['dimensions', 'aspectRatio'], 6499 useEngine: true 6500 }, 6501 background: { 6502 value: ['color', 'gradient'], 6503 support: ['color', 'gradients'], 6504 useEngine: true 6505 }, 6506 backgroundColor: { 6507 value: ['color', 'background'], 6508 support: ['color', 'background'], 6509 requiresOptOut: true, 6510 useEngine: true 6511 }, 6512 backgroundImage: { 6513 value: ['background', 'backgroundImage'], 6514 support: ['background', 'backgroundImage'], 6515 useEngine: true 6516 }, 6517 backgroundRepeat: { 6518 value: ['background', 'backgroundRepeat'], 6519 support: ['background', 'backgroundRepeat'], 6520 useEngine: true 6521 }, 6522 backgroundSize: { 6523 value: ['background', 'backgroundSize'], 6524 support: ['background', 'backgroundSize'], 6525 useEngine: true 6526 }, 6527 backgroundPosition: { 6528 value: ['background', 'backgroundPosition'], 6529 support: ['background', 'backgroundPosition'], 6530 useEngine: true 6531 }, 6532 borderColor: { 6533 value: ['border', 'color'], 6534 support: ['__experimentalBorder', 'color'], 6535 useEngine: true 6536 }, 6537 borderRadius: { 6538 value: ['border', 'radius'], 6539 support: ['__experimentalBorder', 'radius'], 6540 properties: { 6541 borderTopLeftRadius: 'topLeft', 6542 borderTopRightRadius: 'topRight', 6543 borderBottomLeftRadius: 'bottomLeft', 6544 borderBottomRightRadius: 'bottomRight' 6545 }, 6546 useEngine: true 6547 }, 6548 borderStyle: { 6549 value: ['border', 'style'], 6550 support: ['__experimentalBorder', 'style'], 6551 useEngine: true 6552 }, 6553 borderWidth: { 6554 value: ['border', 'width'], 6555 support: ['__experimentalBorder', 'width'], 6556 useEngine: true 6557 }, 6558 borderTopColor: { 6559 value: ['border', 'top', 'color'], 6560 support: ['__experimentalBorder', 'color'], 6561 useEngine: true 6562 }, 6563 borderTopStyle: { 6564 value: ['border', 'top', 'style'], 6565 support: ['__experimentalBorder', 'style'], 6566 useEngine: true 6567 }, 6568 borderTopWidth: { 6569 value: ['border', 'top', 'width'], 6570 support: ['__experimentalBorder', 'width'], 6571 useEngine: true 6572 }, 6573 borderRightColor: { 6574 value: ['border', 'right', 'color'], 6575 support: ['__experimentalBorder', 'color'], 6576 useEngine: true 6577 }, 6578 borderRightStyle: { 6579 value: ['border', 'right', 'style'], 6580 support: ['__experimentalBorder', 'style'], 6581 useEngine: true 6582 }, 6583 borderRightWidth: { 6584 value: ['border', 'right', 'width'], 6585 support: ['__experimentalBorder', 'width'], 6586 useEngine: true 6587 }, 6588 borderBottomColor: { 6589 value: ['border', 'bottom', 'color'], 6590 support: ['__experimentalBorder', 'color'], 6591 useEngine: true 6592 }, 6593 borderBottomStyle: { 6594 value: ['border', 'bottom', 'style'], 6595 support: ['__experimentalBorder', 'style'], 6596 useEngine: true 6597 }, 6598 borderBottomWidth: { 6599 value: ['border', 'bottom', 'width'], 6600 support: ['__experimentalBorder', 'width'], 6601 useEngine: true 6602 }, 6603 borderLeftColor: { 6604 value: ['border', 'left', 'color'], 6605 support: ['__experimentalBorder', 'color'], 6606 useEngine: true 6607 }, 6608 borderLeftStyle: { 6609 value: ['border', 'left', 'style'], 6610 support: ['__experimentalBorder', 'style'], 6611 useEngine: true 6612 }, 6613 borderLeftWidth: { 6614 value: ['border', 'left', 'width'], 6615 support: ['__experimentalBorder', 'width'], 6616 useEngine: true 6617 }, 6618 color: { 6619 value: ['color', 'text'], 6620 support: ['color', 'text'], 6621 requiresOptOut: true, 6622 useEngine: true 6623 }, 6624 columnCount: { 6625 value: ['typography', 'textColumns'], 6626 support: ['typography', 'textColumns'], 6627 useEngine: true 6628 }, 6629 filter: { 6630 value: ['filter', 'duotone'], 6631 support: ['filter', 'duotone'] 6632 }, 6633 linkColor: { 6634 value: ['elements', 'link', 'color', 'text'], 6635 support: ['color', 'link'] 6636 }, 6637 captionColor: { 6638 value: ['elements', 'caption', 'color', 'text'], 6639 support: ['color', 'caption'] 6640 }, 6641 buttonColor: { 6642 value: ['elements', 'button', 'color', 'text'], 6643 support: ['color', 'button'] 6644 }, 6645 buttonBackgroundColor: { 6646 value: ['elements', 'button', 'color', 'background'], 6647 support: ['color', 'button'] 6648 }, 6649 headingColor: { 6650 value: ['elements', 'heading', 'color', 'text'], 6651 support: ['color', 'heading'] 6652 }, 6653 headingBackgroundColor: { 6654 value: ['elements', 'heading', 'color', 'background'], 6655 support: ['color', 'heading'] 6656 }, 6657 fontFamily: { 6658 value: ['typography', 'fontFamily'], 6659 support: ['typography', '__experimentalFontFamily'], 6660 useEngine: true 6661 }, 6662 fontSize: { 6663 value: ['typography', 'fontSize'], 6664 support: ['typography', 'fontSize'], 6665 useEngine: true 6666 }, 6667 fontStyle: { 6668 value: ['typography', 'fontStyle'], 6669 support: ['typography', '__experimentalFontStyle'], 6670 useEngine: true 6671 }, 6672 fontWeight: { 6673 value: ['typography', 'fontWeight'], 6674 support: ['typography', '__experimentalFontWeight'], 6675 useEngine: true 6676 }, 6677 lineHeight: { 6678 value: ['typography', 'lineHeight'], 6679 support: ['typography', 'lineHeight'], 6680 useEngine: true 6681 }, 6682 margin: { 6683 value: ['spacing', 'margin'], 6684 support: ['spacing', 'margin'], 6685 properties: { 6686 marginTop: 'top', 6687 marginRight: 'right', 6688 marginBottom: 'bottom', 6689 marginLeft: 'left' 6690 }, 6691 useEngine: true 6692 }, 6693 minHeight: { 6694 value: ['dimensions', 'minHeight'], 6695 support: ['dimensions', 'minHeight'], 6696 useEngine: true 6697 }, 6698 padding: { 6699 value: ['spacing', 'padding'], 6700 support: ['spacing', 'padding'], 6701 properties: { 6702 paddingTop: 'top', 6703 paddingRight: 'right', 6704 paddingBottom: 'bottom', 6705 paddingLeft: 'left' 6706 }, 6707 useEngine: true 6708 }, 6709 textAlign: { 6710 value: ['typography', 'textAlign'], 6711 support: ['typography', 'textAlign'], 6712 useEngine: false 6713 }, 6714 textDecoration: { 6715 value: ['typography', 'textDecoration'], 6716 support: ['typography', '__experimentalTextDecoration'], 6717 useEngine: true 6718 }, 6719 textTransform: { 6720 value: ['typography', 'textTransform'], 6721 support: ['typography', '__experimentalTextTransform'], 6722 useEngine: true 6723 }, 6724 letterSpacing: { 6725 value: ['typography', 'letterSpacing'], 6726 support: ['typography', '__experimentalLetterSpacing'], 6727 useEngine: true 6728 }, 6729 writingMode: { 6730 value: ['typography', 'writingMode'], 6731 support: ['typography', '__experimentalWritingMode'], 6732 useEngine: true 6733 }, 6734 '--wp--style--root--padding': { 6735 value: ['spacing', 'padding'], 6736 support: ['spacing', 'padding'], 6737 properties: { 6738 '--wp--style--root--padding-top': 'top', 6739 '--wp--style--root--padding-right': 'right', 6740 '--wp--style--root--padding-bottom': 'bottom', 6741 '--wp--style--root--padding-left': 'left' 6742 }, 6743 rootOnly: true 6744 } 6745 }; 6746 const __EXPERIMENTAL_ELEMENTS = { 6747 link: 'a:where(:not(.wp-element-button))', 6748 heading: 'h1, h2, h3, h4, h5, h6', 6749 h1: 'h1', 6750 h2: 'h2', 6751 h3: 'h3', 6752 h4: 'h4', 6753 h5: 'h5', 6754 h6: 'h6', 6755 button: '.wp-element-button, .wp-block-button__link', 6756 caption: '.wp-element-caption, .wp-block-audio figcaption, .wp-block-embed figcaption, .wp-block-gallery figcaption, .wp-block-image figcaption, .wp-block-table figcaption, .wp-block-video figcaption', 6757 cite: 'cite' 6758 }; 6759 6760 // These paths may have three origins, custom, theme, and default, 6761 // and are expected to override other origins with custom, theme, 6762 // and default priority. 6763 const __EXPERIMENTAL_PATHS_WITH_OVERRIDE = { 6764 'color.duotone': true, 6765 'color.gradients': true, 6766 'color.palette': true, 6767 'dimensions.aspectRatios': true, 6768 'typography.fontSizes': true, 6769 'spacing.spacingSizes': true 6770 }; 6771 6772 ;// CONCATENATED MODULE: external ["wp","privateApis"] 6773 const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"]; 6774 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/lock-unlock.js 6775 /** 6776 * WordPress dependencies 6777 */ 6778 6779 const { 6780 lock, 6781 unlock 6782 } = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', '@wordpress/blocks'); 6783 6784 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/registration.js 6785 /* eslint no-console: [ 'error', { allow: [ 'error', 'warn' ] } ] */ 6786 6787 /** 6788 * WordPress dependencies 6789 */ 6790 6791 6792 6793 /** 6794 * Internal dependencies 6795 */ 6796 const i18nBlockSchema = { 6797 title: "block title", 6798 description: "block description", 6799 keywords: ["block keyword"], 6800 styles: [{ 6801 label: "block style label" 6802 }], 6803 variations: [{ 6804 title: "block variation title", 6805 description: "block variation description", 6806 keywords: ["block variation keyword"] 6807 }] 6808 }; 6809 6810 6811 6812 /** 6813 * An icon type definition. One of a Dashicon slug, an element, 6814 * or a component. 6815 * 6816 * @typedef {(string|Element|Component)} WPIcon 6817 * 6818 * @see https://developer.wordpress.org/resource/dashicons/ 6819 */ 6820 6821 /** 6822 * Render behavior of a block type icon; one of a Dashicon slug, an element, 6823 * or a component. 6824 * 6825 * @typedef {WPIcon} WPBlockTypeIconRender 6826 */ 6827 6828 /** 6829 * An object describing a normalized block type icon. 6830 * 6831 * @typedef {Object} WPBlockTypeIconDescriptor 6832 * 6833 * @property {WPBlockTypeIconRender} src Render behavior of the icon, 6834 * one of a Dashicon slug, an 6835 * element, or a component. 6836 * @property {string} background Optimal background hex string 6837 * color when displaying icon. 6838 * @property {string} foreground Optimal foreground hex string 6839 * color when displaying icon. 6840 * @property {string} shadowColor Optimal shadow hex string 6841 * color when displaying icon. 6842 */ 6843 6844 /** 6845 * Value to use to render the icon for a block type in an editor interface, 6846 * either a Dashicon slug, an element, a component, or an object describing 6847 * the icon. 6848 * 6849 * @typedef {(WPBlockTypeIconDescriptor|WPBlockTypeIconRender)} WPBlockTypeIcon 6850 */ 6851 6852 /** 6853 * Named block variation scopes. 6854 * 6855 * @typedef {'block'|'inserter'|'transform'} WPBlockVariationScope 6856 */ 6857 6858 /** 6859 * An object describing a variation defined for the block type. 6860 * 6861 * @typedef {Object} WPBlockVariation 6862 * 6863 * @property {string} name The unique and machine-readable name. 6864 * @property {string} title A human-readable variation title. 6865 * @property {string} [description] A detailed variation description. 6866 * @property {string} [category] Block type category classification, 6867 * used in search interfaces to arrange 6868 * block types by category. 6869 * @property {WPIcon} [icon] An icon helping to visualize the variation. 6870 * @property {boolean} [isDefault] Indicates whether the current variation is 6871 * the default one. Defaults to `false`. 6872 * @property {Object} [attributes] Values which override block attributes. 6873 * @property {Array[]} [innerBlocks] Initial configuration of nested blocks. 6874 * @property {Object} [example] Example provides structured data for 6875 * the block preview. You can set to 6876 * `undefined` to disable the preview shown 6877 * for the block type. 6878 * @property {WPBlockVariationScope[]} [scope] The list of scopes where the variation 6879 * is applicable. When not provided, it 6880 * assumes all available scopes. 6881 * @property {string[]} [keywords] An array of terms (which can be translated) 6882 * that help users discover the variation 6883 * while searching. 6884 * @property {Function|string[]} [isActive] This can be a function or an array of block attributes. 6885 * Function that accepts a block's attributes and the 6886 * variation's attributes and determines if a variation is active. 6887 * This function doesn't try to find a match dynamically based 6888 * on all block's attributes, as in many cases some attributes are irrelevant. 6889 * An example would be for `embed` block where we only care 6890 * about `providerNameSlug` attribute's value. 6891 * We can also use a `string[]` to tell which attributes 6892 * should be compared as a shorthand. Each attributes will 6893 * be matched and the variation will be active if all of them are matching. 6894 */ 6895 6896 /** 6897 * Defined behavior of a block type. 6898 * 6899 * @typedef {Object} WPBlockType 6900 * 6901 * @property {string} name Block type's namespaced name. 6902 * @property {string} title Human-readable block type label. 6903 * @property {string} [description] A detailed block type description. 6904 * @property {string} [category] Block type category classification, 6905 * used in search interfaces to arrange 6906 * block types by category. 6907 * @property {WPBlockTypeIcon} [icon] Block type icon. 6908 * @property {string[]} [keywords] Additional keywords to produce block 6909 * type as result in search interfaces. 6910 * @property {Object} [attributes] Block type attributes. 6911 * @property {Component} [save] Optional component describing 6912 * serialized markup structure of a 6913 * block type. 6914 * @property {Component} edit Component rendering an element to 6915 * manipulate the attributes of a block 6916 * in the context of an editor. 6917 * @property {WPBlockVariation[]} [variations] The list of block variations. 6918 * @property {Object} [example] Example provides structured data for 6919 * the block preview. When not defined 6920 * then no preview is shown. 6921 */ 6922 6923 function isObject(object) { 6924 return object !== null && typeof object === 'object'; 6925 } 6926 6927 /** 6928 * Sets the server side block definition of blocks. 6929 * 6930 * @param {Object} definitions Server-side block definitions 6931 */ 6932 // eslint-disable-next-line camelcase 6933 function unstable__bootstrapServerSideBlockDefinitions(definitions) { 6934 const { 6935 addBootstrappedBlockType 6936 } = unlock((0,external_wp_data_namespaceObject.dispatch)(store)); 6937 for (const [name, blockType] of Object.entries(definitions)) { 6938 addBootstrappedBlockType(name, blockType); 6939 } 6940 } 6941 6942 /** 6943 * Gets block settings from metadata loaded from `block.json` file. 6944 * 6945 * @param {Object} metadata Block metadata loaded from `block.json`. 6946 * @param {string} metadata.textdomain Textdomain to use with translations. 6947 * 6948 * @return {Object} Block settings. 6949 */ 6950 function getBlockSettingsFromMetadata({ 6951 textdomain, 6952 ...metadata 6953 }) { 6954 const allowedFields = ['apiVersion', 'title', 'category', 'parent', 'ancestor', 'icon', 'description', 'keywords', 'attributes', 'providesContext', 'usesContext', 'selectors', 'supports', 'styles', 'example', 'variations', 'blockHooks', 'allowedBlocks']; 6955 const settings = Object.fromEntries(Object.entries(metadata).filter(([key]) => allowedFields.includes(key))); 6956 if (textdomain) { 6957 Object.keys(i18nBlockSchema).forEach(key => { 6958 if (!settings[key]) { 6959 return; 6960 } 6961 settings[key] = translateBlockSettingUsingI18nSchema(i18nBlockSchema[key], settings[key], textdomain); 6962 }); 6963 } 6964 return settings; 6965 } 6966 6967 /** 6968 * Registers a new block provided a unique name and an object defining its 6969 * behavior. Once registered, the block is made available as an option to any 6970 * editor interface where blocks are implemented. 6971 * 6972 * For more in-depth information on registering a custom block see the 6973 * [Create a block tutorial](https://developer.wordpress.org/block-editor/getting-started/create-block/). 6974 * 6975 * @param {string|Object} blockNameOrMetadata Block type name or its metadata. 6976 * @param {Object} settings Block settings. 6977 * 6978 * @example 6979 * ```js 6980 * import { __ } from '@wordpress/i18n'; 6981 * import { registerBlockType } from '@wordpress/blocks' 6982 * 6983 * registerBlockType( 'namespace/block-name', { 6984 * title: __( 'My First Block' ), 6985 * edit: () => <div>{ __( 'Hello from the editor!' ) }</div>, 6986 * save: () => <div>Hello from the saved content!</div>, 6987 * } ); 6988 * ``` 6989 * 6990 * @return {WPBlockType | undefined} The block, if it has been successfully registered; 6991 * otherwise `undefined`. 6992 */ 6993 function registerBlockType(blockNameOrMetadata, settings) { 6994 const name = isObject(blockNameOrMetadata) ? blockNameOrMetadata.name : blockNameOrMetadata; 6995 if (typeof name !== 'string') { 6996 console.error('Block names must be strings.'); 6997 return; 6998 } 6999 if (!/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/.test(name)) { 7000 console.error('Block names must contain a namespace prefix, include only lowercase alphanumeric characters or dashes, and start with a letter. Example: my-plugin/my-custom-block'); 7001 return; 7002 } 7003 if ((0,external_wp_data_namespaceObject.select)(store).getBlockType(name)) { 7004 console.error('Block "' + name + '" is already registered.'); 7005 return; 7006 } 7007 const { 7008 addBootstrappedBlockType, 7009 addUnprocessedBlockType 7010 } = unlock((0,external_wp_data_namespaceObject.dispatch)(store)); 7011 if (isObject(blockNameOrMetadata)) { 7012 const metadata = getBlockSettingsFromMetadata(blockNameOrMetadata); 7013 addBootstrappedBlockType(name, metadata); 7014 } 7015 addUnprocessedBlockType(name, settings); 7016 return (0,external_wp_data_namespaceObject.select)(store).getBlockType(name); 7017 } 7018 7019 /** 7020 * Translates block settings provided with metadata using the i18n schema. 7021 * 7022 * @param {string|string[]|Object[]} i18nSchema I18n schema for the block setting. 7023 * @param {string|string[]|Object[]} settingValue Value for the block setting. 7024 * @param {string} textdomain Textdomain to use with translations. 7025 * 7026 * @return {string|string[]|Object[]} Translated setting. 7027 */ 7028 function translateBlockSettingUsingI18nSchema(i18nSchema, settingValue, textdomain) { 7029 if (typeof i18nSchema === 'string' && typeof settingValue === 'string') { 7030 // eslint-disable-next-line @wordpress/i18n-no-variables, @wordpress/i18n-text-domain 7031 return (0,external_wp_i18n_namespaceObject._x)(settingValue, i18nSchema, textdomain); 7032 } 7033 if (Array.isArray(i18nSchema) && i18nSchema.length && Array.isArray(settingValue)) { 7034 return settingValue.map(value => translateBlockSettingUsingI18nSchema(i18nSchema[0], value, textdomain)); 7035 } 7036 if (isObject(i18nSchema) && Object.entries(i18nSchema).length && isObject(settingValue)) { 7037 return Object.keys(settingValue).reduce((accumulator, key) => { 7038 if (!i18nSchema[key]) { 7039 accumulator[key] = settingValue[key]; 7040 return accumulator; 7041 } 7042 accumulator[key] = translateBlockSettingUsingI18nSchema(i18nSchema[key], settingValue[key], textdomain); 7043 return accumulator; 7044 }, {}); 7045 } 7046 return settingValue; 7047 } 7048 7049 /** 7050 * Registers a new block collection to group blocks in the same namespace in the inserter. 7051 * 7052 * @param {string} namespace The namespace to group blocks by in the inserter; corresponds to the block namespace. 7053 * @param {Object} settings The block collection settings. 7054 * @param {string} settings.title The title to display in the block inserter. 7055 * @param {Object} [settings.icon] The icon to display in the block inserter. 7056 * 7057 * @example 7058 * ```js 7059 * import { __ } from '@wordpress/i18n'; 7060 * import { registerBlockCollection, registerBlockType } from '@wordpress/blocks'; 7061 * 7062 * // Register the collection. 7063 * registerBlockCollection( 'my-collection', { 7064 * title: __( 'Custom Collection' ), 7065 * } ); 7066 * 7067 * // Register a block in the same namespace to add it to the collection. 7068 * registerBlockType( 'my-collection/block-name', { 7069 * title: __( 'My First Block' ), 7070 * edit: () => <div>{ __( 'Hello from the editor!' ) }</div>, 7071 * save: () => <div>'Hello from the saved content!</div>, 7072 * } ); 7073 * ``` 7074 */ 7075 function registerBlockCollection(namespace, { 7076 title, 7077 icon 7078 }) { 7079 (0,external_wp_data_namespaceObject.dispatch)(store).addBlockCollection(namespace, title, icon); 7080 } 7081 7082 /** 7083 * Unregisters a block collection 7084 * 7085 * @param {string} namespace The namespace to group blocks by in the inserter; corresponds to the block namespace 7086 * 7087 * @example 7088 * ```js 7089 * import { unregisterBlockCollection } from '@wordpress/blocks'; 7090 * 7091 * unregisterBlockCollection( 'my-collection' ); 7092 * ``` 7093 */ 7094 function unregisterBlockCollection(namespace) { 7095 dispatch(blocksStore).removeBlockCollection(namespace); 7096 } 7097 7098 /** 7099 * Unregisters a block. 7100 * 7101 * @param {string} name Block name. 7102 * 7103 * @example 7104 * ```js 7105 * import { __ } from '@wordpress/i18n'; 7106 * import { unregisterBlockType } from '@wordpress/blocks'; 7107 * 7108 * const ExampleComponent = () => { 7109 * return ( 7110 * <Button 7111 * onClick={ () => 7112 * unregisterBlockType( 'my-collection/block-name' ) 7113 * } 7114 * > 7115 * { __( 'Unregister my custom block.' ) } 7116 * </Button> 7117 * ); 7118 * }; 7119 * ``` 7120 * 7121 * @return {WPBlockType | undefined} The previous block value, if it has been successfully 7122 * unregistered; otherwise `undefined`. 7123 */ 7124 function unregisterBlockType(name) { 7125 const oldBlock = (0,external_wp_data_namespaceObject.select)(store).getBlockType(name); 7126 if (!oldBlock) { 7127 console.error('Block "' + name + '" is not registered.'); 7128 return; 7129 } 7130 (0,external_wp_data_namespaceObject.dispatch)(store).removeBlockTypes(name); 7131 return oldBlock; 7132 } 7133 7134 /** 7135 * Assigns name of block for handling non-block content. 7136 * 7137 * @param {string} blockName Block name. 7138 */ 7139 function setFreeformContentHandlerName(blockName) { 7140 (0,external_wp_data_namespaceObject.dispatch)(store).setFreeformFallbackBlockName(blockName); 7141 } 7142 7143 /** 7144 * Retrieves name of block handling non-block content, or undefined if no 7145 * handler has been defined. 7146 * 7147 * @return {?string} Block name. 7148 */ 7149 function getFreeformContentHandlerName() { 7150 return (0,external_wp_data_namespaceObject.select)(store).getFreeformFallbackBlockName(); 7151 } 7152 7153 /** 7154 * Retrieves name of block used for handling grouping interactions. 7155 * 7156 * @return {?string} Block name. 7157 */ 7158 function getGroupingBlockName() { 7159 return (0,external_wp_data_namespaceObject.select)(store).getGroupingBlockName(); 7160 } 7161 7162 /** 7163 * Assigns name of block handling unregistered block types. 7164 * 7165 * @param {string} blockName Block name. 7166 */ 7167 function setUnregisteredTypeHandlerName(blockName) { 7168 (0,external_wp_data_namespaceObject.dispatch)(store).setUnregisteredFallbackBlockName(blockName); 7169 } 7170 7171 /** 7172 * Retrieves name of block handling unregistered block types, or undefined if no 7173 * handler has been defined. 7174 * 7175 * @return {?string} Block name. 7176 */ 7177 function getUnregisteredTypeHandlerName() { 7178 return (0,external_wp_data_namespaceObject.select)(store).getUnregisteredFallbackBlockName(); 7179 } 7180 7181 /** 7182 * Assigns the default block name. 7183 * 7184 * @param {string} name Block name. 7185 * 7186 * @example 7187 * ```js 7188 * import { setDefaultBlockName } from '@wordpress/blocks'; 7189 * 7190 * const ExampleComponent = () => { 7191 * 7192 * return ( 7193 * <Button onClick={ () => setDefaultBlockName( 'core/heading' ) }> 7194 * { __( 'Set the default block to Heading' ) } 7195 * </Button> 7196 * ); 7197 * }; 7198 * ``` 7199 */ 7200 function setDefaultBlockName(name) { 7201 (0,external_wp_data_namespaceObject.dispatch)(store).setDefaultBlockName(name); 7202 } 7203 7204 /** 7205 * Assigns name of block for handling block grouping interactions. 7206 * 7207 * This function lets you select a different block to group other blocks in instead of the 7208 * default `core/group` block. This function must be used in a component or when the DOM is fully 7209 * loaded. See https://developer.wordpress.org/block-editor/reference-guides/packages/packages-dom-ready/ 7210 * 7211 * @param {string} name Block name. 7212 * 7213 * @example 7214 * ```js 7215 * import { setGroupingBlockName } from '@wordpress/blocks'; 7216 * 7217 * const ExampleComponent = () => { 7218 * 7219 * return ( 7220 * <Button onClick={ () => setGroupingBlockName( 'core/columns' ) }> 7221 * { __( 'Wrap in columns' ) } 7222 * </Button> 7223 * ); 7224 * }; 7225 * ``` 7226 */ 7227 function setGroupingBlockName(name) { 7228 (0,external_wp_data_namespaceObject.dispatch)(store).setGroupingBlockName(name); 7229 } 7230 7231 /** 7232 * Retrieves the default block name. 7233 * 7234 * @return {?string} Block name. 7235 */ 7236 function getDefaultBlockName() { 7237 return (0,external_wp_data_namespaceObject.select)(store).getDefaultBlockName(); 7238 } 7239 7240 /** 7241 * Returns a registered block type. 7242 * 7243 * @param {string} name Block name. 7244 * 7245 * @return {?Object} Block type. 7246 */ 7247 function getBlockType(name) { 7248 return (0,external_wp_data_namespaceObject.select)(store)?.getBlockType(name); 7249 } 7250 7251 /** 7252 * Returns all registered blocks. 7253 * 7254 * @return {Array} Block settings. 7255 */ 7256 function getBlockTypes() { 7257 return (0,external_wp_data_namespaceObject.select)(store).getBlockTypes(); 7258 } 7259 7260 /** 7261 * Returns the block support value for a feature, if defined. 7262 * 7263 * @param {(string|Object)} nameOrType Block name or type object 7264 * @param {string} feature Feature to retrieve 7265 * @param {*} defaultSupports Default value to return if not 7266 * explicitly defined 7267 * 7268 * @return {?*} Block support value 7269 */ 7270 function getBlockSupport(nameOrType, feature, defaultSupports) { 7271 return (0,external_wp_data_namespaceObject.select)(store).getBlockSupport(nameOrType, feature, defaultSupports); 7272 } 7273 7274 /** 7275 * Returns true if the block defines support for a feature, or false otherwise. 7276 * 7277 * @param {(string|Object)} nameOrType Block name or type object. 7278 * @param {string} feature Feature to test. 7279 * @param {boolean} defaultSupports Whether feature is supported by 7280 * default if not explicitly defined. 7281 * 7282 * @return {boolean} Whether block supports feature. 7283 */ 7284 function hasBlockSupport(nameOrType, feature, defaultSupports) { 7285 return (0,external_wp_data_namespaceObject.select)(store).hasBlockSupport(nameOrType, feature, defaultSupports); 7286 } 7287 7288 /** 7289 * Determines whether or not the given block is a reusable block. This is a 7290 * special block type that is used to point to a global block stored via the 7291 * API. 7292 * 7293 * @param {Object} blockOrType Block or Block Type to test. 7294 * 7295 * @return {boolean} Whether the given block is a reusable block. 7296 */ 7297 function isReusableBlock(blockOrType) { 7298 return blockOrType?.name === 'core/block'; 7299 } 7300 7301 /** 7302 * Determines whether or not the given block is a template part. This is a 7303 * special block type that allows composing a page template out of reusable 7304 * design elements. 7305 * 7306 * @param {Object} blockOrType Block or Block Type to test. 7307 * 7308 * @return {boolean} Whether the given block is a template part. 7309 */ 7310 function isTemplatePart(blockOrType) { 7311 return blockOrType?.name === 'core/template-part'; 7312 } 7313 7314 /** 7315 * Returns an array with the child blocks of a given block. 7316 * 7317 * @param {string} blockName Name of block (example: “latest-posts”). 7318 * 7319 * @return {Array} Array of child block names. 7320 */ 7321 const getChildBlockNames = blockName => { 7322 return (0,external_wp_data_namespaceObject.select)(store).getChildBlockNames(blockName); 7323 }; 7324 7325 /** 7326 * Returns a boolean indicating if a block has child blocks or not. 7327 * 7328 * @param {string} blockName Name of block (example: “latest-posts”). 7329 * 7330 * @return {boolean} True if a block contains child blocks and false otherwise. 7331 */ 7332 const hasChildBlocks = blockName => { 7333 return (0,external_wp_data_namespaceObject.select)(store).hasChildBlocks(blockName); 7334 }; 7335 7336 /** 7337 * Returns a boolean indicating if a block has at least one child block with inserter support. 7338 * 7339 * @param {string} blockName Block type name. 7340 * 7341 * @return {boolean} True if a block contains at least one child blocks with inserter support 7342 * and false otherwise. 7343 */ 7344 const hasChildBlocksWithInserterSupport = blockName => { 7345 return (0,external_wp_data_namespaceObject.select)(store).hasChildBlocksWithInserterSupport(blockName); 7346 }; 7347 7348 /** 7349 * Registers a new block style for the given block types. 7350 * 7351 * For more information on connecting the styles with CSS 7352 * [the official documentation](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-styles/#styles). 7353 * 7354 * @param {string|Array} blockNames Name of blocks e.g. “core/latest-posts” or `["core/group", "core/columns"]`. 7355 * @param {Object} styleVariation Object containing `name` which is the class name applied to the block and `label` which identifies the variation to the user. 7356 * 7357 * @example 7358 * ```js 7359 * import { __ } from '@wordpress/i18n'; 7360 * import { registerBlockStyle } from '@wordpress/blocks'; 7361 * import { Button } from '@wordpress/components'; 7362 * 7363 * 7364 * const ExampleComponent = () => { 7365 * return ( 7366 * <Button 7367 * onClick={ () => { 7368 * registerBlockStyle( 'core/quote', { 7369 * name: 'fancy-quote', 7370 * label: __( 'Fancy Quote' ), 7371 * } ); 7372 * } } 7373 * > 7374 * { __( 'Add a new block style for core/quote' ) } 7375 * </Button> 7376 * ); 7377 * }; 7378 * ``` 7379 */ 7380 const registerBlockStyle = (blockNames, styleVariation) => { 7381 (0,external_wp_data_namespaceObject.dispatch)(store).addBlockStyles(blockNames, styleVariation); 7382 }; 7383 7384 /** 7385 * Unregisters a block style for the given block. 7386 * 7387 * @param {string} blockName Name of block (example: “core/latest-posts”). 7388 * @param {string} styleVariationName Name of class applied to the block. 7389 * 7390 * @example 7391 * ```js 7392 * import { __ } from '@wordpress/i18n'; 7393 * import { unregisterBlockStyle } from '@wordpress/blocks'; 7394 * import { Button } from '@wordpress/components'; 7395 * 7396 * const ExampleComponent = () => { 7397 * return ( 7398 * <Button 7399 * onClick={ () => { 7400 * unregisterBlockStyle( 'core/quote', 'plain' ); 7401 * } } 7402 * > 7403 * { __( 'Remove the "Plain" block style for core/quote' ) } 7404 * </Button> 7405 * ); 7406 * }; 7407 * ``` 7408 */ 7409 const unregisterBlockStyle = (blockName, styleVariationName) => { 7410 (0,external_wp_data_namespaceObject.dispatch)(store).removeBlockStyles(blockName, styleVariationName); 7411 }; 7412 7413 /** 7414 * Returns an array with the variations of a given block type. 7415 * Ignored from documentation as the recommended usage is via useSelect from @wordpress/data. 7416 * 7417 * @ignore 7418 * 7419 * @param {string} blockName Name of block (example: “core/columns”). 7420 * @param {WPBlockVariationScope} [scope] Block variation scope name. 7421 * 7422 * @return {(WPBlockVariation[]|void)} Block variations. 7423 */ 7424 const getBlockVariations = (blockName, scope) => { 7425 return (0,external_wp_data_namespaceObject.select)(store).getBlockVariations(blockName, scope); 7426 }; 7427 7428 /** 7429 * Registers a new block variation for the given block type. 7430 * 7431 * For more information on block variations see 7432 * [the official documentation ](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-variations/). 7433 * 7434 * @param {string} blockName Name of the block (example: “core/columns”). 7435 * @param {WPBlockVariation} variation Object describing a block variation. 7436 * 7437 * @example 7438 * ```js 7439 * import { __ } from '@wordpress/i18n'; 7440 * import { registerBlockVariation } from '@wordpress/blocks'; 7441 * import { Button } from '@wordpress/components'; 7442 * 7443 * const ExampleComponent = () => { 7444 * return ( 7445 * <Button 7446 * onClick={ () => { 7447 * registerBlockVariation( 'core/embed', { 7448 * name: 'custom', 7449 * title: __( 'My Custom Embed' ), 7450 * attributes: { providerNameSlug: 'custom' }, 7451 * } ); 7452 * } } 7453 * > 7454 * __( 'Add a custom variation for core/embed' ) } 7455 * </Button> 7456 * ); 7457 * }; 7458 * ``` 7459 */ 7460 const registerBlockVariation = (blockName, variation) => { 7461 if (typeof variation.name !== 'string') { 7462 console.warn('Variation names must be unique strings.'); 7463 } 7464 (0,external_wp_data_namespaceObject.dispatch)(store).addBlockVariations(blockName, variation); 7465 }; 7466 7467 /** 7468 * Unregisters a block variation defined for the given block type. 7469 * 7470 * @param {string} blockName Name of the block (example: “core/columns”). 7471 * @param {string} variationName Name of the variation defined for the block. 7472 * 7473 * @example 7474 * ```js 7475 * import { __ } from '@wordpress/i18n'; 7476 * import { unregisterBlockVariation } from '@wordpress/blocks'; 7477 * import { Button } from '@wordpress/components'; 7478 * 7479 * const ExampleComponent = () => { 7480 * return ( 7481 * <Button 7482 * onClick={ () => { 7483 * unregisterBlockVariation( 'core/embed', 'youtube' ); 7484 * } } 7485 * > 7486 * { __( 'Remove the YouTube variation from core/embed' ) } 7487 * </Button> 7488 * ); 7489 * }; 7490 * ``` 7491 */ 7492 const unregisterBlockVariation = (blockName, variationName) => { 7493 (0,external_wp_data_namespaceObject.dispatch)(store).removeBlockVariations(blockName, variationName); 7494 }; 7495 7496 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/utils.js 7497 /** 7498 * External dependencies 7499 */ 7500 7501 7502 7503 7504 /** 7505 * WordPress dependencies 7506 */ 7507 7508 7509 7510 7511 7512 /** 7513 * Internal dependencies 7514 */ 7515 7516 7517 k([names, a11y]); 7518 7519 /** 7520 * Array of icon colors containing a color to be used if the icon color 7521 * was not explicitly set but the icon background color was. 7522 * 7523 * @type {Object} 7524 */ 7525 const ICON_COLORS = ['#191e23', '#f8f9f9']; 7526 7527 /** 7528 * Determines whether the block's attributes are equal to the default attributes 7529 * which means the block is unmodified. 7530 * 7531 * @param {WPBlock} block Block Object 7532 * 7533 * @return {boolean} Whether the block is an unmodified block. 7534 */ 7535 function isUnmodifiedBlock(block) { 7536 var _getBlockType$attribu; 7537 return Object.entries((_getBlockType$attribu = getBlockType(block.name)?.attributes) !== null && _getBlockType$attribu !== void 0 ? _getBlockType$attribu : {}).every(([key, definition]) => { 7538 const value = block.attributes[key]; 7539 7540 // Every attribute that has a default must match the default. 7541 if (definition.hasOwnProperty('default')) { 7542 return value === definition.default; 7543 } 7544 7545 // The rich text type is a bit different from the rest because it 7546 // has an implicit default value of an empty RichTextData instance, 7547 // so check the length of the value. 7548 if (definition.type === 'rich-text') { 7549 return !value?.length; 7550 } 7551 7552 // Every attribute that doesn't have a default should be undefined. 7553 return value === undefined; 7554 }); 7555 } 7556 7557 /** 7558 * Determines whether the block is a default block and its attributes are equal 7559 * to the default attributes which means the block is unmodified. 7560 * 7561 * @param {WPBlock} block Block Object 7562 * 7563 * @return {boolean} Whether the block is an unmodified default block. 7564 */ 7565 function isUnmodifiedDefaultBlock(block) { 7566 return block.name === getDefaultBlockName() && isUnmodifiedBlock(block); 7567 } 7568 7569 /** 7570 * Function that checks if the parameter is a valid icon. 7571 * 7572 * @param {*} icon Parameter to be checked. 7573 * 7574 * @return {boolean} True if the parameter is a valid icon and false otherwise. 7575 */ 7576 7577 function isValidIcon(icon) { 7578 return !!icon && (typeof icon === 'string' || (0,external_wp_element_namespaceObject.isValidElement)(icon) || typeof icon === 'function' || icon instanceof external_wp_element_namespaceObject.Component); 7579 } 7580 7581 /** 7582 * Function that receives an icon as set by the blocks during the registration 7583 * and returns a new icon object that is normalized so we can rely on just on possible icon structure 7584 * in the codebase. 7585 * 7586 * @param {WPBlockTypeIconRender} icon Render behavior of a block type icon; 7587 * one of a Dashicon slug, an element, or a 7588 * component. 7589 * 7590 * @return {WPBlockTypeIconDescriptor} Object describing the icon. 7591 */ 7592 function normalizeIconObject(icon) { 7593 icon = icon || BLOCK_ICON_DEFAULT; 7594 if (isValidIcon(icon)) { 7595 return { 7596 src: icon 7597 }; 7598 } 7599 if ('background' in icon) { 7600 const colordBgColor = w(icon.background); 7601 const getColorContrast = iconColor => colordBgColor.contrast(iconColor); 7602 const maxContrast = Math.max(...ICON_COLORS.map(getColorContrast)); 7603 return { 7604 ...icon, 7605 foreground: icon.foreground ? icon.foreground : ICON_COLORS.find(iconColor => getColorContrast(iconColor) === maxContrast), 7606 shadowColor: colordBgColor.alpha(0.3).toRgbString() 7607 }; 7608 } 7609 return icon; 7610 } 7611 7612 /** 7613 * Normalizes block type passed as param. When string is passed then 7614 * it converts it to the matching block type object. 7615 * It passes the original object otherwise. 7616 * 7617 * @param {string|Object} blockTypeOrName Block type or name. 7618 * 7619 * @return {?Object} Block type. 7620 */ 7621 function normalizeBlockType(blockTypeOrName) { 7622 if (typeof blockTypeOrName === 'string') { 7623 return getBlockType(blockTypeOrName); 7624 } 7625 return blockTypeOrName; 7626 } 7627 7628 /** 7629 * Get the label for the block, usually this is either the block title, 7630 * or the value of the block's `label` function when that's specified. 7631 * 7632 * @param {Object} blockType The block type. 7633 * @param {Object} attributes The values of the block's attributes. 7634 * @param {Object} context The intended use for the label. 7635 * 7636 * @return {string} The block label. 7637 */ 7638 function getBlockLabel(blockType, attributes, context = 'visual') { 7639 const { 7640 __experimentalLabel: getLabel, 7641 title 7642 } = blockType; 7643 const label = getLabel && getLabel(attributes, { 7644 context 7645 }); 7646 if (!label) { 7647 return title; 7648 } 7649 if (label.toPlainText) { 7650 return label.toPlainText(); 7651 } 7652 7653 // Strip any HTML (i.e. RichText formatting) before returning. 7654 return (0,external_wp_dom_namespaceObject.__unstableStripHTML)(label); 7655 } 7656 7657 /** 7658 * Get a label for the block for use by screenreaders, this is more descriptive 7659 * than the visual label and includes the block title and the value of the 7660 * `getLabel` function if it's specified. 7661 * 7662 * @param {?Object} blockType The block type. 7663 * @param {Object} attributes The values of the block's attributes. 7664 * @param {?number} position The position of the block in the block list. 7665 * @param {string} [direction='vertical'] The direction of the block layout. 7666 * 7667 * @return {string} The block label. 7668 */ 7669 function getAccessibleBlockLabel(blockType, attributes, position, direction = 'vertical') { 7670 // `title` is already localized, `label` is a user-supplied value. 7671 const title = blockType?.title; 7672 const label = blockType ? getBlockLabel(blockType, attributes, 'accessibility') : ''; 7673 const hasPosition = position !== undefined; 7674 7675 // getBlockLabel returns the block title as a fallback when there's no label, 7676 // if it did return the title, this function needs to avoid adding the 7677 // title twice within the accessible label. Use this `hasLabel` boolean to 7678 // handle that. 7679 const hasLabel = label && label !== title; 7680 if (hasPosition && direction === 'vertical') { 7681 if (hasLabel) { 7682 return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: accessibility text. 1: The block title. 2: The block row number. 3: The block label.. */ 7683 (0,external_wp_i18n_namespaceObject.__)('%1$s Block. Row %2$d. %3$s'), title, position, label); 7684 } 7685 return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: accessibility text. 1: The block title. 2: The block row number. */ 7686 (0,external_wp_i18n_namespaceObject.__)('%1$s Block. Row %2$d'), title, position); 7687 } else if (hasPosition && direction === 'horizontal') { 7688 if (hasLabel) { 7689 return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: accessibility text. 1: The block title. 2: The block column number. 3: The block label.. */ 7690 (0,external_wp_i18n_namespaceObject.__)('%1$s Block. Column %2$d. %3$s'), title, position, label); 7691 } 7692 return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: accessibility text. 1: The block title. 2: The block column number. */ 7693 (0,external_wp_i18n_namespaceObject.__)('%1$s Block. Column %2$d'), title, position); 7694 } 7695 if (hasLabel) { 7696 return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: accessibility text. %1: The block title. %2: The block label. */ 7697 (0,external_wp_i18n_namespaceObject.__)('%1$s Block. %2$s'), title, label); 7698 } 7699 return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: accessibility text. %s: The block title. */ 7700 (0,external_wp_i18n_namespaceObject.__)('%s Block'), title); 7701 } 7702 function getDefault(attributeSchema) { 7703 if (attributeSchema.default !== undefined) { 7704 return attributeSchema.default; 7705 } 7706 if (attributeSchema.type === 'rich-text') { 7707 return new external_wp_richText_namespaceObject.RichTextData(); 7708 } 7709 } 7710 7711 /** 7712 * Ensure attributes contains only values defined by block type, and merge 7713 * default values for missing attributes. 7714 * 7715 * @param {string} name The block's name. 7716 * @param {Object} attributes The block's attributes. 7717 * @return {Object} The sanitized attributes. 7718 */ 7719 function __experimentalSanitizeBlockAttributes(name, attributes) { 7720 // Get the type definition associated with a registered block. 7721 const blockType = getBlockType(name); 7722 if (undefined === blockType) { 7723 throw new Error(`Block type '$name}' is not registered.`); 7724 } 7725 return Object.entries(blockType.attributes).reduce((accumulator, [key, schema]) => { 7726 const value = attributes[key]; 7727 if (undefined !== value) { 7728 if (schema.type === 'rich-text') { 7729 if (value instanceof external_wp_richText_namespaceObject.RichTextData) { 7730 accumulator[key] = value; 7731 } else if (typeof value === 'string') { 7732 accumulator[key] = external_wp_richText_namespaceObject.RichTextData.fromHTMLString(value); 7733 } 7734 } else if (schema.type === 'string' && value instanceof external_wp_richText_namespaceObject.RichTextData) { 7735 accumulator[key] = value.toHTMLString(); 7736 } else { 7737 accumulator[key] = value; 7738 } 7739 } else { 7740 const _default = getDefault(schema); 7741 if (undefined !== _default) { 7742 accumulator[key] = _default; 7743 } 7744 } 7745 if (['node', 'children'].indexOf(schema.source) !== -1) { 7746 // Ensure value passed is always an array, which we're expecting in 7747 // the RichText component to handle the deprecated value. 7748 if (typeof accumulator[key] === 'string') { 7749 accumulator[key] = [accumulator[key]]; 7750 } else if (!Array.isArray(accumulator[key])) { 7751 accumulator[key] = []; 7752 } 7753 } 7754 return accumulator; 7755 }, {}); 7756 } 7757 7758 /** 7759 * Filter block attributes by `role` and return their names. 7760 * 7761 * @param {string} name Block attribute's name. 7762 * @param {string} role The role of a block attribute. 7763 * 7764 * @return {string[]} The attribute names that have the provided role. 7765 */ 7766 function __experimentalGetBlockAttributesNamesByRole(name, role) { 7767 const attributes = getBlockType(name)?.attributes; 7768 if (!attributes) { 7769 return []; 7770 } 7771 const attributesNames = Object.keys(attributes); 7772 if (!role) { 7773 return attributesNames; 7774 } 7775 return attributesNames.filter(attributeName => attributes[attributeName]?.__experimentalRole === role); 7776 } 7777 7778 /** 7779 * Return a new object with the specified keys omitted. 7780 * 7781 * @param {Object} object Original object. 7782 * @param {Array} keys Keys to be omitted. 7783 * 7784 * @return {Object} Object with omitted keys. 7785 */ 7786 function omit(object, keys) { 7787 return Object.fromEntries(Object.entries(object).filter(([key]) => !keys.includes(key))); 7788 } 7789 7790 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/reducer.js 7791 /** 7792 * External dependencies 7793 */ 7794 7795 7796 /** 7797 * WordPress dependencies 7798 */ 7799 7800 7801 7802 /** 7803 * Internal dependencies 7804 */ 7805 7806 7807 /** 7808 * @typedef {Object} WPBlockCategory 7809 * 7810 * @property {string} slug Unique category slug. 7811 * @property {string} title Category label, for display in user interface. 7812 */ 7813 7814 /** 7815 * Default set of categories. 7816 * 7817 * @type {WPBlockCategory[]} 7818 */ 7819 const DEFAULT_CATEGORIES = [{ 7820 slug: 'text', 7821 title: (0,external_wp_i18n_namespaceObject.__)('Text') 7822 }, { 7823 slug: 'media', 7824 title: (0,external_wp_i18n_namespaceObject.__)('Media') 7825 }, { 7826 slug: 'design', 7827 title: (0,external_wp_i18n_namespaceObject.__)('Design') 7828 }, { 7829 slug: 'widgets', 7830 title: (0,external_wp_i18n_namespaceObject.__)('Widgets') 7831 }, { 7832 slug: 'theme', 7833 title: (0,external_wp_i18n_namespaceObject.__)('Theme') 7834 }, { 7835 slug: 'embed', 7836 title: (0,external_wp_i18n_namespaceObject.__)('Embeds') 7837 }, { 7838 slug: 'reusable', 7839 title: (0,external_wp_i18n_namespaceObject.__)('Reusable blocks') 7840 }]; 7841 7842 // Key block types by their name. 7843 function keyBlockTypesByName(types) { 7844 return types.reduce((newBlockTypes, block) => ({ 7845 ...newBlockTypes, 7846 [block.name]: block 7847 }), {}); 7848 } 7849 7850 // Filter items to ensure they're unique by their name. 7851 function getUniqueItemsByName(items) { 7852 return items.reduce((acc, currentItem) => { 7853 if (!acc.some(item => item.name === currentItem.name)) { 7854 acc.push(currentItem); 7855 } 7856 return acc; 7857 }, []); 7858 } 7859 function bootstrappedBlockTypes(state = {}, action) { 7860 switch (action.type) { 7861 case 'ADD_BOOTSTRAPPED_BLOCK_TYPE': 7862 const { 7863 name, 7864 blockType 7865 } = action; 7866 const serverDefinition = state[name]; 7867 let newDefinition; 7868 // Don't overwrite if already set. It covers the case when metadata 7869 // was initialized from the server. 7870 if (serverDefinition) { 7871 // The `blockHooks` prop is not yet included in the server provided 7872 // definitions and needs to be polyfilled. This can be removed when the 7873 // minimum supported WordPress is >= 6.4. 7874 if (serverDefinition.blockHooks === undefined && blockType.blockHooks) { 7875 newDefinition = { 7876 ...serverDefinition, 7877 ...newDefinition, 7878 blockHooks: blockType.blockHooks 7879 }; 7880 } 7881 7882 // The `allowedBlocks` prop is not yet included in the server provided 7883 // definitions and needs to be polyfilled. This can be removed when the 7884 // minimum supported WordPress is >= 6.5. 7885 if (serverDefinition.allowedBlocks === undefined && blockType.allowedBlocks) { 7886 newDefinition = { 7887 ...serverDefinition, 7888 ...newDefinition, 7889 allowedBlocks: blockType.allowedBlocks 7890 }; 7891 } 7892 } else { 7893 newDefinition = Object.fromEntries(Object.entries(blockType).filter(([, value]) => value !== null && value !== undefined).map(([key, value]) => [camelCase(key), value])); 7894 newDefinition.name = name; 7895 } 7896 if (newDefinition) { 7897 return { 7898 ...state, 7899 [name]: newDefinition 7900 }; 7901 } 7902 return state; 7903 case 'REMOVE_BLOCK_TYPES': 7904 return omit(state, action.names); 7905 } 7906 return state; 7907 } 7908 7909 /** 7910 * Reducer managing the unprocessed block types in a form passed when registering the by block. 7911 * It's for internal use only. It allows recomputing the processed block types on-demand after block type filters 7912 * get added or removed. 7913 * 7914 * @param {Object} state Current state. 7915 * @param {Object} action Dispatched action. 7916 * 7917 * @return {Object} Updated state. 7918 */ 7919 function unprocessedBlockTypes(state = {}, action) { 7920 switch (action.type) { 7921 case 'ADD_UNPROCESSED_BLOCK_TYPE': 7922 return { 7923 ...state, 7924 [action.name]: action.blockType 7925 }; 7926 case 'REMOVE_BLOCK_TYPES': 7927 return omit(state, action.names); 7928 } 7929 return state; 7930 } 7931 7932 /** 7933 * Reducer managing the processed block types with all filters applied. 7934 * The state is derived from the `unprocessedBlockTypes` reducer. 7935 * 7936 * @param {Object} state Current state. 7937 * @param {Object} action Dispatched action. 7938 * 7939 * @return {Object} Updated state. 7940 */ 7941 function blockTypes(state = {}, action) { 7942 switch (action.type) { 7943 case 'ADD_BLOCK_TYPES': 7944 return { 7945 ...state, 7946 ...keyBlockTypesByName(action.blockTypes) 7947 }; 7948 case 'REMOVE_BLOCK_TYPES': 7949 return omit(state, action.names); 7950 } 7951 return state; 7952 } 7953 7954 /** 7955 * Reducer managing the block styles. 7956 * 7957 * @param {Object} state Current state. 7958 * @param {Object} action Dispatched action. 7959 * 7960 * @return {Object} Updated state. 7961 */ 7962 function blockStyles(state = {}, action) { 7963 var _state$action$blockNa; 7964 switch (action.type) { 7965 case 'ADD_BLOCK_TYPES': 7966 return { 7967 ...state, 7968 ...Object.fromEntries(Object.entries(keyBlockTypesByName(action.blockTypes)).map(([name, blockType]) => { 7969 var _blockType$styles, _state$blockType$name; 7970 return [name, getUniqueItemsByName([...((_blockType$styles = blockType.styles) !== null && _blockType$styles !== void 0 ? _blockType$styles : []).map(style => ({ 7971 ...style, 7972 source: 'block' 7973 })), ...((_state$blockType$name = state[blockType.name]) !== null && _state$blockType$name !== void 0 ? _state$blockType$name : []).filter(({ 7974 source 7975 }) => 'block' !== source)])]; 7976 })) 7977 }; 7978 case 'ADD_BLOCK_STYLES': 7979 const updatedStyles = {}; 7980 action.blockNames.forEach(blockName => { 7981 var _state$blockName; 7982 updatedStyles[blockName] = getUniqueItemsByName([...((_state$blockName = state[blockName]) !== null && _state$blockName !== void 0 ? _state$blockName : []), ...action.styles]); 7983 }); 7984 return { 7985 ...state, 7986 ...updatedStyles 7987 }; 7988 case 'REMOVE_BLOCK_STYLES': 7989 return { 7990 ...state, 7991 [action.blockName]: ((_state$action$blockNa = state[action.blockName]) !== null && _state$action$blockNa !== void 0 ? _state$action$blockNa : []).filter(style => action.styleNames.indexOf(style.name) === -1) 7992 }; 7993 } 7994 return state; 7995 } 7996 7997 /** 7998 * Reducer managing the block variations. 7999 * 8000 * @param {Object} state Current state. 8001 * @param {Object} action Dispatched action. 8002 * 8003 * @return {Object} Updated state. 8004 */ 8005 function blockVariations(state = {}, action) { 8006 var _state$action$blockNa2, _state$action$blockNa3; 8007 switch (action.type) { 8008 case 'ADD_BLOCK_TYPES': 8009 return { 8010 ...state, 8011 ...Object.fromEntries(Object.entries(keyBlockTypesByName(action.blockTypes)).map(([name, blockType]) => { 8012 var _blockType$variations, _state$blockType$name2; 8013 return [name, getUniqueItemsByName([...((_blockType$variations = blockType.variations) !== null && _blockType$variations !== void 0 ? _blockType$variations : []).map(variation => ({ 8014 ...variation, 8015 source: 'block' 8016 })), ...((_state$blockType$name2 = state[blockType.name]) !== null && _state$blockType$name2 !== void 0 ? _state$blockType$name2 : []).filter(({ 8017 source 8018 }) => 'block' !== source)])]; 8019 })) 8020 }; 8021 case 'ADD_BLOCK_VARIATIONS': 8022 return { 8023 ...state, 8024 [action.blockName]: getUniqueItemsByName([...((_state$action$blockNa2 = state[action.blockName]) !== null && _state$action$blockNa2 !== void 0 ? _state$action$blockNa2 : []), ...action.variations]) 8025 }; 8026 case 'REMOVE_BLOCK_VARIATIONS': 8027 return { 8028 ...state, 8029 [action.blockName]: ((_state$action$blockNa3 = state[action.blockName]) !== null && _state$action$blockNa3 !== void 0 ? _state$action$blockNa3 : []).filter(variation => action.variationNames.indexOf(variation.name) === -1) 8030 }; 8031 } 8032 return state; 8033 } 8034 8035 /** 8036 * Higher-order Reducer creating a reducer keeping track of given block name. 8037 * 8038 * @param {string} setActionType Action type. 8039 * 8040 * @return {Function} Reducer. 8041 */ 8042 function createBlockNameSetterReducer(setActionType) { 8043 return (state = null, action) => { 8044 switch (action.type) { 8045 case 'REMOVE_BLOCK_TYPES': 8046 if (action.names.indexOf(state) !== -1) { 8047 return null; 8048 } 8049 return state; 8050 case setActionType: 8051 return action.name || null; 8052 } 8053 return state; 8054 }; 8055 } 8056 const defaultBlockName = createBlockNameSetterReducer('SET_DEFAULT_BLOCK_NAME'); 8057 const freeformFallbackBlockName = createBlockNameSetterReducer('SET_FREEFORM_FALLBACK_BLOCK_NAME'); 8058 const unregisteredFallbackBlockName = createBlockNameSetterReducer('SET_UNREGISTERED_FALLBACK_BLOCK_NAME'); 8059 const groupingBlockName = createBlockNameSetterReducer('SET_GROUPING_BLOCK_NAME'); 8060 8061 /** 8062 * Reducer managing the categories 8063 * 8064 * @param {WPBlockCategory[]} state Current state. 8065 * @param {Object} action Dispatched action. 8066 * 8067 * @return {WPBlockCategory[]} Updated state. 8068 */ 8069 function categories(state = DEFAULT_CATEGORIES, action) { 8070 switch (action.type) { 8071 case 'SET_CATEGORIES': 8072 return action.categories || []; 8073 case 'UPDATE_CATEGORY': 8074 { 8075 if (!action.category || !Object.keys(action.category).length) { 8076 return state; 8077 } 8078 const categoryToChange = state.find(({ 8079 slug 8080 }) => slug === action.slug); 8081 if (categoryToChange) { 8082 return state.map(category => { 8083 if (category.slug === action.slug) { 8084 return { 8085 ...category, 8086 ...action.category 8087 }; 8088 } 8089 return category; 8090 }); 8091 } 8092 } 8093 } 8094 return state; 8095 } 8096 function collections(state = {}, action) { 8097 switch (action.type) { 8098 case 'ADD_BLOCK_COLLECTION': 8099 return { 8100 ...state, 8101 [action.namespace]: { 8102 title: action.title, 8103 icon: action.icon 8104 } 8105 }; 8106 case 'REMOVE_BLOCK_COLLECTION': 8107 return omit(state, action.namespace); 8108 } 8109 return state; 8110 } 8111 function blockBindingsSources(state = {}, action) { 8112 if (action.type === 'REGISTER_BLOCK_BINDINGS_SOURCE') { 8113 return { 8114 ...state, 8115 [action.sourceName]: { 8116 label: action.sourceLabel, 8117 getValue: action.getValue, 8118 setValue: action.setValue, 8119 setValues: action.setValues, 8120 getPlaceholder: action.getPlaceholder, 8121 canUserEditValue: action.canUserEditValue || (() => false) 8122 } 8123 }; 8124 } 8125 return state; 8126 } 8127 /* harmony default export */ const reducer = ((0,external_wp_data_namespaceObject.combineReducers)({ 8128 bootstrappedBlockTypes, 8129 unprocessedBlockTypes, 8130 blockTypes, 8131 blockStyles, 8132 blockVariations, 8133 defaultBlockName, 8134 freeformFallbackBlockName, 8135 unregisteredFallbackBlockName, 8136 groupingBlockName, 8137 categories, 8138 collections, 8139 blockBindingsSources 8140 })); 8141 8142 // EXTERNAL MODULE: ./node_modules/remove-accents/index.js 8143 var remove_accents = __webpack_require__(9681); 8144 var remove_accents_default = /*#__PURE__*/__webpack_require__.n(remove_accents); 8145 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/utils.js 8146 /** 8147 * Helper util to return a value from a certain path of the object. 8148 * Path is specified as either: 8149 * - a string of properties, separated by dots, for example: "x.y". 8150 * - an array of properties, for example `[ 'x', 'y' ]`. 8151 * You can also specify a default value in case the result is nullish. 8152 * 8153 * @param {Object} object Input object. 8154 * @param {string|Array} path Path to the object property. 8155 * @param {*} defaultValue Default value if the value at the specified path is nullish. 8156 * @return {*} Value of the object property at the specified path. 8157 */ 8158 const getValueFromObjectPath = (object, path, defaultValue) => { 8159 var _value; 8160 const normalizedPath = Array.isArray(path) ? path : path.split('.'); 8161 let value = object; 8162 normalizedPath.forEach(fieldName => { 8163 value = value?.[fieldName]; 8164 }); 8165 return (_value = value) !== null && _value !== void 0 ? _value : defaultValue; 8166 }; 8167 function utils_isObject(candidate) { 8168 return typeof candidate === 'object' && candidate.constructor === Object && candidate !== null; 8169 } 8170 8171 /** 8172 * Determine whether a set of object properties matches a given object. 8173 * 8174 * Given an object of block attributes and an object of variation attributes, 8175 * this function checks recursively whether all the variation attributes are 8176 * present in the block attributes object. 8177 * 8178 * @param {Object} blockAttributes The object to inspect. 8179 * @param {Object} variationAttributes The object of property values to match. 8180 * @return {boolean} Whether the block attributes match the variation attributes. 8181 */ 8182 function matchesAttributes(blockAttributes, variationAttributes) { 8183 if (utils_isObject(blockAttributes) && utils_isObject(variationAttributes)) { 8184 return Object.entries(variationAttributes).every(([key, value]) => matchesAttributes(blockAttributes?.[key], value)); 8185 } 8186 return blockAttributes === variationAttributes; 8187 } 8188 8189 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/selectors.js 8190 /** 8191 * External dependencies 8192 */ 8193 8194 8195 /** 8196 * WordPress dependencies 8197 */ 8198 8199 8200 8201 /** 8202 * Internal dependencies 8203 */ 8204 8205 8206 /** @typedef {import('../api/registration').WPBlockVariation} WPBlockVariation */ 8207 /** @typedef {import('../api/registration').WPBlockVariationScope} WPBlockVariationScope */ 8208 /** @typedef {import('./reducer').WPBlockCategory} WPBlockCategory */ 8209 8210 /** 8211 * Given a block name or block type object, returns the corresponding 8212 * normalized block type object. 8213 * 8214 * @param {Object} state Blocks state. 8215 * @param {(string|Object)} nameOrType Block name or type object 8216 * 8217 * @return {Object} Block type object. 8218 */ 8219 const getNormalizedBlockType = (state, nameOrType) => 'string' === typeof nameOrType ? selectors_getBlockType(state, nameOrType) : nameOrType; 8220 8221 /** 8222 * Returns all the available block types. 8223 * 8224 * @param {Object} state Data state. 8225 * 8226 * @example 8227 * ```js 8228 * import { store as blocksStore } from '@wordpress/blocks'; 8229 * import { useSelect } from '@wordpress/data'; 8230 * 8231 * const ExampleComponent = () => { 8232 * const blockTypes = useSelect( 8233 * ( select ) => select( blocksStore ).getBlockTypes(), 8234 * [] 8235 * ); 8236 * 8237 * return ( 8238 * <ul> 8239 * { blockTypes.map( ( block ) => ( 8240 * <li key={ block.name }>{ block.title }</li> 8241 * ) ) } 8242 * </ul> 8243 * ); 8244 * }; 8245 * ``` 8246 * 8247 * @return {Array} Block Types. 8248 */ 8249 const selectors_getBlockTypes = (0,external_wp_data_namespaceObject.createSelector)(state => Object.values(state.blockTypes), state => [state.blockTypes]); 8250 8251 /** 8252 * Returns a block type by name. 8253 * 8254 * @param {Object} state Data state. 8255 * @param {string} name Block type name. 8256 * 8257 * @example 8258 * ```js 8259 * import { store as blocksStore } from '@wordpress/blocks'; 8260 * import { useSelect } from '@wordpress/data'; 8261 * 8262 * const ExampleComponent = () => { 8263 * const paragraphBlock = useSelect( ( select ) => 8264 * ( select ) => select( blocksStore ).getBlockType( 'core/paragraph' ), 8265 * [] 8266 * ); 8267 * 8268 * return ( 8269 * <ul> 8270 * { paragraphBlock && 8271 * Object.entries( paragraphBlock.supports ).map( 8272 * ( blockSupportsEntry ) => { 8273 * const [ propertyName, value ] = blockSupportsEntry; 8274 * return ( 8275 * <li 8276 * key={ propertyName } 8277 * >{ `${ propertyName } : ${ value }` }</li> 8278 * ); 8279 * } 8280 * ) } 8281 * </ul> 8282 * ); 8283 * }; 8284 * ``` 8285 * 8286 * @return {Object?} Block Type. 8287 */ 8288 function selectors_getBlockType(state, name) { 8289 return state.blockTypes[name]; 8290 } 8291 8292 /** 8293 * Returns block styles by block name. 8294 * 8295 * @param {Object} state Data state. 8296 * @param {string} name Block type name. 8297 * 8298 * @example 8299 * ```js 8300 * import { store as blocksStore } from '@wordpress/blocks'; 8301 * import { useSelect } from '@wordpress/data'; 8302 * 8303 * const ExampleComponent = () => { 8304 * const buttonBlockStyles = useSelect( ( select ) => 8305 * select( blocksStore ).getBlockStyles( 'core/button' ), 8306 * [] 8307 * ); 8308 * 8309 * return ( 8310 * <ul> 8311 * { buttonBlockStyles && 8312 * buttonBlockStyles.map( ( style ) => ( 8313 * <li key={ style.name }>{ style.label }</li> 8314 * ) ) } 8315 * </ul> 8316 * ); 8317 * }; 8318 * ``` 8319 * 8320 * @return {Array?} Block Styles. 8321 */ 8322 function getBlockStyles(state, name) { 8323 return state.blockStyles[name]; 8324 } 8325 8326 /** 8327 * Returns block variations by block name. 8328 * 8329 * @param {Object} state Data state. 8330 * @param {string} blockName Block type name. 8331 * @param {WPBlockVariationScope} [scope] Block variation scope name. 8332 * 8333 * @example 8334 * ```js 8335 * import { store as blocksStore } from '@wordpress/blocks'; 8336 * import { useSelect } from '@wordpress/data'; 8337 * 8338 * const ExampleComponent = () => { 8339 * const socialLinkVariations = useSelect( ( select ) => 8340 * select( blocksStore ).getBlockVariations( 'core/social-link' ), 8341 * [] 8342 * ); 8343 * 8344 * return ( 8345 * <ul> 8346 * { socialLinkVariations && 8347 * socialLinkVariations.map( ( variation ) => ( 8348 * <li key={ variation.name }>{ variation.title }</li> 8349 * ) ) } 8350 * </ul> 8351 * ); 8352 * }; 8353 * ``` 8354 * 8355 * @return {(WPBlockVariation[]|void)} Block variations. 8356 */ 8357 const selectors_getBlockVariations = (0,external_wp_data_namespaceObject.createSelector)((state, blockName, scope) => { 8358 const variations = state.blockVariations[blockName]; 8359 if (!variations || !scope) { 8360 return variations; 8361 } 8362 return variations.filter(variation => { 8363 // For backward compatibility reasons, variation's scope defaults to 8364 // `block` and `inserter` when not set. 8365 return (variation.scope || ['block', 'inserter']).includes(scope); 8366 }); 8367 }, (state, blockName) => [state.blockVariations[blockName]]); 8368 8369 /** 8370 * Returns the active block variation for a given block based on its attributes. 8371 * Variations are determined by their `isActive` property. 8372 * Which is either an array of block attribute keys or a function. 8373 * 8374 * In case of an array of block attribute keys, the `attributes` are compared 8375 * to the variation's attributes using strict equality check. 8376 * 8377 * In case of function type, the function should accept a block's attributes 8378 * and the variation's attributes and determines if a variation is active. 8379 * A function that accepts a block's attributes and the variation's attributes and determines if a variation is active. 8380 * 8381 * @param {Object} state Data state. 8382 * @param {string} blockName Name of block (example: “core/columns”). 8383 * @param {Object} attributes Block attributes used to determine active variation. 8384 * @param {WPBlockVariationScope} [scope] Block variation scope name. 8385 * 8386 * @example 8387 * ```js 8388 * import { __ } from '@wordpress/i18n'; 8389 * import { store as blocksStore } from '@wordpress/blocks'; 8390 * import { store as blockEditorStore } from '@wordpress/block-editor'; 8391 * import { useSelect } from '@wordpress/data'; 8392 * 8393 * const ExampleComponent = () => { 8394 * // This example assumes that a core/embed block is the first block in the Block Editor. 8395 * const activeBlockVariation = useSelect( ( select ) => { 8396 * // Retrieve the list of blocks. 8397 * const [ firstBlock ] = select( blockEditorStore ).getBlocks() 8398 * 8399 * // Return the active block variation for the first block. 8400 * return select( blocksStore ).getActiveBlockVariation( 8401 * firstBlock.name, 8402 * firstBlock.attributes 8403 * ); 8404 * }, [] ); 8405 * 8406 * return activeBlockVariation && activeBlockVariation.name === 'spotify' ? ( 8407 * <p>{ __( 'Spotify variation' ) }</p> 8408 * ) : ( 8409 * <p>{ __( 'Other variation' ) }</p> 8410 * ); 8411 * }; 8412 * ``` 8413 * 8414 * @return {(WPBlockVariation|undefined)} Active block variation. 8415 */ 8416 function getActiveBlockVariation(state, blockName, attributes, scope) { 8417 const variations = selectors_getBlockVariations(state, blockName, scope); 8418 if (!variations) { 8419 return variations; 8420 } 8421 const blockType = selectors_getBlockType(state, blockName); 8422 const attributeKeys = Object.keys(blockType?.attributes || {}); 8423 let match; 8424 let maxMatchedAttributes = 0; 8425 for (const variation of variations) { 8426 if (Array.isArray(variation.isActive)) { 8427 const definedAttributes = variation.isActive.filter(attribute => { 8428 // We support nested attribute paths, e.g. `layout.type`. 8429 // In this case, we need to check if the part before the 8430 // first dot is a known attribute. 8431 const topLevelAttribute = attribute.split('.')[0]; 8432 return attributeKeys.includes(topLevelAttribute); 8433 }); 8434 const definedAttributesLength = definedAttributes.length; 8435 if (definedAttributesLength === 0) { 8436 continue; 8437 } 8438 const isMatch = definedAttributes.every(attribute => { 8439 const variationAttributeValue = getValueFromObjectPath(variation.attributes, attribute); 8440 if (variationAttributeValue === undefined) { 8441 return false; 8442 } 8443 let blockAttributeValue = getValueFromObjectPath(attributes, attribute); 8444 if (blockAttributeValue instanceof external_wp_richText_namespaceObject.RichTextData) { 8445 blockAttributeValue = blockAttributeValue.toHTMLString(); 8446 } 8447 return matchesAttributes(blockAttributeValue, variationAttributeValue); 8448 }); 8449 if (isMatch && definedAttributesLength > maxMatchedAttributes) { 8450 match = variation; 8451 maxMatchedAttributes = definedAttributesLength; 8452 } 8453 } else if (variation.isActive?.(attributes, variation.attributes)) { 8454 // If isActive is a function, we cannot know how many attributes it matches. 8455 // This means that we cannot compare the specificity of our matches, 8456 // and simply return the best match we have found. 8457 return match || variation; 8458 } 8459 } 8460 return match; 8461 } 8462 8463 /** 8464 * Returns the default block variation for the given block type. 8465 * When there are multiple variations annotated as the default one, 8466 * the last added item is picked. This simplifies registering overrides. 8467 * When there is no default variation set, it returns the first item. 8468 * 8469 * @param {Object} state Data state. 8470 * @param {string} blockName Block type name. 8471 * @param {WPBlockVariationScope} [scope] Block variation scope name. 8472 * 8473 * @example 8474 * ```js 8475 * import { __, sprintf } from '@wordpress/i18n'; 8476 * import { store as blocksStore } from '@wordpress/blocks'; 8477 * import { useSelect } from '@wordpress/data'; 8478 * 8479 * const ExampleComponent = () => { 8480 * const defaultEmbedBlockVariation = useSelect( ( select ) => 8481 * select( blocksStore ).getDefaultBlockVariation( 'core/embed' ), 8482 * [] 8483 * ); 8484 * 8485 * return ( 8486 * defaultEmbedBlockVariation && ( 8487 * <p> 8488 * { sprintf( 8489 * __( 'core/embed default variation: %s' ), 8490 * defaultEmbedBlockVariation.title 8491 * ) } 8492 * </p> 8493 * ) 8494 * ); 8495 * }; 8496 * ``` 8497 * 8498 * @return {?WPBlockVariation} The default block variation. 8499 */ 8500 function getDefaultBlockVariation(state, blockName, scope) { 8501 const variations = selectors_getBlockVariations(state, blockName, scope); 8502 const defaultVariation = [...variations].reverse().find(({ 8503 isDefault 8504 }) => !!isDefault); 8505 return defaultVariation || variations[0]; 8506 } 8507 8508 /** 8509 * Returns all the available block categories. 8510 * 8511 * @param {Object} state Data state. 8512 * 8513 * @example 8514 * ```js 8515 * import { store as blocksStore } from '@wordpress/blocks'; 8516 * import { useSelect, } from '@wordpress/data'; 8517 * 8518 * const ExampleComponent = () => { 8519 * const blockCategories = useSelect( ( select ) => 8520 * select( blocksStore ).getCategories(), 8521 * [] 8522 * ); 8523 * 8524 * return ( 8525 * <ul> 8526 * { blockCategories.map( ( category ) => ( 8527 * <li key={ category.slug }>{ category.title }</li> 8528 * ) ) } 8529 * </ul> 8530 * ); 8531 * }; 8532 * ``` 8533 * 8534 * @return {WPBlockCategory[]} Categories list. 8535 */ 8536 function getCategories(state) { 8537 return state.categories; 8538 } 8539 8540 /** 8541 * Returns all the available collections. 8542 * 8543 * @param {Object} state Data state. 8544 * 8545 * @example 8546 * ```js 8547 * import { store as blocksStore } from '@wordpress/blocks'; 8548 * import { useSelect } from '@wordpress/data'; 8549 * 8550 * const ExampleComponent = () => { 8551 * const blockCollections = useSelect( ( select ) => 8552 * select( blocksStore ).getCollections(), 8553 * [] 8554 * ); 8555 * 8556 * return ( 8557 * <ul> 8558 * { Object.values( blockCollections ).length > 0 && 8559 * Object.values( blockCollections ).map( ( collection ) => ( 8560 * <li key={ collection.title }>{ collection.title }</li> 8561 * ) ) } 8562 * </ul> 8563 * ); 8564 * }; 8565 * ``` 8566 * 8567 * @return {Object} Collections list. 8568 */ 8569 function getCollections(state) { 8570 return state.collections; 8571 } 8572 8573 /** 8574 * Returns the name of the default block name. 8575 * 8576 * @param {Object} state Data state. 8577 * 8578 * @example 8579 * ```js 8580 * import { __, sprintf } from '@wordpress/i18n'; 8581 * import { store as blocksStore } from '@wordpress/blocks'; 8582 * import { useSelect } from '@wordpress/data'; 8583 * 8584 * const ExampleComponent = () => { 8585 * const defaultBlockName = useSelect( ( select ) => 8586 * select( blocksStore ).getDefaultBlockName(), 8587 * [] 8588 * ); 8589 * 8590 * return ( 8591 * defaultBlockName && ( 8592 * <p> 8593 * { sprintf( __( 'Default block name: %s' ), defaultBlockName ) } 8594 * </p> 8595 * ) 8596 * ); 8597 * }; 8598 * ``` 8599 * 8600 * @return {string?} Default block name. 8601 */ 8602 function selectors_getDefaultBlockName(state) { 8603 return state.defaultBlockName; 8604 } 8605 8606 /** 8607 * Returns the name of the block for handling non-block content. 8608 * 8609 * @param {Object} state Data state. 8610 * 8611 * @example 8612 * ```js 8613 * import { __, sprintf } from '@wordpress/i18n'; 8614 * import { store as blocksStore } from '@wordpress/blocks'; 8615 * import { useSelect } from '@wordpress/data'; 8616 * 8617 * const ExampleComponent = () => { 8618 * const freeformFallbackBlockName = useSelect( ( select ) => 8619 * select( blocksStore ).getFreeformFallbackBlockName(), 8620 * [] 8621 * ); 8622 * 8623 * return ( 8624 * freeformFallbackBlockName && ( 8625 * <p> 8626 * { sprintf( __( 8627 * 'Freeform fallback block name: %s' ), 8628 * freeformFallbackBlockName 8629 * ) } 8630 * </p> 8631 * ) 8632 * ); 8633 * }; 8634 * ``` 8635 * 8636 * @return {string?} Name of the block for handling non-block content. 8637 */ 8638 function getFreeformFallbackBlockName(state) { 8639 return state.freeformFallbackBlockName; 8640 } 8641 8642 /** 8643 * Returns the name of the block for handling unregistered blocks. 8644 * 8645 * @param {Object} state Data state. 8646 * 8647 * @example 8648 * ```js 8649 * import { __, sprintf } from '@wordpress/i18n'; 8650 * import { store as blocksStore } from '@wordpress/blocks'; 8651 * import { useSelect } from '@wordpress/data'; 8652 * 8653 * const ExampleComponent = () => { 8654 * const unregisteredFallbackBlockName = useSelect( ( select ) => 8655 * select( blocksStore ).getUnregisteredFallbackBlockName(), 8656 * [] 8657 * ); 8658 * 8659 * return ( 8660 * unregisteredFallbackBlockName && ( 8661 * <p> 8662 * { sprintf( __( 8663 * 'Unregistered fallback block name: %s' ), 8664 * unregisteredFallbackBlockName 8665 * ) } 8666 * </p> 8667 * ) 8668 * ); 8669 * }; 8670 * ``` 8671 * 8672 * @return {string?} Name of the block for handling unregistered blocks. 8673 */ 8674 function getUnregisteredFallbackBlockName(state) { 8675 return state.unregisteredFallbackBlockName; 8676 } 8677 8678 /** 8679 * Returns the name of the block for handling the grouping of blocks. 8680 * 8681 * @param {Object} state Data state. 8682 * 8683 * @example 8684 * ```js 8685 * import { __, sprintf } from '@wordpress/i18n'; 8686 * import { store as blocksStore } from '@wordpress/blocks'; 8687 * import { useSelect } from '@wordpress/data'; 8688 * 8689 * const ExampleComponent = () => { 8690 * const groupingBlockName = useSelect( ( select ) => 8691 * select( blocksStore ).getGroupingBlockName(), 8692 * [] 8693 * ); 8694 * 8695 * return ( 8696 * groupingBlockName && ( 8697 * <p> 8698 * { sprintf( 8699 * __( 'Default grouping block name: %s' ), 8700 * groupingBlockName 8701 * ) } 8702 * </p> 8703 * ) 8704 * ); 8705 * }; 8706 * ``` 8707 * 8708 * @return {string?} Name of the block for handling the grouping of blocks. 8709 */ 8710 function selectors_getGroupingBlockName(state) { 8711 return state.groupingBlockName; 8712 } 8713 8714 /** 8715 * Returns an array with the child blocks of a given block. 8716 * 8717 * @param {Object} state Data state. 8718 * @param {string} blockName Block type name. 8719 * 8720 * @example 8721 * ```js 8722 * import { store as blocksStore } from '@wordpress/blocks'; 8723 * import { useSelect } from '@wordpress/data'; 8724 * 8725 * const ExampleComponent = () => { 8726 * const childBlockNames = useSelect( ( select ) => 8727 * select( blocksStore ).getChildBlockNames( 'core/navigation' ), 8728 * [] 8729 * ); 8730 * 8731 * return ( 8732 * <ul> 8733 * { childBlockNames && 8734 * childBlockNames.map( ( child ) => ( 8735 * <li key={ child }>{ child }</li> 8736 * ) ) } 8737 * </ul> 8738 * ); 8739 * }; 8740 * ``` 8741 * 8742 * @return {Array} Array of child block names. 8743 */ 8744 const selectors_getChildBlockNames = (0,external_wp_data_namespaceObject.createSelector)((state, blockName) => { 8745 return selectors_getBlockTypes(state).filter(blockType => { 8746 return blockType.parent?.includes(blockName); 8747 }).map(({ 8748 name 8749 }) => name); 8750 }, state => [state.blockTypes]); 8751 8752 /** 8753 * Returns the block support value for a feature, if defined. 8754 * 8755 * @param {Object} state Data state. 8756 * @param {(string|Object)} nameOrType Block name or type object 8757 * @param {Array|string} feature Feature to retrieve 8758 * @param {*} defaultSupports Default value to return if not 8759 * explicitly defined 8760 * 8761 * @example 8762 * ```js 8763 * import { __, sprintf } from '@wordpress/i18n'; 8764 * import { store as blocksStore } from '@wordpress/blocks'; 8765 * import { useSelect } from '@wordpress/data'; 8766 * 8767 * const ExampleComponent = () => { 8768 * const paragraphBlockSupportValue = useSelect( ( select ) => 8769 * select( blocksStore ).getBlockSupport( 'core/paragraph', 'anchor' ), 8770 * [] 8771 * ); 8772 * 8773 * return ( 8774 * <p> 8775 * { sprintf( 8776 * __( 'core/paragraph supports.anchor value: %s' ), 8777 * paragraphBlockSupportValue 8778 * ) } 8779 * </p> 8780 * ); 8781 * }; 8782 * ``` 8783 * 8784 * @return {?*} Block support value 8785 */ 8786 const selectors_getBlockSupport = (state, nameOrType, feature, defaultSupports) => { 8787 const blockType = getNormalizedBlockType(state, nameOrType); 8788 if (!blockType?.supports) { 8789 return defaultSupports; 8790 } 8791 return getValueFromObjectPath(blockType.supports, feature, defaultSupports); 8792 }; 8793 8794 /** 8795 * Returns true if the block defines support for a feature, or false otherwise. 8796 * 8797 * @param {Object} state Data state. 8798 * @param {(string|Object)} nameOrType Block name or type object. 8799 * @param {string} feature Feature to test. 8800 * @param {boolean} defaultSupports Whether feature is supported by 8801 * default if not explicitly defined. 8802 * 8803 * @example 8804 * ```js 8805 * import { __, sprintf } from '@wordpress/i18n'; 8806 * import { store as blocksStore } from '@wordpress/blocks'; 8807 * import { useSelect } from '@wordpress/data'; 8808 * 8809 * const ExampleComponent = () => { 8810 * const paragraphBlockSupportClassName = useSelect( ( select ) => 8811 * select( blocksStore ).hasBlockSupport( 'core/paragraph', 'className' ), 8812 * [] 8813 * ); 8814 * 8815 * return ( 8816 * <p> 8817 * { sprintf( 8818 * __( 'core/paragraph supports custom class name?: %s' ), 8819 * paragraphBlockSupportClassName 8820 * ) } 8821 * /p> 8822 * ); 8823 * }; 8824 * ``` 8825 * 8826 * @return {boolean} Whether block supports feature. 8827 */ 8828 function selectors_hasBlockSupport(state, nameOrType, feature, defaultSupports) { 8829 return !!selectors_getBlockSupport(state, nameOrType, feature, defaultSupports); 8830 } 8831 8832 /** 8833 * Normalizes a search term string: removes accents, converts to lowercase, removes extra whitespace. 8834 * 8835 * @param {string|null|undefined} term Search term to normalize. 8836 * @return {string} Normalized search term. 8837 */ 8838 function getNormalizedSearchTerm(term) { 8839 return remove_accents_default()(term !== null && term !== void 0 ? term : '').toLowerCase().trim(); 8840 } 8841 8842 /** 8843 * Returns true if the block type by the given name or object value matches a 8844 * search term, or false otherwise. 8845 * 8846 * @param {Object} state Blocks state. 8847 * @param {(string|Object)} nameOrType Block name or type object. 8848 * @param {string} searchTerm Search term by which to filter. 8849 * 8850 * @example 8851 * ```js 8852 * import { __, sprintf } from '@wordpress/i18n'; 8853 * import { store as blocksStore } from '@wordpress/blocks'; 8854 * import { useSelect } from '@wordpress/data'; 8855 * 8856 * const ExampleComponent = () => { 8857 * const termFound = useSelect( 8858 * ( select ) => 8859 * select( blocksStore ).isMatchingSearchTerm( 8860 * 'core/navigation', 8861 * 'theme' 8862 * ), 8863 * [] 8864 * ); 8865 * 8866 * return ( 8867 * <p> 8868 * { sprintf( 8869 * __( 8870 * 'Search term was found in the title, keywords, category or description in block.json: %s' 8871 * ), 8872 * termFound 8873 * ) } 8874 * </p> 8875 * ); 8876 * }; 8877 * ``` 8878 * 8879 * @return {Object[]} Whether block type matches search term. 8880 */ 8881 function isMatchingSearchTerm(state, nameOrType, searchTerm = '') { 8882 const blockType = getNormalizedBlockType(state, nameOrType); 8883 const normalizedSearchTerm = getNormalizedSearchTerm(searchTerm); 8884 const isSearchMatch = candidate => getNormalizedSearchTerm(candidate).includes(normalizedSearchTerm); 8885 return isSearchMatch(blockType.title) || blockType.keywords?.some(isSearchMatch) || isSearchMatch(blockType.category) || typeof blockType.description === 'string' && isSearchMatch(blockType.description); 8886 } 8887 8888 /** 8889 * Returns a boolean indicating if a block has child blocks or not. 8890 * 8891 * @param {Object} state Data state. 8892 * @param {string} blockName Block type name. 8893 * 8894 * @example 8895 * ```js 8896 * import { __, sprintf } from '@wordpress/i18n'; 8897 * import { store as blocksStore } from '@wordpress/blocks'; 8898 * import { useSelect } from '@wordpress/data'; 8899 * 8900 * const ExampleComponent = () => { 8901 * const navigationBlockHasChildBlocks = useSelect( ( select ) => 8902 * select( blocksStore ).hasChildBlocks( 'core/navigation' ), 8903 * [] 8904 * ); 8905 * 8906 * return ( 8907 * <p> 8908 * { sprintf( 8909 * __( 'core/navigation has child blocks: %s' ), 8910 * navigationBlockHasChildBlocks 8911 * ) } 8912 * </p> 8913 * ); 8914 * }; 8915 * ``` 8916 * 8917 * @return {boolean} True if a block contains child blocks and false otherwise. 8918 */ 8919 const selectors_hasChildBlocks = (state, blockName) => { 8920 return selectors_getChildBlockNames(state, blockName).length > 0; 8921 }; 8922 8923 /** 8924 * Returns a boolean indicating if a block has at least one child block with inserter support. 8925 * 8926 * @param {Object} state Data state. 8927 * @param {string} blockName Block type name. 8928 * 8929 * @example 8930 * ```js 8931 * import { __, sprintf } from '@wordpress/i18n'; 8932 * import { store as blocksStore } from '@wordpress/blocks'; 8933 * import { useSelect } from '@wordpress/data'; 8934 * 8935 * const ExampleComponent = () => { 8936 * const navigationBlockHasChildBlocksWithInserterSupport = useSelect( ( select ) => 8937 * select( blocksStore ).hasChildBlocksWithInserterSupport( 8938 * 'core/navigation' 8939 * ), 8940 * [] 8941 * ); 8942 * 8943 * return ( 8944 * <p> 8945 * { sprintf( 8946 * __( 'core/navigation has child blocks with inserter support: %s' ), 8947 * navigationBlockHasChildBlocksWithInserterSupport 8948 * ) } 8949 * </p> 8950 * ); 8951 * }; 8952 * ``` 8953 * 8954 * @return {boolean} True if a block contains at least one child blocks with inserter support 8955 * and false otherwise. 8956 */ 8957 const selectors_hasChildBlocksWithInserterSupport = (state, blockName) => { 8958 return selectors_getChildBlockNames(state, blockName).some(childBlockName => { 8959 return selectors_hasBlockSupport(state, childBlockName, 'inserter', true); 8960 }); 8961 }; 8962 8963 /** 8964 * DO-NOT-USE in production. 8965 * This selector is created for internal/experimental only usage and may be 8966 * removed anytime without any warning, causing breakage on any plugin or theme invoking it. 8967 */ 8968 const __experimentalHasContentRoleAttribute = (0,external_wp_data_namespaceObject.createSelector)((state, blockTypeName) => { 8969 const blockType = selectors_getBlockType(state, blockTypeName); 8970 if (!blockType) { 8971 return false; 8972 } 8973 return Object.entries(blockType.attributes).some(([, { 8974 __experimentalRole 8975 }]) => __experimentalRole === 'content'); 8976 }, (state, blockTypeName) => [state.blockTypes[blockTypeName]?.attributes]); 8977 8978 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/private-selectors.js 8979 /** 8980 * WordPress dependencies 8981 */ 8982 8983 8984 /** 8985 * Internal dependencies 8986 */ 8987 8988 8989 8990 const ROOT_BLOCK_SUPPORTS = ['background', 'backgroundColor', 'color', 'linkColor', 'captionColor', 'buttonColor', 'headingColor', 'fontFamily', 'fontSize', 'fontStyle', 'fontWeight', 'lineHeight', 'padding', 'contentSize', 'wideSize', 'blockGap', 'textDecoration', 'textTransform', 'letterSpacing']; 8991 8992 /** 8993 * Filters the list of supported styles for a given element. 8994 * 8995 * @param {string[]} blockSupports list of supported styles. 8996 * @param {string|undefined} name block name. 8997 * @param {string|undefined} element element name. 8998 * 8999 * @return {string[]} filtered list of supported styles. 9000 */ 9001 function filterElementBlockSupports(blockSupports, name, element) { 9002 return blockSupports.filter(support => { 9003 if (support === 'fontSize' && element === 'heading') { 9004 return false; 9005 } 9006 9007 // This is only available for links 9008 if (support === 'textDecoration' && !name && element !== 'link') { 9009 return false; 9010 } 9011 9012 // This is only available for heading, button, caption and text 9013 if (support === 'textTransform' && !name && !(['heading', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(element) || element === 'butt