react-markdown-table-ts 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -6,32 +6,8 @@ var require$$0 = require('react');
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
9
- function _interopNamespace(e) {
10
- if (e && e.__esModule) return e;
11
- var n = Object.create(null);
12
- if (e) {
13
- Object.keys(e).forEach(function (k) {
14
- if (k !== 'default') {
15
- var d = Object.getOwnPropertyDescriptor(e, k);
16
- Object.defineProperty(n, k, d.get ? d : {
17
- enumerable: true,
18
- get: function () { return e[k]; }
19
- });
20
- }
21
- });
22
- }
23
- n["default"] = e;
24
- return Object.freeze(n);
25
- }
26
-
27
9
  var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
28
10
 
29
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
30
-
31
- function getDefaultExportFromCjs (x) {
32
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
33
- }
34
-
35
11
  var jsxRuntime = {exports: {}};
36
12
 
37
13
  var reactJsxRuntime_production_min = {};
@@ -1405,1961 +1381,6 @@ if (process.env.NODE_ENV === 'production') {
1405
1381
 
1406
1382
  var jsxRuntimeExports = jsxRuntime.exports;
1407
1383
 
1408
- var prism = {exports: {}};
1409
-
1410
- prism.exports;
1411
-
1412
- (function (module) {
1413
- /* **********************************************
1414
- Begin prism-core.js
1415
- ********************************************** */
1416
-
1417
- /// <reference lib="WebWorker"/>
1418
-
1419
- var _self = (typeof window !== 'undefined')
1420
- ? window // if in browser
1421
- : (
1422
- (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
1423
- ? self // if in worker
1424
- : {} // if in node js
1425
- );
1426
-
1427
- /**
1428
- * Prism: Lightweight, robust, elegant syntax highlighting
1429
- *
1430
- * @license MIT <https://opensource.org/licenses/MIT>
1431
- * @author Lea Verou <https://lea.verou.me>
1432
- * @namespace
1433
- * @public
1434
- */
1435
- var Prism = (function (_self) {
1436
-
1437
- // Private helper vars
1438
- var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i;
1439
- var uniqueId = 0;
1440
-
1441
- // The grammar object for plaintext
1442
- var plainTextGrammar = {};
1443
-
1444
-
1445
- var _ = {
1446
- /**
1447
- * By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
1448
- * current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
1449
- * additional languages or plugins yourself.
1450
- *
1451
- * By setting this value to `true`, Prism will not automatically highlight all code elements on the page.
1452
- *
1453
- * You obviously have to change this value before the automatic highlighting started. To do this, you can add an
1454
- * empty Prism object into the global scope before loading the Prism script like this:
1455
- *
1456
- * ```js
1457
- * window.Prism = window.Prism || {};
1458
- * Prism.manual = true;
1459
- * // add a new <script> to load Prism's script
1460
- * ```
1461
- *
1462
- * @default false
1463
- * @type {boolean}
1464
- * @memberof Prism
1465
- * @public
1466
- */
1467
- manual: _self.Prism && _self.Prism.manual,
1468
- /**
1469
- * By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses
1470
- * `addEventListener` to communicate with its parent instance. However, if you're using Prism manually in your
1471
- * own worker, you don't want it to do this.
1472
- *
1473
- * By setting this value to `true`, Prism will not add its own listeners to the worker.
1474
- *
1475
- * You obviously have to change this value before Prism executes. To do this, you can add an
1476
- * empty Prism object into the global scope before loading the Prism script like this:
1477
- *
1478
- * ```js
1479
- * window.Prism = window.Prism || {};
1480
- * Prism.disableWorkerMessageHandler = true;
1481
- * // Load Prism's script
1482
- * ```
1483
- *
1484
- * @default false
1485
- * @type {boolean}
1486
- * @memberof Prism
1487
- * @public
1488
- */
1489
- disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
1490
-
1491
- /**
1492
- * A namespace for utility methods.
1493
- *
1494
- * All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
1495
- * change or disappear at any time.
1496
- *
1497
- * @namespace
1498
- * @memberof Prism
1499
- */
1500
- util: {
1501
- encode: function encode(tokens) {
1502
- if (tokens instanceof Token) {
1503
- return new Token(tokens.type, encode(tokens.content), tokens.alias);
1504
- } else if (Array.isArray(tokens)) {
1505
- return tokens.map(encode);
1506
- } else {
1507
- return tokens.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/\u00a0/g, ' ');
1508
- }
1509
- },
1510
-
1511
- /**
1512
- * Returns the name of the type of the given value.
1513
- *
1514
- * @param {any} o
1515
- * @returns {string}
1516
- * @example
1517
- * type(null) === 'Null'
1518
- * type(undefined) === 'Undefined'
1519
- * type(123) === 'Number'
1520
- * type('foo') === 'String'
1521
- * type(true) === 'Boolean'
1522
- * type([1, 2]) === 'Array'
1523
- * type({}) === 'Object'
1524
- * type(String) === 'Function'
1525
- * type(/abc+/) === 'RegExp'
1526
- */
1527
- type: function (o) {
1528
- return Object.prototype.toString.call(o).slice(8, -1);
1529
- },
1530
-
1531
- /**
1532
- * Returns a unique number for the given object. Later calls will still return the same number.
1533
- *
1534
- * @param {Object} obj
1535
- * @returns {number}
1536
- */
1537
- objId: function (obj) {
1538
- if (!obj['__id']) {
1539
- Object.defineProperty(obj, '__id', { value: ++uniqueId });
1540
- }
1541
- return obj['__id'];
1542
- },
1543
-
1544
- /**
1545
- * Creates a deep clone of the given object.
1546
- *
1547
- * The main intended use of this function is to clone language definitions.
1548
- *
1549
- * @param {T} o
1550
- * @param {Record<number, any>} [visited]
1551
- * @returns {T}
1552
- * @template T
1553
- */
1554
- clone: function deepClone(o, visited) {
1555
- visited = visited || {};
1556
-
1557
- var clone; var id;
1558
- switch (_.util.type(o)) {
1559
- case 'Object':
1560
- id = _.util.objId(o);
1561
- if (visited[id]) {
1562
- return visited[id];
1563
- }
1564
- clone = /** @type {Record<string, any>} */ ({});
1565
- visited[id] = clone;
1566
-
1567
- for (var key in o) {
1568
- if (o.hasOwnProperty(key)) {
1569
- clone[key] = deepClone(o[key], visited);
1570
- }
1571
- }
1572
-
1573
- return /** @type {any} */ (clone);
1574
-
1575
- case 'Array':
1576
- id = _.util.objId(o);
1577
- if (visited[id]) {
1578
- return visited[id];
1579
- }
1580
- clone = [];
1581
- visited[id] = clone;
1582
-
1583
- (/** @type {Array} */(/** @type {any} */(o))).forEach(function (v, i) {
1584
- clone[i] = deepClone(v, visited);
1585
- });
1586
-
1587
- return /** @type {any} */ (clone);
1588
-
1589
- default:
1590
- return o;
1591
- }
1592
- },
1593
-
1594
- /**
1595
- * Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class.
1596
- *
1597
- * If no language is set for the element or the element is `null` or `undefined`, `none` will be returned.
1598
- *
1599
- * @param {Element} element
1600
- * @returns {string}
1601
- */
1602
- getLanguage: function (element) {
1603
- while (element) {
1604
- var m = lang.exec(element.className);
1605
- if (m) {
1606
- return m[1].toLowerCase();
1607
- }
1608
- element = element.parentElement;
1609
- }
1610
- return 'none';
1611
- },
1612
-
1613
- /**
1614
- * Sets the Prism `language-xxxx` class of the given element.
1615
- *
1616
- * @param {Element} element
1617
- * @param {string} language
1618
- * @returns {void}
1619
- */
1620
- setLanguage: function (element, language) {
1621
- // remove all `language-xxxx` classes
1622
- // (this might leave behind a leading space)
1623
- element.className = element.className.replace(RegExp(lang, 'gi'), '');
1624
-
1625
- // add the new `language-xxxx` class
1626
- // (using `classList` will automatically clean up spaces for us)
1627
- element.classList.add('language-' + language);
1628
- },
1629
-
1630
- /**
1631
- * Returns the script element that is currently executing.
1632
- *
1633
- * This does __not__ work for line script element.
1634
- *
1635
- * @returns {HTMLScriptElement | null}
1636
- */
1637
- currentScript: function () {
1638
- if (typeof document === 'undefined') {
1639
- return null;
1640
- }
1641
- if ('currentScript' in document && 1 < 2 /* hack to trip TS' flow analysis */) {
1642
- return /** @type {any} */ (document.currentScript);
1643
- }
1644
-
1645
- // IE11 workaround
1646
- // we'll get the src of the current script by parsing IE11's error stack trace
1647
- // this will not work for inline scripts
1648
-
1649
- try {
1650
- throw new Error();
1651
- } catch (err) {
1652
- // Get file src url from stack. Specifically works with the format of stack traces in IE.
1653
- // A stack will look like this:
1654
- //
1655
- // Error
1656
- // at _.util.currentScript (http://localhost/components/prism-core.js:119:5)
1657
- // at Global code (http://localhost/components/prism-core.js:606:1)
1658
-
1659
- var src = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(err.stack) || [])[1];
1660
- if (src) {
1661
- var scripts = document.getElementsByTagName('script');
1662
- for (var i in scripts) {
1663
- if (scripts[i].src == src) {
1664
- return scripts[i];
1665
- }
1666
- }
1667
- }
1668
- return null;
1669
- }
1670
- },
1671
-
1672
- /**
1673
- * Returns whether a given class is active for `element`.
1674
- *
1675
- * The class can be activated if `element` or one of its ancestors has the given class and it can be deactivated
1676
- * if `element` or one of its ancestors has the negated version of the given class. The _negated version_ of the
1677
- * given class is just the given class with a `no-` prefix.
1678
- *
1679
- * Whether the class is active is determined by the closest ancestor of `element` (where `element` itself is
1680
- * closest ancestor) that has the given class or the negated version of it. If neither `element` nor any of its
1681
- * ancestors have the given class or the negated version of it, then the default activation will be returned.
1682
- *
1683
- * In the paradoxical situation where the closest ancestor contains __both__ the given class and the negated
1684
- * version of it, the class is considered active.
1685
- *
1686
- * @param {Element} element
1687
- * @param {string} className
1688
- * @param {boolean} [defaultActivation=false]
1689
- * @returns {boolean}
1690
- */
1691
- isActive: function (element, className, defaultActivation) {
1692
- var no = 'no-' + className;
1693
-
1694
- while (element) {
1695
- var classList = element.classList;
1696
- if (classList.contains(className)) {
1697
- return true;
1698
- }
1699
- if (classList.contains(no)) {
1700
- return false;
1701
- }
1702
- element = element.parentElement;
1703
- }
1704
- return !!defaultActivation;
1705
- }
1706
- },
1707
-
1708
- /**
1709
- * This namespace contains all currently loaded languages and the some helper functions to create and modify languages.
1710
- *
1711
- * @namespace
1712
- * @memberof Prism
1713
- * @public
1714
- */
1715
- languages: {
1716
- /**
1717
- * The grammar for plain, unformatted text.
1718
- */
1719
- plain: plainTextGrammar,
1720
- plaintext: plainTextGrammar,
1721
- text: plainTextGrammar,
1722
- txt: plainTextGrammar,
1723
-
1724
- /**
1725
- * Creates a deep copy of the language with the given id and appends the given tokens.
1726
- *
1727
- * If a token in `redef` also appears in the copied language, then the existing token in the copied language
1728
- * will be overwritten at its original position.
1729
- *
1730
- * ## Best practices
1731
- *
1732
- * Since the position of overwriting tokens (token in `redef` that overwrite tokens in the copied language)
1733
- * doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to
1734
- * understand the language definition because, normally, the order of tokens matters in Prism grammars.
1735
- *
1736
- * Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens.
1737
- * Furthermore, all non-overwriting tokens should be placed after the overwriting ones.
1738
- *
1739
- * @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`.
1740
- * @param {Grammar} redef The new tokens to append.
1741
- * @returns {Grammar} The new language created.
1742
- * @public
1743
- * @example
1744
- * Prism.languages['css-with-colors'] = Prism.languages.extend('css', {
1745
- * // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token
1746
- * // at its original position
1747
- * 'comment': { ... },
1748
- * // CSS doesn't have a 'color' token, so this token will be appended
1749
- * 'color': /\b(?:red|green|blue)\b/
1750
- * });
1751
- */
1752
- extend: function (id, redef) {
1753
- var lang = _.util.clone(_.languages[id]);
1754
-
1755
- for (var key in redef) {
1756
- lang[key] = redef[key];
1757
- }
1758
-
1759
- return lang;
1760
- },
1761
-
1762
- /**
1763
- * Inserts tokens _before_ another token in a language definition or any other grammar.
1764
- *
1765
- * ## Usage
1766
- *
1767
- * This helper method makes it easy to modify existing languages. For example, the CSS language definition
1768
- * not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded
1769
- * in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the
1770
- * appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do
1771
- * this:
1772
- *
1773
- * ```js
1774
- * Prism.languages.markup.style = {
1775
- * // token
1776
- * };
1777
- * ```
1778
- *
1779
- * then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens
1780
- * before existing tokens. For the CSS example above, you would use it like this:
1781
- *
1782
- * ```js
1783
- * Prism.languages.insertBefore('markup', 'cdata', {
1784
- * 'style': {
1785
- * // token
1786
- * }
1787
- * });
1788
- * ```
1789
- *
1790
- * ## Special cases
1791
- *
1792
- * If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar
1793
- * will be ignored.
1794
- *
1795
- * This behavior can be used to insert tokens after `before`:
1796
- *
1797
- * ```js
1798
- * Prism.languages.insertBefore('markup', 'comment', {
1799
- * 'comment': Prism.languages.markup.comment,
1800
- * // tokens after 'comment'
1801
- * });
1802
- * ```
1803
- *
1804
- * ## Limitations
1805
- *
1806
- * The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object
1807
- * properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave
1808
- * differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily
1809
- * deleting properties which is necessary to insert at arbitrary positions.
1810
- *
1811
- * To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object.
1812
- * Instead, it will create a new object and replace all references to the target object with the new one. This
1813
- * can be done without temporarily deleting properties, so the iteration order is well-defined.
1814
- *
1815
- * However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if
1816
- * you hold the target object in a variable, then the value of the variable will not change.
1817
- *
1818
- * ```js
1819
- * var oldMarkup = Prism.languages.markup;
1820
- * var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... });
1821
- *
1822
- * assert(oldMarkup !== Prism.languages.markup);
1823
- * assert(newMarkup === Prism.languages.markup);
1824
- * ```
1825
- *
1826
- * @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the
1827
- * object to be modified.
1828
- * @param {string} before The key to insert before.
1829
- * @param {Grammar} insert An object containing the key-value pairs to be inserted.
1830
- * @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the
1831
- * object to be modified.
1832
- *
1833
- * Defaults to `Prism.languages`.
1834
- * @returns {Grammar} The new grammar object.
1835
- * @public
1836
- */
1837
- insertBefore: function (inside, before, insert, root) {
1838
- root = root || /** @type {any} */ (_.languages);
1839
- var grammar = root[inside];
1840
- /** @type {Grammar} */
1841
- var ret = {};
1842
-
1843
- for (var token in grammar) {
1844
- if (grammar.hasOwnProperty(token)) {
1845
-
1846
- if (token == before) {
1847
- for (var newToken in insert) {
1848
- if (insert.hasOwnProperty(newToken)) {
1849
- ret[newToken] = insert[newToken];
1850
- }
1851
- }
1852
- }
1853
-
1854
- // Do not insert token which also occur in insert. See #1525
1855
- if (!insert.hasOwnProperty(token)) {
1856
- ret[token] = grammar[token];
1857
- }
1858
- }
1859
- }
1860
-
1861
- var old = root[inside];
1862
- root[inside] = ret;
1863
-
1864
- // Update references in other language definitions
1865
- _.languages.DFS(_.languages, function (key, value) {
1866
- if (value === old && key != inside) {
1867
- this[key] = ret;
1868
- }
1869
- });
1870
-
1871
- return ret;
1872
- },
1873
-
1874
- // Traverse a language definition with Depth First Search
1875
- DFS: function DFS(o, callback, type, visited) {
1876
- visited = visited || {};
1877
-
1878
- var objId = _.util.objId;
1879
-
1880
- for (var i in o) {
1881
- if (o.hasOwnProperty(i)) {
1882
- callback.call(o, i, o[i], type || i);
1883
-
1884
- var property = o[i];
1885
- var propertyType = _.util.type(property);
1886
-
1887
- if (propertyType === 'Object' && !visited[objId(property)]) {
1888
- visited[objId(property)] = true;
1889
- DFS(property, callback, null, visited);
1890
- } else if (propertyType === 'Array' && !visited[objId(property)]) {
1891
- visited[objId(property)] = true;
1892
- DFS(property, callback, i, visited);
1893
- }
1894
- }
1895
- }
1896
- }
1897
- },
1898
-
1899
- plugins: {},
1900
-
1901
- /**
1902
- * This is the most high-level function in Prism’s API.
1903
- * It fetches all the elements that have a `.language-xxxx` class and then calls {@link Prism.highlightElement} on
1904
- * each one of them.
1905
- *
1906
- * This is equivalent to `Prism.highlightAllUnder(document, async, callback)`.
1907
- *
1908
- * @param {boolean} [async=false] Same as in {@link Prism.highlightAllUnder}.
1909
- * @param {HighlightCallback} [callback] Same as in {@link Prism.highlightAllUnder}.
1910
- * @memberof Prism
1911
- * @public
1912
- */
1913
- highlightAll: function (async, callback) {
1914
- _.highlightAllUnder(document, async, callback);
1915
- },
1916
-
1917
- /**
1918
- * Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
1919
- * {@link Prism.highlightElement} on each one of them.
1920
- *
1921
- * The following hooks will be run:
1922
- * 1. `before-highlightall`
1923
- * 2. `before-all-elements-highlight`
1924
- * 3. All hooks of {@link Prism.highlightElement} for each element.
1925
- *
1926
- * @param {ParentNode} container The root element, whose descendants that have a `.language-xxxx` class will be highlighted.
1927
- * @param {boolean} [async=false] Whether each element is to be highlighted asynchronously using Web Workers.
1928
- * @param {HighlightCallback} [callback] An optional callback to be invoked on each element after its highlighting is done.
1929
- * @memberof Prism
1930
- * @public
1931
- */
1932
- highlightAllUnder: function (container, async, callback) {
1933
- var env = {
1934
- callback: callback,
1935
- container: container,
1936
- selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
1937
- };
1938
-
1939
- _.hooks.run('before-highlightall', env);
1940
-
1941
- env.elements = Array.prototype.slice.apply(env.container.querySelectorAll(env.selector));
1942
-
1943
- _.hooks.run('before-all-elements-highlight', env);
1944
-
1945
- for (var i = 0, element; (element = env.elements[i++]);) {
1946
- _.highlightElement(element, async === true, env.callback);
1947
- }
1948
- },
1949
-
1950
- /**
1951
- * Highlights the code inside a single element.
1952
- *
1953
- * The following hooks will be run:
1954
- * 1. `before-sanity-check`
1955
- * 2. `before-highlight`
1956
- * 3. All hooks of {@link Prism.highlight}. These hooks will be run by an asynchronous worker if `async` is `true`.
1957
- * 4. `before-insert`
1958
- * 5. `after-highlight`
1959
- * 6. `complete`
1960
- *
1961
- * Some the above hooks will be skipped if the element doesn't contain any text or there is no grammar loaded for
1962
- * the element's language.
1963
- *
1964
- * @param {Element} element The element containing the code.
1965
- * It must have a class of `language-xxxx` to be processed, where `xxxx` is a valid language identifier.
1966
- * @param {boolean} [async=false] Whether the element is to be highlighted asynchronously using Web Workers
1967
- * to improve performance and avoid blocking the UI when highlighting very large chunks of code. This option is
1968
- * [disabled by default](https://prismjs.com/faq.html#why-is-asynchronous-highlighting-disabled-by-default).
1969
- *
1970
- * Note: All language definitions required to highlight the code must be included in the main `prism.js` file for
1971
- * asynchronous highlighting to work. You can build your own bundle on the
1972
- * [Download page](https://prismjs.com/download.html).
1973
- * @param {HighlightCallback} [callback] An optional callback to be invoked after the highlighting is done.
1974
- * Mostly useful when `async` is `true`, since in that case, the highlighting is done asynchronously.
1975
- * @memberof Prism
1976
- * @public
1977
- */
1978
- highlightElement: function (element, async, callback) {
1979
- // Find language
1980
- var language = _.util.getLanguage(element);
1981
- var grammar = _.languages[language];
1982
-
1983
- // Set language on the element, if not present
1984
- _.util.setLanguage(element, language);
1985
-
1986
- // Set language on the parent, for styling
1987
- var parent = element.parentElement;
1988
- if (parent && parent.nodeName.toLowerCase() === 'pre') {
1989
- _.util.setLanguage(parent, language);
1990
- }
1991
-
1992
- var code = element.textContent;
1993
-
1994
- var env = {
1995
- element: element,
1996
- language: language,
1997
- grammar: grammar,
1998
- code: code
1999
- };
2000
-
2001
- function insertHighlightedCode(highlightedCode) {
2002
- env.highlightedCode = highlightedCode;
2003
-
2004
- _.hooks.run('before-insert', env);
2005
-
2006
- env.element.innerHTML = env.highlightedCode;
2007
-
2008
- _.hooks.run('after-highlight', env);
2009
- _.hooks.run('complete', env);
2010
- callback && callback.call(env.element);
2011
- }
2012
-
2013
- _.hooks.run('before-sanity-check', env);
2014
-
2015
- // plugins may change/add the parent/element
2016
- parent = env.element.parentElement;
2017
- if (parent && parent.nodeName.toLowerCase() === 'pre' && !parent.hasAttribute('tabindex')) {
2018
- parent.setAttribute('tabindex', '0');
2019
- }
2020
-
2021
- if (!env.code) {
2022
- _.hooks.run('complete', env);
2023
- callback && callback.call(env.element);
2024
- return;
2025
- }
2026
-
2027
- _.hooks.run('before-highlight', env);
2028
-
2029
- if (!env.grammar) {
2030
- insertHighlightedCode(_.util.encode(env.code));
2031
- return;
2032
- }
2033
-
2034
- if (async && _self.Worker) {
2035
- var worker = new Worker(_.filename);
2036
-
2037
- worker.onmessage = function (evt) {
2038
- insertHighlightedCode(evt.data);
2039
- };
2040
-
2041
- worker.postMessage(JSON.stringify({
2042
- language: env.language,
2043
- code: env.code,
2044
- immediateClose: true
2045
- }));
2046
- } else {
2047
- insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
2048
- }
2049
- },
2050
-
2051
- /**
2052
- * Low-level function, only use if you know what you’re doing. It accepts a string of text as input
2053
- * and the language definitions to use, and returns a string with the HTML produced.
2054
- *
2055
- * The following hooks will be run:
2056
- * 1. `before-tokenize`
2057
- * 2. `after-tokenize`
2058
- * 3. `wrap`: On each {@link Token}.
2059
- *
2060
- * @param {string} text A string with the code to be highlighted.
2061
- * @param {Grammar} grammar An object containing the tokens to use.
2062
- *
2063
- * Usually a language definition like `Prism.languages.markup`.
2064
- * @param {string} language The name of the language definition passed to `grammar`.
2065
- * @returns {string} The highlighted HTML.
2066
- * @memberof Prism
2067
- * @public
2068
- * @example
2069
- * Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
2070
- */
2071
- highlight: function (text, grammar, language) {
2072
- var env = {
2073
- code: text,
2074
- grammar: grammar,
2075
- language: language
2076
- };
2077
- _.hooks.run('before-tokenize', env);
2078
- if (!env.grammar) {
2079
- throw new Error('The language "' + env.language + '" has no grammar.');
2080
- }
2081
- env.tokens = _.tokenize(env.code, env.grammar);
2082
- _.hooks.run('after-tokenize', env);
2083
- return Token.stringify(_.util.encode(env.tokens), env.language);
2084
- },
2085
-
2086
- /**
2087
- * This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
2088
- * and the language definitions to use, and returns an array with the tokenized code.
2089
- *
2090
- * When the language definition includes nested tokens, the function is called recursively on each of these tokens.
2091
- *
2092
- * This method could be useful in other contexts as well, as a very crude parser.
2093
- *
2094
- * @param {string} text A string with the code to be highlighted.
2095
- * @param {Grammar} grammar An object containing the tokens to use.
2096
- *
2097
- * Usually a language definition like `Prism.languages.markup`.
2098
- * @returns {TokenStream} An array of strings and tokens, a token stream.
2099
- * @memberof Prism
2100
- * @public
2101
- * @example
2102
- * let code = `var foo = 0;`;
2103
- * let tokens = Prism.tokenize(code, Prism.languages.javascript);
2104
- * tokens.forEach(token => {
2105
- * if (token instanceof Prism.Token && token.type === 'number') {
2106
- * console.log(`Found numeric literal: ${token.content}`);
2107
- * }
2108
- * });
2109
- */
2110
- tokenize: function (text, grammar) {
2111
- var rest = grammar.rest;
2112
- if (rest) {
2113
- for (var token in rest) {
2114
- grammar[token] = rest[token];
2115
- }
2116
-
2117
- delete grammar.rest;
2118
- }
2119
-
2120
- var tokenList = new LinkedList();
2121
- addAfter(tokenList, tokenList.head, text);
2122
-
2123
- matchGrammar(text, tokenList, grammar, tokenList.head, 0);
2124
-
2125
- return toArray(tokenList);
2126
- },
2127
-
2128
- /**
2129
- * @namespace
2130
- * @memberof Prism
2131
- * @public
2132
- */
2133
- hooks: {
2134
- all: {},
2135
-
2136
- /**
2137
- * Adds the given callback to the list of callbacks for the given hook.
2138
- *
2139
- * The callback will be invoked when the hook it is registered for is run.
2140
- * Hooks are usually directly run by a highlight function but you can also run hooks yourself.
2141
- *
2142
- * One callback function can be registered to multiple hooks and the same hook multiple times.
2143
- *
2144
- * @param {string} name The name of the hook.
2145
- * @param {HookCallback} callback The callback function which is given environment variables.
2146
- * @public
2147
- */
2148
- add: function (name, callback) {
2149
- var hooks = _.hooks.all;
2150
-
2151
- hooks[name] = hooks[name] || [];
2152
-
2153
- hooks[name].push(callback);
2154
- },
2155
-
2156
- /**
2157
- * Runs a hook invoking all registered callbacks with the given environment variables.
2158
- *
2159
- * Callbacks will be invoked synchronously and in the order in which they were registered.
2160
- *
2161
- * @param {string} name The name of the hook.
2162
- * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
2163
- * @public
2164
- */
2165
- run: function (name, env) {
2166
- var callbacks = _.hooks.all[name];
2167
-
2168
- if (!callbacks || !callbacks.length) {
2169
- return;
2170
- }
2171
-
2172
- for (var i = 0, callback; (callback = callbacks[i++]);) {
2173
- callback(env);
2174
- }
2175
- }
2176
- },
2177
-
2178
- Token: Token
2179
- };
2180
- _self.Prism = _;
2181
-
2182
-
2183
- // Typescript note:
2184
- // The following can be used to import the Token type in JSDoc:
2185
- //
2186
- // @typedef {InstanceType<import("./prism-core")["Token"]>} Token
2187
-
2188
- /**
2189
- * Creates a new token.
2190
- *
2191
- * @param {string} type See {@link Token#type type}
2192
- * @param {string | TokenStream} content See {@link Token#content content}
2193
- * @param {string|string[]} [alias] The alias(es) of the token.
2194
- * @param {string} [matchedStr=""] A copy of the full string this token was created from.
2195
- * @class
2196
- * @global
2197
- * @public
2198
- */
2199
- function Token(type, content, alias, matchedStr) {
2200
- /**
2201
- * The type of the token.
2202
- *
2203
- * This is usually the key of a pattern in a {@link Grammar}.
2204
- *
2205
- * @type {string}
2206
- * @see GrammarToken
2207
- * @public
2208
- */
2209
- this.type = type;
2210
- /**
2211
- * The strings or tokens contained by this token.
2212
- *
2213
- * This will be a token stream if the pattern matched also defined an `inside` grammar.
2214
- *
2215
- * @type {string | TokenStream}
2216
- * @public
2217
- */
2218
- this.content = content;
2219
- /**
2220
- * The alias(es) of the token.
2221
- *
2222
- * @type {string|string[]}
2223
- * @see GrammarToken
2224
- * @public
2225
- */
2226
- this.alias = alias;
2227
- // Copy of the full string this token was created from
2228
- this.length = (matchedStr || '').length | 0;
2229
- }
2230
-
2231
- /**
2232
- * A token stream is an array of strings and {@link Token Token} objects.
2233
- *
2234
- * Token streams have to fulfill a few properties that are assumed by most functions (mostly internal ones) that process
2235
- * them.
2236
- *
2237
- * 1. No adjacent strings.
2238
- * 2. No empty strings.
2239
- *
2240
- * The only exception here is the token stream that only contains the empty string and nothing else.
2241
- *
2242
- * @typedef {Array<string | Token>} TokenStream
2243
- * @global
2244
- * @public
2245
- */
2246
-
2247
- /**
2248
- * Converts the given token or token stream to an HTML representation.
2249
- *
2250
- * The following hooks will be run:
2251
- * 1. `wrap`: On each {@link Token}.
2252
- *
2253
- * @param {string | Token | TokenStream} o The token or token stream to be converted.
2254
- * @param {string} language The name of current language.
2255
- * @returns {string} The HTML representation of the token or token stream.
2256
- * @memberof Token
2257
- * @static
2258
- */
2259
- Token.stringify = function stringify(o, language) {
2260
- if (typeof o == 'string') {
2261
- return o;
2262
- }
2263
- if (Array.isArray(o)) {
2264
- var s = '';
2265
- o.forEach(function (e) {
2266
- s += stringify(e, language);
2267
- });
2268
- return s;
2269
- }
2270
-
2271
- var env = {
2272
- type: o.type,
2273
- content: stringify(o.content, language),
2274
- tag: 'span',
2275
- classes: ['token', o.type],
2276
- attributes: {},
2277
- language: language
2278
- };
2279
-
2280
- var aliases = o.alias;
2281
- if (aliases) {
2282
- if (Array.isArray(aliases)) {
2283
- Array.prototype.push.apply(env.classes, aliases);
2284
- } else {
2285
- env.classes.push(aliases);
2286
- }
2287
- }
2288
-
2289
- _.hooks.run('wrap', env);
2290
-
2291
- var attributes = '';
2292
- for (var name in env.attributes) {
2293
- attributes += ' ' + name + '="' + (env.attributes[name] || '').replace(/"/g, '&quot;') + '"';
2294
- }
2295
-
2296
- return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + attributes + '>' + env.content + '</' + env.tag + '>';
2297
- };
2298
-
2299
- /**
2300
- * @param {RegExp} pattern
2301
- * @param {number} pos
2302
- * @param {string} text
2303
- * @param {boolean} lookbehind
2304
- * @returns {RegExpExecArray | null}
2305
- */
2306
- function matchPattern(pattern, pos, text, lookbehind) {
2307
- pattern.lastIndex = pos;
2308
- var match = pattern.exec(text);
2309
- if (match && lookbehind && match[1]) {
2310
- // change the match to remove the text matched by the Prism lookbehind group
2311
- var lookbehindLength = match[1].length;
2312
- match.index += lookbehindLength;
2313
- match[0] = match[0].slice(lookbehindLength);
2314
- }
2315
- return match;
2316
- }
2317
-
2318
- /**
2319
- * @param {string} text
2320
- * @param {LinkedList<string | Token>} tokenList
2321
- * @param {any} grammar
2322
- * @param {LinkedListNode<string | Token>} startNode
2323
- * @param {number} startPos
2324
- * @param {RematchOptions} [rematch]
2325
- * @returns {void}
2326
- * @private
2327
- *
2328
- * @typedef RematchOptions
2329
- * @property {string} cause
2330
- * @property {number} reach
2331
- */
2332
- function matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) {
2333
- for (var token in grammar) {
2334
- if (!grammar.hasOwnProperty(token) || !grammar[token]) {
2335
- continue;
2336
- }
2337
-
2338
- var patterns = grammar[token];
2339
- patterns = Array.isArray(patterns) ? patterns : [patterns];
2340
-
2341
- for (var j = 0; j < patterns.length; ++j) {
2342
- if (rematch && rematch.cause == token + ',' + j) {
2343
- return;
2344
- }
2345
-
2346
- var patternObj = patterns[j];
2347
- var inside = patternObj.inside;
2348
- var lookbehind = !!patternObj.lookbehind;
2349
- var greedy = !!patternObj.greedy;
2350
- var alias = patternObj.alias;
2351
-
2352
- if (greedy && !patternObj.pattern.global) {
2353
- // Without the global flag, lastIndex won't work
2354
- var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0];
2355
- patternObj.pattern = RegExp(patternObj.pattern.source, flags + 'g');
2356
- }
2357
-
2358
- /** @type {RegExp} */
2359
- var pattern = patternObj.pattern || patternObj;
2360
-
2361
- for ( // iterate the token list and keep track of the current token/string position
2362
- var currentNode = startNode.next, pos = startPos;
2363
- currentNode !== tokenList.tail;
2364
- pos += currentNode.value.length, currentNode = currentNode.next
2365
- ) {
2366
-
2367
- if (rematch && pos >= rematch.reach) {
2368
- break;
2369
- }
2370
-
2371
- var str = currentNode.value;
2372
-
2373
- if (tokenList.length > text.length) {
2374
- // Something went terribly wrong, ABORT, ABORT!
2375
- return;
2376
- }
2377
-
2378
- if (str instanceof Token) {
2379
- continue;
2380
- }
2381
-
2382
- var removeCount = 1; // this is the to parameter of removeBetween
2383
- var match;
2384
-
2385
- if (greedy) {
2386
- match = matchPattern(pattern, pos, text, lookbehind);
2387
- if (!match || match.index >= text.length) {
2388
- break;
2389
- }
2390
-
2391
- var from = match.index;
2392
- var to = match.index + match[0].length;
2393
- var p = pos;
2394
-
2395
- // find the node that contains the match
2396
- p += currentNode.value.length;
2397
- while (from >= p) {
2398
- currentNode = currentNode.next;
2399
- p += currentNode.value.length;
2400
- }
2401
- // adjust pos (and p)
2402
- p -= currentNode.value.length;
2403
- pos = p;
2404
-
2405
- // the current node is a Token, then the match starts inside another Token, which is invalid
2406
- if (currentNode.value instanceof Token) {
2407
- continue;
2408
- }
2409
-
2410
- // find the last node which is affected by this match
2411
- for (
2412
- var k = currentNode;
2413
- k !== tokenList.tail && (p < to || typeof k.value === 'string');
2414
- k = k.next
2415
- ) {
2416
- removeCount++;
2417
- p += k.value.length;
2418
- }
2419
- removeCount--;
2420
-
2421
- // replace with the new match
2422
- str = text.slice(pos, p);
2423
- match.index -= pos;
2424
- } else {
2425
- match = matchPattern(pattern, 0, str, lookbehind);
2426
- if (!match) {
2427
- continue;
2428
- }
2429
- }
2430
-
2431
- // eslint-disable-next-line no-redeclare
2432
- var from = match.index;
2433
- var matchStr = match[0];
2434
- var before = str.slice(0, from);
2435
- var after = str.slice(from + matchStr.length);
2436
-
2437
- var reach = pos + str.length;
2438
- if (rematch && reach > rematch.reach) {
2439
- rematch.reach = reach;
2440
- }
2441
-
2442
- var removeFrom = currentNode.prev;
2443
-
2444
- if (before) {
2445
- removeFrom = addAfter(tokenList, removeFrom, before);
2446
- pos += before.length;
2447
- }
2448
-
2449
- removeRange(tokenList, removeFrom, removeCount);
2450
-
2451
- var wrapped = new Token(token, inside ? _.tokenize(matchStr, inside) : matchStr, alias, matchStr);
2452
- currentNode = addAfter(tokenList, removeFrom, wrapped);
2453
-
2454
- if (after) {
2455
- addAfter(tokenList, currentNode, after);
2456
- }
2457
-
2458
- if (removeCount > 1) {
2459
- // at least one Token object was removed, so we have to do some rematching
2460
- // this can only happen if the current pattern is greedy
2461
-
2462
- /** @type {RematchOptions} */
2463
- var nestedRematch = {
2464
- cause: token + ',' + j,
2465
- reach: reach
2466
- };
2467
- matchGrammar(text, tokenList, grammar, currentNode.prev, pos, nestedRematch);
2468
-
2469
- // the reach might have been extended because of the rematching
2470
- if (rematch && nestedRematch.reach > rematch.reach) {
2471
- rematch.reach = nestedRematch.reach;
2472
- }
2473
- }
2474
- }
2475
- }
2476
- }
2477
- }
2478
-
2479
- /**
2480
- * @typedef LinkedListNode
2481
- * @property {T} value
2482
- * @property {LinkedListNode<T> | null} prev The previous node.
2483
- * @property {LinkedListNode<T> | null} next The next node.
2484
- * @template T
2485
- * @private
2486
- */
2487
-
2488
- /**
2489
- * @template T
2490
- * @private
2491
- */
2492
- function LinkedList() {
2493
- /** @type {LinkedListNode<T>} */
2494
- var head = { value: null, prev: null, next: null };
2495
- /** @type {LinkedListNode<T>} */
2496
- var tail = { value: null, prev: head, next: null };
2497
- head.next = tail;
2498
-
2499
- /** @type {LinkedListNode<T>} */
2500
- this.head = head;
2501
- /** @type {LinkedListNode<T>} */
2502
- this.tail = tail;
2503
- this.length = 0;
2504
- }
2505
-
2506
- /**
2507
- * Adds a new node with the given value to the list.
2508
- *
2509
- * @param {LinkedList<T>} list
2510
- * @param {LinkedListNode<T>} node
2511
- * @param {T} value
2512
- * @returns {LinkedListNode<T>} The added node.
2513
- * @template T
2514
- */
2515
- function addAfter(list, node, value) {
2516
- // assumes that node != list.tail && values.length >= 0
2517
- var next = node.next;
2518
-
2519
- var newNode = { value: value, prev: node, next: next };
2520
- node.next = newNode;
2521
- next.prev = newNode;
2522
- list.length++;
2523
-
2524
- return newNode;
2525
- }
2526
- /**
2527
- * Removes `count` nodes after the given node. The given node will not be removed.
2528
- *
2529
- * @param {LinkedList<T>} list
2530
- * @param {LinkedListNode<T>} node
2531
- * @param {number} count
2532
- * @template T
2533
- */
2534
- function removeRange(list, node, count) {
2535
- var next = node.next;
2536
- for (var i = 0; i < count && next !== list.tail; i++) {
2537
- next = next.next;
2538
- }
2539
- node.next = next;
2540
- next.prev = node;
2541
- list.length -= i;
2542
- }
2543
- /**
2544
- * @param {LinkedList<T>} list
2545
- * @returns {T[]}
2546
- * @template T
2547
- */
2548
- function toArray(list) {
2549
- var array = [];
2550
- var node = list.head.next;
2551
- while (node !== list.tail) {
2552
- array.push(node.value);
2553
- node = node.next;
2554
- }
2555
- return array;
2556
- }
2557
-
2558
-
2559
- if (!_self.document) {
2560
- if (!_self.addEventListener) {
2561
- // in Node.js
2562
- return _;
2563
- }
2564
-
2565
- if (!_.disableWorkerMessageHandler) {
2566
- // In worker
2567
- _self.addEventListener('message', function (evt) {
2568
- var message = JSON.parse(evt.data);
2569
- var lang = message.language;
2570
- var code = message.code;
2571
- var immediateClose = message.immediateClose;
2572
-
2573
- _self.postMessage(_.highlight(code, _.languages[lang], lang));
2574
- if (immediateClose) {
2575
- _self.close();
2576
- }
2577
- }, false);
2578
- }
2579
-
2580
- return _;
2581
- }
2582
-
2583
- // Get current script and highlight
2584
- var script = _.util.currentScript();
2585
-
2586
- if (script) {
2587
- _.filename = script.src;
2588
-
2589
- if (script.hasAttribute('data-manual')) {
2590
- _.manual = true;
2591
- }
2592
- }
2593
-
2594
- function highlightAutomaticallyCallback() {
2595
- if (!_.manual) {
2596
- _.highlightAll();
2597
- }
2598
- }
2599
-
2600
- if (!_.manual) {
2601
- // If the document state is "loading", then we'll use DOMContentLoaded.
2602
- // If the document state is "interactive" and the prism.js script is deferred, then we'll also use the
2603
- // DOMContentLoaded event because there might be some plugins or languages which have also been deferred and they
2604
- // might take longer one animation frame to execute which can create a race condition where only some plugins have
2605
- // been loaded when Prism.highlightAll() is executed, depending on how fast resources are loaded.
2606
- // See https://github.com/PrismJS/prism/issues/2102
2607
- var readyState = document.readyState;
2608
- if (readyState === 'loading' || readyState === 'interactive' && script && script.defer) {
2609
- document.addEventListener('DOMContentLoaded', highlightAutomaticallyCallback);
2610
- } else {
2611
- if (window.requestAnimationFrame) {
2612
- window.requestAnimationFrame(highlightAutomaticallyCallback);
2613
- } else {
2614
- window.setTimeout(highlightAutomaticallyCallback, 16);
2615
- }
2616
- }
2617
- }
2618
-
2619
- return _;
2620
-
2621
- }(_self));
2622
-
2623
- if (module.exports) {
2624
- module.exports = Prism;
2625
- }
2626
-
2627
- // hack for components to work correctly in node.js
2628
- if (typeof commonjsGlobal !== 'undefined') {
2629
- commonjsGlobal.Prism = Prism;
2630
- }
2631
-
2632
- // some additional documentation/types
2633
-
2634
- /**
2635
- * The expansion of a simple `RegExp` literal to support additional properties.
2636
- *
2637
- * @typedef GrammarToken
2638
- * @property {RegExp} pattern The regular expression of the token.
2639
- * @property {boolean} [lookbehind=false] If `true`, then the first capturing group of `pattern` will (effectively)
2640
- * behave as a lookbehind group meaning that the captured text will not be part of the matched text of the new token.
2641
- * @property {boolean} [greedy=false] Whether the token is greedy.
2642
- * @property {string|string[]} [alias] An optional alias or list of aliases.
2643
- * @property {Grammar} [inside] The nested grammar of this token.
2644
- *
2645
- * The `inside` grammar will be used to tokenize the text value of each token of this kind.
2646
- *
2647
- * This can be used to make nested and even recursive language definitions.
2648
- *
2649
- * Note: This can cause infinite recursion. Be careful when you embed different languages or even the same language into
2650
- * each another.
2651
- * @global
2652
- * @public
2653
- */
2654
-
2655
- /**
2656
- * @typedef Grammar
2657
- * @type {Object<string, RegExp | GrammarToken | Array<RegExp | GrammarToken>>}
2658
- * @property {Grammar} [rest] An optional grammar object that will be appended to this grammar.
2659
- * @global
2660
- * @public
2661
- */
2662
-
2663
- /**
2664
- * A function which will invoked after an element was successfully highlighted.
2665
- *
2666
- * @callback HighlightCallback
2667
- * @param {Element} element The element successfully highlighted.
2668
- * @returns {void}
2669
- * @global
2670
- * @public
2671
- */
2672
-
2673
- /**
2674
- * @callback HookCallback
2675
- * @param {Object<string, any>} env The environment variables of the hook.
2676
- * @returns {void}
2677
- * @global
2678
- * @public
2679
- */
2680
-
2681
-
2682
- /* **********************************************
2683
- Begin prism-markup.js
2684
- ********************************************** */
2685
-
2686
- Prism.languages.markup = {
2687
- 'comment': {
2688
- pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
2689
- greedy: true
2690
- },
2691
- 'prolog': {
2692
- pattern: /<\?[\s\S]+?\?>/,
2693
- greedy: true
2694
- },
2695
- 'doctype': {
2696
- // https://www.w3.org/TR/xml/#NT-doctypedecl
2697
- pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
2698
- greedy: true,
2699
- inside: {
2700
- 'internal-subset': {
2701
- pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
2702
- lookbehind: true,
2703
- greedy: true,
2704
- inside: null // see below
2705
- },
2706
- 'string': {
2707
- pattern: /"[^"]*"|'[^']*'/,
2708
- greedy: true
2709
- },
2710
- 'punctuation': /^<!|>$|[[\]]/,
2711
- 'doctype-tag': /^DOCTYPE/i,
2712
- 'name': /[^\s<>'"]+/
2713
- }
2714
- },
2715
- 'cdata': {
2716
- pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
2717
- greedy: true
2718
- },
2719
- 'tag': {
2720
- pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
2721
- greedy: true,
2722
- inside: {
2723
- 'tag': {
2724
- pattern: /^<\/?[^\s>\/]+/,
2725
- inside: {
2726
- 'punctuation': /^<\/?/,
2727
- 'namespace': /^[^\s>\/:]+:/
2728
- }
2729
- },
2730
- 'special-attr': [],
2731
- 'attr-value': {
2732
- pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
2733
- inside: {
2734
- 'punctuation': [
2735
- {
2736
- pattern: /^=/,
2737
- alias: 'attr-equals'
2738
- },
2739
- {
2740
- pattern: /^(\s*)["']|["']$/,
2741
- lookbehind: true
2742
- }
2743
- ]
2744
- }
2745
- },
2746
- 'punctuation': /\/?>/,
2747
- 'attr-name': {
2748
- pattern: /[^\s>\/]+/,
2749
- inside: {
2750
- 'namespace': /^[^\s>\/:]+:/
2751
- }
2752
- }
2753
-
2754
- }
2755
- },
2756
- 'entity': [
2757
- {
2758
- pattern: /&[\da-z]{1,8};/i,
2759
- alias: 'named-entity'
2760
- },
2761
- /&#x?[\da-f]{1,8};/i
2762
- ]
2763
- };
2764
-
2765
- Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] =
2766
- Prism.languages.markup['entity'];
2767
- Prism.languages.markup['doctype'].inside['internal-subset'].inside = Prism.languages.markup;
2768
-
2769
- // Plugin to make entity title show the real entity, idea by Roman Komarov
2770
- Prism.hooks.add('wrap', function (env) {
2771
-
2772
- if (env.type === 'entity') {
2773
- env.attributes['title'] = env.content.replace(/&amp;/, '&');
2774
- }
2775
- });
2776
-
2777
- Object.defineProperty(Prism.languages.markup.tag, 'addInlined', {
2778
- /**
2779
- * Adds an inlined language to markup.
2780
- *
2781
- * An example of an inlined language is CSS with `<style>` tags.
2782
- *
2783
- * @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
2784
- * case insensitive.
2785
- * @param {string} lang The language key.
2786
- * @example
2787
- * addInlined('style', 'css');
2788
- */
2789
- value: function addInlined(tagName, lang) {
2790
- var includedCdataInside = {};
2791
- includedCdataInside['language-' + lang] = {
2792
- pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
2793
- lookbehind: true,
2794
- inside: Prism.languages[lang]
2795
- };
2796
- includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i;
2797
-
2798
- var inside = {
2799
- 'included-cdata': {
2800
- pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
2801
- inside: includedCdataInside
2802
- }
2803
- };
2804
- inside['language-' + lang] = {
2805
- pattern: /[\s\S]+/,
2806
- inside: Prism.languages[lang]
2807
- };
2808
-
2809
- var def = {};
2810
- def[tagName] = {
2811
- pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function () { return tagName; }), 'i'),
2812
- lookbehind: true,
2813
- greedy: true,
2814
- inside: inside
2815
- };
2816
-
2817
- Prism.languages.insertBefore('markup', 'cdata', def);
2818
- }
2819
- });
2820
- Object.defineProperty(Prism.languages.markup.tag, 'addAttribute', {
2821
- /**
2822
- * Adds an pattern to highlight languages embedded in HTML attributes.
2823
- *
2824
- * An example of an inlined language is CSS with `style` attributes.
2825
- *
2826
- * @param {string} attrName The name of the tag that contains the inlined language. This name will be treated as
2827
- * case insensitive.
2828
- * @param {string} lang The language key.
2829
- * @example
2830
- * addAttribute('style', 'css');
2831
- */
2832
- value: function (attrName, lang) {
2833
- Prism.languages.markup.tag.inside['special-attr'].push({
2834
- pattern: RegExp(
2835
- /(^|["'\s])/.source + '(?:' + attrName + ')' + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
2836
- 'i'
2837
- ),
2838
- lookbehind: true,
2839
- inside: {
2840
- 'attr-name': /^[^\s=]+/,
2841
- 'attr-value': {
2842
- pattern: /=[\s\S]+/,
2843
- inside: {
2844
- 'value': {
2845
- pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
2846
- lookbehind: true,
2847
- alias: [lang, 'language-' + lang],
2848
- inside: Prism.languages[lang]
2849
- },
2850
- 'punctuation': [
2851
- {
2852
- pattern: /^=/,
2853
- alias: 'attr-equals'
2854
- },
2855
- /"|'/
2856
- ]
2857
- }
2858
- }
2859
- }
2860
- });
2861
- }
2862
- });
2863
-
2864
- Prism.languages.html = Prism.languages.markup;
2865
- Prism.languages.mathml = Prism.languages.markup;
2866
- Prism.languages.svg = Prism.languages.markup;
2867
-
2868
- Prism.languages.xml = Prism.languages.extend('markup', {});
2869
- Prism.languages.ssml = Prism.languages.xml;
2870
- Prism.languages.atom = Prism.languages.xml;
2871
- Prism.languages.rss = Prism.languages.xml;
2872
-
2873
-
2874
- /* **********************************************
2875
- Begin prism-css.js
2876
- ********************************************** */
2877
-
2878
- (function (Prism) {
2879
-
2880
- var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
2881
-
2882
- Prism.languages.css = {
2883
- 'comment': /\/\*[\s\S]*?\*\//,
2884
- 'atrule': {
2885
- pattern: RegExp('@[\\w-](?:' + /[^;{\s"']|\s+(?!\s)/.source + '|' + string.source + ')*?' + /(?:;|(?=\s*\{))/.source),
2886
- inside: {
2887
- 'rule': /^@[\w-]+/,
2888
- 'selector-function-argument': {
2889
- pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
2890
- lookbehind: true,
2891
- alias: 'selector'
2892
- },
2893
- 'keyword': {
2894
- pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
2895
- lookbehind: true
2896
- }
2897
- // See rest below
2898
- }
2899
- },
2900
- 'url': {
2901
- // https://drafts.csswg.org/css-values-3/#urls
2902
- pattern: RegExp('\\burl\\((?:' + string.source + '|' + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ')\\)', 'i'),
2903
- greedy: true,
2904
- inside: {
2905
- 'function': /^url/i,
2906
- 'punctuation': /^\(|\)$/,
2907
- 'string': {
2908
- pattern: RegExp('^' + string.source + '$'),
2909
- alias: 'url'
2910
- }
2911
- }
2912
- },
2913
- 'selector': {
2914
- pattern: RegExp('(^|[{}\\s])[^{}\\s](?:[^{};"\'\\s]|\\s+(?![\\s{])|' + string.source + ')*(?=\\s*\\{)'),
2915
- lookbehind: true
2916
- },
2917
- 'string': {
2918
- pattern: string,
2919
- greedy: true
2920
- },
2921
- 'property': {
2922
- pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
2923
- lookbehind: true
2924
- },
2925
- 'important': /!important\b/i,
2926
- 'function': {
2927
- pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
2928
- lookbehind: true
2929
- },
2930
- 'punctuation': /[(){};:,]/
2931
- };
2932
-
2933
- Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
2934
-
2935
- var markup = Prism.languages.markup;
2936
- if (markup) {
2937
- markup.tag.addInlined('style', 'css');
2938
- markup.tag.addAttribute('style', 'css');
2939
- }
2940
-
2941
- }(Prism));
2942
-
2943
-
2944
- /* **********************************************
2945
- Begin prism-clike.js
2946
- ********************************************** */
2947
-
2948
- Prism.languages.clike = {
2949
- 'comment': [
2950
- {
2951
- pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
2952
- lookbehind: true,
2953
- greedy: true
2954
- },
2955
- {
2956
- pattern: /(^|[^\\:])\/\/.*/,
2957
- lookbehind: true,
2958
- greedy: true
2959
- }
2960
- ],
2961
- 'string': {
2962
- pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
2963
- greedy: true
2964
- },
2965
- 'class-name': {
2966
- pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
2967
- lookbehind: true,
2968
- inside: {
2969
- 'punctuation': /[.\\]/
2970
- }
2971
- },
2972
- 'keyword': /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
2973
- 'boolean': /\b(?:false|true)\b/,
2974
- 'function': /\b\w+(?=\()/,
2975
- 'number': /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
2976
- 'operator': /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
2977
- 'punctuation': /[{}[\];(),.:]/
2978
- };
2979
-
2980
-
2981
- /* **********************************************
2982
- Begin prism-javascript.js
2983
- ********************************************** */
2984
-
2985
- Prism.languages.javascript = Prism.languages.extend('clike', {
2986
- 'class-name': [
2987
- Prism.languages.clike['class-name'],
2988
- {
2989
- pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
2990
- lookbehind: true
2991
- }
2992
- ],
2993
- 'keyword': [
2994
- {
2995
- pattern: /((?:^|\})\s*)catch\b/,
2996
- lookbehind: true
2997
- },
2998
- {
2999
- pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
3000
- lookbehind: true
3001
- },
3002
- ],
3003
- // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
3004
- 'function': /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
3005
- 'number': {
3006
- pattern: RegExp(
3007
- /(^|[^\w$])/.source +
3008
- '(?:' +
3009
- (
3010
- // constant
3011
- /NaN|Infinity/.source +
3012
- '|' +
3013
- // binary integer
3014
- /0[bB][01]+(?:_[01]+)*n?/.source +
3015
- '|' +
3016
- // octal integer
3017
- /0[oO][0-7]+(?:_[0-7]+)*n?/.source +
3018
- '|' +
3019
- // hexadecimal integer
3020
- /0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source +
3021
- '|' +
3022
- // decimal bigint
3023
- /\d+(?:_\d+)*n/.source +
3024
- '|' +
3025
- // decimal number (integer or float) but no bigint
3026
- /(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source
3027
- ) +
3028
- ')' +
3029
- /(?![\w$])/.source
3030
- ),
3031
- lookbehind: true
3032
- },
3033
- 'operator': /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
3034
- });
3035
-
3036
- Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;
3037
-
3038
- Prism.languages.insertBefore('javascript', 'keyword', {
3039
- 'regex': {
3040
- pattern: RegExp(
3041
- // lookbehind
3042
- // eslint-disable-next-line regexp/no-dupe-characters-character-class
3043
- /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source +
3044
- // Regex pattern:
3045
- // There are 2 regex patterns here. The RegExp set notation proposal added support for nested character
3046
- // classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible
3047
- // with the only syntax, so we have to define 2 different regex patterns.
3048
- /\//.source +
3049
- '(?:' +
3050
- /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source +
3051
- '|' +
3052
- // `v` flag syntax. This supports 3 levels of nested character classes.
3053
- /(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source +
3054
- ')' +
3055
- // lookahead
3056
- /(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
3057
- ),
3058
- lookbehind: true,
3059
- greedy: true,
3060
- inside: {
3061
- 'regex-source': {
3062
- pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
3063
- lookbehind: true,
3064
- alias: 'language-regex',
3065
- inside: Prism.languages.regex
3066
- },
3067
- 'regex-delimiter': /^\/|\/$/,
3068
- 'regex-flags': /^[a-z]+$/,
3069
- }
3070
- },
3071
- // This must be declared before keyword because we use "function" inside the look-forward
3072
- 'function-variable': {
3073
- pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,
3074
- alias: 'function'
3075
- },
3076
- 'parameter': [
3077
- {
3078
- pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
3079
- lookbehind: true,
3080
- inside: Prism.languages.javascript
3081
- },
3082
- {
3083
- pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
3084
- lookbehind: true,
3085
- inside: Prism.languages.javascript
3086
- },
3087
- {
3088
- pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
3089
- lookbehind: true,
3090
- inside: Prism.languages.javascript
3091
- },
3092
- {
3093
- pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,
3094
- lookbehind: true,
3095
- inside: Prism.languages.javascript
3096
- }
3097
- ],
3098
- 'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/
3099
- });
3100
-
3101
- Prism.languages.insertBefore('javascript', 'string', {
3102
- 'hashbang': {
3103
- pattern: /^#!.*/,
3104
- greedy: true,
3105
- alias: 'comment'
3106
- },
3107
- 'template-string': {
3108
- pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
3109
- greedy: true,
3110
- inside: {
3111
- 'template-punctuation': {
3112
- pattern: /^`|`$/,
3113
- alias: 'string'
3114
- },
3115
- 'interpolation': {
3116
- pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
3117
- lookbehind: true,
3118
- inside: {
3119
- 'interpolation-punctuation': {
3120
- pattern: /^\$\{|\}$/,
3121
- alias: 'punctuation'
3122
- },
3123
- rest: Prism.languages.javascript
3124
- }
3125
- },
3126
- 'string': /[\s\S]+/
3127
- }
3128
- },
3129
- 'string-property': {
3130
- pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
3131
- lookbehind: true,
3132
- greedy: true,
3133
- alias: 'property'
3134
- }
3135
- });
3136
-
3137
- Prism.languages.insertBefore('javascript', 'operator', {
3138
- 'literal-property': {
3139
- pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
3140
- lookbehind: true,
3141
- alias: 'property'
3142
- },
3143
- });
3144
-
3145
- if (Prism.languages.markup) {
3146
- Prism.languages.markup.tag.addInlined('script', 'javascript');
3147
-
3148
- // add attribute support for all DOM events.
3149
- // https://developer.mozilla.org/en-US/docs/Web/Events#Standard_events
3150
- Prism.languages.markup.tag.addAttribute(
3151
- /on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,
3152
- 'javascript'
3153
- );
3154
- }
3155
-
3156
- Prism.languages.js = Prism.languages.javascript;
3157
-
3158
-
3159
- /* **********************************************
3160
- Begin prism-file-highlight.js
3161
- ********************************************** */
3162
-
3163
- (function () {
3164
-
3165
- if (typeof Prism === 'undefined' || typeof document === 'undefined') {
3166
- return;
3167
- }
3168
-
3169
- // https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#Polyfill
3170
- if (!Element.prototype.matches) {
3171
- Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
3172
- }
3173
-
3174
- var LOADING_MESSAGE = 'Loading…';
3175
- var FAILURE_MESSAGE = function (status, message) {
3176
- return '✖ Error ' + status + ' while fetching file: ' + message;
3177
- };
3178
- var FAILURE_EMPTY_MESSAGE = '✖ Error: File does not exist or is empty';
3179
-
3180
- var EXTENSIONS = {
3181
- 'js': 'javascript',
3182
- 'py': 'python',
3183
- 'rb': 'ruby',
3184
- 'ps1': 'powershell',
3185
- 'psm1': 'powershell',
3186
- 'sh': 'bash',
3187
- 'bat': 'batch',
3188
- 'h': 'c',
3189
- 'tex': 'latex'
3190
- };
3191
-
3192
- var STATUS_ATTR = 'data-src-status';
3193
- var STATUS_LOADING = 'loading';
3194
- var STATUS_LOADED = 'loaded';
3195
- var STATUS_FAILED = 'failed';
3196
-
3197
- var SELECTOR = 'pre[data-src]:not([' + STATUS_ATTR + '="' + STATUS_LOADED + '"])'
3198
- + ':not([' + STATUS_ATTR + '="' + STATUS_LOADING + '"])';
3199
-
3200
- /**
3201
- * Loads the given file.
3202
- *
3203
- * @param {string} src The URL or path of the source file to load.
3204
- * @param {(result: string) => void} success
3205
- * @param {(reason: string) => void} error
3206
- */
3207
- function loadFile(src, success, error) {
3208
- var xhr = new XMLHttpRequest();
3209
- xhr.open('GET', src, true);
3210
- xhr.onreadystatechange = function () {
3211
- if (xhr.readyState == 4) {
3212
- if (xhr.status < 400 && xhr.responseText) {
3213
- success(xhr.responseText);
3214
- } else {
3215
- if (xhr.status >= 400) {
3216
- error(FAILURE_MESSAGE(xhr.status, xhr.statusText));
3217
- } else {
3218
- error(FAILURE_EMPTY_MESSAGE);
3219
- }
3220
- }
3221
- }
3222
- };
3223
- xhr.send(null);
3224
- }
3225
-
3226
- /**
3227
- * Parses the given range.
3228
- *
3229
- * This returns a range with inclusive ends.
3230
- *
3231
- * @param {string | null | undefined} range
3232
- * @returns {[number, number | undefined] | undefined}
3233
- */
3234
- function parseRange(range) {
3235
- var m = /^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(range || '');
3236
- if (m) {
3237
- var start = Number(m[1]);
3238
- var comma = m[2];
3239
- var end = m[3];
3240
-
3241
- if (!comma) {
3242
- return [start, start];
3243
- }
3244
- if (!end) {
3245
- return [start, undefined];
3246
- }
3247
- return [start, Number(end)];
3248
- }
3249
- return undefined;
3250
- }
3251
-
3252
- Prism.hooks.add('before-highlightall', function (env) {
3253
- env.selector += ', ' + SELECTOR;
3254
- });
3255
-
3256
- Prism.hooks.add('before-sanity-check', function (env) {
3257
- var pre = /** @type {HTMLPreElement} */ (env.element);
3258
- if (pre.matches(SELECTOR)) {
3259
- env.code = ''; // fast-path the whole thing and go to complete
3260
-
3261
- pre.setAttribute(STATUS_ATTR, STATUS_LOADING); // mark as loading
3262
-
3263
- // add code element with loading message
3264
- var code = pre.appendChild(document.createElement('CODE'));
3265
- code.textContent = LOADING_MESSAGE;
3266
-
3267
- var src = pre.getAttribute('data-src');
3268
-
3269
- var language = env.language;
3270
- if (language === 'none') {
3271
- // the language might be 'none' because there is no language set;
3272
- // in this case, we want to use the extension as the language
3273
- var extension = (/\.(\w+)$/.exec(src) || [, 'none'])[1];
3274
- language = EXTENSIONS[extension] || extension;
3275
- }
3276
-
3277
- // set language classes
3278
- Prism.util.setLanguage(code, language);
3279
- Prism.util.setLanguage(pre, language);
3280
-
3281
- // preload the language
3282
- var autoloader = Prism.plugins.autoloader;
3283
- if (autoloader) {
3284
- autoloader.loadLanguages(language);
3285
- }
3286
-
3287
- // load file
3288
- loadFile(
3289
- src,
3290
- function (text) {
3291
- // mark as loaded
3292
- pre.setAttribute(STATUS_ATTR, STATUS_LOADED);
3293
-
3294
- // handle data-range
3295
- var range = parseRange(pre.getAttribute('data-range'));
3296
- if (range) {
3297
- var lines = text.split(/\r\n?|\n/g);
3298
-
3299
- // the range is one-based and inclusive on both ends
3300
- var start = range[0];
3301
- var end = range[1] == null ? lines.length : range[1];
3302
-
3303
- if (start < 0) { start += lines.length; }
3304
- start = Math.max(0, Math.min(start - 1, lines.length));
3305
- if (end < 0) { end += lines.length; }
3306
- end = Math.max(0, Math.min(end, lines.length));
3307
-
3308
- text = lines.slice(start, end).join('\n');
3309
-
3310
- // add data-start for line numbers
3311
- if (!pre.hasAttribute('data-start')) {
3312
- pre.setAttribute('data-start', String(start + 1));
3313
- }
3314
- }
3315
-
3316
- // highlight code
3317
- code.textContent = text;
3318
- Prism.highlightElement(code);
3319
- },
3320
- function (error) {
3321
- // mark as failed
3322
- pre.setAttribute(STATUS_ATTR, STATUS_FAILED);
3323
-
3324
- code.textContent = error;
3325
- }
3326
- );
3327
- }
3328
- });
3329
-
3330
- Prism.plugins.fileHighlight = {
3331
- /**
3332
- * Executes the File Highlight plugin for all matching `pre` elements under the given container.
3333
- *
3334
- * Note: Elements which are already loaded or currently loading will not be touched by this method.
3335
- *
3336
- * @param {ParentNode} [container=document]
3337
- */
3338
- highlight: function highlight(container) {
3339
- var elements = (container || document).querySelectorAll(SELECTOR);
3340
-
3341
- for (var i = 0, element; (element = elements[i++]);) {
3342
- Prism.highlightElement(element);
3343
- }
3344
- }
3345
- };
3346
-
3347
- var logged = false;
3348
- /** @deprecated Use `Prism.plugins.fileHighlight.highlight` instead. */
3349
- Prism.fileHighlight = function () {
3350
- if (!logged) {
3351
- console.warn('Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead.');
3352
- logged = true;
3353
- }
3354
- Prism.plugins.fileHighlight.highlight.apply(this, arguments);
3355
- };
3356
-
3357
- }());
3358
- } (prism));
3359
-
3360
- var prismExports = prism.exports;
3361
- var Prism = /*@__PURE__*/getDefaultExportFromCjs(prismExports);
3362
-
3363
1384
  /******************************************************************************
3364
1385
  Copyright (c) Microsoft Corporation.
3365
1386
 
@@ -3561,8 +1582,8 @@ var MarkdownTableError = /** @class */ (function (_super) {
3561
1582
  * @param props - The props to validate.
3562
1583
  */
3563
1584
  function validateMarkdownTableProps(props) {
3564
- var _a = props.data, data = _a === void 0 ? null : _a, _b = props.hasHeader, hasHeader = _b === void 0 ? true : _b, columnAlignments = props.columnAlignments, _c = props.isCompact, isCompact = _c === void 0 ? false : _c, _d = props.hasTabs, hasTabs = _d === void 0 ? false : _d, _e = props.canReplaceNewlines, canReplaceNewlines = _e === void 0 ? false : _e;
3565
- if (!data || !Array.isArray(data)) {
1585
+ var data = props.data, _a = props.hasHeader, hasHeader = _a === void 0 ? true : _a, columnAlignments = props.columnAlignments, _b = props.isCompact, isCompact = _b === void 0 ? false : _b, _c = props.hasTabs, hasTabs = _c === void 0 ? false : _c, _d = props.canReplaceNewlines, canReplaceNewlines = _d === void 0 ? false : _d;
1586
+ if (!Array.isArray(data)) {
3566
1587
  throw new MarkdownTableError("The 'data' prop must be a two-dimensional array.");
3567
1588
  }
3568
1589
  if (data.length === 0) {
@@ -3619,19 +1640,16 @@ function validateMarkdownTableProps(props) {
3619
1640
  }
3620
1641
 
3621
1642
  /**
3622
- * React component that generates and displays Markdown table syntax with syntax highlighting and line numbers.
1643
+ * React component that generates and displays Markdown table syntax.
3623
1644
  * @param props - The input parameters for table generation.
3624
1645
  * @returns A <pre> element containing the Markdown table syntax or an error message.
3625
1646
  */
3626
1647
  var MarkdownTable = function (_a) {
3627
- var _b = _a.data, data = _b === void 0 ? null : _b, _c = _a.hasHeader, hasHeader = _c === void 0 ? true : _c, _d = _a.columnAlignments, columnAlignments = _d === void 0 ? [] : _d, _e = _a.isCompact, isCompact = _e === void 0 ? false : _e, _f = _a.hasTabs, hasTabs = _f === void 0 ? false : _f, _g = _a.canReplaceNewlines, canReplaceNewlines = _g === void 0 ? false : _g, _h = _a.className, className = _h === void 0 ? '' : _h, onTableCreate = _a.onTableCreate, _j = _a.theme, theme = _j === void 0 ? 'prism' : _j;
3628
- // Ref to the code element
3629
- var codeRef = require$$0.useRef(null);
1648
+ var _b = _a.data, data = _b === void 0 ? null : _b, _c = _a.hasHeader, hasHeader = _c === void 0 ? true : _c, _d = _a.columnAlignments, columnAlignments = _d === void 0 ? [] : _d, _e = _a.isCompact, isCompact = _e === void 0 ? false : _e, _f = _a.hasTabs, hasTabs = _f === void 0 ? false : _f, _g = _a.canReplaceNewlines, canReplaceNewlines = _g === void 0 ? false : _g, className = _a.className, onTableCreate = _a.onTableCreate;
3630
1649
  // Invert isCompact to get adjustColumnWidths
3631
1650
  var adjustColumnWidths = !isCompact;
3632
1651
  // Generate Markdown table
3633
1652
  var markdownSyntax = require$$0.useMemo(function () {
3634
- var _a;
3635
1653
  if (data === null) {
3636
1654
  return 'Error: No data provided for the table.';
3637
1655
  }
@@ -3651,13 +1669,9 @@ var MarkdownTable = function (_a) {
3651
1669
  rows: data.slice(1),
3652
1670
  }
3653
1671
  : {
3654
- header: generateAlphabetHeaders(((_a = data[0]) === null || _a === void 0 ? void 0 : _a.length) || 0),
1672
+ header: generateAlphabetHeaders(data[0].length),
3655
1673
  rows: data,
3656
1674
  };
3657
- // Handle case where data might be an empty array
3658
- if (!tableData.header || tableData.rows === undefined) {
3659
- throw new MarkdownTableError('Data provided is incomplete or malformed.');
3660
- }
3661
1675
  return generateMarkdownTableString(tableData, columnAlignments, adjustColumnWidths, hasTabs, canReplaceNewlines);
3662
1676
  }
3663
1677
  catch (error) {
@@ -3665,8 +1679,7 @@ var MarkdownTable = function (_a) {
3665
1679
  return "Error: ".concat(error.message);
3666
1680
  }
3667
1681
  else {
3668
- // Optionally, you can handle unexpected errors here
3669
- return 'An unexpected error occurred while generating the table.';
1682
+ throw error;
3670
1683
  }
3671
1684
  }
3672
1685
  }, [
@@ -3676,30 +1689,13 @@ var MarkdownTable = function (_a) {
3676
1689
  isCompact,
3677
1690
  hasTabs,
3678
1691
  canReplaceNewlines,
3679
- adjustColumnWidths,
3680
1692
  ]);
3681
1693
  require$$0.useEffect(function () {
3682
1694
  if (onTableCreate) {
3683
1695
  onTableCreate(markdownSyntax);
3684
1696
  }
3685
1697
  }, [markdownSyntax, onTableCreate]);
3686
- require$$0.useEffect(function () {
3687
- // Ensure that Prism and window are available (client-side)
3688
- if (typeof window !== 'undefined') {
3689
- // Dynamically import the desired theme CSS
3690
- (function (t) { return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(t)); }); })("../styles/themes/".concat(theme, ".css"))
3691
- .then(function () {
3692
- // Once the theme CSS is loaded, highlight the code
3693
- if (codeRef.current) {
3694
- Prism.highlightElement(codeRef.current);
3695
- }
3696
- })
3697
- .catch(function (err) {
3698
- console.error("Failed to load Prism theme: ".concat(theme), err);
3699
- });
3700
- }
3701
- }, [markdownSyntax, theme]);
3702
- return (jsxRuntimeExports.jsx("pre", { className: "line-numbers language-markdown ".concat(className), children: jsxRuntimeExports.jsx("code", { ref: codeRef, className: "language-markdown", children: markdownSyntax }) }));
1698
+ return jsxRuntimeExports.jsx("pre", { className: className, children: markdownSyntax });
3703
1699
  };
3704
1700
  /**
3705
1701
  * Generates alphabetical headers (A, B, C, ...) based on the number of columns.