react-markdown-table-ts 0.1.5 → 0.1.7

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