@heartlandone/vega 2.75.0 → 2.76.0
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/cjs/{app-globals-bf183914.js → app-globals-12b7d808.js} +28 -32
- package/dist/cjs/breakpoints-751d433a.js +56 -0
- package/dist/cjs/{child-nodes-event-prevent-slimmer-aca87dac.js → child-nodes-event-prevent-slimmer-84435957.js} +2 -2
- package/dist/cjs/{child-nodes-notify-observer-slimmer-257fedb3.js → child-nodes-notify-observer-slimmer-ed39283b.js} +1 -1
- package/dist/cjs/{code-block-c1d2e6a8.js → code-block-f1480ec3.js} +17 -17
- package/dist/cjs/{component-global-style-slimmer-adfa2e59.js → component-global-style-slimmer-93c5fb50.js} +2 -1
- package/dist/cjs/{component-usage-runtime-metrics-d10ace87.js → component-usage-runtime-metrics-4572c5b7.js} +1 -1
- package/dist/cjs/{component-value-history-controller-slimmer.abstract-787c67dc.js → component-value-history-controller-slimmer.abstract-a9264cc8.js} +5 -5
- package/dist/cjs/{create-public-api-runtime-metrics-slimmer-e2e274e1.js → create-public-api-runtime-metrics-slimmer-9cb09fb2.js} +3 -41
- package/dist/cjs/{dark-mode-style-controller-c21172aa.js → dark-mode-style-controller-3a04af3d.js} +292 -1254
- package/dist/cjs/{date-required-rule-30ee62d0.js → date-required-rule-912469e0.js} +1 -1
- package/dist/cjs/{design-token-cbc01283.js → design-token-41baf118.js} +2 -2
- package/dist/cjs/dom-node-subject-observer-factory-c62823de.js +141 -0
- package/dist/cjs/{dto-renderer-manager-2fc24151.js → dto-renderer-manager-809c947b.js} +230 -55
- package/dist/cjs/{element-appender-slimmer-318d29c7.js → element-appender-slimmer-34e4eb56.js} +349 -166
- package/dist/cjs/{event-emit-slimmer-2dacabbd.js → event-emit-slimmer-062cdcb8.js} +2 -2
- package/dist/cjs/{feature-flag-controller-ce2162c8.js → feature-flag-controller-04cb1e69.js} +7 -1
- package/dist/cjs/{form-field-controller-slimmer-aef2fb1e.js → form-field-controller-slimmer-102f37c7.js} +13 -14
- package/dist/cjs/{internal-icon-manager-32f9ed63.js → icon-manager-c12c6ea9.js} +1 -52
- package/dist/cjs/{image-annotation-action-e4a35325.js → image-annotation-action-8d9fa20c.js} +10 -9
- package/dist/cjs/index-592b4052.js +220 -0
- package/dist/cjs/{index-4d7bce1a.js → index-f054eb5d.js} +15 -3
- package/dist/cjs/index.cjs.js +68 -65
- package/dist/cjs/{inject-keyboard-manager-d21b4387.js → inject-keyboard-manager-0f5bd568.js} +1 -1
- package/dist/cjs/internal-icon-manager-c989189a.js +55 -0
- package/dist/cjs/{translation-5f9f9c0c.js → internal-translation-controller-053eb0f1.js} +0 -93
- package/dist/cjs/{internal-vega-event-manager-6befeb34.js → internal-vega-event-manager-f7ecf3d4.js} +81 -81
- package/dist/cjs/internal-vega-z-index-manager-f03ddb37.js +180 -0
- package/dist/cjs/{keyboard-manager-3dea6b28.js → keyboard-manager-055e9f67.js} +2 -2
- package/dist/cjs/{keyboard-manager-slimmer-0d45f944.js → keyboard-manager-slimmer-0cc0c1c7.js} +1 -1
- package/dist/cjs/loader.cjs.js +26 -23
- package/dist/cjs/misc-3d30df91.js +41 -0
- package/dist/cjs/{month-view-generator-49cc5fc2.js → month-view-generator-6a6dd527.js} +1 -1
- package/dist/cjs/{page-resize-observer-slimmer-11937d6f.js → page-resize-observer-slimmer-7f065ee1.js} +2 -54
- package/dist/cjs/{public-rules-661823fa.js → public-rules-922849f3.js} +12 -13
- package/dist/cjs/{range-79b668e7.js → range-8aa49b08.js} +2 -2
- package/dist/cjs/{responsive-format-facade-f71d399c.js → responsive-format-facade-ea59bdcd.js} +13 -22
- package/dist/cjs/{rich-text-editor-required-rule-d5feeffd.js → rich-text-editor-required-rule-22225840.js} +1 -1
- package/dist/cjs/{string-format-strategy.abstract-63514c60.js → string-format-strategy.abstract-f2575647.js} +1 -1
- package/dist/cjs/{string-input-formatter-slimmer-f3e0bbc7.js → string-input-formatter-slimmer-0a334fc6.js} +5 -5
- package/dist/cjs/{string-mask-strategy-d23ac21a.js → string-mask-strategy-dda58395.js} +2 -2
- package/dist/cjs/{style-formatter-566df206.js → style-formatter-0c3ced39.js} +2 -2
- package/dist/cjs/{sub-state-notify-slimmer-468e19aa.js → sub-state-notify-slimmer-58121111.js} +1 -1
- package/dist/cjs/{sub-state-observer-slimmer-5d0b8ac3.js → sub-state-observer-slimmer-1dfbc4c3.js} +2 -2
- package/dist/cjs/{time-required-rule-c96ecdc9.js → time-required-rule-d6fa7aa8.js} +1 -1
- package/dist/cjs/{function-extension-ca9aa115.js → token-extension-07cac85d.js} +501 -387
- package/dist/cjs/{translation-slimmer-f0ebe710.js → translation-slimmer-4533bd67.js} +4 -4
- package/dist/cjs/{type-guard-a0f026d8.js → type-guard-407ba0b8.js} +3 -3
- package/dist/cjs/{ui-9e181079.js → ui-234ea151.js} +12 -0
- package/dist/cjs/{valid-credit-card-number-rule-c854bed9.js → valid-credit-card-number-rule-41a8b51b.js} +1 -1
- package/dist/cjs/vega-accordion.cjs.entry.js +21 -30
- package/dist/cjs/vega-app-footer.cjs.entry.js +3 -3
- package/dist/cjs/vega-app-header-button.cjs.entry.js +183 -49
- package/dist/cjs/vega-backdrop.cjs.entry.js +2 -2
- package/dist/cjs/vega-banner.cjs.entry.js +15 -13
- package/dist/cjs/vega-bar-chart.cjs.entry.js +1 -1
- package/dist/cjs/vega-box.cjs.entry.js +18 -33
- package/dist/cjs/vega-brand-logo.cjs.entry.js +7 -5
- package/dist/cjs/vega-breadcrumb.cjs.entry.js +14 -13
- package/dist/cjs/vega-button-circle.cjs.entry.js +20 -30
- package/dist/cjs/vega-button-group_2.cjs.entry.js +15 -15
- package/dist/cjs/vega-button-link.cjs.entry.js +15 -14
- package/dist/cjs/vega-button.cjs.entry.js +21 -30
- package/dist/cjs/vega-calendar_4.cjs.entry.js +48 -45
- package/dist/cjs/vega-card.cjs.entry.js +9 -28
- package/dist/cjs/vega-carousel.cjs.entry.js +15 -26
- package/dist/cjs/vega-checkbox_2.cjs.entry.js +22 -20
- package/dist/cjs/vega-chip.cjs.entry.js +22 -33
- package/dist/cjs/vega-code-block.cjs.entry.js +658 -2709
- package/dist/cjs/vega-color-picker.cjs.entry.js +15 -12
- package/dist/cjs/vega-combo-box.cjs.entry.js +29 -28
- package/dist/cjs/vega-counter-badge.cjs.entry.js +1 -1
- package/dist/cjs/vega-date-picker_2.cjs.entry.js +53 -56
- package/dist/cjs/vega-dialog-controller-03ef4d9a.js +84 -0
- package/dist/cjs/vega-dialog_2.cjs.entry.js +37 -44
- package/dist/cjs/vega-divider.cjs.entry.js +12 -30
- package/dist/cjs/vega-dropdown_5.cjs.entry.js +49 -55
- package/dist/cjs/vega-env-manager-23b8b23c.js +2 -2
- package/dist/cjs/{dom-node-subject-observer-factory-b5e71bf6.js → vega-event-id-ee01d8dd.js} +0 -139
- package/dist/cjs/vega-field-error.cjs.entry.js +1 -1
- package/dist/cjs/vega-field-label.cjs.entry.js +9 -8
- package/dist/cjs/vega-file-uploader.cjs.entry.js +28 -23
- package/dist/cjs/vega-flag-icon.cjs.entry.js +13 -27
- package/dist/cjs/vega-flex.cjs.entry.js +11 -28
- package/dist/cjs/vega-font.cjs.entry.js +12 -29
- package/dist/cjs/vega-form.cjs.entry.js +24 -22
- package/dist/cjs/vega-grid.cjs.entry.js +9 -28
- package/dist/cjs/vega-hint.cjs.entry.js +1 -1
- package/dist/cjs/vega-icon.cjs.entry.js +18 -31
- package/dist/cjs/vega-image-uploader.cjs.entry.js +34 -37
- package/dist/cjs/vega-input-credit-card.cjs.entry.js +31 -27
- package/dist/cjs/vega-input-numeric.cjs.entry.js +24 -22
- package/dist/cjs/vega-input-passcode.cjs.entry.js +26 -24
- package/dist/cjs/vega-input-phone-number.cjs.entry.js +31 -35
- package/dist/cjs/vega-input-range.cjs.entry.js +22 -20
- package/dist/cjs/vega-input-select.cjs.entry.js +41 -46
- package/dist/cjs/vega-input.cjs.entry.js +43 -31
- package/dist/cjs/vega-item-toggle.cjs.entry.js +8 -7
- package/dist/cjs/vega-left-nav_5.cjs.entry.js +38 -40
- package/dist/cjs/vega-line-chart.cjs.entry.js +1 -1
- package/dist/cjs/vega-loader-wrapper_2.cjs.entry.js +16 -32
- package/dist/cjs/vega-page-notification_2.cjs.entry.js +5 -4
- package/dist/cjs/vega-pagination-page-selector-mobile.cjs.entry.js +12 -12
- package/dist/cjs/vega-pagination-page-size-selector-mobile.cjs.entry.js +9 -10
- package/dist/cjs/vega-pagination.cjs.entry.js +28 -38
- package/dist/cjs/vega-pie-chart.cjs.entry.js +1 -1
- package/dist/cjs/vega-popover_2.cjs.entry.js +21 -31
- package/dist/cjs/vega-progress-tracker_2.cjs.entry.js +66 -39
- package/dist/cjs/vega-radio_2.cjs.entry.js +25 -23
- package/dist/cjs/vega-rich-text-content.cjs.entry.js +22 -20
- package/dist/cjs/vega-rich-text-editor_4.cjs.entry.js +115 -62
- package/dist/cjs/vega-section-title.cjs.entry.js +1 -1
- package/dist/cjs/vega-segment-control.cjs.entry.js +10 -8
- package/dist/cjs/vega-selection-chip_2.cjs.entry.js +25 -32
- package/dist/cjs/vega-selection-tile_2.cjs.entry.js +22 -20
- package/dist/cjs/vega-sidenav_3.cjs.entry.js +34 -40
- package/dist/cjs/vega-signature-capture.cjs.entry.js +27 -31
- package/dist/cjs/vega-skeleton.cjs.entry.js +1 -1
- package/dist/cjs/vega-slot-container.cjs.entry.js +1 -1
- package/dist/cjs/vega-stepper.cjs.entry.js +23 -21
- package/dist/cjs/vega-tab-group_2.cjs.entry.js +15 -14
- package/dist/cjs/vega-table_11.cjs.entry.js +67 -68
- package/dist/cjs/vega-text.cjs.entry.js +4 -3
- package/dist/cjs/vega-textarea.cjs.entry.js +22 -20
- package/dist/cjs/vega-time-picker_2.cjs.entry.js +35 -41
- package/dist/cjs/vega-toggle-switch.cjs.entry.js +15 -12
- package/dist/cjs/vega-tooltip_2.cjs.entry.js +17 -28
- package/dist/cjs/vega.cjs.js +26 -23
- package/dist/cjs/{index-95fca64f.js → wait-for-component-did-render-70a01bf9.js} +1 -12
- package/dist/collection/components/vega-app-header-button/vega-app-header-button.js +17 -2
- package/dist/collection/components/vega-box/slimmers/controllers/vega-box-responsive-style-controller.js +2 -1
- package/dist/collection/components/vega-box/slimmers/controllers/vega-box-state-styles-controller.js +2 -1
- package/dist/collection/components/vega-button/vega-button.js +2 -1
- package/dist/collection/components/vega-button-circle/vega-button-circle.js +2 -1
- package/dist/collection/components/vega-button-link/vega-button-link.css +1 -1
- package/dist/collection/components/vega-button-link/vega-button-link.js +2 -1
- package/dist/collection/components/vega-calendar/slimmers/common/helpers/repeat-pattern/base-repeat-pattern.js +1 -1
- package/dist/collection/components/vega-calendar/slimmers/common/helpers/repeat-pattern/calendar-event-daily-repeat-pattern.js +1 -1
- package/dist/collection/components/vega-calendar/slimmers/common/helpers/repeat-pattern/calendar-event-monthly-repeat-pattern.js +1 -1
- package/dist/collection/components/vega-calendar/slimmers/common/helpers/repeat-pattern/calendar-event-weekly-repeat-pattern.js +1 -1
- package/dist/collection/components/vega-calendar/slimmers/common/helpers/repeat-pattern/calendar-event-yearly-repeat-pattern.js +1 -1
- package/dist/collection/components/vega-code-block/slimmers/controllers/prism-code-highlight-parse-controller.js +5 -14
- package/dist/collection/components/vega-combo-box/slimmers/renderers/vega-combo-box-dropdown-renderer.js +2 -2
- package/dist/collection/components/vega-date-picker/slimmers/controllers/vega-date-picker-calendar-open-state-controller.js +1 -1
- package/dist/collection/components/vega-date-picker/slimmers/renderers/vega-date-picker-calendar-renderer.js +1 -1
- package/dist/collection/components/vega-dropdown/slimmers/controllers/vega-dropdown-search-controller.js +2 -2
- package/dist/collection/components/vega-dropdown/slimmers/renderers/vega-dropdown-list-renderer.js +2 -2
- package/dist/collection/components/vega-dropdown/vega-dropdown-group/slimmers/renderers/vega-dropdown-group-renderer.js +3 -3
- package/dist/collection/components/vega-dropdown/vega-dropdown-item/slimmers/renderers/vega-dropdown-item-renderer.js +6 -4
- package/dist/collection/components/vega-icon/vega-icon.js +2 -1
- package/dist/collection/components/vega-input/slimmers/renderers/vega-input-input-container-renderer.js +10 -2
- package/dist/collection/components/vega-input-phone-number/slimmers/renderers/country-select-renderer.js +1 -1
- package/dist/collection/components/vega-input-select/slimmers/renderers/vega-input-select-dropdown-renderer.js +2 -2
- package/dist/collection/components/vega-pagination/vega-pagination.js +1 -1
- package/dist/collection/components/vega-progress-tracker/slimmers/controllers/dto/internal-progress-tracker-step.js +30 -6
- package/dist/collection/components/vega-progress-tracker/slimmers/controllers/vega-progress-tracker-current-steps-controller.js +1 -1
- package/dist/collection/components/vega-progress-tracker/slimmers/renderers/vega-progress-tracker-renderer.js +8 -1
- package/dist/collection/components/vega-progress-tracker/vega-progress-tracker-step/vega-progress-tracker-step.js +27 -0
- package/dist/collection/components/vega-progress-tracker/vega-progress-tracker.css +12 -0
- package/dist/collection/components/vega-progress-tracker/vega-progress-tracker.js +8 -3
- package/dist/collection/components/vega-rich-text-content/vega-rich-text-content.js +1 -1
- package/dist/collection/components/vega-rich-text-editor/dto/blocks/html-block.js +16 -0
- package/dist/collection/components/vega-rich-text-editor/dto/content-state.js +3 -22
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/html-cleaner/html-content-cleaner.js +59 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/html-cleaner/index.js +4 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/html-cleaner/processors/remove-whitespace-after-opening-tag-processor.js +21 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/html-cleaner/processors/remove-whitespace-before-closing-tag-processor.js +21 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/html-cleaner/processors/remove-whitespace-between-tags-processor.js +77 -0
- package/dist/collection/components/vega-rich-text-editor/slimmers/controllers/value-controller.js +1 -1
- package/dist/collection/components/vega-rich-text-editor/slimmers/renderers/tools/link-toolbar-button-slimmer.js +1 -1
- package/dist/collection/components/vega-rich-text-editor/test/dto/blocks/html-block.test.js +39 -0
- package/dist/collection/components/vega-rich-text-editor/test/dto/content-state.test.js +166 -1
- package/dist/collection/components/vega-rich-text-editor/test/html-cleaner/html-content-cleaner.test.js +186 -0
- package/dist/collection/components/vega-rich-text-editor/test/html-cleaner/remove-whitespace-after-opening-tag-processor.test.js +22 -0
- package/dist/collection/components/vega-rich-text-editor/test/html-cleaner/remove-whitespace-before-closing-tag-processor.test.js +22 -0
- package/dist/collection/components/vega-rich-text-editor/test/html-cleaner/remove-whitespace-between-tags-processor.test.js +26 -0
- package/dist/collection/components/vega-signature-capture/slimmers/written-mode/controllers/written-mode-svg-controller.js +2 -1
- package/dist/collection/components/vega-table/interface.js +3 -0
- package/dist/collection/components/vega-table/vega-table-foot-cell/slimmers/renderers/vega-table-foot-cell-renderer.js +1 -1
- package/dist/collection/global/scripts/before-vega-load.js +4 -3
- package/dist/collection/helpers/calendar/calendar-date.js +1 -1
- package/dist/collection/helpers/calendar/calendar-event.js +1 -1
- package/dist/collection/helpers/calendar/calendar-time.js +1 -1
- package/dist/collection/helpers/code-format/code-formatter.js +57 -7
- package/dist/collection/helpers/code-format/test/code-formatter.test.js +49 -1
- package/dist/collection/helpers/common/index.js +2 -37
- package/dist/collection/helpers/common/test/wait-for-vega-handler.test.js +2 -2
- package/dist/collection/helpers/common/wait-for-component-did-render.js +27 -0
- package/dist/collection/helpers/common/wait-for-vega-handler.js +12 -1
- package/dist/collection/helpers/feature-control/feature-flags-map.js +6 -0
- package/dist/collection/helpers/formatter/responsive-map-formatter/responsive-border-radius-style-formatter.js +1 -1
- package/dist/collection/helpers/public-api.js +0 -2
- package/dist/collection/helpers/slimmers/component-global-style-slimmer.js +2 -1
- package/dist/collection/helpers/slimmers/field-error-ui-controller-slimmer.js +3 -4
- package/dist/collection/helpers/slimmers/form-field-message-translator.js +1 -1
- package/dist/collection/helpers/slimmers/global/vega-translate-observer-slimmer.js +1 -1
- package/dist/collection/helpers/slimmers/global/vega-watch-method-cancel-slimmer.js +1 -1
- package/dist/collection/helpers/slimmers/mutation-observer/aria-attributes-value-mapper.js +128 -0
- package/dist/collection/helpers/slimmers/mutation-observer/test/aria-attributes-value-mapper.test.js +196 -0
- package/dist/collection/helpers/slimmers/position-calculation/base-position-calculation-strategy.js +162 -151
- package/dist/collection/helpers/slimmers/position-calculation/position-calculation-controller.js +9 -0
- package/dist/collection/helpers/slimmers/position-calculation/screen-position-calculation-strategy.js +112 -1
- package/dist/collection/helpers/slimmers/position-calculation/screen-scroll-position-update.js +53 -0
- package/dist/collection/helpers/slimmers/position-calculation/test/screen-position-calculation-strategy.test.js +103 -6
- package/dist/collection/helpers/slimmers/string-input-formatter-slimmer.js +1 -1
- package/dist/collection/helpers/slimmers/translation/translation-slimmer.js +1 -1
- package/dist/collection/helpers/theme/controllers/brand-style-controller.js +3 -1
- package/dist/collection/helpers/theme/controllers/color-schema-overriding-controller.js +8 -6
- package/dist/collection/helpers/theme/controllers/dark-mode-style-controller.js +3 -1
- package/dist/collection/helpers/theme/internal-theme-manager.js +2 -1
- package/dist/collection/helpers/theme/tests/theme-manager-controller.test.js +1 -2
- package/dist/collection/helpers/ui/element-appender.js +4 -5
- package/dist/collection/helpers/ui/test/element-appender.test.js +66 -17
- package/dist/collection/index.js +2 -0
- package/dist/collection/polyfill/prism/index.js +2 -0
- package/dist/collection/polyfill/prism/languages/css.js +86 -0
- package/dist/collection/polyfill/prism/languages/javascript.js +96 -0
- package/dist/collection/polyfill/prism/languages/jsx.js +46 -0
- package/dist/collection/polyfill/prism/languages/language-registry.js +41 -0
- package/dist/collection/polyfill/prism/languages/markup.js +71 -0
- package/dist/collection/polyfill/prism/languages/tsx.js +10 -0
- package/dist/collection/polyfill/prism/languages/typescript.js +64 -0
- package/dist/collection/polyfill/prism/test/css.test.js +61 -0
- package/dist/collection/polyfill/prism/test/javascript.test.js +113 -0
- package/dist/collection/polyfill/prism/test/jsx.test.js +48 -0
- package/dist/collection/polyfill/prism/test/language-registry.test.js +77 -0
- package/dist/collection/polyfill/prism/test/markup.test.js +57 -0
- package/dist/collection/polyfill/prism/test/test-utils.js +22 -0
- package/dist/collection/polyfill/prism/test/tokenizer.test.js +180 -0
- package/dist/collection/polyfill/prism/test/tsx.test.js +87 -0
- package/dist/collection/polyfill/prism/test/typescript.test.js +86 -0
- package/dist/collection/polyfill/prism/tokenizer.js +242 -0
- package/dist/collection/polyfill/prism/types.js +1 -0
- package/dist/collection/polyfill/tinycolor/tinycolor-polyfill.js +320 -0
- package/dist/collection/polyfill/tinycolor/tinycolor-polyfill.test.js +361 -0
- package/dist/collection/types/ui.type.js +12 -0
- package/dist/collection/utils/e2e-utils.js +10 -3
- package/dist/collection/utils/sanitize/constants/tag-sets.js +5 -0
- package/dist/collection/utils/sanitize/core/html-sanitizer.js +39 -0
- package/dist/collection/utils/sanitize/core/sanitize-strategy.js +62 -0
- package/dist/collection/utils/sanitize/core/types.js +4 -0
- package/dist/collection/utils/sanitize/index.js +12 -0
- package/dist/collection/utils/sanitize/strategies/empty-sanitize-strategy.js +17 -0
- package/dist/collection/utils/sanitize/strategies/index.js +3 -0
- package/dist/collection/utils/sanitize/strategies/label-sanitize-strategy.js +13 -0
- package/dist/collection/utils/sanitize/strategies/style-sanitize-strategy.js +50 -0
- package/dist/collection/utils/sanitize/test/empty-strategy.test.js +12 -0
- package/dist/collection/utils/sanitize/test/html-sanitizer.test.js +57 -0
- package/dist/collection/utils/sanitize/test/label-strategy.test.js +56 -0
- package/dist/collection/utils/sanitize/test/sanitize-strategy.test.js +85 -0
- package/dist/collection/utils/sanitize/test/sanitize.test.js +22 -0
- package/dist/collection/utils/sanitize/test/serialize-fragment.test.js +25 -0
- package/dist/collection/utils/sanitize/test/style-strategy.test.js +45 -0
- package/dist/collection/utils/sanitize/utils/serialize-fragment.js +17 -0
- package/dist/esm/{app-globals-f3414aca.js → app-globals-c0676920.js} +12 -16
- package/dist/esm/breakpoints-56e5407b.js +53 -0
- package/dist/esm/{child-nodes-event-prevent-slimmer-e662bee2.js → child-nodes-event-prevent-slimmer-649b9d30.js} +2 -2
- package/dist/esm/{child-nodes-notify-observer-slimmer-b676cd2b.js → child-nodes-notify-observer-slimmer-541dd6a4.js} +1 -1
- package/dist/esm/{code-block-8ee34ab6.js → code-block-b6247a45.js} +7 -7
- package/dist/esm/{component-global-style-slimmer-08046b38.js → component-global-style-slimmer-ac703085.js} +2 -1
- package/dist/esm/{component-usage-runtime-metrics-a84cc93e.js → component-usage-runtime-metrics-46020a03.js} +1 -1
- package/dist/esm/{component-value-history-controller-slimmer.abstract-a61bf821.js → component-value-history-controller-slimmer.abstract-2bb8533d.js} +6 -6
- package/dist/esm/{create-public-api-runtime-metrics-slimmer-bedf3a1e.js → create-public-api-runtime-metrics-slimmer-aaadaa08.js} +3 -38
- package/dist/esm/{dark-mode-style-controller-de88a117.js → dark-mode-style-controller-82e5c1c6.js} +292 -1254
- package/dist/esm/{date-required-rule-47ecc28f.js → date-required-rule-e771e7d9.js} +1 -1
- package/dist/esm/{design-token-9b299589.js → design-token-4aee1c56.js} +2 -2
- package/dist/esm/dom-node-subject-observer-factory-82f346e3.js +138 -0
- package/dist/esm/{dto-renderer-manager-f07cf2d9.js → dto-renderer-manager-6fd22ab7.js} +204 -29
- package/dist/esm/{element-appender-slimmer-7cb08343.js → element-appender-slimmer-e4713a72.js} +348 -165
- package/dist/esm/{event-emit-slimmer-09827cec.js → event-emit-slimmer-ffaecb9a.js} +2 -2
- package/dist/esm/{feature-flag-controller-51659753.js → feature-flag-controller-09ea7e87.js} +7 -1
- package/dist/esm/{form-field-controller-slimmer-5d9dc384.js → form-field-controller-slimmer-5817d14d.js} +10 -11
- package/dist/esm/{internal-icon-manager-f0486245.js → icon-manager-539d7cf7.js} +2 -52
- package/dist/esm/{image-annotation-action-53529cd9.js → image-annotation-action-6701b4c9.js} +6 -5
- package/dist/esm/index-3b327f29.js +215 -0
- package/dist/esm/{index-e9da316f.js → index-bfc6dfa2.js} +13 -1
- package/dist/esm/index.js +32 -29
- package/dist/esm/{inject-keyboard-manager-83d76ff5.js → inject-keyboard-manager-78730062.js} +1 -1
- package/dist/esm/internal-icon-manager-bd80b3bb.js +53 -0
- package/dist/esm/{translation-96e5debd.js → internal-translation-controller-911515f9.js} +1 -93
- package/dist/esm/{internal-vega-event-manager-efb6786e.js → internal-vega-event-manager-32a3d848.js} +1 -1
- package/dist/esm/internal-vega-z-index-manager-7d2b54c3.js +178 -0
- package/dist/esm/{keyboard-manager-c92808d8.js → keyboard-manager-38934f94.js} +2 -2
- package/dist/esm/{keyboard-manager-slimmer-79c78ce8.js → keyboard-manager-slimmer-9984d922.js} +1 -1
- package/dist/esm/loader.js +27 -24
- package/dist/esm/misc-9fdbcfbb.js +37 -0
- package/dist/esm/{month-view-generator-16192182.js → month-view-generator-eaf9029c.js} +1 -1
- package/dist/esm/{page-resize-observer-slimmer-8744cb44.js → page-resize-observer-slimmer-d6af0d86.js} +2 -52
- package/dist/esm/{public-rules-6ebdfcf5.js → public-rules-25cc3a39.js} +13 -14
- package/dist/esm/{range-5257c062.js → range-663f44dc.js} +2 -2
- package/dist/esm/{responsive-format-facade-05e53016.js → responsive-format-facade-7a071174.js} +3 -12
- package/dist/esm/{rich-text-editor-required-rule-f63a37d1.js → rich-text-editor-required-rule-a238b862.js} +1 -1
- package/dist/esm/{string-format-strategy.abstract-fc60db79.js → string-format-strategy.abstract-713fba36.js} +1 -1
- package/dist/esm/{string-input-formatter-slimmer-ee32b1fd.js → string-input-formatter-slimmer-5b413ff9.js} +4 -4
- package/dist/esm/{string-mask-strategy-0b0accaa.js → string-mask-strategy-6beaf664.js} +2 -2
- package/dist/esm/{style-formatter-5f5bd714.js → style-formatter-3d06b72d.js} +2 -2
- package/dist/esm/{sub-state-notify-slimmer-4453047a.js → sub-state-notify-slimmer-5133f1a8.js} +2 -2
- package/dist/esm/{sub-state-observer-slimmer-202ec7dc.js → sub-state-observer-slimmer-478c9f41.js} +3 -3
- package/dist/esm/{time-required-rule-5fa43804.js → time-required-rule-e4138a76.js} +1 -1
- package/dist/esm/{function-extension-63028f20.js → token-extension-e33fd151.js} +488 -376
- package/dist/esm/{translation-slimmer-c936cb1b.js → translation-slimmer-2394b173.js} +1 -1
- package/dist/esm/{type-guard-c65a227d.js → type-guard-f50e34d6.js} +1 -1
- package/dist/esm/{ui-bb99c0c2.js → ui-ee31416b.js} +12 -0
- package/dist/esm/{valid-credit-card-number-rule-666c415d.js → valid-credit-card-number-rule-22ce81db.js} +1 -1
- package/dist/esm/vega-accordion.entry.js +19 -28
- package/dist/esm/vega-app-footer.entry.js +3 -3
- package/dist/esm/vega-app-header-button.entry.js +174 -40
- package/dist/esm/vega-backdrop.entry.js +2 -2
- package/dist/esm/vega-banner.entry.js +12 -10
- package/dist/esm/vega-bar-chart.entry.js +1 -1
- package/dist/esm/vega-box.entry.js +14 -29
- package/dist/esm/vega-brand-logo.entry.js +7 -5
- package/dist/esm/vega-breadcrumb.entry.js +11 -10
- package/dist/esm/vega-button-circle.entry.js +19 -29
- package/dist/esm/vega-button-group_2.entry.js +12 -12
- package/dist/esm/vega-button-link.entry.js +13 -12
- package/dist/esm/vega-button.entry.js +19 -28
- package/dist/esm/vega-calendar_4.entry.js +23 -20
- package/dist/esm/vega-card.entry.js +9 -28
- package/dist/esm/vega-carousel.entry.js +14 -25
- package/dist/esm/vega-checkbox_2.entry.js +19 -17
- package/dist/esm/vega-chip.entry.js +18 -29
- package/dist/esm/vega-code-block.entry.js +653 -2704
- package/dist/esm/vega-color-picker.entry.js +15 -12
- package/dist/esm/vega-combo-box.entry.js +22 -21
- package/dist/esm/vega-counter-badge.entry.js +1 -1
- package/dist/esm/vega-date-picker_2.entry.js +34 -37
- package/dist/esm/vega-dialog-controller-bbb2fc52.js +82 -0
- package/dist/esm/vega-dialog_2.entry.js +23 -30
- package/dist/esm/vega-divider.entry.js +11 -29
- package/dist/esm/vega-dropdown_5.entry.js +39 -45
- package/dist/esm/vega-env-manager-8f8dc473.js +2 -2
- package/dist/esm/vega-event-id-38aa77a0.js +113 -0
- package/dist/esm/vega-field-error.entry.js +1 -1
- package/dist/esm/vega-field-label.entry.js +7 -6
- package/dist/esm/vega-file-uploader.entry.js +19 -14
- package/dist/esm/vega-flag-icon.entry.js +12 -26
- package/dist/esm/vega-flex.entry.js +11 -28
- package/dist/esm/vega-font.entry.js +11 -28
- package/dist/esm/vega-form.entry.js +20 -18
- package/dist/esm/vega-grid.entry.js +9 -28
- package/dist/esm/vega-hint.entry.js +1 -1
- package/dist/esm/vega-icon.entry.js +15 -28
- package/dist/esm/vega-image-uploader.entry.js +28 -31
- package/dist/esm/vega-input-credit-card.entry.js +25 -21
- package/dist/esm/vega-input-numeric.entry.js +21 -19
- package/dist/esm/vega-input-passcode.entry.js +20 -18
- package/dist/esm/vega-input-phone-number.entry.js +27 -31
- package/dist/esm/vega-input-range.entry.js +19 -17
- package/dist/esm/vega-input-select.entry.js +27 -32
- package/dist/esm/vega-input.entry.js +33 -21
- package/dist/esm/{vega-internal-event-id-4a06d705.js → vega-internal-event-id-799d012e.js} +1 -1
- package/dist/esm/vega-item-toggle.entry.js +6 -5
- package/dist/esm/vega-left-nav_5.entry.js +29 -31
- package/dist/esm/vega-line-chart.entry.js +1 -1
- package/dist/esm/vega-loader-wrapper_2.entry.js +13 -29
- package/dist/esm/vega-page-notification_2.entry.js +4 -3
- package/dist/esm/vega-pagination-page-selector-mobile.entry.js +9 -9
- package/dist/esm/vega-pagination-page-size-selector-mobile.entry.js +7 -8
- package/dist/esm/vega-pagination.entry.js +20 -30
- package/dist/esm/vega-pie-chart.entry.js +1 -1
- package/dist/esm/vega-popover_2.entry.js +20 -30
- package/dist/esm/vega-progress-tracker_2.entry.js +64 -37
- package/dist/esm/vega-radio_2.entry.js +21 -19
- package/dist/esm/vega-rich-text-content.entry.js +18 -16
- package/dist/esm/vega-rich-text-editor_4.entry.js +90 -37
- package/dist/esm/vega-section-title.entry.js +1 -1
- package/dist/esm/vega-segment-control.entry.js +9 -7
- package/dist/esm/vega-selection-chip_2.entry.js +22 -29
- package/dist/esm/vega-selection-tile_2.entry.js +19 -17
- package/dist/esm/vega-sidenav_3.entry.js +24 -30
- package/dist/esm/vega-signature-capture.entry.js +24 -28
- package/dist/esm/vega-skeleton.entry.js +1 -1
- package/dist/esm/vega-slot-container.entry.js +1 -1
- package/dist/esm/vega-stepper.entry.js +18 -16
- package/dist/esm/vega-tab-group_2.entry.js +11 -10
- package/dist/esm/vega-table_11.entry.js +28 -29
- package/dist/esm/vega-text.entry.js +4 -3
- package/dist/esm/vega-textarea.entry.js +18 -16
- package/dist/esm/vega-time-picker_2.entry.js +26 -32
- package/dist/esm/vega-toggle-switch.entry.js +15 -12
- package/dist/esm/vega-tooltip_2.entry.js +18 -29
- package/dist/esm/vega.js +27 -24
- package/dist/esm/{index-51a7da7f.js → wait-for-component-did-render-b08ef07b.js} +3 -13
- package/dist/sri/vega-sri-manifest.json +415 -403
- package/dist/types/components/vega-app-footer/types.d.ts +18 -0
- package/dist/types/components/vega-app-header-button/types.d.ts +31 -0
- package/dist/types/components/vega-app-header-button/vega-app-header-button.d.ts +2 -0
- package/dist/types/components/vega-banner/types.d.ts +9 -0
- package/dist/types/components/vega-box/interface.d.ts +46 -0
- package/dist/types/components/vega-breadcrumb/types.d.ts +28 -0
- package/dist/types/components/vega-button/types.d.ts +12 -0
- package/dist/types/components/vega-button-circle/types.d.ts +9 -0
- package/dist/types/components/vega-button-group/types.d.ts +48 -0
- package/dist/types/components/vega-button-link/types.d.ts +3 -0
- package/dist/types/components/vega-calendar/types.d.ts +189 -0
- package/dist/types/components/vega-calendar/vega-calendar-event-preview/types.d.ts +6 -0
- package/dist/types/components/vega-chart/vega-bar-chart/types.d.ts +3 -0
- package/dist/types/components/vega-chip/types.d.ts +12 -0
- package/dist/types/components/vega-code-block/slimmers/controllers/prism-code-highlight-parse-controller.d.ts +2 -10
- package/dist/types/components/vega-combo-box/types.d.ts +6 -0
- package/dist/types/components/vega-date-picker/types.d.ts +39 -0
- package/dist/types/components/vega-dialog/types.d.ts +5 -0
- package/dist/types/components/vega-divider/interface.d.ts +18 -0
- package/dist/types/components/vega-dropdown/types.d.ts +30 -0
- package/dist/types/components/vega-dropdown/vega-dropdown-item/types.d.ts +9 -1
- package/dist/types/components/vega-field-error/types.d.ts +12 -0
- package/dist/types/components/vega-field-label/types.d.ts +16 -0
- package/dist/types/components/vega-file-uploader/types.d.ts +12 -0
- package/dist/types/components/vega-font/types.d.ts +3 -0
- package/dist/types/components/vega-form/types.d.ts +45 -0
- package/dist/types/components/vega-image-uploader/types.d.ts +33 -1
- package/dist/types/components/vega-input/types.d.ts +31 -0
- package/dist/types/components/vega-input-phone-number/types.d.ts +15 -0
- package/dist/types/components/vega-input-range/types.d.ts +9 -0
- package/dist/types/components/vega-input-select/types.d.ts +45 -0
- package/dist/types/components/vega-item-toggle/types.d.ts +21 -0
- package/dist/types/components/vega-loading-indicator/types.d.ts +3 -0
- package/dist/types/components/vega-modal/types.d.ts +9 -0
- package/dist/types/components/vega-nav/interface.d.ts +108 -0
- package/dist/types/components/vega-page-notification/types.d.ts +15 -0
- package/dist/types/components/vega-pagination/types.d.ts +11 -0
- package/dist/types/components/vega-progress-tracker/slimmers/controllers/dto/internal-progress-tracker-step.d.ts +16 -4
- package/dist/types/components/vega-progress-tracker/type.d.ts +8 -0
- package/dist/types/components/vega-progress-tracker/vega-progress-tracker-step/vega-progress-tracker-step.d.ts +6 -0
- package/dist/types/components/vega-progress-tracker/vega-progress-tracker.d.ts +2 -2
- package/dist/types/components/vega-rich-text-editor/dto/blocks/html-block.d.ts +10 -0
- package/dist/types/components/vega-rich-text-editor/interface.d.ts +473 -2
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/html-cleaner/html-content-cleaner-processor.interface.d.ts +13 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/html-cleaner/html-content-cleaner.d.ts +35 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/html-cleaner/index.d.ts +4 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/html-cleaner/processors/remove-whitespace-after-opening-tag-processor.d.ts +19 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/html-cleaner/processors/remove-whitespace-before-closing-tag-processor.d.ts +19 -0
- package/dist/types/components/vega-rich-text-editor/slimmers/controllers/html-cleaner/processors/remove-whitespace-between-tags-processor.d.ts +59 -0
- package/dist/types/components/vega-rich-text-editor/test/html-cleaner/html-content-cleaner.test.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/test/html-cleaner/remove-whitespace-after-opening-tag-processor.test.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/test/html-cleaner/remove-whitespace-before-closing-tag-processor.test.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/test/html-cleaner/remove-whitespace-between-tags-processor.test.d.ts +1 -0
- package/dist/types/components/vega-rich-text-editor/vega-rich-text-image-editor/types.d.ts +24 -0
- package/dist/types/components/vega-rich-text-editor/vega-rich-text-link-editor/types.d.ts +24 -0
- package/dist/types/components/vega-segment-control/types.d.ts +18 -0
- package/dist/types/components/vega-selection-chip/interface.d.ts +12 -0
- package/dist/types/components/vega-selection-chip/vega-selection-chip-group/interface.d.ts +4 -0
- package/dist/types/components/vega-selection-tile/interface.d.ts +9 -0
- package/dist/types/components/vega-sidenav/types.d.ts +51 -0
- package/dist/types/components/vega-signature-capture/types.d.ts +29 -2
- package/dist/types/components/vega-skeleton/interface.d.ts +6 -0
- package/dist/types/components/vega-tab-group/types.d.ts +36 -0
- package/dist/types/components/vega-table/interface.d.ts +237 -20
- package/dist/types/components/vega-table/vega-table-expand-row/types.d.ts +6 -0
- package/dist/types/components/vega-table/vega-table-foot/types.d.ts +9 -0
- package/dist/types/components/vega-table/vega-table-foot-row/types.d.ts +9 -0
- package/dist/types/components/vega-table/vega-table-head/types.d.ts +9 -0
- package/dist/types/components/vega-table/vega-table-head-row/types.d.ts +12 -0
- package/dist/types/components/vega-table/vega-table-row/types.d.ts +18 -0
- package/dist/types/components/vega-text/types.d.ts +6 -0
- package/dist/types/components/vega-time-picker/types.d.ts +33 -0
- package/dist/types/components/vega-virtual-scroll/types.d.ts +30 -1
- package/dist/types/components.d.ts +13 -3
- package/dist/types/helpers/code-format/code-formatter.d.ts +14 -0
- package/dist/types/helpers/common/index.d.ts +2 -15
- package/dist/types/helpers/common/wait-for-component-did-render.d.ts +8 -0
- package/dist/types/helpers/common/wait-for-vega-handler.d.ts +6 -15
- package/dist/types/helpers/feature-control/feature-flag.d.ts +2 -1
- package/dist/types/helpers/public-api.d.ts +0 -2
- package/dist/types/helpers/slimmers/mutation-observer/aria-attributes-value-mapper.d.ts +44 -0
- package/dist/types/helpers/slimmers/mutation-observer/test/aria-attributes-value-mapper.test.d.ts +1 -0
- package/dist/types/helpers/slimmers/position-calculation/base-position-calculation-strategy.d.ts +57 -48
- package/dist/types/helpers/slimmers/position-calculation/position-calculation-controller.d.ts +5 -0
- package/dist/types/helpers/slimmers/position-calculation/screen-position-calculation-strategy.d.ts +41 -1
- package/dist/types/helpers/slimmers/position-calculation/screen-scroll-position-update.d.ts +39 -0
- package/dist/types/helpers/ui/element-appender.d.ts +0 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/polyfill/prism/index.d.ts +3 -0
- package/dist/types/polyfill/prism/languages/css.d.ts +6 -0
- package/dist/types/polyfill/prism/languages/javascript.d.ts +7 -0
- package/dist/types/polyfill/prism/languages/jsx.d.ts +7 -0
- package/dist/types/polyfill/prism/languages/language-registry.d.ts +8 -0
- package/dist/types/polyfill/prism/languages/markup.d.ts +6 -0
- package/dist/types/polyfill/prism/languages/tsx.d.ts +7 -0
- package/dist/types/polyfill/prism/languages/typescript.d.ts +2 -0
- package/dist/types/polyfill/prism/test/css.test.d.ts +1 -0
- package/dist/types/polyfill/prism/test/javascript.test.d.ts +1 -0
- package/dist/types/polyfill/prism/test/jsx.test.d.ts +1 -0
- package/dist/types/polyfill/prism/test/language-registry.test.d.ts +1 -0
- package/dist/types/polyfill/prism/test/markup.test.d.ts +1 -0
- package/dist/types/polyfill/prism/test/test-utils.d.ts +10 -0
- package/dist/types/polyfill/prism/test/tokenizer.test.d.ts +1 -0
- package/dist/types/polyfill/prism/test/tsx.test.d.ts +1 -0
- package/dist/types/polyfill/prism/test/typescript.test.d.ts +1 -0
- package/dist/types/polyfill/prism/tokenizer.d.ts +17 -0
- package/dist/types/polyfill/prism/types.d.ts +25 -0
- package/dist/types/polyfill/tinycolor/tinycolor-polyfill.d.ts +149 -0
- package/dist/types/polyfill/tinycolor/tinycolor-polyfill.test.d.ts +1 -0
- package/dist/types/types/components.type.d.ts +4 -1
- package/dist/types/types/design-token.type.d.ts +36 -0
- package/dist/types/types/flag.type.d.ts +3 -0
- package/dist/types/types/general.d.ts +12 -0
- package/dist/types/types/ui.type.d.ts +372 -0
- package/dist/types/types/vega-chart.d.ts +281 -2
- package/dist/types/utils/e2e-utils.d.ts +2 -0
- package/dist/types/utils/sanitize/constants/tag-sets.d.ts +6 -0
- package/dist/types/utils/sanitize/core/html-sanitizer.d.ts +22 -0
- package/dist/types/utils/sanitize/core/sanitize-strategy.d.ts +27 -0
- package/dist/types/utils/sanitize/core/types.d.ts +13 -0
- package/dist/types/utils/sanitize/index.d.ts +12 -0
- package/dist/types/utils/sanitize/strategies/empty-sanitize-strategy.d.ts +14 -0
- package/dist/types/utils/sanitize/strategies/index.d.ts +3 -0
- package/dist/types/utils/sanitize/strategies/label-sanitize-strategy.d.ts +10 -0
- package/dist/types/utils/sanitize/strategies/style-sanitize-strategy.d.ts +24 -0
- package/dist/types/utils/sanitize/test/empty-strategy.test.d.ts +1 -0
- package/dist/types/utils/sanitize/test/html-sanitizer.test.d.ts +1 -0
- package/dist/types/utils/sanitize/test/label-strategy.test.d.ts +1 -0
- package/dist/types/utils/sanitize/test/sanitize-strategy.test.d.ts +1 -0
- package/dist/types/utils/sanitize/test/sanitize.test.d.ts +1 -0
- package/dist/types/utils/sanitize/test/serialize-fragment.test.d.ts +1 -0
- package/dist/types/utils/sanitize/test/style-strategy.test.d.ts +1 -0
- package/dist/types/utils/sanitize/utils/serialize-fragment.d.ts +12 -0
- package/dist/vega/index.esm.js +1 -1
- package/dist/vega/p-01d58eb8.entry.js +1 -0
- package/dist/vega/p-021d4ae4.js +1 -0
- package/dist/vega/p-02a7d60c.entry.js +1 -0
- package/dist/vega/{p-66fa700b.js → p-02c9796a.js} +1 -1
- package/dist/vega/p-033c31d8.entry.js +1 -0
- package/dist/vega/{p-e77a83e4.js → p-07cb0243.js} +1 -1
- package/dist/vega/p-087ea379.entry.js +1 -0
- package/dist/vega/{p-e5af5a4d.entry.js → p-0b4880bd.entry.js} +1 -1
- package/dist/vega/{p-920719ad.js → p-0e679d8c.js} +1 -1
- package/dist/vega/{p-c9b6b5a9.js → p-10734a00.js} +1 -1
- package/dist/vega/p-154f9cf7.entry.js +1 -0
- package/dist/vega/p-179aad4f.entry.js +1 -0
- package/dist/vega/p-1a3236e7.entry.js +1 -0
- package/dist/vega/p-1f3cd061.entry.js +1 -0
- package/dist/vega/p-1f5e35dc.entry.js +1 -0
- package/dist/vega/p-242fbcad.entry.js +1 -0
- package/dist/vega/p-249df6d2.entry.js +1 -0
- package/dist/vega/p-28ad1864.entry.js +1 -0
- package/dist/vega/p-2a10e2e5.js +1 -0
- package/dist/vega/p-2b49686d.entry.js +1 -0
- package/dist/vega/p-2ba78982.entry.js +1 -0
- package/dist/vega/p-2bb5a232.js +1 -0
- package/dist/vega/{p-e9b86dac.entry.js → p-2c1a85dd.entry.js} +1 -1
- package/dist/vega/p-2cc9d126.entry.js +1 -0
- package/dist/vega/p-2d69632d.js +1 -0
- package/dist/vega/p-2e91295d.entry.js +1 -0
- package/dist/vega/p-31ac7386.js +1 -0
- package/dist/vega/p-32033e7a.js +1 -0
- package/dist/vega/p-32183637.entry.js +1 -0
- package/dist/vega/p-3244c605.entry.js +1 -0
- package/dist/vega/p-32faa460.entry.js +1 -0
- package/dist/vega/p-33f9ad94.entry.js +1 -0
- package/dist/vega/{p-4897bedd.entry.js → p-358b4a06.entry.js} +1 -1
- package/dist/vega/p-3afc025e.entry.js +1 -0
- package/dist/vega/p-3d8122ab.entry.js +1 -0
- package/dist/vega/{p-ea04a387.entry.js → p-3f3c771a.entry.js} +1 -1
- package/dist/vega/{p-1f83cebf.js → p-415ffa35.js} +1 -1
- package/dist/vega/{p-d849e0f5.js → p-4415ad28.js} +1 -1
- package/dist/vega/{p-ce1a2982.js → p-464559e3.js} +1 -1
- package/dist/vega/p-49845a91.js +1 -0
- package/dist/vega/{p-e16b3adf.js → p-4bffdb28.js} +1 -1
- package/dist/vega/p-4e017458.entry.js +1 -0
- package/dist/vega/p-4e4a0228.entry.js +1 -0
- package/dist/vega/{p-a2aeb646.js → p-4ea30592.js} +1 -1
- package/dist/vega/{p-0b38a01f.entry.js → p-51fcb07f.entry.js} +1 -1
- package/dist/vega/p-57927b10.entry.js +1 -0
- package/dist/vega/p-5831d6d3.entry.js +1 -0
- package/dist/vega/p-593e0f80.js +1 -0
- package/dist/vega/p-5a25014f.js +1 -0
- package/dist/vega/p-5eb7f382.js +1 -0
- package/dist/vega/p-5f377954.js +1 -1
- package/dist/vega/p-644f701a.js +1 -0
- package/dist/vega/p-6a62e476.entry.js +1 -0
- package/dist/vega/{p-75f981ce.js → p-6b6f0fb4.js} +1 -1
- package/dist/vega/p-6d219c44.entry.js +1 -0
- package/dist/vega/p-6d60b66a.entry.js +1 -0
- package/dist/vega/{p-ad2055f4.entry.js → p-6dcdb580.entry.js} +1 -1
- package/dist/vega/{p-c8f1b9d5.js → p-7181861a.js} +1 -1
- package/dist/vega/p-76181a70.entry.js +1 -0
- package/dist/vega/p-781fd6e0.js +1 -0
- package/dist/vega/p-7958614a.entry.js +1 -0
- package/dist/vega/{p-5b71c85e.js → p-7c39ce96.js} +1 -1
- package/dist/vega/p-7d7aaff9.entry.js +1 -0
- package/dist/vega/{p-4dd6554e.entry.js → p-7f46cc1e.entry.js} +1 -1
- package/dist/vega/{p-badad9ed.js → p-81b044b9.js} +1 -1
- package/dist/vega/p-8950987b.entry.js +1 -0
- package/dist/vega/p-89f2e16d.entry.js +1 -0
- package/dist/vega/p-8ac2d165.js +1 -0
- package/dist/vega/p-8b153acd.entry.js +1 -0
- package/dist/vega/p-8b5d3a52.js +1 -0
- package/dist/vega/{p-fff13ed1.entry.js → p-8b891f36.entry.js} +1 -1
- package/dist/vega/p-8dbdd609.entry.js +1 -0
- package/dist/vega/{p-dd11f735.js → p-9339c6c4.js} +1 -1
- package/dist/vega/p-94a77fbe.entry.js +1 -0
- package/dist/vega/p-95528b47.js +1 -0
- package/dist/vega/p-9a137bab.entry.js +1 -0
- package/dist/vega/{p-6f8be8ea.js → p-a0b66c25.js} +1 -1
- package/dist/vega/{p-0bb3be0b.entry.js → p-a13a73fa.entry.js} +1 -1
- package/dist/vega/p-a560d8c5.entry.js +1 -0
- package/dist/vega/{p-d0e31633.js → p-a786259a.js} +1 -1
- package/dist/vega/p-a7a8a4eb.entry.js +1 -0
- package/dist/vega/p-a8792e3d.js +1 -0
- package/dist/vega/{p-60851f9d.js → p-aa1174dc.js} +1 -1
- package/dist/vega/p-ab834f06.js +1 -0
- package/dist/vega/p-b136ebba.entry.js +1 -0
- package/dist/vega/p-b201f379.js +1 -0
- package/dist/vega/p-b256b7a4.js +1 -0
- package/dist/vega/p-b366deff.entry.js +1 -0
- package/dist/vega/p-b597393b.entry.js +1 -0
- package/dist/vega/p-b7f3221f.js +1 -0
- package/dist/vega/p-bb5e0192.entry.js +1 -0
- package/dist/vega/p-be1a210b.js +1 -0
- package/dist/vega/p-bebfbe95.entry.js +1 -0
- package/dist/vega/p-bf6fc19f.entry.js +1 -0
- package/dist/vega/p-c1d13eec.entry.js +1 -0
- package/dist/vega/p-c29068fb.entry.js +1 -0
- package/dist/vega/p-c3d2f316.js +1 -0
- package/dist/vega/{p-671afda4.entry.js → p-c72e08c6.entry.js} +1 -1
- package/dist/vega/p-c801c85d.js +1 -0
- package/dist/vega/p-c8feb644.entry.js +1 -0
- package/dist/vega/p-ca5898dc.entry.js +1 -0
- package/dist/vega/p-d555f677.entry.js +1 -0
- package/dist/vega/p-d64fab3d.js +1 -0
- package/dist/vega/p-d6dbbe61.entry.js +1 -0
- package/dist/vega/p-d7a78c5e.entry.js +1 -0
- package/dist/vega/p-d8fadcdc.entry.js +1 -0
- package/dist/vega/p-dad3ba5f.js +1 -0
- package/dist/vega/p-dd3a94f4.entry.js +1 -0
- package/dist/vega/p-e1431c14.entry.js +1 -0
- package/dist/vega/p-e1fbfd20.js +1 -0
- package/dist/vega/p-e2af0e24.entry.js +1 -0
- package/dist/vega/{p-521d1d07.js → p-e52890db.js} +1 -1
- package/dist/vega/{p-1298b126.js → p-e632475e.js} +1 -1
- package/dist/vega/p-e6adf829.js +1 -0
- package/dist/vega/{p-77edf50c.js → p-e827d56d.js} +1 -1
- package/dist/vega/p-e8775a56.entry.js +1 -0
- package/dist/vega/p-e89e3ede.entry.js +1 -0
- package/dist/vega/p-eda988d5.entry.js +1 -0
- package/dist/vega/p-f05b8f76.entry.js +1 -0
- package/dist/vega/p-f0e828d8.js +1 -0
- package/dist/vega/p-f14a5eae.entry.js +1 -0
- package/dist/vega/p-f2b0b58a.js +1 -0
- package/dist/vega/p-f3d0f2dc.js +1 -0
- package/dist/vega/{p-5910be31.entry.js → p-f5bafc45.entry.js} +1 -1
- package/dist/vega/p-fc1fa345.js +1 -0
- package/dist/vega/p-fd7ddd64.entry.js +1 -0
- package/dist/vega/vega.esm.js +1 -1
- package/package.json +3 -5
- package/dist/cjs/_commonjsHelpers-537d719a.js +0 -20
- package/dist/cjs/language-extension-38e4905e.js +0 -210
- package/dist/cjs/sanitize-fb222510.js +0 -131
- package/dist/cjs/wait-for-vega-handler-5469ff80.js +0 -63
- package/dist/collection/utils/sanitize.js +0 -126
- package/dist/collection/utils/test/sanitize.test.js +0 -65
- package/dist/esm/_commonjsHelpers-9943807e.js +0 -17
- package/dist/esm/dom-node-subject-observer-factory-064ee2b2.js +0 -250
- package/dist/esm/language-extension-c4ff21dd.js +0 -207
- package/dist/esm/sanitize-fd0cb40d.js +0 -129
- package/dist/esm/wait-for-vega-handler-c2c07ac3.js +0 -61
- package/dist/types/utils/sanitize.d.ts +0 -71
- package/dist/vega/p-011b94b1.entry.js +0 -1
- package/dist/vega/p-06aaced4.js +0 -1
- package/dist/vega/p-07d3df01.entry.js +0 -1
- package/dist/vega/p-08f18b22.entry.js +0 -1
- package/dist/vega/p-10ac8b57.js +0 -1
- package/dist/vega/p-112455b1.js +0 -1
- package/dist/vega/p-17c55205.entry.js +0 -1
- package/dist/vega/p-1e0d8228.entry.js +0 -1
- package/dist/vega/p-20ad42be.js +0 -1
- package/dist/vega/p-22b2841f.entry.js +0 -1
- package/dist/vega/p-22c5d83b.js +0 -1
- package/dist/vega/p-34246870.entry.js +0 -1
- package/dist/vega/p-35bf5789.entry.js +0 -1
- package/dist/vega/p-3bbc0c7d.entry.js +0 -1
- package/dist/vega/p-3bf66be2.js +0 -1
- package/dist/vega/p-3c5a28e4.entry.js +0 -1
- package/dist/vega/p-3cfd8616.entry.js +0 -1
- package/dist/vega/p-3e5f362f.js +0 -1
- package/dist/vega/p-43f585f7.entry.js +0 -1
- package/dist/vega/p-476a173a.js +0 -1
- package/dist/vega/p-4a537391.entry.js +0 -1
- package/dist/vega/p-509eb52e.entry.js +0 -1
- package/dist/vega/p-50ab977c.entry.js +0 -1
- package/dist/vega/p-53a694d1.entry.js +0 -1
- package/dist/vega/p-56e97df8.js +0 -1
- package/dist/vega/p-5a27084e.entry.js +0 -1
- package/dist/vega/p-5d676a94.js +0 -1
- package/dist/vega/p-5df9a856.entry.js +0 -1
- package/dist/vega/p-5ea2e43c.entry.js +0 -1
- package/dist/vega/p-60274fb1.js +0 -1
- package/dist/vega/p-60da99c6.entry.js +0 -1
- package/dist/vega/p-67f18b9e.entry.js +0 -1
- package/dist/vega/p-67fcf6f2.entry.js +0 -9
- package/dist/vega/p-6a2205a1.entry.js +0 -1
- package/dist/vega/p-6a4277df.entry.js +0 -1
- package/dist/vega/p-6e136980.js +0 -1
- package/dist/vega/p-6f239144.entry.js +0 -1
- package/dist/vega/p-7045e84c.entry.js +0 -1
- package/dist/vega/p-7288f8c4.js +0 -1
- package/dist/vega/p-747d6afc.entry.js +0 -1
- package/dist/vega/p-75651f32.entry.js +0 -1
- package/dist/vega/p-7ae55fd5.js +0 -1
- package/dist/vega/p-81134e9e.entry.js +0 -1
- package/dist/vega/p-87238c4c.entry.js +0 -1
- package/dist/vega/p-8a887843.entry.js +0 -1
- package/dist/vega/p-8c0eb12f.entry.js +0 -1
- package/dist/vega/p-8c9ea6f4.js +0 -1
- package/dist/vega/p-8d0ca805.js +0 -1
- package/dist/vega/p-8e42a14c.entry.js +0 -1
- package/dist/vega/p-91ec2e30.js +0 -1
- package/dist/vega/p-94394df7.entry.js +0 -1
- package/dist/vega/p-991008a8.entry.js +0 -1
- package/dist/vega/p-9fd503e9.entry.js +0 -1
- package/dist/vega/p-a20854d6.entry.js +0 -1
- package/dist/vega/p-a4670e23.js +0 -1
- package/dist/vega/p-a530797f.entry.js +0 -1
- package/dist/vega/p-a5bd3c15.entry.js +0 -1
- package/dist/vega/p-a65941d0.entry.js +0 -1
- package/dist/vega/p-a85ad369.entry.js +0 -1
- package/dist/vega/p-a86010f7.entry.js +0 -1
- package/dist/vega/p-aa10eeb3.entry.js +0 -1
- package/dist/vega/p-ab2f35af.entry.js +0 -1
- package/dist/vega/p-ac4563d7.js +0 -1
- package/dist/vega/p-aedf7146.js +0 -1
- package/dist/vega/p-b4ea3fad.js +0 -1
- package/dist/vega/p-bb4a558d.entry.js +0 -1
- package/dist/vega/p-bb8339ed.entry.js +0 -1
- package/dist/vega/p-be930e85.entry.js +0 -1
- package/dist/vega/p-bf2bd6d0.entry.js +0 -1
- package/dist/vega/p-c379a5a5.entry.js +0 -1
- package/dist/vega/p-c616c592.js +0 -1
- package/dist/vega/p-ca3472c1.entry.js +0 -1
- package/dist/vega/p-cc43bffb.js +0 -1
- package/dist/vega/p-d6ed3d76.entry.js +0 -1
- package/dist/vega/p-db8cdba6.js +0 -1
- package/dist/vega/p-e1610196.entry.js +0 -1
- package/dist/vega/p-e87b0b4a.entry.js +0 -1
- package/dist/vega/p-e9c4fd24.entry.js +0 -1
- package/dist/vega/p-eb60cfe1.entry.js +0 -1
- package/dist/vega/p-ef001c70.entry.js +0 -1
- package/dist/vega/p-ef9cbad1.js +0 -1
- package/dist/vega/p-f383c856.js +0 -1
- package/dist/vega/p-f3c3ff26.entry.js +0 -1
- package/dist/vega/p-f52a0155.entry.js +0 -1
- package/dist/vega/p-f69f84a7.js +0 -1
- package/dist/vega/p-f8f7cf48.entry.js +0 -1
- package/dist/vega/p-fba14ad2.entry.js +0 -1
- package/dist/vega/p-fbd64f9c.entry.js +0 -1
- package/dist/vega/p-fdc270b8.entry.js +0 -1
- package/dist/vega/p-fe12eff6.js +0 -1
- package/dist/vega/p-ffbff9b5.entry.js +0 -1
- /package/dist/{types/utils/test/sanitize.test.d.ts → collection/components/vega-rich-text-editor/slimmers/controllers/html-cleaner/html-content-cleaner-processor.interface.js} +0 -0
- /package/dist/vega/{p-d9671d27.js → p-6c170474.js} +0 -0
|
@@ -4,44 +4,47 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-58ea899e.js');
|
|
6
6
|
const globalSlimmerRegistry = require('./global-slimmer-registry-b3bce7e0.js');
|
|
7
|
-
const componentUsageRuntimeMetrics = require('./component-usage-runtime-metrics-
|
|
7
|
+
const componentUsageRuntimeMetrics = require('./component-usage-runtime-metrics-4572c5b7.js');
|
|
8
8
|
const component = require('./component-1e352960.js');
|
|
9
|
-
const internalIconManager = require('./internal-icon-manager-
|
|
9
|
+
const internalIconManager = require('./internal-icon-manager-c989189a.js');
|
|
10
10
|
const trashCan = require('./trash-can-46a5e19a.js');
|
|
11
|
-
const domNodeSubjectObserverFactory = require('./dom-node-subject-observer-factory-
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
11
|
+
const domNodeSubjectObserverFactory = require('./dom-node-subject-observer-factory-c62823de.js');
|
|
12
|
+
const vegaEventId = require('./vega-event-id-ee01d8dd.js');
|
|
13
|
+
const codeBlock = require('./code-block-f1480ec3.js');
|
|
14
|
+
const ui = require('./ui-234ea151.js');
|
|
15
|
+
const eventEmitSlimmer = require('./event-emit-slimmer-062cdcb8.js');
|
|
15
16
|
const object = require('./object-e2e28e3d.js');
|
|
16
|
-
const translationSlimmer = require('./translation-slimmer-
|
|
17
|
-
const componentValueHistoryControllerSlimmer_abstract = require('./component-value-history-controller-slimmer.abstract-
|
|
17
|
+
const translationSlimmer = require('./translation-slimmer-4533bd67.js');
|
|
18
|
+
const componentValueHistoryControllerSlimmer_abstract = require('./component-value-history-controller-slimmer.abstract-a9264cc8.js');
|
|
18
19
|
const changeManager = require('./change-manager-a297e4d2.js');
|
|
19
20
|
const vegaInternalEventId = require('./vega-internal-event-id-f2465f1b.js');
|
|
20
21
|
const timer = require('./timer-5f33058b.js');
|
|
21
|
-
const childNodesEventPreventSlimmer = require('./child-nodes-event-prevent-slimmer-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
require('./create-public-api-runtime-metrics-slimmer-
|
|
22
|
+
const childNodesEventPreventSlimmer = require('./child-nodes-event-prevent-slimmer-84435957.js');
|
|
23
|
+
const componentGlobalStyleSlimmer = require('./component-global-style-slimmer-93c5fb50.js');
|
|
24
|
+
require('./icon-manager-c12c6ea9.js');
|
|
25
|
+
require('./create-public-api-runtime-metrics-slimmer-9cb09fb2.js');
|
|
25
26
|
require('./dynamic-slimmer-f31fdfd7.js');
|
|
27
|
+
require('./misc-3d30df91.js');
|
|
26
28
|
require('./observer-f49483e8.js');
|
|
27
29
|
require('./string-39438062.js');
|
|
28
|
-
require('./type-guard-
|
|
30
|
+
require('./type-guard-407ba0b8.js');
|
|
29
31
|
require('./breakpoints-ebde4837.js');
|
|
30
32
|
require('./ui-32e69595.js');
|
|
31
33
|
require('./typography-4560e7f1.js');
|
|
32
|
-
require('./translation-
|
|
34
|
+
require('./internal-translation-controller-053eb0f1.js');
|
|
33
35
|
require('./static-subject-title-5829a298.js');
|
|
34
|
-
require('./dark-mode-style-controller-
|
|
36
|
+
require('./dark-mode-style-controller-3a04af3d.js');
|
|
35
37
|
require('./vega-nonce-manager-df69d3ed.js');
|
|
36
38
|
require('./try-get-document-c0ebd39a.js');
|
|
37
|
-
require('./
|
|
38
|
-
require('./
|
|
39
|
+
require('./index-592b4052.js');
|
|
40
|
+
require('./internal-vega-event-manager-f7ecf3d4.js');
|
|
41
|
+
require('./range-8aa49b08.js');
|
|
39
42
|
require('./synchronize-task-queue-1ee80e94.js');
|
|
40
|
-
require('./keyboard-manager-slimmer-
|
|
41
|
-
require('./keyboard-manager-
|
|
43
|
+
require('./keyboard-manager-slimmer-0cc0c1c7.js');
|
|
44
|
+
require('./keyboard-manager-055e9f67.js');
|
|
42
45
|
require('./vega-env-manager-23b8b23c.js');
|
|
43
|
-
require('./feature-flag-controller-
|
|
44
|
-
require('./index-
|
|
46
|
+
require('./feature-flag-controller-04cb1e69.js');
|
|
47
|
+
require('./index-f054eb5d.js');
|
|
45
48
|
|
|
46
49
|
var __decorate$c = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
47
50
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -67,7 +70,7 @@ class VegaCodeBlockRenderer extends globalSlimmerRegistry.VegaSlimmer {
|
|
|
67
70
|
* @param {HTMLVegaInputSelectElement} node - The language select element.
|
|
68
71
|
*/
|
|
69
72
|
this.handleLanguageChange = (node) => {
|
|
70
|
-
domNodeSubjectObserverFactory.DomNodeSubjectObserverFactory.addUniqueObserverToNode(node,
|
|
73
|
+
domNodeSubjectObserverFactory.DomNodeSubjectObserverFactory.addUniqueObserverToNode(node, vegaEventId.VegaChange, (payload) => {
|
|
71
74
|
var _a;
|
|
72
75
|
this.valueController.updateValue((_a = this.value) === null || _a === void 0 ? void 0 : _a.code, payload.detail);
|
|
73
76
|
});
|
|
@@ -78,7 +81,7 @@ class VegaCodeBlockRenderer extends globalSlimmerRegistry.VegaSlimmer {
|
|
|
78
81
|
* @param {HTMLVegaButtonCircleElement} node - The delete button.
|
|
79
82
|
*/
|
|
80
83
|
this.handleDeleteClick = (node) => {
|
|
81
|
-
domNodeSubjectObserverFactory.DomNodeSubjectObserverFactory.addUniqueObserverToNode(node,
|
|
84
|
+
domNodeSubjectObserverFactory.DomNodeSubjectObserverFactory.addUniqueObserverToNode(node, vegaEventId.VegaClick, () => {
|
|
82
85
|
const event = this.removeEventEmitter.emit();
|
|
83
86
|
if (!event.defaultPrevented) {
|
|
84
87
|
this.host.remove();
|
|
@@ -955,7 +958,7 @@ class VegaCodeBlockCopyButtonRenderer extends globalSlimmerRegistry.VegaSlimmer
|
|
|
955
958
|
* @param {HTMLVegaButtonCircleElement} node - The copy button.
|
|
956
959
|
*/
|
|
957
960
|
this.handleCopyClick = (node) => {
|
|
958
|
-
domNodeSubjectObserverFactory.DomNodeSubjectObserverFactory.addUniqueObserverToNode(node,
|
|
961
|
+
domNodeSubjectObserverFactory.DomNodeSubjectObserverFactory.addUniqueObserverToNode(node, vegaEventId.VegaClick, async () => {
|
|
959
962
|
var _a;
|
|
960
963
|
const content = ((_a = this.value) === null || _a === void 0 ? void 0 : _a.code) || '';
|
|
961
964
|
if (content && globalThis.navigator && globalThis.navigator.clipboard) {
|
|
@@ -1002,2712 +1005,658 @@ __decorate$5([
|
|
|
1002
1005
|
globalSlimmerRegistry.MapToComponentField()
|
|
1003
1006
|
], VegaCodeBlockCopyButtonRenderer.prototype, "translationSlimmer", void 0);
|
|
1004
1007
|
|
|
1005
|
-
var prism = _commonjsHelpers.createCommonjsModule(function (module) {
|
|
1006
|
-
/* **********************************************
|
|
1007
|
-
Begin prism-core.js
|
|
1008
|
-
********************************************** */
|
|
1009
|
-
|
|
1010
|
-
/// <reference lib="WebWorker"/>
|
|
1011
|
-
|
|
1012
|
-
var _self = (typeof window !== 'undefined')
|
|
1013
|
-
? window // if in browser
|
|
1014
|
-
: (
|
|
1015
|
-
(typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
|
|
1016
|
-
? self // if in worker
|
|
1017
|
-
: {} // if in node js
|
|
1018
|
-
);
|
|
1019
|
-
|
|
1020
1008
|
/**
|
|
1021
|
-
*
|
|
1009
|
+
* Unique placeholder used to mark greedy-matched regions so they are not
|
|
1010
|
+
* re-tokenized by later grammar rules. The surrounding curly-brace pairs
|
|
1011
|
+
* make an accidental collision with real source code extremely unlikely.
|
|
1012
|
+
*/
|
|
1013
|
+
const GREEDY_PLACEHOLDER = '\x00GREEDY_PLACEHOLDER\x00';
|
|
1014
|
+
/**
|
|
1015
|
+
* Core tokenizer that converts source code into syntax tokens based on a grammar definition.
|
|
1016
|
+
* This is a local replacement for Prism tokenize.
|
|
1017
|
+
*
|
|
1018
|
+
* The tokenizer works by:
|
|
1019
|
+
* 1. Pre-processing greedy patterns to claim their matched regions first
|
|
1020
|
+
* 2. Iterating through all grammar rules in order
|
|
1021
|
+
* 3. Finding regex matches in the source text
|
|
1022
|
+
* 4. Splitting the text into matched (typed) and unmatched (plain) segments
|
|
1023
|
+
* 5. Recursively tokenizing nested content when an `inside` grammar is specified
|
|
1022
1024
|
*
|
|
1023
|
-
* @
|
|
1024
|
-
* @
|
|
1025
|
-
* @
|
|
1026
|
-
* @public
|
|
1025
|
+
* @param {string} code - The source code string to tokenize.
|
|
1026
|
+
* @param {Grammar} grammar - The grammar rules to apply for tokenization.
|
|
1027
|
+
* @returns {(string | SyntaxToken)[]} An array of plain strings and syntax tokens.
|
|
1027
1028
|
*/
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
var plainTextGrammar = {};
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
var _ = {
|
|
1039
|
-
/**
|
|
1040
|
-
* By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
|
|
1041
|
-
* current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
|
|
1042
|
-
* additional languages or plugins yourself.
|
|
1043
|
-
*
|
|
1044
|
-
* By setting this value to `true`, Prism will not automatically highlight all code elements on the page.
|
|
1045
|
-
*
|
|
1046
|
-
* You obviously have to change this value before the automatic highlighting started. To do this, you can add an
|
|
1047
|
-
* empty Prism object into the global scope before loading the Prism script like this:
|
|
1048
|
-
*
|
|
1049
|
-
* ```js
|
|
1050
|
-
* window.Prism = window.Prism || {};
|
|
1051
|
-
* Prism.manual = true;
|
|
1052
|
-
* // add a new <script> to load Prism's script
|
|
1053
|
-
* ```
|
|
1054
|
-
*
|
|
1055
|
-
* @default false
|
|
1056
|
-
* @type {boolean}
|
|
1057
|
-
* @memberof Prism
|
|
1058
|
-
* @public
|
|
1059
|
-
*/
|
|
1060
|
-
manual: _self.Prism && _self.Prism.manual,
|
|
1061
|
-
/**
|
|
1062
|
-
* By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses
|
|
1063
|
-
* `addEventListener` to communicate with its parent instance. However, if you're using Prism manually in your
|
|
1064
|
-
* own worker, you don't want it to do this.
|
|
1065
|
-
*
|
|
1066
|
-
* By setting this value to `true`, Prism will not add its own listeners to the worker.
|
|
1067
|
-
*
|
|
1068
|
-
* You obviously have to change this value before Prism executes. To do this, you can add an
|
|
1069
|
-
* empty Prism object into the global scope before loading the Prism script like this:
|
|
1070
|
-
*
|
|
1071
|
-
* ```js
|
|
1072
|
-
* window.Prism = window.Prism || {};
|
|
1073
|
-
* Prism.disableWorkerMessageHandler = true;
|
|
1074
|
-
* // Load Prism's script
|
|
1075
|
-
* ```
|
|
1076
|
-
*
|
|
1077
|
-
* @default false
|
|
1078
|
-
* @type {boolean}
|
|
1079
|
-
* @memberof Prism
|
|
1080
|
-
* @public
|
|
1081
|
-
*/
|
|
1082
|
-
disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
|
|
1083
|
-
|
|
1084
|
-
/**
|
|
1085
|
-
* A namespace for utility methods.
|
|
1086
|
-
*
|
|
1087
|
-
* All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
|
|
1088
|
-
* change or disappear at any time.
|
|
1089
|
-
*
|
|
1090
|
-
* @namespace
|
|
1091
|
-
* @memberof Prism
|
|
1092
|
-
*/
|
|
1093
|
-
util: {
|
|
1094
|
-
encode: function encode(tokens) {
|
|
1095
|
-
if (tokens instanceof Token) {
|
|
1096
|
-
return new Token(tokens.type, encode(tokens.content), tokens.alias);
|
|
1097
|
-
} else if (Array.isArray(tokens)) {
|
|
1098
|
-
return tokens.map(encode);
|
|
1099
|
-
} else {
|
|
1100
|
-
return tokens.replace(/&/g, '&').replace(/</g, '<').replace(/\u00a0/g, ' ');
|
|
1101
|
-
}
|
|
1102
|
-
},
|
|
1103
|
-
|
|
1104
|
-
/**
|
|
1105
|
-
* Returns the name of the type of the given value.
|
|
1106
|
-
*
|
|
1107
|
-
* @param {any} o
|
|
1108
|
-
* @returns {string}
|
|
1109
|
-
* @example
|
|
1110
|
-
* type(null) === 'Null'
|
|
1111
|
-
* type(undefined) === 'Undefined'
|
|
1112
|
-
* type(123) === 'Number'
|
|
1113
|
-
* type('foo') === 'String'
|
|
1114
|
-
* type(true) === 'Boolean'
|
|
1115
|
-
* type([1, 2]) === 'Array'
|
|
1116
|
-
* type({}) === 'Object'
|
|
1117
|
-
* type(String) === 'Function'
|
|
1118
|
-
* type(/abc+/) === 'RegExp'
|
|
1119
|
-
*/
|
|
1120
|
-
type: function (o) {
|
|
1121
|
-
return Object.prototype.toString.call(o).slice(8, -1);
|
|
1122
|
-
},
|
|
1123
|
-
|
|
1124
|
-
/**
|
|
1125
|
-
* Returns a unique number for the given object. Later calls will still return the same number.
|
|
1126
|
-
*
|
|
1127
|
-
* @param {Object} obj
|
|
1128
|
-
* @returns {number}
|
|
1129
|
-
*/
|
|
1130
|
-
objId: function (obj) {
|
|
1131
|
-
if (!obj['__id']) {
|
|
1132
|
-
Object.defineProperty(obj, '__id', { value: ++uniqueId });
|
|
1133
|
-
}
|
|
1134
|
-
return obj['__id'];
|
|
1135
|
-
},
|
|
1136
|
-
|
|
1137
|
-
/**
|
|
1138
|
-
* Creates a deep clone of the given object.
|
|
1139
|
-
*
|
|
1140
|
-
* The main intended use of this function is to clone language definitions.
|
|
1141
|
-
*
|
|
1142
|
-
* @param {T} o
|
|
1143
|
-
* @param {Record<number, any>} [visited]
|
|
1144
|
-
* @returns {T}
|
|
1145
|
-
* @template T
|
|
1146
|
-
*/
|
|
1147
|
-
clone: function deepClone(o, visited) {
|
|
1148
|
-
visited = visited || {};
|
|
1149
|
-
|
|
1150
|
-
var clone; var id;
|
|
1151
|
-
switch (_.util.type(o)) {
|
|
1152
|
-
case 'Object':
|
|
1153
|
-
id = _.util.objId(o);
|
|
1154
|
-
if (visited[id]) {
|
|
1155
|
-
return visited[id];
|
|
1156
|
-
}
|
|
1157
|
-
clone = /** @type {Record<string, any>} */ ({});
|
|
1158
|
-
visited[id] = clone;
|
|
1159
|
-
|
|
1160
|
-
for (var key in o) {
|
|
1161
|
-
if (o.hasOwnProperty(key)) {
|
|
1162
|
-
clone[key] = deepClone(o[key], visited);
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
|
|
1166
|
-
return /** @type {any} */ (clone);
|
|
1167
|
-
|
|
1168
|
-
case 'Array':
|
|
1169
|
-
id = _.util.objId(o);
|
|
1170
|
-
if (visited[id]) {
|
|
1171
|
-
return visited[id];
|
|
1172
|
-
}
|
|
1173
|
-
clone = [];
|
|
1174
|
-
visited[id] = clone;
|
|
1175
|
-
|
|
1176
|
-
(/** @type {Array} */(/** @type {any} */(o))).forEach(function (v, i) {
|
|
1177
|
-
clone[i] = deepClone(v, visited);
|
|
1178
|
-
});
|
|
1179
|
-
|
|
1180
|
-
return /** @type {any} */ (clone);
|
|
1181
|
-
|
|
1182
|
-
default:
|
|
1183
|
-
return o;
|
|
1184
|
-
}
|
|
1185
|
-
},
|
|
1186
|
-
|
|
1187
|
-
/**
|
|
1188
|
-
* Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class.
|
|
1189
|
-
*
|
|
1190
|
-
* If no language is set for the element or the element is `null` or `undefined`, `none` will be returned.
|
|
1191
|
-
*
|
|
1192
|
-
* @param {Element} element
|
|
1193
|
-
* @returns {string}
|
|
1194
|
-
*/
|
|
1195
|
-
getLanguage: function (element) {
|
|
1196
|
-
while (element) {
|
|
1197
|
-
var m = lang.exec(element.className);
|
|
1198
|
-
if (m) {
|
|
1199
|
-
return m[1].toLowerCase();
|
|
1200
|
-
}
|
|
1201
|
-
element = element.parentElement;
|
|
1202
|
-
}
|
|
1203
|
-
return 'none';
|
|
1204
|
-
},
|
|
1205
|
-
|
|
1206
|
-
/**
|
|
1207
|
-
* Sets the Prism `language-xxxx` class of the given element.
|
|
1208
|
-
*
|
|
1209
|
-
* @param {Element} element
|
|
1210
|
-
* @param {string} language
|
|
1211
|
-
* @returns {void}
|
|
1212
|
-
*/
|
|
1213
|
-
setLanguage: function (element, language) {
|
|
1214
|
-
// remove all `language-xxxx` classes
|
|
1215
|
-
// (this might leave behind a leading space)
|
|
1216
|
-
element.className = element.className.replace(RegExp(lang, 'gi'), '');
|
|
1217
|
-
|
|
1218
|
-
// add the new `language-xxxx` class
|
|
1219
|
-
// (using `classList` will automatically clean up spaces for us)
|
|
1220
|
-
element.classList.add('language-' + language);
|
|
1221
|
-
},
|
|
1222
|
-
|
|
1223
|
-
/**
|
|
1224
|
-
* Returns the script element that is currently executing.
|
|
1225
|
-
*
|
|
1226
|
-
* This does __not__ work for line script element.
|
|
1227
|
-
*
|
|
1228
|
-
* @returns {HTMLScriptElement | null}
|
|
1229
|
-
*/
|
|
1230
|
-
currentScript: function () {
|
|
1231
|
-
if (typeof document === 'undefined') {
|
|
1232
|
-
return null;
|
|
1233
|
-
}
|
|
1234
|
-
if (document.currentScript && document.currentScript.tagName === 'SCRIPT' && 1 < 2 /* hack to trip TS' flow analysis */) {
|
|
1235
|
-
return /** @type {any} */ (document.currentScript);
|
|
1236
|
-
}
|
|
1237
|
-
|
|
1238
|
-
// IE11 workaround
|
|
1239
|
-
// we'll get the src of the current script by parsing IE11's error stack trace
|
|
1240
|
-
// this will not work for inline scripts
|
|
1241
|
-
|
|
1242
|
-
try {
|
|
1243
|
-
throw new Error();
|
|
1244
|
-
} catch (err) {
|
|
1245
|
-
// Get file src url from stack. Specifically works with the format of stack traces in IE.
|
|
1246
|
-
// A stack will look like this:
|
|
1247
|
-
//
|
|
1248
|
-
// Error
|
|
1249
|
-
// at _.util.currentScript (http://localhost/components/prism-core.js:119:5)
|
|
1250
|
-
// at Global code (http://localhost/components/prism-core.js:606:1)
|
|
1251
|
-
|
|
1252
|
-
var src = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(err.stack) || [])[1];
|
|
1253
|
-
if (src) {
|
|
1254
|
-
var scripts = document.getElementsByTagName('script');
|
|
1255
|
-
for (var i in scripts) {
|
|
1256
|
-
if (scripts[i].src == src) {
|
|
1257
|
-
return scripts[i];
|
|
1258
|
-
}
|
|
1259
|
-
}
|
|
1260
|
-
}
|
|
1261
|
-
return null;
|
|
1262
|
-
}
|
|
1263
|
-
},
|
|
1264
|
-
|
|
1265
|
-
/**
|
|
1266
|
-
* Returns whether a given class is active for `element`.
|
|
1267
|
-
*
|
|
1268
|
-
* The class can be activated if `element` or one of its ancestors has the given class and it can be deactivated
|
|
1269
|
-
* if `element` or one of its ancestors has the negated version of the given class. The _negated version_ of the
|
|
1270
|
-
* given class is just the given class with a `no-` prefix.
|
|
1271
|
-
*
|
|
1272
|
-
* Whether the class is active is determined by the closest ancestor of `element` (where `element` itself is
|
|
1273
|
-
* closest ancestor) that has the given class or the negated version of it. If neither `element` nor any of its
|
|
1274
|
-
* ancestors have the given class or the negated version of it, then the default activation will be returned.
|
|
1275
|
-
*
|
|
1276
|
-
* In the paradoxical situation where the closest ancestor contains __both__ the given class and the negated
|
|
1277
|
-
* version of it, the class is considered active.
|
|
1278
|
-
*
|
|
1279
|
-
* @param {Element} element
|
|
1280
|
-
* @param {string} className
|
|
1281
|
-
* @param {boolean} [defaultActivation=false]
|
|
1282
|
-
* @returns {boolean}
|
|
1283
|
-
*/
|
|
1284
|
-
isActive: function (element, className, defaultActivation) {
|
|
1285
|
-
var no = 'no-' + className;
|
|
1286
|
-
|
|
1287
|
-
while (element) {
|
|
1288
|
-
var classList = element.classList;
|
|
1289
|
-
if (classList.contains(className)) {
|
|
1290
|
-
return true;
|
|
1291
|
-
}
|
|
1292
|
-
if (classList.contains(no)) {
|
|
1293
|
-
return false;
|
|
1294
|
-
}
|
|
1295
|
-
element = element.parentElement;
|
|
1296
|
-
}
|
|
1297
|
-
return !!defaultActivation;
|
|
1298
|
-
}
|
|
1299
|
-
},
|
|
1300
|
-
|
|
1301
|
-
/**
|
|
1302
|
-
* This namespace contains all currently loaded languages and the some helper functions to create and modify languages.
|
|
1303
|
-
*
|
|
1304
|
-
* @namespace
|
|
1305
|
-
* @memberof Prism
|
|
1306
|
-
* @public
|
|
1307
|
-
*/
|
|
1308
|
-
languages: {
|
|
1309
|
-
/**
|
|
1310
|
-
* The grammar for plain, unformatted text.
|
|
1311
|
-
*/
|
|
1312
|
-
plain: plainTextGrammar,
|
|
1313
|
-
plaintext: plainTextGrammar,
|
|
1314
|
-
text: plainTextGrammar,
|
|
1315
|
-
txt: plainTextGrammar,
|
|
1316
|
-
|
|
1317
|
-
/**
|
|
1318
|
-
* Creates a deep copy of the language with the given id and appends the given tokens.
|
|
1319
|
-
*
|
|
1320
|
-
* If a token in `redef` also appears in the copied language, then the existing token in the copied language
|
|
1321
|
-
* will be overwritten at its original position.
|
|
1322
|
-
*
|
|
1323
|
-
* ## Best practices
|
|
1324
|
-
*
|
|
1325
|
-
* Since the position of overwriting tokens (token in `redef` that overwrite tokens in the copied language)
|
|
1326
|
-
* doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to
|
|
1327
|
-
* understand the language definition because, normally, the order of tokens matters in Prism grammars.
|
|
1328
|
-
*
|
|
1329
|
-
* Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens.
|
|
1330
|
-
* Furthermore, all non-overwriting tokens should be placed after the overwriting ones.
|
|
1331
|
-
*
|
|
1332
|
-
* @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`.
|
|
1333
|
-
* @param {Grammar} redef The new tokens to append.
|
|
1334
|
-
* @returns {Grammar} The new language created.
|
|
1335
|
-
* @public
|
|
1336
|
-
* @example
|
|
1337
|
-
* Prism.languages['css-with-colors'] = Prism.languages.extend('css', {
|
|
1338
|
-
* // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token
|
|
1339
|
-
* // at its original position
|
|
1340
|
-
* 'comment': { ... },
|
|
1341
|
-
* // CSS doesn't have a 'color' token, so this token will be appended
|
|
1342
|
-
* 'color': /\b(?:red|green|blue)\b/
|
|
1343
|
-
* });
|
|
1344
|
-
*/
|
|
1345
|
-
extend: function (id, redef) {
|
|
1346
|
-
var lang = _.util.clone(_.languages[id]);
|
|
1347
|
-
|
|
1348
|
-
for (var key in redef) {
|
|
1349
|
-
lang[key] = redef[key];
|
|
1350
|
-
}
|
|
1351
|
-
|
|
1352
|
-
return lang;
|
|
1353
|
-
},
|
|
1354
|
-
|
|
1355
|
-
/**
|
|
1356
|
-
* Inserts tokens _before_ another token in a language definition or any other grammar.
|
|
1357
|
-
*
|
|
1358
|
-
* ## Usage
|
|
1359
|
-
*
|
|
1360
|
-
* This helper method makes it easy to modify existing languages. For example, the CSS language definition
|
|
1361
|
-
* not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded
|
|
1362
|
-
* in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the
|
|
1363
|
-
* appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do
|
|
1364
|
-
* this:
|
|
1365
|
-
*
|
|
1366
|
-
* ```js
|
|
1367
|
-
* Prism.languages.markup.style = {
|
|
1368
|
-
* // token
|
|
1369
|
-
* };
|
|
1370
|
-
* ```
|
|
1371
|
-
*
|
|
1372
|
-
* then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens
|
|
1373
|
-
* before existing tokens. For the CSS example above, you would use it like this:
|
|
1374
|
-
*
|
|
1375
|
-
* ```js
|
|
1376
|
-
* Prism.languages.insertBefore('markup', 'cdata', {
|
|
1377
|
-
* 'style': {
|
|
1378
|
-
* // token
|
|
1379
|
-
* }
|
|
1380
|
-
* });
|
|
1381
|
-
* ```
|
|
1382
|
-
*
|
|
1383
|
-
* ## Special cases
|
|
1384
|
-
*
|
|
1385
|
-
* If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar
|
|
1386
|
-
* will be ignored.
|
|
1387
|
-
*
|
|
1388
|
-
* This behavior can be used to insert tokens after `before`:
|
|
1389
|
-
*
|
|
1390
|
-
* ```js
|
|
1391
|
-
* Prism.languages.insertBefore('markup', 'comment', {
|
|
1392
|
-
* 'comment': Prism.languages.markup.comment,
|
|
1393
|
-
* // tokens after 'comment'
|
|
1394
|
-
* });
|
|
1395
|
-
* ```
|
|
1396
|
-
*
|
|
1397
|
-
* ## Limitations
|
|
1398
|
-
*
|
|
1399
|
-
* The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object
|
|
1400
|
-
* properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave
|
|
1401
|
-
* differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily
|
|
1402
|
-
* deleting properties which is necessary to insert at arbitrary positions.
|
|
1403
|
-
*
|
|
1404
|
-
* To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object.
|
|
1405
|
-
* Instead, it will create a new object and replace all references to the target object with the new one. This
|
|
1406
|
-
* can be done without temporarily deleting properties, so the iteration order is well-defined.
|
|
1407
|
-
*
|
|
1408
|
-
* However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if
|
|
1409
|
-
* you hold the target object in a variable, then the value of the variable will not change.
|
|
1410
|
-
*
|
|
1411
|
-
* ```js
|
|
1412
|
-
* var oldMarkup = Prism.languages.markup;
|
|
1413
|
-
* var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... });
|
|
1414
|
-
*
|
|
1415
|
-
* assert(oldMarkup !== Prism.languages.markup);
|
|
1416
|
-
* assert(newMarkup === Prism.languages.markup);
|
|
1417
|
-
* ```
|
|
1418
|
-
*
|
|
1419
|
-
* @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the
|
|
1420
|
-
* object to be modified.
|
|
1421
|
-
* @param {string} before The key to insert before.
|
|
1422
|
-
* @param {Grammar} insert An object containing the key-value pairs to be inserted.
|
|
1423
|
-
* @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the
|
|
1424
|
-
* object to be modified.
|
|
1425
|
-
*
|
|
1426
|
-
* Defaults to `Prism.languages`.
|
|
1427
|
-
* @returns {Grammar} The new grammar object.
|
|
1428
|
-
* @public
|
|
1429
|
-
*/
|
|
1430
|
-
insertBefore: function (inside, before, insert, root) {
|
|
1431
|
-
root = root || /** @type {any} */ (_.languages);
|
|
1432
|
-
var grammar = root[inside];
|
|
1433
|
-
/** @type {Grammar} */
|
|
1434
|
-
var ret = {};
|
|
1435
|
-
|
|
1436
|
-
for (var token in grammar) {
|
|
1437
|
-
if (grammar.hasOwnProperty(token)) {
|
|
1438
|
-
|
|
1439
|
-
if (token == before) {
|
|
1440
|
-
for (var newToken in insert) {
|
|
1441
|
-
if (insert.hasOwnProperty(newToken)) {
|
|
1442
|
-
ret[newToken] = insert[newToken];
|
|
1443
|
-
}
|
|
1444
|
-
}
|
|
1445
|
-
}
|
|
1446
|
-
|
|
1447
|
-
// Do not insert token which also occur in insert. See #1525
|
|
1448
|
-
if (!insert.hasOwnProperty(token)) {
|
|
1449
|
-
ret[token] = grammar[token];
|
|
1450
|
-
}
|
|
1451
|
-
}
|
|
1452
|
-
}
|
|
1453
|
-
|
|
1454
|
-
var old = root[inside];
|
|
1455
|
-
root[inside] = ret;
|
|
1456
|
-
|
|
1457
|
-
// Update references in other language definitions
|
|
1458
|
-
_.languages.DFS(_.languages, function (key, value) {
|
|
1459
|
-
if (value === old && key != inside) {
|
|
1460
|
-
this[key] = ret;
|
|
1461
|
-
}
|
|
1462
|
-
});
|
|
1463
|
-
|
|
1464
|
-
return ret;
|
|
1465
|
-
},
|
|
1466
|
-
|
|
1467
|
-
// Traverse a language definition with Depth First Search
|
|
1468
|
-
DFS: function DFS(o, callback, type, visited) {
|
|
1469
|
-
visited = visited || {};
|
|
1470
|
-
|
|
1471
|
-
var objId = _.util.objId;
|
|
1472
|
-
|
|
1473
|
-
for (var i in o) {
|
|
1474
|
-
if (o.hasOwnProperty(i)) {
|
|
1475
|
-
callback.call(o, i, o[i], type || i);
|
|
1476
|
-
|
|
1477
|
-
var property = o[i];
|
|
1478
|
-
var propertyType = _.util.type(property);
|
|
1479
|
-
|
|
1480
|
-
if (propertyType === 'Object' && !visited[objId(property)]) {
|
|
1481
|
-
visited[objId(property)] = true;
|
|
1482
|
-
DFS(property, callback, null, visited);
|
|
1483
|
-
} else if (propertyType === 'Array' && !visited[objId(property)]) {
|
|
1484
|
-
visited[objId(property)] = true;
|
|
1485
|
-
DFS(property, callback, i, visited);
|
|
1486
|
-
}
|
|
1487
|
-
}
|
|
1488
|
-
}
|
|
1489
|
-
}
|
|
1490
|
-
},
|
|
1491
|
-
|
|
1492
|
-
plugins: {},
|
|
1493
|
-
|
|
1494
|
-
/**
|
|
1495
|
-
* This is the most high-level function in Prism’s API.
|
|
1496
|
-
* It fetches all the elements that have a `.language-xxxx` class and then calls {@link Prism.highlightElement} on
|
|
1497
|
-
* each one of them.
|
|
1498
|
-
*
|
|
1499
|
-
* This is equivalent to `Prism.highlightAllUnder(document, async, callback)`.
|
|
1500
|
-
*
|
|
1501
|
-
* @param {boolean} [async=false] Same as in {@link Prism.highlightAllUnder}.
|
|
1502
|
-
* @param {HighlightCallback} [callback] Same as in {@link Prism.highlightAllUnder}.
|
|
1503
|
-
* @memberof Prism
|
|
1504
|
-
* @public
|
|
1505
|
-
*/
|
|
1506
|
-
highlightAll: function (async, callback) {
|
|
1507
|
-
_.highlightAllUnder(document, async, callback);
|
|
1508
|
-
},
|
|
1509
|
-
|
|
1510
|
-
/**
|
|
1511
|
-
* Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
|
|
1512
|
-
* {@link Prism.highlightElement} on each one of them.
|
|
1513
|
-
*
|
|
1514
|
-
* The following hooks will be run:
|
|
1515
|
-
* 1. `before-highlightall`
|
|
1516
|
-
* 2. `before-all-elements-highlight`
|
|
1517
|
-
* 3. All hooks of {@link Prism.highlightElement} for each element.
|
|
1518
|
-
*
|
|
1519
|
-
* @param {ParentNode} container The root element, whose descendants that have a `.language-xxxx` class will be highlighted.
|
|
1520
|
-
* @param {boolean} [async=false] Whether each element is to be highlighted asynchronously using Web Workers.
|
|
1521
|
-
* @param {HighlightCallback} [callback] An optional callback to be invoked on each element after its highlighting is done.
|
|
1522
|
-
* @memberof Prism
|
|
1523
|
-
* @public
|
|
1524
|
-
*/
|
|
1525
|
-
highlightAllUnder: function (container, async, callback) {
|
|
1526
|
-
var env = {
|
|
1527
|
-
callback: callback,
|
|
1528
|
-
container: container,
|
|
1529
|
-
selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
|
|
1530
|
-
};
|
|
1531
|
-
|
|
1532
|
-
_.hooks.run('before-highlightall', env);
|
|
1533
|
-
|
|
1534
|
-
env.elements = Array.prototype.slice.apply(env.container.querySelectorAll(env.selector));
|
|
1535
|
-
|
|
1536
|
-
_.hooks.run('before-all-elements-highlight', env);
|
|
1537
|
-
|
|
1538
|
-
for (var i = 0, element; (element = env.elements[i++]);) {
|
|
1539
|
-
_.highlightElement(element, async === true, env.callback);
|
|
1540
|
-
}
|
|
1541
|
-
},
|
|
1542
|
-
|
|
1543
|
-
/**
|
|
1544
|
-
* Highlights the code inside a single element.
|
|
1545
|
-
*
|
|
1546
|
-
* The following hooks will be run:
|
|
1547
|
-
* 1. `before-sanity-check`
|
|
1548
|
-
* 2. `before-highlight`
|
|
1549
|
-
* 3. All hooks of {@link Prism.highlight}. These hooks will be run by an asynchronous worker if `async` is `true`.
|
|
1550
|
-
* 4. `before-insert`
|
|
1551
|
-
* 5. `after-highlight`
|
|
1552
|
-
* 6. `complete`
|
|
1553
|
-
*
|
|
1554
|
-
* Some the above hooks will be skipped if the element doesn't contain any text or there is no grammar loaded for
|
|
1555
|
-
* the element's language.
|
|
1556
|
-
*
|
|
1557
|
-
* @param {Element} element The element containing the code.
|
|
1558
|
-
* It must have a class of `language-xxxx` to be processed, where `xxxx` is a valid language identifier.
|
|
1559
|
-
* @param {boolean} [async=false] Whether the element is to be highlighted asynchronously using Web Workers
|
|
1560
|
-
* to improve performance and avoid blocking the UI when highlighting very large chunks of code. This option is
|
|
1561
|
-
* [disabled by default](https://prismjs.com/faq.html#why-is-asynchronous-highlighting-disabled-by-default).
|
|
1562
|
-
*
|
|
1563
|
-
* Note: All language definitions required to highlight the code must be included in the main `prism.js` file for
|
|
1564
|
-
* asynchronous highlighting to work. You can build your own bundle on the
|
|
1565
|
-
* [Download page](https://prismjs.com/download.html).
|
|
1566
|
-
* @param {HighlightCallback} [callback] An optional callback to be invoked after the highlighting is done.
|
|
1567
|
-
* Mostly useful when `async` is `true`, since in that case, the highlighting is done asynchronously.
|
|
1568
|
-
* @memberof Prism
|
|
1569
|
-
* @public
|
|
1570
|
-
*/
|
|
1571
|
-
highlightElement: function (element, async, callback) {
|
|
1572
|
-
// Find language
|
|
1573
|
-
var language = _.util.getLanguage(element);
|
|
1574
|
-
var grammar = _.languages[language];
|
|
1575
|
-
|
|
1576
|
-
// Set language on the element, if not present
|
|
1577
|
-
_.util.setLanguage(element, language);
|
|
1578
|
-
|
|
1579
|
-
// Set language on the parent, for styling
|
|
1580
|
-
var parent = element.parentElement;
|
|
1581
|
-
if (parent && parent.nodeName.toLowerCase() === 'pre') {
|
|
1582
|
-
_.util.setLanguage(parent, language);
|
|
1583
|
-
}
|
|
1584
|
-
|
|
1585
|
-
var code = element.textContent;
|
|
1586
|
-
|
|
1587
|
-
var env = {
|
|
1588
|
-
element: element,
|
|
1589
|
-
language: language,
|
|
1590
|
-
grammar: grammar,
|
|
1591
|
-
code: code
|
|
1592
|
-
};
|
|
1593
|
-
|
|
1594
|
-
function insertHighlightedCode(highlightedCode) {
|
|
1595
|
-
env.highlightedCode = highlightedCode;
|
|
1596
|
-
|
|
1597
|
-
_.hooks.run('before-insert', env);
|
|
1598
|
-
|
|
1599
|
-
env.element.innerHTML = env.highlightedCode;
|
|
1600
|
-
|
|
1601
|
-
_.hooks.run('after-highlight', env);
|
|
1602
|
-
_.hooks.run('complete', env);
|
|
1603
|
-
callback && callback.call(env.element);
|
|
1604
|
-
}
|
|
1605
|
-
|
|
1606
|
-
_.hooks.run('before-sanity-check', env);
|
|
1607
|
-
|
|
1608
|
-
// plugins may change/add the parent/element
|
|
1609
|
-
parent = env.element.parentElement;
|
|
1610
|
-
if (parent && parent.nodeName.toLowerCase() === 'pre' && !parent.hasAttribute('tabindex')) {
|
|
1611
|
-
parent.setAttribute('tabindex', '0');
|
|
1612
|
-
}
|
|
1613
|
-
|
|
1614
|
-
if (!env.code) {
|
|
1615
|
-
_.hooks.run('complete', env);
|
|
1616
|
-
callback && callback.call(env.element);
|
|
1617
|
-
return;
|
|
1618
|
-
}
|
|
1619
|
-
|
|
1620
|
-
_.hooks.run('before-highlight', env);
|
|
1621
|
-
|
|
1622
|
-
if (!env.grammar) {
|
|
1623
|
-
insertHighlightedCode(_.util.encode(env.code));
|
|
1624
|
-
return;
|
|
1625
|
-
}
|
|
1626
|
-
|
|
1627
|
-
if (async && _self.Worker) {
|
|
1628
|
-
var worker = new Worker(_.filename);
|
|
1629
|
-
|
|
1630
|
-
worker.onmessage = function (evt) {
|
|
1631
|
-
insertHighlightedCode(evt.data);
|
|
1632
|
-
};
|
|
1633
|
-
|
|
1634
|
-
worker.postMessage(JSON.stringify({
|
|
1635
|
-
language: env.language,
|
|
1636
|
-
code: env.code,
|
|
1637
|
-
immediateClose: true
|
|
1638
|
-
}));
|
|
1639
|
-
} else {
|
|
1640
|
-
insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
|
|
1641
|
-
}
|
|
1642
|
-
},
|
|
1643
|
-
|
|
1644
|
-
/**
|
|
1645
|
-
* Low-level function, only use if you know what you’re doing. It accepts a string of text as input
|
|
1646
|
-
* and the language definitions to use, and returns a string with the HTML produced.
|
|
1647
|
-
*
|
|
1648
|
-
* The following hooks will be run:
|
|
1649
|
-
* 1. `before-tokenize`
|
|
1650
|
-
* 2. `after-tokenize`
|
|
1651
|
-
* 3. `wrap`: On each {@link Token}.
|
|
1652
|
-
*
|
|
1653
|
-
* @param {string} text A string with the code to be highlighted.
|
|
1654
|
-
* @param {Grammar} grammar An object containing the tokens to use.
|
|
1655
|
-
*
|
|
1656
|
-
* Usually a language definition like `Prism.languages.markup`.
|
|
1657
|
-
* @param {string} language The name of the language definition passed to `grammar`.
|
|
1658
|
-
* @returns {string} The highlighted HTML.
|
|
1659
|
-
* @memberof Prism
|
|
1660
|
-
* @public
|
|
1661
|
-
* @example
|
|
1662
|
-
* Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
|
|
1663
|
-
*/
|
|
1664
|
-
highlight: function (text, grammar, language) {
|
|
1665
|
-
var env = {
|
|
1666
|
-
code: text,
|
|
1667
|
-
grammar: grammar,
|
|
1668
|
-
language: language
|
|
1669
|
-
};
|
|
1670
|
-
_.hooks.run('before-tokenize', env);
|
|
1671
|
-
if (!env.grammar) {
|
|
1672
|
-
throw new Error('The language "' + env.language + '" has no grammar.');
|
|
1673
|
-
}
|
|
1674
|
-
env.tokens = _.tokenize(env.code, env.grammar);
|
|
1675
|
-
_.hooks.run('after-tokenize', env);
|
|
1676
|
-
return Token.stringify(_.util.encode(env.tokens), env.language);
|
|
1677
|
-
},
|
|
1678
|
-
|
|
1679
|
-
/**
|
|
1680
|
-
* This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
|
|
1681
|
-
* and the language definitions to use, and returns an array with the tokenized code.
|
|
1682
|
-
*
|
|
1683
|
-
* When the language definition includes nested tokens, the function is called recursively on each of these tokens.
|
|
1684
|
-
*
|
|
1685
|
-
* This method could be useful in other contexts as well, as a very crude parser.
|
|
1686
|
-
*
|
|
1687
|
-
* @param {string} text A string with the code to be highlighted.
|
|
1688
|
-
* @param {Grammar} grammar An object containing the tokens to use.
|
|
1689
|
-
*
|
|
1690
|
-
* Usually a language definition like `Prism.languages.markup`.
|
|
1691
|
-
* @returns {TokenStream} An array of strings and tokens, a token stream.
|
|
1692
|
-
* @memberof Prism
|
|
1693
|
-
* @public
|
|
1694
|
-
* @example
|
|
1695
|
-
* let code = `var foo = 0;`;
|
|
1696
|
-
* let tokens = Prism.tokenize(code, Prism.languages.javascript);
|
|
1697
|
-
* tokens.forEach(token => {
|
|
1698
|
-
* if (token instanceof Prism.Token && token.type === 'number') {
|
|
1699
|
-
* console.log(`Found numeric literal: ${token.content}`);
|
|
1700
|
-
* }
|
|
1701
|
-
* });
|
|
1702
|
-
*/
|
|
1703
|
-
tokenize: function (text, grammar) {
|
|
1704
|
-
var rest = grammar.rest;
|
|
1705
|
-
if (rest) {
|
|
1706
|
-
for (var token in rest) {
|
|
1707
|
-
grammar[token] = rest[token];
|
|
1708
|
-
}
|
|
1709
|
-
|
|
1710
|
-
delete grammar.rest;
|
|
1711
|
-
}
|
|
1712
|
-
|
|
1713
|
-
var tokenList = new LinkedList();
|
|
1714
|
-
addAfter(tokenList, tokenList.head, text);
|
|
1715
|
-
|
|
1716
|
-
matchGrammar(text, tokenList, grammar, tokenList.head, 0);
|
|
1717
|
-
|
|
1718
|
-
return toArray(tokenList);
|
|
1719
|
-
},
|
|
1720
|
-
|
|
1721
|
-
/**
|
|
1722
|
-
* @namespace
|
|
1723
|
-
* @memberof Prism
|
|
1724
|
-
* @public
|
|
1725
|
-
*/
|
|
1726
|
-
hooks: {
|
|
1727
|
-
all: {},
|
|
1728
|
-
|
|
1729
|
-
/**
|
|
1730
|
-
* Adds the given callback to the list of callbacks for the given hook.
|
|
1731
|
-
*
|
|
1732
|
-
* The callback will be invoked when the hook it is registered for is run.
|
|
1733
|
-
* Hooks are usually directly run by a highlight function but you can also run hooks yourself.
|
|
1734
|
-
*
|
|
1735
|
-
* One callback function can be registered to multiple hooks and the same hook multiple times.
|
|
1736
|
-
*
|
|
1737
|
-
* @param {string} name The name of the hook.
|
|
1738
|
-
* @param {HookCallback} callback The callback function which is given environment variables.
|
|
1739
|
-
* @public
|
|
1740
|
-
*/
|
|
1741
|
-
add: function (name, callback) {
|
|
1742
|
-
var hooks = _.hooks.all;
|
|
1743
|
-
|
|
1744
|
-
hooks[name] = hooks[name] || [];
|
|
1745
|
-
|
|
1746
|
-
hooks[name].push(callback);
|
|
1747
|
-
},
|
|
1748
|
-
|
|
1749
|
-
/**
|
|
1750
|
-
* Runs a hook invoking all registered callbacks with the given environment variables.
|
|
1751
|
-
*
|
|
1752
|
-
* Callbacks will be invoked synchronously and in the order in which they were registered.
|
|
1753
|
-
*
|
|
1754
|
-
* @param {string} name The name of the hook.
|
|
1755
|
-
* @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
|
|
1756
|
-
* @public
|
|
1757
|
-
*/
|
|
1758
|
-
run: function (name, env) {
|
|
1759
|
-
var callbacks = _.hooks.all[name];
|
|
1760
|
-
|
|
1761
|
-
if (!callbacks || !callbacks.length) {
|
|
1762
|
-
return;
|
|
1763
|
-
}
|
|
1764
|
-
|
|
1765
|
-
for (var i = 0, callback; (callback = callbacks[i++]);) {
|
|
1766
|
-
callback(env);
|
|
1767
|
-
}
|
|
1768
|
-
}
|
|
1769
|
-
},
|
|
1770
|
-
|
|
1771
|
-
Token: Token
|
|
1772
|
-
};
|
|
1773
|
-
_self.Prism = _;
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
// Typescript note:
|
|
1777
|
-
// The following can be used to import the Token type in JSDoc:
|
|
1778
|
-
//
|
|
1779
|
-
// @typedef {InstanceType<import("./prism-core")["Token"]>} Token
|
|
1780
|
-
|
|
1781
|
-
/**
|
|
1782
|
-
* Creates a new token.
|
|
1783
|
-
*
|
|
1784
|
-
* @param {string} type See {@link Token#type type}
|
|
1785
|
-
* @param {string | TokenStream} content See {@link Token#content content}
|
|
1786
|
-
* @param {string|string[]} [alias] The alias(es) of the token.
|
|
1787
|
-
* @param {string} [matchedStr=""] A copy of the full string this token was created from.
|
|
1788
|
-
* @class
|
|
1789
|
-
* @global
|
|
1790
|
-
* @public
|
|
1791
|
-
*/
|
|
1792
|
-
function Token(type, content, alias, matchedStr) {
|
|
1793
|
-
/**
|
|
1794
|
-
* The type of the token.
|
|
1795
|
-
*
|
|
1796
|
-
* This is usually the key of a pattern in a {@link Grammar}.
|
|
1797
|
-
*
|
|
1798
|
-
* @type {string}
|
|
1799
|
-
* @see GrammarToken
|
|
1800
|
-
* @public
|
|
1801
|
-
*/
|
|
1802
|
-
this.type = type;
|
|
1803
|
-
/**
|
|
1804
|
-
* The strings or tokens contained by this token.
|
|
1805
|
-
*
|
|
1806
|
-
* This will be a token stream if the pattern matched also defined an `inside` grammar.
|
|
1807
|
-
*
|
|
1808
|
-
* @type {string | TokenStream}
|
|
1809
|
-
* @public
|
|
1810
|
-
*/
|
|
1811
|
-
this.content = content;
|
|
1812
|
-
/**
|
|
1813
|
-
* The alias(es) of the token.
|
|
1814
|
-
*
|
|
1815
|
-
* @type {string|string[]}
|
|
1816
|
-
* @see GrammarToken
|
|
1817
|
-
* @public
|
|
1818
|
-
*/
|
|
1819
|
-
this.alias = alias;
|
|
1820
|
-
// Copy of the full string this token was created from
|
|
1821
|
-
this.length = (matchedStr || '').length | 0;
|
|
1822
|
-
}
|
|
1823
|
-
|
|
1824
|
-
/**
|
|
1825
|
-
* A token stream is an array of strings and {@link Token Token} objects.
|
|
1826
|
-
*
|
|
1827
|
-
* Token streams have to fulfill a few properties that are assumed by most functions (mostly internal ones) that process
|
|
1828
|
-
* them.
|
|
1829
|
-
*
|
|
1830
|
-
* 1. No adjacent strings.
|
|
1831
|
-
* 2. No empty strings.
|
|
1832
|
-
*
|
|
1833
|
-
* The only exception here is the token stream that only contains the empty string and nothing else.
|
|
1834
|
-
*
|
|
1835
|
-
* @typedef {Array<string | Token>} TokenStream
|
|
1836
|
-
* @global
|
|
1837
|
-
* @public
|
|
1838
|
-
*/
|
|
1839
|
-
|
|
1840
|
-
/**
|
|
1841
|
-
* Converts the given token or token stream to an HTML representation.
|
|
1842
|
-
*
|
|
1843
|
-
* The following hooks will be run:
|
|
1844
|
-
* 1. `wrap`: On each {@link Token}.
|
|
1845
|
-
*
|
|
1846
|
-
* @param {string | Token | TokenStream} o The token or token stream to be converted.
|
|
1847
|
-
* @param {string} language The name of current language.
|
|
1848
|
-
* @returns {string} The HTML representation of the token or token stream.
|
|
1849
|
-
* @memberof Token
|
|
1850
|
-
* @static
|
|
1851
|
-
*/
|
|
1852
|
-
Token.stringify = function stringify(o, language) {
|
|
1853
|
-
if (typeof o == 'string') {
|
|
1854
|
-
return o;
|
|
1855
|
-
}
|
|
1856
|
-
if (Array.isArray(o)) {
|
|
1857
|
-
var s = '';
|
|
1858
|
-
o.forEach(function (e) {
|
|
1859
|
-
s += stringify(e, language);
|
|
1860
|
-
});
|
|
1861
|
-
return s;
|
|
1862
|
-
}
|
|
1863
|
-
|
|
1864
|
-
var env = {
|
|
1865
|
-
type: o.type,
|
|
1866
|
-
content: stringify(o.content, language),
|
|
1867
|
-
tag: 'span',
|
|
1868
|
-
classes: ['token', o.type],
|
|
1869
|
-
attributes: {},
|
|
1870
|
-
language: language
|
|
1871
|
-
};
|
|
1872
|
-
|
|
1873
|
-
var aliases = o.alias;
|
|
1874
|
-
if (aliases) {
|
|
1875
|
-
if (Array.isArray(aliases)) {
|
|
1876
|
-
Array.prototype.push.apply(env.classes, aliases);
|
|
1877
|
-
} else {
|
|
1878
|
-
env.classes.push(aliases);
|
|
1879
|
-
}
|
|
1880
|
-
}
|
|
1881
|
-
|
|
1882
|
-
_.hooks.run('wrap', env);
|
|
1883
|
-
|
|
1884
|
-
var attributes = '';
|
|
1885
|
-
for (var name in env.attributes) {
|
|
1886
|
-
attributes += ' ' + name + '="' + (env.attributes[name] || '').replace(/"/g, '"') + '"';
|
|
1887
|
-
}
|
|
1888
|
-
|
|
1889
|
-
return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + attributes + '>' + env.content + '</' + env.tag + '>';
|
|
1890
|
-
};
|
|
1891
|
-
|
|
1892
|
-
/**
|
|
1893
|
-
* @param {RegExp} pattern
|
|
1894
|
-
* @param {number} pos
|
|
1895
|
-
* @param {string} text
|
|
1896
|
-
* @param {boolean} lookbehind
|
|
1897
|
-
* @returns {RegExpExecArray | null}
|
|
1898
|
-
*/
|
|
1899
|
-
function matchPattern(pattern, pos, text, lookbehind) {
|
|
1900
|
-
pattern.lastIndex = pos;
|
|
1901
|
-
var match = pattern.exec(text);
|
|
1902
|
-
if (match && lookbehind && match[1]) {
|
|
1903
|
-
// change the match to remove the text matched by the Prism lookbehind group
|
|
1904
|
-
var lookbehindLength = match[1].length;
|
|
1905
|
-
match.index += lookbehindLength;
|
|
1906
|
-
match[0] = match[0].slice(lookbehindLength);
|
|
1907
|
-
}
|
|
1908
|
-
return match;
|
|
1909
|
-
}
|
|
1910
|
-
|
|
1911
|
-
/**
|
|
1912
|
-
* @param {string} text
|
|
1913
|
-
* @param {LinkedList<string | Token>} tokenList
|
|
1914
|
-
* @param {any} grammar
|
|
1915
|
-
* @param {LinkedListNode<string | Token>} startNode
|
|
1916
|
-
* @param {number} startPos
|
|
1917
|
-
* @param {RematchOptions} [rematch]
|
|
1918
|
-
* @returns {void}
|
|
1919
|
-
* @private
|
|
1920
|
-
*
|
|
1921
|
-
* @typedef RematchOptions
|
|
1922
|
-
* @property {string} cause
|
|
1923
|
-
* @property {number} reach
|
|
1924
|
-
*/
|
|
1925
|
-
function matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) {
|
|
1926
|
-
for (var token in grammar) {
|
|
1927
|
-
if (!grammar.hasOwnProperty(token) || !grammar[token]) {
|
|
1928
|
-
continue;
|
|
1929
|
-
}
|
|
1930
|
-
|
|
1931
|
-
var patterns = grammar[token];
|
|
1932
|
-
patterns = Array.isArray(patterns) ? patterns : [patterns];
|
|
1933
|
-
|
|
1934
|
-
for (var j = 0; j < patterns.length; ++j) {
|
|
1935
|
-
if (rematch && rematch.cause == token + ',' + j) {
|
|
1936
|
-
return;
|
|
1937
|
-
}
|
|
1938
|
-
|
|
1939
|
-
var patternObj = patterns[j];
|
|
1940
|
-
var inside = patternObj.inside;
|
|
1941
|
-
var lookbehind = !!patternObj.lookbehind;
|
|
1942
|
-
var greedy = !!patternObj.greedy;
|
|
1943
|
-
var alias = patternObj.alias;
|
|
1944
|
-
|
|
1945
|
-
if (greedy && !patternObj.pattern.global) {
|
|
1946
|
-
// Without the global flag, lastIndex won't work
|
|
1947
|
-
var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0];
|
|
1948
|
-
patternObj.pattern = RegExp(patternObj.pattern.source, flags + 'g');
|
|
1949
|
-
}
|
|
1950
|
-
|
|
1951
|
-
/** @type {RegExp} */
|
|
1952
|
-
var pattern = patternObj.pattern || patternObj;
|
|
1953
|
-
|
|
1954
|
-
for ( // iterate the token list and keep track of the current token/string position
|
|
1955
|
-
var currentNode = startNode.next, pos = startPos;
|
|
1956
|
-
currentNode !== tokenList.tail;
|
|
1957
|
-
pos += currentNode.value.length, currentNode = currentNode.next
|
|
1958
|
-
) {
|
|
1959
|
-
|
|
1960
|
-
if (rematch && pos >= rematch.reach) {
|
|
1961
|
-
break;
|
|
1962
|
-
}
|
|
1963
|
-
|
|
1964
|
-
var str = currentNode.value;
|
|
1965
|
-
|
|
1966
|
-
if (tokenList.length > text.length) {
|
|
1967
|
-
// Something went terribly wrong, ABORT, ABORT!
|
|
1968
|
-
return;
|
|
1969
|
-
}
|
|
1970
|
-
|
|
1971
|
-
if (str instanceof Token) {
|
|
1972
|
-
continue;
|
|
1973
|
-
}
|
|
1974
|
-
|
|
1975
|
-
var removeCount = 1; // this is the to parameter of removeBetween
|
|
1976
|
-
var match;
|
|
1977
|
-
|
|
1978
|
-
if (greedy) {
|
|
1979
|
-
match = matchPattern(pattern, pos, text, lookbehind);
|
|
1980
|
-
if (!match || match.index >= text.length) {
|
|
1981
|
-
break;
|
|
1982
|
-
}
|
|
1983
|
-
|
|
1984
|
-
var from = match.index;
|
|
1985
|
-
var to = match.index + match[0].length;
|
|
1986
|
-
var p = pos;
|
|
1987
|
-
|
|
1988
|
-
// find the node that contains the match
|
|
1989
|
-
p += currentNode.value.length;
|
|
1990
|
-
while (from >= p) {
|
|
1991
|
-
currentNode = currentNode.next;
|
|
1992
|
-
p += currentNode.value.length;
|
|
1993
|
-
}
|
|
1994
|
-
// adjust pos (and p)
|
|
1995
|
-
p -= currentNode.value.length;
|
|
1996
|
-
pos = p;
|
|
1997
|
-
|
|
1998
|
-
// the current node is a Token, then the match starts inside another Token, which is invalid
|
|
1999
|
-
if (currentNode.value instanceof Token) {
|
|
2000
|
-
continue;
|
|
2001
|
-
}
|
|
2002
|
-
|
|
2003
|
-
// find the last node which is affected by this match
|
|
2004
|
-
for (
|
|
2005
|
-
var k = currentNode;
|
|
2006
|
-
k !== tokenList.tail && (p < to || typeof k.value === 'string');
|
|
2007
|
-
k = k.next
|
|
2008
|
-
) {
|
|
2009
|
-
removeCount++;
|
|
2010
|
-
p += k.value.length;
|
|
2011
|
-
}
|
|
2012
|
-
removeCount--;
|
|
2013
|
-
|
|
2014
|
-
// replace with the new match
|
|
2015
|
-
str = text.slice(pos, p);
|
|
2016
|
-
match.index -= pos;
|
|
2017
|
-
} else {
|
|
2018
|
-
match = matchPattern(pattern, 0, str, lookbehind);
|
|
2019
|
-
if (!match) {
|
|
2020
|
-
continue;
|
|
2021
|
-
}
|
|
2022
|
-
}
|
|
2023
|
-
|
|
2024
|
-
// eslint-disable-next-line no-redeclare
|
|
2025
|
-
var from = match.index;
|
|
2026
|
-
var matchStr = match[0];
|
|
2027
|
-
var before = str.slice(0, from);
|
|
2028
|
-
var after = str.slice(from + matchStr.length);
|
|
2029
|
-
|
|
2030
|
-
var reach = pos + str.length;
|
|
2031
|
-
if (rematch && reach > rematch.reach) {
|
|
2032
|
-
rematch.reach = reach;
|
|
2033
|
-
}
|
|
2034
|
-
|
|
2035
|
-
var removeFrom = currentNode.prev;
|
|
2036
|
-
|
|
2037
|
-
if (before) {
|
|
2038
|
-
removeFrom = addAfter(tokenList, removeFrom, before);
|
|
2039
|
-
pos += before.length;
|
|
2040
|
-
}
|
|
2041
|
-
|
|
2042
|
-
removeRange(tokenList, removeFrom, removeCount);
|
|
2043
|
-
|
|
2044
|
-
var wrapped = new Token(token, inside ? _.tokenize(matchStr, inside) : matchStr, alias, matchStr);
|
|
2045
|
-
currentNode = addAfter(tokenList, removeFrom, wrapped);
|
|
2046
|
-
|
|
2047
|
-
if (after) {
|
|
2048
|
-
addAfter(tokenList, currentNode, after);
|
|
2049
|
-
}
|
|
2050
|
-
|
|
2051
|
-
if (removeCount > 1) {
|
|
2052
|
-
// at least one Token object was removed, so we have to do some rematching
|
|
2053
|
-
// this can only happen if the current pattern is greedy
|
|
2054
|
-
|
|
2055
|
-
/** @type {RematchOptions} */
|
|
2056
|
-
var nestedRematch = {
|
|
2057
|
-
cause: token + ',' + j,
|
|
2058
|
-
reach: reach
|
|
2059
|
-
};
|
|
2060
|
-
matchGrammar(text, tokenList, grammar, currentNode.prev, pos, nestedRematch);
|
|
2061
|
-
|
|
2062
|
-
// the reach might have been extended because of the rematching
|
|
2063
|
-
if (rematch && nestedRematch.reach > rematch.reach) {
|
|
2064
|
-
rematch.reach = nestedRematch.reach;
|
|
2065
|
-
}
|
|
2066
|
-
}
|
|
2067
|
-
}
|
|
2068
|
-
}
|
|
2069
|
-
}
|
|
2070
|
-
}
|
|
2071
|
-
|
|
2072
|
-
/**
|
|
2073
|
-
* @typedef LinkedListNode
|
|
2074
|
-
* @property {T} value
|
|
2075
|
-
* @property {LinkedListNode<T> | null} prev The previous node.
|
|
2076
|
-
* @property {LinkedListNode<T> | null} next The next node.
|
|
2077
|
-
* @template T
|
|
2078
|
-
* @private
|
|
2079
|
-
*/
|
|
2080
|
-
|
|
2081
|
-
/**
|
|
2082
|
-
* @template T
|
|
2083
|
-
* @private
|
|
2084
|
-
*/
|
|
2085
|
-
function LinkedList() {
|
|
2086
|
-
/** @type {LinkedListNode<T>} */
|
|
2087
|
-
var head = { value: null, prev: null, next: null };
|
|
2088
|
-
/** @type {LinkedListNode<T>} */
|
|
2089
|
-
var tail = { value: null, prev: head, next: null };
|
|
2090
|
-
head.next = tail;
|
|
2091
|
-
|
|
2092
|
-
/** @type {LinkedListNode<T>} */
|
|
2093
|
-
this.head = head;
|
|
2094
|
-
/** @type {LinkedListNode<T>} */
|
|
2095
|
-
this.tail = tail;
|
|
2096
|
-
this.length = 0;
|
|
2097
|
-
}
|
|
2098
|
-
|
|
2099
|
-
/**
|
|
2100
|
-
* Adds a new node with the given value to the list.
|
|
2101
|
-
*
|
|
2102
|
-
* @param {LinkedList<T>} list
|
|
2103
|
-
* @param {LinkedListNode<T>} node
|
|
2104
|
-
* @param {T} value
|
|
2105
|
-
* @returns {LinkedListNode<T>} The added node.
|
|
2106
|
-
* @template T
|
|
2107
|
-
*/
|
|
2108
|
-
function addAfter(list, node, value) {
|
|
2109
|
-
// assumes that node != list.tail && values.length >= 0
|
|
2110
|
-
var next = node.next;
|
|
2111
|
-
|
|
2112
|
-
var newNode = { value: value, prev: node, next: next };
|
|
2113
|
-
node.next = newNode;
|
|
2114
|
-
next.prev = newNode;
|
|
2115
|
-
list.length++;
|
|
2116
|
-
|
|
2117
|
-
return newNode;
|
|
2118
|
-
}
|
|
2119
|
-
/**
|
|
2120
|
-
* Removes `count` nodes after the given node. The given node will not be removed.
|
|
2121
|
-
*
|
|
2122
|
-
* @param {LinkedList<T>} list
|
|
2123
|
-
* @param {LinkedListNode<T>} node
|
|
2124
|
-
* @param {number} count
|
|
2125
|
-
* @template T
|
|
2126
|
-
*/
|
|
2127
|
-
function removeRange(list, node, count) {
|
|
2128
|
-
var next = node.next;
|
|
2129
|
-
for (var i = 0; i < count && next !== list.tail; i++) {
|
|
2130
|
-
next = next.next;
|
|
2131
|
-
}
|
|
2132
|
-
node.next = next;
|
|
2133
|
-
next.prev = node;
|
|
2134
|
-
list.length -= i;
|
|
2135
|
-
}
|
|
2136
|
-
/**
|
|
2137
|
-
* @param {LinkedList<T>} list
|
|
2138
|
-
* @returns {T[]}
|
|
2139
|
-
* @template T
|
|
2140
|
-
*/
|
|
2141
|
-
function toArray(list) {
|
|
2142
|
-
var array = [];
|
|
2143
|
-
var node = list.head.next;
|
|
2144
|
-
while (node !== list.tail) {
|
|
2145
|
-
array.push(node.value);
|
|
2146
|
-
node = node.next;
|
|
2147
|
-
}
|
|
2148
|
-
return array;
|
|
2149
|
-
}
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
if (!_self.document) {
|
|
2153
|
-
if (!_self.addEventListener) {
|
|
2154
|
-
// in Node.js
|
|
2155
|
-
return _;
|
|
2156
|
-
}
|
|
2157
|
-
|
|
2158
|
-
if (!_.disableWorkerMessageHandler) {
|
|
2159
|
-
// In worker
|
|
2160
|
-
_self.addEventListener('message', function (evt) {
|
|
2161
|
-
var message = JSON.parse(evt.data);
|
|
2162
|
-
var lang = message.language;
|
|
2163
|
-
var code = message.code;
|
|
2164
|
-
var immediateClose = message.immediateClose;
|
|
2165
|
-
|
|
2166
|
-
_self.postMessage(_.highlight(code, _.languages[lang], lang));
|
|
2167
|
-
if (immediateClose) {
|
|
2168
|
-
_self.close();
|
|
2169
|
-
}
|
|
2170
|
-
}, false);
|
|
2171
|
-
}
|
|
2172
|
-
|
|
2173
|
-
return _;
|
|
2174
|
-
}
|
|
2175
|
-
|
|
2176
|
-
// Get current script and highlight
|
|
2177
|
-
var script = _.util.currentScript();
|
|
2178
|
-
|
|
2179
|
-
if (script) {
|
|
2180
|
-
_.filename = script.src;
|
|
2181
|
-
|
|
2182
|
-
if (script.hasAttribute('data-manual')) {
|
|
2183
|
-
_.manual = true;
|
|
2184
|
-
}
|
|
2185
|
-
}
|
|
2186
|
-
|
|
2187
|
-
function highlightAutomaticallyCallback() {
|
|
2188
|
-
if (!_.manual) {
|
|
2189
|
-
_.highlightAll();
|
|
2190
|
-
}
|
|
2191
|
-
}
|
|
2192
|
-
|
|
2193
|
-
if (!_.manual) {
|
|
2194
|
-
// If the document state is "loading", then we'll use DOMContentLoaded.
|
|
2195
|
-
// If the document state is "interactive" and the prism.js script is deferred, then we'll also use the
|
|
2196
|
-
// DOMContentLoaded event because there might be some plugins or languages which have also been deferred and they
|
|
2197
|
-
// might take longer one animation frame to execute which can create a race condition where only some plugins have
|
|
2198
|
-
// been loaded when Prism.highlightAll() is executed, depending on how fast resources are loaded.
|
|
2199
|
-
// See https://github.com/PrismJS/prism/issues/2102
|
|
2200
|
-
var readyState = document.readyState;
|
|
2201
|
-
if (readyState === 'loading' || readyState === 'interactive' && script && script.defer) {
|
|
2202
|
-
document.addEventListener('DOMContentLoaded', highlightAutomaticallyCallback);
|
|
2203
|
-
} else {
|
|
2204
|
-
if (window.requestAnimationFrame) {
|
|
2205
|
-
window.requestAnimationFrame(highlightAutomaticallyCallback);
|
|
2206
|
-
} else {
|
|
2207
|
-
window.setTimeout(highlightAutomaticallyCallback, 16);
|
|
2208
|
-
}
|
|
2209
|
-
}
|
|
2210
|
-
}
|
|
2211
|
-
|
|
2212
|
-
return _;
|
|
2213
|
-
|
|
2214
|
-
}(_self));
|
|
2215
|
-
|
|
2216
|
-
if (module.exports) {
|
|
2217
|
-
module.exports = Prism;
|
|
2218
|
-
}
|
|
2219
|
-
|
|
2220
|
-
// hack for components to work correctly in node.js
|
|
2221
|
-
if (typeof _commonjsHelpers.commonjsGlobal !== 'undefined') {
|
|
2222
|
-
_commonjsHelpers.commonjsGlobal.Prism = Prism;
|
|
1029
|
+
function tokenize(code, grammar) {
|
|
1030
|
+
if (!code || !grammar) {
|
|
1031
|
+
return [code];
|
|
1032
|
+
}
|
|
1033
|
+
const tokens = [code];
|
|
1034
|
+
matchGrammar(tokens, grammar);
|
|
1035
|
+
return tokens;
|
|
2223
1036
|
}
|
|
2224
|
-
|
|
2225
|
-
// some additional documentation/types
|
|
2226
|
-
|
|
2227
1037
|
/**
|
|
2228
|
-
*
|
|
1038
|
+
* Apply grammar rules to tokenize string entries in the token list.
|
|
1039
|
+
* Greedy patterns are applied first: their matched regions are replaced with
|
|
1040
|
+
* opaque placeholder tokens so that subsequent (non-greedy) rules cannot
|
|
1041
|
+
* match inside those regions. After all rules have run the placeholders are
|
|
1042
|
+
* restored to the original matched text.
|
|
2229
1043
|
*
|
|
2230
|
-
* @
|
|
2231
|
-
* @
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
1044
|
+
* @param {(string | SyntaxToken)[]} tokens - The current token list to process in-place.
|
|
1045
|
+
* @param {Grammar} grammar - The grammar rules to apply.
|
|
1046
|
+
*/
|
|
1047
|
+
function matchGrammar(tokens, grammar) {
|
|
1048
|
+
const greedyEntries = [];
|
|
1049
|
+
const nonGreedyEntries = [];
|
|
1050
|
+
for (const tokenType of Object.keys(grammar)) {
|
|
1051
|
+
const grammarEntry = grammar[tokenType];
|
|
1052
|
+
const patterns = Array.isArray(grammarEntry) ? grammarEntry : [grammarEntry];
|
|
1053
|
+
for (const patternDef of patterns) {
|
|
1054
|
+
if (patternDef.greedy) {
|
|
1055
|
+
greedyEntries.push({ tokenType, patternDef });
|
|
1056
|
+
}
|
|
1057
|
+
else {
|
|
1058
|
+
nonGreedyEntries.push({ tokenType, patternDef });
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
// --- Phase 1: Apply greedy patterns first --------------------------------
|
|
1063
|
+
// Greedy patterns claim regions of the source text exclusively.
|
|
1064
|
+
// We replace matched regions with a placeholder string of equal length so
|
|
1065
|
+
// that character offsets remain stable. Each greedy match is recorded so
|
|
1066
|
+
// we can later restore the original text inside the token.
|
|
1067
|
+
if (greedyEntries.length > 0) {
|
|
1068
|
+
applyGreedyPatterns(tokens, greedyEntries);
|
|
1069
|
+
}
|
|
1070
|
+
// --- Phase 2: Apply remaining non-greedy patterns ------------------------
|
|
1071
|
+
for (const { tokenType, patternDef } of nonGreedyEntries) {
|
|
1072
|
+
applyPattern(tokens, tokenType, patternDef);
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
/**
|
|
1076
|
+
* Process all greedy patterns against the current token list.
|
|
2237
1077
|
*
|
|
2238
|
-
*
|
|
1078
|
+
* For every plain-string entry in the list the function builds a *mask* string
|
|
1079
|
+
* of the same length. Greedy matches are recorded and their corresponding
|
|
1080
|
+
* character ranges in the mask are overwritten with a placeholder character so
|
|
1081
|
+
* that later greedy patterns (and all non-greedy patterns) will never match
|
|
1082
|
+
* inside an already-claimed region.
|
|
2239
1083
|
*
|
|
2240
|
-
*
|
|
1084
|
+
* After all greedy patterns have been collected the affected string entries are
|
|
1085
|
+
* rebuilt by splicing in SyntaxToken objects for each greedy match.
|
|
2241
1086
|
*
|
|
2242
|
-
*
|
|
2243
|
-
*
|
|
2244
|
-
* @global
|
|
2245
|
-
* @public
|
|
1087
|
+
* @param {(string | SyntaxToken)[]} tokens - The token list to process in-place.
|
|
1088
|
+
* @param {{ tokenType: string; patternDef: GrammarPattern }[]} greedyEntries - Greedy patterns to apply.
|
|
2246
1089
|
*/
|
|
2247
|
-
|
|
1090
|
+
function applyGreedyPatterns(tokens, greedyEntries) {
|
|
1091
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
1092
|
+
const token = tokens[i];
|
|
1093
|
+
/* istanbul ignore next -- defensive: greedy phase only sees strings from initial tokenize() call */
|
|
1094
|
+
if (typeof token !== 'string') {
|
|
1095
|
+
continue;
|
|
1096
|
+
}
|
|
1097
|
+
// Build the full text by concatenating all consecutive string segments
|
|
1098
|
+
// so greedy regex can match across them — but for simplicity we operate
|
|
1099
|
+
// per-segment, which matches prismjs behavior for the patterns we use.
|
|
1100
|
+
const originalText = token;
|
|
1101
|
+
// Mask tracks which characters have been claimed. A GREEDY_PLACEHOLDER
|
|
1102
|
+
// character at position j means that character is already part of a greedy match.
|
|
1103
|
+
let mask = originalText;
|
|
1104
|
+
const matches = [];
|
|
1105
|
+
for (const { tokenType, patternDef } of greedyEntries) {
|
|
1106
|
+
const { pattern, lookbehind, inside } = patternDef;
|
|
1107
|
+
const regex = new RegExp(pattern.source, pattern.flags.replace(/g/g, '') + 'g');
|
|
1108
|
+
let execResult;
|
|
1109
|
+
while ((execResult = regex.exec(mask)) !== null) {
|
|
1110
|
+
let matchIndex = execResult.index;
|
|
1111
|
+
let match = execResult[0];
|
|
1112
|
+
/* istanbul ignore next -- defensive: prevents infinite loop on zero-length regex matches */
|
|
1113
|
+
if (match.length === 0) {
|
|
1114
|
+
regex.lastIndex++;
|
|
1115
|
+
continue;
|
|
1116
|
+
}
|
|
1117
|
+
// If matched text contains a placeholder char it overlaps a
|
|
1118
|
+
// previously claimed region — skip it.
|
|
1119
|
+
/* istanbul ignore next -- defensive: prevents re-tokenizing already-claimed greedy regions */
|
|
1120
|
+
if (match.indexOf(GREEDY_PLACEHOLDER) !== -1) {
|
|
1121
|
+
continue;
|
|
1122
|
+
}
|
|
1123
|
+
if (lookbehind && execResult[1]) {
|
|
1124
|
+
const lookbehindLength = execResult[1].length;
|
|
1125
|
+
matchIndex += lookbehindLength;
|
|
1126
|
+
match = match.slice(lookbehindLength);
|
|
1127
|
+
}
|
|
1128
|
+
// Record the match and blank out the region in the mask.
|
|
1129
|
+
const matchEnd = matchIndex + match.length;
|
|
1130
|
+
matches.push({
|
|
1131
|
+
tokenType,
|
|
1132
|
+
matchStart: matchIndex,
|
|
1133
|
+
matchEnd,
|
|
1134
|
+
matchText: originalText.slice(matchIndex, matchEnd),
|
|
1135
|
+
inside,
|
|
1136
|
+
});
|
|
1137
|
+
// Replace matched region in the mask with placeholder so later
|
|
1138
|
+
// patterns cannot match inside it.
|
|
1139
|
+
mask =
|
|
1140
|
+
mask.slice(0, matchIndex) +
|
|
1141
|
+
GREEDY_PLACEHOLDER.repeat(match.length).slice(0, match.length) +
|
|
1142
|
+
mask.slice(matchEnd);
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
if (matches.length === 0) {
|
|
1146
|
+
continue;
|
|
1147
|
+
}
|
|
1148
|
+
// Sort matches by start position for deterministic splicing.
|
|
1149
|
+
matches.sort((a, b) => a.matchStart - b.matchStart);
|
|
1150
|
+
// Build replacement array.
|
|
1151
|
+
const replacement = [];
|
|
1152
|
+
let lastIndex = 0;
|
|
1153
|
+
for (const m of matches) {
|
|
1154
|
+
if (m.matchStart > lastIndex) {
|
|
1155
|
+
replacement.push(originalText.slice(lastIndex, m.matchStart));
|
|
1156
|
+
}
|
|
1157
|
+
let content = m.matchText;
|
|
1158
|
+
if (m.inside) {
|
|
1159
|
+
const nested = tokenize(m.matchText, m.inside);
|
|
1160
|
+
content = nested.length === 1 ? nested[0] : nested;
|
|
1161
|
+
}
|
|
1162
|
+
replacement.push({ type: m.tokenType, content });
|
|
1163
|
+
lastIndex = m.matchEnd;
|
|
1164
|
+
}
|
|
1165
|
+
if (lastIndex < originalText.length) {
|
|
1166
|
+
replacement.push(originalText.slice(lastIndex));
|
|
1167
|
+
}
|
|
1168
|
+
tokens.splice(i, 1, ...replacement);
|
|
1169
|
+
i += replacement.length - 1;
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
2248
1172
|
/**
|
|
2249
|
-
*
|
|
2250
|
-
*
|
|
2251
|
-
*
|
|
2252
|
-
*
|
|
2253
|
-
* @
|
|
1173
|
+
* Apply a single pattern definition across all string entries in the token list.
|
|
1174
|
+
* For each string entry, finds ALL matches of the pattern and splits the string
|
|
1175
|
+
* into alternating unmatched/matched segments in one pass.
|
|
1176
|
+
*
|
|
1177
|
+
* @param {(string | SyntaxToken)[]} tokens - The token list to process.
|
|
1178
|
+
* @param {string} tokenType - The token type name for matched content.
|
|
1179
|
+
* @param {GrammarPattern} patternDef - The pattern definition to apply.
|
|
2254
1180
|
*/
|
|
2255
|
-
|
|
1181
|
+
function applyPattern(tokens, tokenType, patternDef) {
|
|
1182
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
1183
|
+
const token = tokens[i];
|
|
1184
|
+
// Only process string tokens, skip already-tokenized entries
|
|
1185
|
+
if (typeof token !== 'string') {
|
|
1186
|
+
continue;
|
|
1187
|
+
}
|
|
1188
|
+
const replacement = tokenizeStringByPattern(token, tokenType, patternDef);
|
|
1189
|
+
// Only splice if matches were found (replacement differs from original)
|
|
1190
|
+
if (replacement.length === 1 && typeof replacement[0] === 'string') {
|
|
1191
|
+
continue;
|
|
1192
|
+
}
|
|
1193
|
+
tokens.splice(i, 1, ...replacement);
|
|
1194
|
+
// Skip past the entire replacement — all matches in this string are handled
|
|
1195
|
+
i += replacement.length - 1;
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
2256
1198
|
/**
|
|
2257
|
-
*
|
|
1199
|
+
* Find all matches of a pattern within a string and return the split result
|
|
1200
|
+
* as an array of alternating plain strings and syntax tokens.
|
|
2258
1201
|
*
|
|
2259
|
-
* @
|
|
2260
|
-
* @param {
|
|
2261
|
-
* @
|
|
2262
|
-
* @
|
|
2263
|
-
* @public
|
|
1202
|
+
* @param {string} text - The string to tokenize.
|
|
1203
|
+
* @param {string} tokenType - The token type name for matched content.
|
|
1204
|
+
* @param {GrammarPattern} patternDef - The pattern definition to apply.
|
|
1205
|
+
* @returns {(string | SyntaxToken)[]} The tokenized result.
|
|
2264
1206
|
*/
|
|
1207
|
+
function tokenizeStringByPattern(text, tokenType, patternDef) {
|
|
1208
|
+
const { pattern, lookbehind, inside } = patternDef;
|
|
1209
|
+
const regex = new RegExp(pattern.source, pattern.flags.replace(/g/g, '') + 'g');
|
|
1210
|
+
const result = [];
|
|
1211
|
+
let lastIndex = 0;
|
|
1212
|
+
let execResult;
|
|
1213
|
+
while ((execResult = regex.exec(text)) !== null) {
|
|
1214
|
+
let matchIndex = execResult.index;
|
|
1215
|
+
let match = execResult[0];
|
|
1216
|
+
// Prevent zero-length match infinite loops
|
|
1217
|
+
if (match.length === 0) {
|
|
1218
|
+
regex.lastIndex++;
|
|
1219
|
+
continue;
|
|
1220
|
+
}
|
|
1221
|
+
// Handle lookbehind: adjust match position and content
|
|
1222
|
+
if (lookbehind && execResult[1]) {
|
|
1223
|
+
const lookbehindLength = execResult[1].length;
|
|
1224
|
+
matchIndex += lookbehindLength;
|
|
1225
|
+
match = match.slice(lookbehindLength);
|
|
1226
|
+
}
|
|
1227
|
+
// Add unmatched text before this match
|
|
1228
|
+
if (matchIndex > lastIndex) {
|
|
1229
|
+
result.push(text.slice(lastIndex, matchIndex));
|
|
1230
|
+
}
|
|
1231
|
+
// Process nested grammar if specified
|
|
1232
|
+
let content = match;
|
|
1233
|
+
if (inside) {
|
|
1234
|
+
const nestedTokens = tokenize(match, inside);
|
|
1235
|
+
content = nestedTokens.length === 1 ? nestedTokens[0] : nestedTokens;
|
|
1236
|
+
}
|
|
1237
|
+
result.push({ type: tokenType, content });
|
|
1238
|
+
lastIndex = matchIndex + match.length;
|
|
1239
|
+
}
|
|
1240
|
+
// Add remaining unmatched text
|
|
1241
|
+
if (lastIndex < text.length) {
|
|
1242
|
+
result.push(text.slice(lastIndex));
|
|
1243
|
+
}
|
|
1244
|
+
/* istanbul ignore next -- defensive: tokenizeStringByPattern always has remainder text */
|
|
1245
|
+
if (result.length === 0) {
|
|
1246
|
+
return [text];
|
|
1247
|
+
}
|
|
1248
|
+
return result;
|
|
1249
|
+
}
|
|
2265
1250
|
|
|
2266
1251
|
/**
|
|
2267
|
-
*
|
|
2268
|
-
*
|
|
2269
|
-
* @returns {void}
|
|
2270
|
-
* @global
|
|
2271
|
-
* @public
|
|
1252
|
+
* Grammar definition for CSS syntax highlighting.
|
|
1253
|
+
* Handles selectors, properties, values, at-rules, comments, strings, and other CSS constructs.
|
|
2272
1254
|
*/
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
/&#x?[\da-f]{1,8};/i
|
|
2355
|
-
]
|
|
1255
|
+
const cssGrammar = {
|
|
1256
|
+
comment: {
|
|
1257
|
+
pattern: /\/\*[\s\S]*?\*\//,
|
|
1258
|
+
greedy: true,
|
|
1259
|
+
},
|
|
1260
|
+
string: {
|
|
1261
|
+
pattern: /("|')(?:\\[\s\S]|(?!\1)[^\\\n\r])*\1/,
|
|
1262
|
+
greedy: true,
|
|
1263
|
+
},
|
|
1264
|
+
atrule: [
|
|
1265
|
+
{
|
|
1266
|
+
pattern: /@[\w-](?:[^;{\s]|\s+(?![\s{]))*(?:;|(?=\s*\{))/,
|
|
1267
|
+
inside: {
|
|
1268
|
+
'rule': { pattern: /^@[\w-]+/ },
|
|
1269
|
+
'selector-function-argument': {
|
|
1270
|
+
pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
|
|
1271
|
+
lookbehind: true,
|
|
1272
|
+
},
|
|
1273
|
+
'keyword': {
|
|
1274
|
+
pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
|
|
1275
|
+
lookbehind: true,
|
|
1276
|
+
},
|
|
1277
|
+
'punctuation': { pattern: /[;:(){}]/ },
|
|
1278
|
+
},
|
|
1279
|
+
},
|
|
1280
|
+
],
|
|
1281
|
+
url: {
|
|
1282
|
+
pattern: /\burl\((?:("|')(?:\\[\s\S]|(?!\1)[^\\\n\r])*\1|(?:[^\\\r\n()"']|\\[\s\S])*)\)/i,
|
|
1283
|
+
greedy: true,
|
|
1284
|
+
inside: {
|
|
1285
|
+
function: { pattern: /^url/i },
|
|
1286
|
+
punctuation: { pattern: /^\(|\)$/ },
|
|
1287
|
+
string: {
|
|
1288
|
+
pattern: /^("|')[\s\S]+(?=\1$)/,
|
|
1289
|
+
lookbehind: true,
|
|
1290
|
+
},
|
|
1291
|
+
},
|
|
1292
|
+
},
|
|
1293
|
+
selector: {
|
|
1294
|
+
pattern: /(?=\S)[^@;{}()]?(?:[^@;{}()\s]|\s+(?![\s{])|\((?:[^()]|\([^()]*\))*\))*(?=\s*\{)/,
|
|
1295
|
+
inside: {
|
|
1296
|
+
'pseudo-element': { pattern: /(?:::)[\w-]+/ },
|
|
1297
|
+
'pseudo-class': { pattern: /(?::)[\w-]+/ },
|
|
1298
|
+
'class': { pattern: /\.[\w-]+/ },
|
|
1299
|
+
'id': { pattern: /#[\w-]+/ },
|
|
1300
|
+
'attribute': {
|
|
1301
|
+
pattern: /\[(?:[^[\]"']|("|')(?:\\[\s\S]|(?!\1)[^\\\n\r])*\1)*\]/,
|
|
1302
|
+
greedy: true,
|
|
1303
|
+
inside: {
|
|
1304
|
+
'punctuation': { pattern: /^\[|\]$/ },
|
|
1305
|
+
'attr-name': { pattern: /^(\s*)(?:(?!\s)[-\w\u00B7\u00C0-\u024F])+/i, lookbehind: true },
|
|
1306
|
+
'attr-value': [{ pattern: /(=\s*)(?:"[^"]*"|'[^']*'|[^\s'"=]+)/, lookbehind: true }],
|
|
1307
|
+
'operator': { pattern: /[|~*^$]?=/ },
|
|
1308
|
+
},
|
|
1309
|
+
},
|
|
1310
|
+
},
|
|
1311
|
+
},
|
|
1312
|
+
property: {
|
|
1313
|
+
pattern: /(?!\s)[-_a-z\u00B7\u00C0-\u024F][-\w\u00B7\u00C0-\u024F]*(?=\s*:)/i,
|
|
1314
|
+
},
|
|
1315
|
+
important: {
|
|
1316
|
+
pattern: /!important\b/i,
|
|
1317
|
+
},
|
|
1318
|
+
function: {
|
|
1319
|
+
pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
|
|
1320
|
+
lookbehind: true,
|
|
1321
|
+
},
|
|
1322
|
+
number: {
|
|
1323
|
+
pattern: /(^|[^\w.-])-?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?/i,
|
|
1324
|
+
lookbehind: true,
|
|
1325
|
+
},
|
|
1326
|
+
unit: {
|
|
1327
|
+
pattern: /(\b\d+)(?:%|[a-z]+)/,
|
|
1328
|
+
lookbehind: true,
|
|
1329
|
+
},
|
|
1330
|
+
punctuation: {
|
|
1331
|
+
pattern: /[(){};:,]/,
|
|
1332
|
+
},
|
|
1333
|
+
operator: {
|
|
1334
|
+
pattern: /[+\-*/=><~^|]+/,
|
|
1335
|
+
},
|
|
2356
1336
|
};
|
|
2357
1337
|
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
/(^|["'\s])/.source + '(?:' + attrName + ')' + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
|
|
2429
|
-
'i'
|
|
2430
|
-
),
|
|
2431
|
-
lookbehind: true,
|
|
2432
|
-
inside: {
|
|
2433
|
-
'attr-name': /^[^\s=]+/,
|
|
2434
|
-
'attr-value': {
|
|
2435
|
-
pattern: /=[\s\S]+/,
|
|
2436
|
-
inside: {
|
|
2437
|
-
'value': {
|
|
2438
|
-
pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
|
|
2439
|
-
lookbehind: true,
|
|
2440
|
-
alias: [lang, 'language-' + lang],
|
|
2441
|
-
inside: Prism.languages[lang]
|
|
2442
|
-
},
|
|
2443
|
-
'punctuation': [
|
|
2444
|
-
{
|
|
2445
|
-
pattern: /^=/,
|
|
2446
|
-
alias: 'attr-equals'
|
|
2447
|
-
},
|
|
2448
|
-
/"|'/
|
|
2449
|
-
]
|
|
2450
|
-
}
|
|
2451
|
-
}
|
|
2452
|
-
}
|
|
2453
|
-
});
|
|
2454
|
-
}
|
|
2455
|
-
});
|
|
2456
|
-
|
|
2457
|
-
Prism.languages.html = Prism.languages.markup;
|
|
2458
|
-
Prism.languages.mathml = Prism.languages.markup;
|
|
2459
|
-
Prism.languages.svg = Prism.languages.markup;
|
|
2460
|
-
|
|
2461
|
-
Prism.languages.xml = Prism.languages.extend('markup', {});
|
|
2462
|
-
Prism.languages.ssml = Prism.languages.xml;
|
|
2463
|
-
Prism.languages.atom = Prism.languages.xml;
|
|
2464
|
-
Prism.languages.rss = Prism.languages.xml;
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
/* **********************************************
|
|
2468
|
-
Begin prism-css.js
|
|
2469
|
-
********************************************** */
|
|
2470
|
-
|
|
2471
|
-
(function (Prism) {
|
|
2472
|
-
|
|
2473
|
-
var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
|
|
2474
|
-
|
|
2475
|
-
Prism.languages.css = {
|
|
2476
|
-
'comment': /\/\*[\s\S]*?\*\//,
|
|
2477
|
-
'atrule': {
|
|
2478
|
-
pattern: RegExp('@[\\w-](?:' + /[^;{\s"']|\s+(?!\s)/.source + '|' + string.source + ')*?' + /(?:;|(?=\s*\{))/.source),
|
|
2479
|
-
inside: {
|
|
2480
|
-
'rule': /^@[\w-]+/,
|
|
2481
|
-
'selector-function-argument': {
|
|
2482
|
-
pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
|
|
2483
|
-
lookbehind: true,
|
|
2484
|
-
alias: 'selector'
|
|
2485
|
-
},
|
|
2486
|
-
'keyword': {
|
|
2487
|
-
pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
|
|
2488
|
-
lookbehind: true
|
|
2489
|
-
}
|
|
2490
|
-
// See rest below
|
|
2491
|
-
}
|
|
2492
|
-
},
|
|
2493
|
-
'url': {
|
|
2494
|
-
// https://drafts.csswg.org/css-values-3/#urls
|
|
2495
|
-
pattern: RegExp('\\burl\\((?:' + string.source + '|' + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ')\\)', 'i'),
|
|
2496
|
-
greedy: true,
|
|
2497
|
-
inside: {
|
|
2498
|
-
'function': /^url/i,
|
|
2499
|
-
'punctuation': /^\(|\)$/,
|
|
2500
|
-
'string': {
|
|
2501
|
-
pattern: RegExp('^' + string.source + '$'),
|
|
2502
|
-
alias: 'url'
|
|
2503
|
-
}
|
|
2504
|
-
}
|
|
2505
|
-
},
|
|
2506
|
-
'selector': {
|
|
2507
|
-
pattern: RegExp('(^|[{}\\s])[^{}\\s](?:[^{};"\'\\s]|\\s+(?![\\s{])|' + string.source + ')*(?=\\s*\\{)'),
|
|
2508
|
-
lookbehind: true
|
|
2509
|
-
},
|
|
2510
|
-
'string': {
|
|
2511
|
-
pattern: string,
|
|
2512
|
-
greedy: true
|
|
2513
|
-
},
|
|
2514
|
-
'property': {
|
|
2515
|
-
pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
|
|
2516
|
-
lookbehind: true
|
|
2517
|
-
},
|
|
2518
|
-
'important': /!important\b/i,
|
|
2519
|
-
'function': {
|
|
2520
|
-
pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
|
|
2521
|
-
lookbehind: true
|
|
2522
|
-
},
|
|
2523
|
-
'punctuation': /[(){};:,]/
|
|
2524
|
-
};
|
|
2525
|
-
|
|
2526
|
-
Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
|
|
2527
|
-
|
|
2528
|
-
var markup = Prism.languages.markup;
|
|
2529
|
-
if (markup) {
|
|
2530
|
-
markup.tag.addInlined('style', 'css');
|
|
2531
|
-
markup.tag.addAttribute('style', 'css');
|
|
2532
|
-
}
|
|
2533
|
-
|
|
2534
|
-
}(Prism));
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
/* **********************************************
|
|
2538
|
-
Begin prism-clike.js
|
|
2539
|
-
********************************************** */
|
|
2540
|
-
|
|
2541
|
-
Prism.languages.clike = {
|
|
2542
|
-
'comment': [
|
|
2543
|
-
{
|
|
2544
|
-
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
|
|
2545
|
-
lookbehind: true,
|
|
2546
|
-
greedy: true
|
|
2547
|
-
},
|
|
2548
|
-
{
|
|
2549
|
-
pattern: /(^|[^\\:])\/\/.*/,
|
|
2550
|
-
lookbehind: true,
|
|
2551
|
-
greedy: true
|
|
2552
|
-
}
|
|
2553
|
-
],
|
|
2554
|
-
'string': {
|
|
2555
|
-
pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
|
|
2556
|
-
greedy: true
|
|
2557
|
-
},
|
|
2558
|
-
'class-name': {
|
|
2559
|
-
pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
|
|
2560
|
-
lookbehind: true,
|
|
2561
|
-
inside: {
|
|
2562
|
-
'punctuation': /[.\\]/
|
|
2563
|
-
}
|
|
2564
|
-
},
|
|
2565
|
-
'keyword': /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
|
|
2566
|
-
'boolean': /\b(?:false|true)\b/,
|
|
2567
|
-
'function': /\b\w+(?=\()/,
|
|
2568
|
-
'number': /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
|
|
2569
|
-
'operator': /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
|
|
2570
|
-
'punctuation': /[{}[\];(),.:]/
|
|
1338
|
+
/**
|
|
1339
|
+
* Grammar definition for HTML/Markup syntax highlighting.
|
|
1340
|
+
* Handles tags, attributes, comments, doctypes, CDATA, entities, and embedded content.
|
|
1341
|
+
*/
|
|
1342
|
+
const markupGrammar = {
|
|
1343
|
+
comment: {
|
|
1344
|
+
pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
|
|
1345
|
+
greedy: true,
|
|
1346
|
+
},
|
|
1347
|
+
prolog: {
|
|
1348
|
+
pattern: /<\?[\s\S]+?\?>/,
|
|
1349
|
+
greedy: true,
|
|
1350
|
+
},
|
|
1351
|
+
doctype: {
|
|
1352
|
+
pattern: /<!DOCTYPE(?:[^>"']|"[^"]*"|'[^']*')+(?:>|$)/i,
|
|
1353
|
+
greedy: true,
|
|
1354
|
+
inside: {
|
|
1355
|
+
'internal-subset': {
|
|
1356
|
+
pattern: /(^[^[]*\[)[\s\S]+(?=\]>$)/,
|
|
1357
|
+
lookbehind: true,
|
|
1358
|
+
greedy: true,
|
|
1359
|
+
},
|
|
1360
|
+
'punctuation': { pattern: /^<!|>$|[[\]]/ },
|
|
1361
|
+
'doctype-tag': { pattern: /^DOCTYPE/i },
|
|
1362
|
+
'name': { pattern: /[^\s<>'"/]+/ },
|
|
1363
|
+
'string': {
|
|
1364
|
+
pattern: /("|')[\s\S]*?\1/,
|
|
1365
|
+
greedy: true,
|
|
1366
|
+
},
|
|
1367
|
+
},
|
|
1368
|
+
},
|
|
1369
|
+
cdata: {
|
|
1370
|
+
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
|
|
1371
|
+
greedy: true,
|
|
1372
|
+
},
|
|
1373
|
+
tag: {
|
|
1374
|
+
pattern: /<\/?(?!\d)[^\s>/=$<%]+(?:\s(?:\s*[^\s>/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
|
|
1375
|
+
greedy: true,
|
|
1376
|
+
inside: {
|
|
1377
|
+
'tag': {
|
|
1378
|
+
pattern: /^<\/?[^\s>/]+/,
|
|
1379
|
+
inside: {
|
|
1380
|
+
punctuation: { pattern: /^<\/?/ },
|
|
1381
|
+
namespace: { pattern: /^[^\s>/:]+:/ },
|
|
1382
|
+
},
|
|
1383
|
+
},
|
|
1384
|
+
'special-attr': [],
|
|
1385
|
+
'attr-value': {
|
|
1386
|
+
pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
|
|
1387
|
+
inside: {
|
|
1388
|
+
punctuation: [{ pattern: /^=/ }, { pattern: /^(\s*)["']|["']$/, lookbehind: true }],
|
|
1389
|
+
},
|
|
1390
|
+
},
|
|
1391
|
+
'punctuation': { pattern: /\/?>/ },
|
|
1392
|
+
'attr-name': {
|
|
1393
|
+
pattern: /[^\s>/]+/,
|
|
1394
|
+
inside: {
|
|
1395
|
+
namespace: { pattern: /^[^\s>/:]+:/ },
|
|
1396
|
+
},
|
|
1397
|
+
},
|
|
1398
|
+
},
|
|
1399
|
+
},
|
|
1400
|
+
entity: [
|
|
1401
|
+
{
|
|
1402
|
+
pattern: /&[\da-z]{1,8};/i,
|
|
1403
|
+
},
|
|
1404
|
+
{
|
|
1405
|
+
pattern: /&#x?[\da-f]{1,8};/i,
|
|
1406
|
+
},
|
|
1407
|
+
],
|
|
2571
1408
|
};
|
|
2572
1409
|
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
}
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
},
|
|
2669
|
-
'parameter': [
|
|
2670
|
-
{
|
|
2671
|
-
pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
|
|
2672
|
-
lookbehind: true,
|
|
2673
|
-
inside: Prism.languages.javascript
|
|
2674
|
-
},
|
|
2675
|
-
{
|
|
2676
|
-
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
|
|
2677
|
-
lookbehind: true,
|
|
2678
|
-
inside: Prism.languages.javascript
|
|
2679
|
-
},
|
|
2680
|
-
{
|
|
2681
|
-
pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
|
|
2682
|
-
lookbehind: true,
|
|
2683
|
-
inside: Prism.languages.javascript
|
|
2684
|
-
},
|
|
2685
|
-
{
|
|
2686
|
-
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*\{)/,
|
|
2687
|
-
lookbehind: true,
|
|
2688
|
-
inside: Prism.languages.javascript
|
|
2689
|
-
}
|
|
2690
|
-
],
|
|
2691
|
-
'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/
|
|
2692
|
-
});
|
|
2693
|
-
|
|
2694
|
-
Prism.languages.insertBefore('javascript', 'string', {
|
|
2695
|
-
'hashbang': {
|
|
2696
|
-
pattern: /^#!.*/,
|
|
2697
|
-
greedy: true,
|
|
2698
|
-
alias: 'comment'
|
|
2699
|
-
},
|
|
2700
|
-
'template-string': {
|
|
2701
|
-
pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
|
|
2702
|
-
greedy: true,
|
|
2703
|
-
inside: {
|
|
2704
|
-
'template-punctuation': {
|
|
2705
|
-
pattern: /^`|`$/,
|
|
2706
|
-
alias: 'string'
|
|
2707
|
-
},
|
|
2708
|
-
'interpolation': {
|
|
2709
|
-
pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
|
|
2710
|
-
lookbehind: true,
|
|
2711
|
-
inside: {
|
|
2712
|
-
'interpolation-punctuation': {
|
|
2713
|
-
pattern: /^\$\{|\}$/,
|
|
2714
|
-
alias: 'punctuation'
|
|
2715
|
-
},
|
|
2716
|
-
rest: Prism.languages.javascript
|
|
2717
|
-
}
|
|
2718
|
-
},
|
|
2719
|
-
'string': /[\s\S]+/
|
|
2720
|
-
}
|
|
2721
|
-
},
|
|
2722
|
-
'string-property': {
|
|
2723
|
-
pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
|
|
2724
|
-
lookbehind: true,
|
|
2725
|
-
greedy: true,
|
|
2726
|
-
alias: 'property'
|
|
2727
|
-
}
|
|
2728
|
-
});
|
|
2729
|
-
|
|
2730
|
-
Prism.languages.insertBefore('javascript', 'operator', {
|
|
2731
|
-
'literal-property': {
|
|
2732
|
-
pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
|
|
2733
|
-
lookbehind: true,
|
|
2734
|
-
alias: 'property'
|
|
2735
|
-
},
|
|
2736
|
-
});
|
|
2737
|
-
|
|
2738
|
-
if (Prism.languages.markup) {
|
|
2739
|
-
Prism.languages.markup.tag.addInlined('script', 'javascript');
|
|
2740
|
-
|
|
2741
|
-
// add attribute support for all DOM events.
|
|
2742
|
-
// https://developer.mozilla.org/en-US/docs/Web/Events#Standard_events
|
|
2743
|
-
Prism.languages.markup.tag.addAttribute(
|
|
2744
|
-
/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,
|
|
2745
|
-
'javascript'
|
|
2746
|
-
);
|
|
2747
|
-
}
|
|
2748
|
-
|
|
2749
|
-
Prism.languages.js = Prism.languages.javascript;
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
/* **********************************************
|
|
2753
|
-
Begin prism-file-highlight.js
|
|
2754
|
-
********************************************** */
|
|
2755
|
-
|
|
2756
|
-
(function () {
|
|
2757
|
-
|
|
2758
|
-
if (typeof Prism === 'undefined' || typeof document === 'undefined') {
|
|
2759
|
-
return;
|
|
2760
|
-
}
|
|
2761
|
-
|
|
2762
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#Polyfill
|
|
2763
|
-
if (!Element.prototype.matches) {
|
|
2764
|
-
Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
|
|
2765
|
-
}
|
|
2766
|
-
|
|
2767
|
-
var LOADING_MESSAGE = 'Loading…';
|
|
2768
|
-
var FAILURE_MESSAGE = function (status, message) {
|
|
2769
|
-
return '✖ Error ' + status + ' while fetching file: ' + message;
|
|
2770
|
-
};
|
|
2771
|
-
var FAILURE_EMPTY_MESSAGE = '✖ Error: File does not exist or is empty';
|
|
2772
|
-
|
|
2773
|
-
var EXTENSIONS = {
|
|
2774
|
-
'js': 'javascript',
|
|
2775
|
-
'py': 'python',
|
|
2776
|
-
'rb': 'ruby',
|
|
2777
|
-
'ps1': 'powershell',
|
|
2778
|
-
'psm1': 'powershell',
|
|
2779
|
-
'sh': 'bash',
|
|
2780
|
-
'bat': 'batch',
|
|
2781
|
-
'h': 'c',
|
|
2782
|
-
'tex': 'latex'
|
|
2783
|
-
};
|
|
2784
|
-
|
|
2785
|
-
var STATUS_ATTR = 'data-src-status';
|
|
2786
|
-
var STATUS_LOADING = 'loading';
|
|
2787
|
-
var STATUS_LOADED = 'loaded';
|
|
2788
|
-
var STATUS_FAILED = 'failed';
|
|
2789
|
-
|
|
2790
|
-
var SELECTOR = 'pre[data-src]:not([' + STATUS_ATTR + '="' + STATUS_LOADED + '"])'
|
|
2791
|
-
+ ':not([' + STATUS_ATTR + '="' + STATUS_LOADING + '"])';
|
|
2792
|
-
|
|
2793
|
-
/**
|
|
2794
|
-
* Loads the given file.
|
|
2795
|
-
*
|
|
2796
|
-
* @param {string} src The URL or path of the source file to load.
|
|
2797
|
-
* @param {(result: string) => void} success
|
|
2798
|
-
* @param {(reason: string) => void} error
|
|
2799
|
-
*/
|
|
2800
|
-
function loadFile(src, success, error) {
|
|
2801
|
-
var xhr = new XMLHttpRequest();
|
|
2802
|
-
xhr.open('GET', src, true);
|
|
2803
|
-
xhr.onreadystatechange = function () {
|
|
2804
|
-
if (xhr.readyState == 4) {
|
|
2805
|
-
if (xhr.status < 400 && xhr.responseText) {
|
|
2806
|
-
success(xhr.responseText);
|
|
2807
|
-
} else {
|
|
2808
|
-
if (xhr.status >= 400) {
|
|
2809
|
-
error(FAILURE_MESSAGE(xhr.status, xhr.statusText));
|
|
2810
|
-
} else {
|
|
2811
|
-
error(FAILURE_EMPTY_MESSAGE);
|
|
2812
|
-
}
|
|
2813
|
-
}
|
|
2814
|
-
}
|
|
2815
|
-
};
|
|
2816
|
-
xhr.send(null);
|
|
2817
|
-
}
|
|
2818
|
-
|
|
2819
|
-
/**
|
|
2820
|
-
* Parses the given range.
|
|
2821
|
-
*
|
|
2822
|
-
* This returns a range with inclusive ends.
|
|
2823
|
-
*
|
|
2824
|
-
* @param {string | null | undefined} range
|
|
2825
|
-
* @returns {[number, number | undefined] | undefined}
|
|
2826
|
-
*/
|
|
2827
|
-
function parseRange(range) {
|
|
2828
|
-
var m = /^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(range || '');
|
|
2829
|
-
if (m) {
|
|
2830
|
-
var start = Number(m[1]);
|
|
2831
|
-
var comma = m[2];
|
|
2832
|
-
var end = m[3];
|
|
2833
|
-
|
|
2834
|
-
if (!comma) {
|
|
2835
|
-
return [start, start];
|
|
2836
|
-
}
|
|
2837
|
-
if (!end) {
|
|
2838
|
-
return [start, undefined];
|
|
2839
|
-
}
|
|
2840
|
-
return [start, Number(end)];
|
|
2841
|
-
}
|
|
2842
|
-
return undefined;
|
|
2843
|
-
}
|
|
2844
|
-
|
|
2845
|
-
Prism.hooks.add('before-highlightall', function (env) {
|
|
2846
|
-
env.selector += ', ' + SELECTOR;
|
|
2847
|
-
});
|
|
2848
|
-
|
|
2849
|
-
Prism.hooks.add('before-sanity-check', function (env) {
|
|
2850
|
-
var pre = /** @type {HTMLPreElement} */ (env.element);
|
|
2851
|
-
if (pre.matches(SELECTOR)) {
|
|
2852
|
-
env.code = ''; // fast-path the whole thing and go to complete
|
|
2853
|
-
|
|
2854
|
-
pre.setAttribute(STATUS_ATTR, STATUS_LOADING); // mark as loading
|
|
2855
|
-
|
|
2856
|
-
// add code element with loading message
|
|
2857
|
-
var code = pre.appendChild(document.createElement('CODE'));
|
|
2858
|
-
code.textContent = LOADING_MESSAGE;
|
|
2859
|
-
|
|
2860
|
-
var src = pre.getAttribute('data-src');
|
|
2861
|
-
|
|
2862
|
-
var language = env.language;
|
|
2863
|
-
if (language === 'none') {
|
|
2864
|
-
// the language might be 'none' because there is no language set;
|
|
2865
|
-
// in this case, we want to use the extension as the language
|
|
2866
|
-
var extension = (/\.(\w+)$/.exec(src) || [, 'none'])[1];
|
|
2867
|
-
language = EXTENSIONS[extension] || extension;
|
|
2868
|
-
}
|
|
2869
|
-
|
|
2870
|
-
// set language classes
|
|
2871
|
-
Prism.util.setLanguage(code, language);
|
|
2872
|
-
Prism.util.setLanguage(pre, language);
|
|
2873
|
-
|
|
2874
|
-
// preload the language
|
|
2875
|
-
var autoloader = Prism.plugins.autoloader;
|
|
2876
|
-
if (autoloader) {
|
|
2877
|
-
autoloader.loadLanguages(language);
|
|
2878
|
-
}
|
|
2879
|
-
|
|
2880
|
-
// load file
|
|
2881
|
-
loadFile(
|
|
2882
|
-
src,
|
|
2883
|
-
function (text) {
|
|
2884
|
-
// mark as loaded
|
|
2885
|
-
pre.setAttribute(STATUS_ATTR, STATUS_LOADED);
|
|
2886
|
-
|
|
2887
|
-
// handle data-range
|
|
2888
|
-
var range = parseRange(pre.getAttribute('data-range'));
|
|
2889
|
-
if (range) {
|
|
2890
|
-
var lines = text.split(/\r\n?|\n/g);
|
|
2891
|
-
|
|
2892
|
-
// the range is one-based and inclusive on both ends
|
|
2893
|
-
var start = range[0];
|
|
2894
|
-
var end = range[1] == null ? lines.length : range[1];
|
|
2895
|
-
|
|
2896
|
-
if (start < 0) { start += lines.length; }
|
|
2897
|
-
start = Math.max(0, Math.min(start - 1, lines.length));
|
|
2898
|
-
if (end < 0) { end += lines.length; }
|
|
2899
|
-
end = Math.max(0, Math.min(end, lines.length));
|
|
2900
|
-
|
|
2901
|
-
text = lines.slice(start, end).join('\n');
|
|
2902
|
-
|
|
2903
|
-
// add data-start for line numbers
|
|
2904
|
-
if (!pre.hasAttribute('data-start')) {
|
|
2905
|
-
pre.setAttribute('data-start', String(start + 1));
|
|
2906
|
-
}
|
|
2907
|
-
}
|
|
2908
|
-
|
|
2909
|
-
// highlight code
|
|
2910
|
-
code.textContent = text;
|
|
2911
|
-
Prism.highlightElement(code);
|
|
2912
|
-
},
|
|
2913
|
-
function (error) {
|
|
2914
|
-
// mark as failed
|
|
2915
|
-
pre.setAttribute(STATUS_ATTR, STATUS_FAILED);
|
|
2916
|
-
|
|
2917
|
-
code.textContent = error;
|
|
2918
|
-
}
|
|
2919
|
-
);
|
|
2920
|
-
}
|
|
2921
|
-
});
|
|
2922
|
-
|
|
2923
|
-
Prism.plugins.fileHighlight = {
|
|
2924
|
-
/**
|
|
2925
|
-
* Executes the File Highlight plugin for all matching `pre` elements under the given container.
|
|
2926
|
-
*
|
|
2927
|
-
* Note: Elements which are already loaded or currently loading will not be touched by this method.
|
|
2928
|
-
*
|
|
2929
|
-
* @param {ParentNode} [container=document]
|
|
2930
|
-
*/
|
|
2931
|
-
highlight: function highlight(container) {
|
|
2932
|
-
var elements = (container || document).querySelectorAll(SELECTOR);
|
|
2933
|
-
|
|
2934
|
-
for (var i = 0, element; (element = elements[i++]);) {
|
|
2935
|
-
Prism.highlightElement(element);
|
|
2936
|
-
}
|
|
2937
|
-
}
|
|
2938
|
-
};
|
|
2939
|
-
|
|
2940
|
-
var logged = false;
|
|
2941
|
-
/** @deprecated Use `Prism.plugins.fileHighlight.highlight` instead. */
|
|
2942
|
-
Prism.fileHighlight = function () {
|
|
2943
|
-
if (!logged) {
|
|
2944
|
-
console.warn('Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead.');
|
|
2945
|
-
logged = true;
|
|
2946
|
-
}
|
|
2947
|
-
Prism.plugins.fileHighlight.highlight.apply(this, arguments);
|
|
2948
|
-
};
|
|
2949
|
-
|
|
2950
|
-
}());
|
|
2951
|
-
});
|
|
2952
|
-
|
|
2953
|
-
Prism.languages.clike = {
|
|
2954
|
-
'comment': [
|
|
2955
|
-
{
|
|
2956
|
-
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
|
|
2957
|
-
lookbehind: true,
|
|
2958
|
-
greedy: true
|
|
2959
|
-
},
|
|
2960
|
-
{
|
|
2961
|
-
pattern: /(^|[^\\:])\/\/.*/,
|
|
2962
|
-
lookbehind: true,
|
|
2963
|
-
greedy: true
|
|
2964
|
-
}
|
|
2965
|
-
],
|
|
2966
|
-
'string': {
|
|
2967
|
-
pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
|
|
2968
|
-
greedy: true
|
|
2969
|
-
},
|
|
2970
|
-
'class-name': {
|
|
2971
|
-
pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
|
|
2972
|
-
lookbehind: true,
|
|
2973
|
-
inside: {
|
|
2974
|
-
'punctuation': /[.\\]/
|
|
2975
|
-
}
|
|
2976
|
-
},
|
|
2977
|
-
'keyword': /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
|
|
2978
|
-
'boolean': /\b(?:false|true)\b/,
|
|
2979
|
-
'function': /\b\w+(?=\()/,
|
|
2980
|
-
'number': /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
|
|
2981
|
-
'operator': /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
|
|
2982
|
-
'punctuation': /[{}[\];(),.:]/
|
|
1410
|
+
/**
|
|
1411
|
+
* Grammar definition for JavaScript syntax highlighting.
|
|
1412
|
+
* Handles keywords, operators, strings, template literals, numbers,
|
|
1413
|
+
* regex literals, comments, functions, classes, and other JS constructs.
|
|
1414
|
+
*/
|
|
1415
|
+
const javascriptGrammar = {
|
|
1416
|
+
'comment': [
|
|
1417
|
+
{
|
|
1418
|
+
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
|
|
1419
|
+
lookbehind: true,
|
|
1420
|
+
greedy: true,
|
|
1421
|
+
},
|
|
1422
|
+
{
|
|
1423
|
+
pattern: /(^|[^\\:])\/\/.*/,
|
|
1424
|
+
lookbehind: true,
|
|
1425
|
+
greedy: true,
|
|
1426
|
+
},
|
|
1427
|
+
],
|
|
1428
|
+
'string': [
|
|
1429
|
+
{
|
|
1430
|
+
pattern: /(["'])(?:\\[\s\S]|(?!\1)[^\\\r\n])*\1/,
|
|
1431
|
+
greedy: true,
|
|
1432
|
+
},
|
|
1433
|
+
],
|
|
1434
|
+
'template-string': {
|
|
1435
|
+
pattern: /`(?:\\[\s\S]|[^\\`])*`/,
|
|
1436
|
+
greedy: true,
|
|
1437
|
+
inside: {
|
|
1438
|
+
'template-punctuation': {
|
|
1439
|
+
pattern: /^`|`$/,
|
|
1440
|
+
},
|
|
1441
|
+
'interpolation': {
|
|
1442
|
+
pattern: /\$\{(?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*\}/,
|
|
1443
|
+
inside: {
|
|
1444
|
+
'interpolation-punctuation': {
|
|
1445
|
+
pattern: /^\$\{|\}$/,
|
|
1446
|
+
},
|
|
1447
|
+
},
|
|
1448
|
+
},
|
|
1449
|
+
'string': {
|
|
1450
|
+
pattern: /[\s\S]+/,
|
|
1451
|
+
},
|
|
1452
|
+
},
|
|
1453
|
+
},
|
|
1454
|
+
'regex': {
|
|
1455
|
+
pattern:
|
|
1456
|
+
// eslint-disable-next-line no-useless-escape
|
|
1457
|
+
/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)\/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[.\r\n,;:})\]]|\/\/))/,
|
|
1458
|
+
lookbehind: true,
|
|
1459
|
+
greedy: true,
|
|
1460
|
+
inside: {
|
|
1461
|
+
'regex-source': {
|
|
1462
|
+
pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
|
|
1463
|
+
lookbehind: true,
|
|
1464
|
+
},
|
|
1465
|
+
'regex-delimiter': {
|
|
1466
|
+
pattern: /^\/|\/$/,
|
|
1467
|
+
},
|
|
1468
|
+
'regex-flags': {
|
|
1469
|
+
pattern: /^[a-z]+$/,
|
|
1470
|
+
},
|
|
1471
|
+
},
|
|
1472
|
+
},
|
|
1473
|
+
'class-name': [
|
|
1474
|
+
{
|
|
1475
|
+
pattern: /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,
|
|
1476
|
+
lookbehind: true,
|
|
1477
|
+
inside: {
|
|
1478
|
+
punctuation: { pattern: /[.\\]/ },
|
|
1479
|
+
},
|
|
1480
|
+
},
|
|
1481
|
+
],
|
|
1482
|
+
'keyword': [
|
|
1483
|
+
{
|
|
1484
|
+
pattern: /\b(?: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)\b/,
|
|
1485
|
+
},
|
|
1486
|
+
],
|
|
1487
|
+
'boolean': {
|
|
1488
|
+
pattern: /\b(?:false|true)\b/,
|
|
1489
|
+
},
|
|
1490
|
+
'number': {
|
|
1491
|
+
pattern: /\b(?:(?:0[xX][\dA-Fa-f](?:_[\dA-Fa-f])*|0[bB][01](?:_[01])*|0[oO][0-7](?:_[0-7])*)n?|(?:\d(?:_\d)*\.?\d*|\.\d+)(?:[Ee][+-]?\d(?:_\d)*)?n?|NaN|Infinity)\b/,
|
|
1492
|
+
},
|
|
1493
|
+
'function': {
|
|
1494
|
+
pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
|
|
1495
|
+
},
|
|
1496
|
+
'operator': {
|
|
1497
|
+
pattern: /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%|&^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/,
|
|
1498
|
+
},
|
|
1499
|
+
'punctuation': {
|
|
1500
|
+
pattern: /[{}[\];(),.:]/,
|
|
1501
|
+
},
|
|
1502
|
+
'constant': {
|
|
1503
|
+
pattern: /\b[A-Z](?:[A-Z_]|\dx)*\b/,
|
|
1504
|
+
},
|
|
2983
1505
|
};
|
|
2984
1506
|
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
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
|
-
Prism.languages.markup = {
|
|
3159
|
-
'comment': {
|
|
3160
|
-
pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
|
|
3161
|
-
greedy: true
|
|
3162
|
-
},
|
|
3163
|
-
'prolog': {
|
|
3164
|
-
pattern: /<\?[\s\S]+?\?>/,
|
|
3165
|
-
greedy: true
|
|
3166
|
-
},
|
|
3167
|
-
'doctype': {
|
|
3168
|
-
// https://www.w3.org/TR/xml/#NT-doctypedecl
|
|
3169
|
-
pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
|
|
3170
|
-
greedy: true,
|
|
3171
|
-
inside: {
|
|
3172
|
-
'internal-subset': {
|
|
3173
|
-
pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
|
|
3174
|
-
lookbehind: true,
|
|
3175
|
-
greedy: true,
|
|
3176
|
-
inside: null // see below
|
|
3177
|
-
},
|
|
3178
|
-
'string': {
|
|
3179
|
-
pattern: /"[^"]*"|'[^']*'/,
|
|
3180
|
-
greedy: true
|
|
3181
|
-
},
|
|
3182
|
-
'punctuation': /^<!|>$|[[\]]/,
|
|
3183
|
-
'doctype-tag': /^DOCTYPE/i,
|
|
3184
|
-
'name': /[^\s<>'"]+/
|
|
3185
|
-
}
|
|
3186
|
-
},
|
|
3187
|
-
'cdata': {
|
|
3188
|
-
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
|
|
3189
|
-
greedy: true
|
|
3190
|
-
},
|
|
3191
|
-
'tag': {
|
|
3192
|
-
pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
|
|
3193
|
-
greedy: true,
|
|
3194
|
-
inside: {
|
|
3195
|
-
'tag': {
|
|
3196
|
-
pattern: /^<\/?[^\s>\/]+/,
|
|
3197
|
-
inside: {
|
|
3198
|
-
'punctuation': /^<\/?/,
|
|
3199
|
-
'namespace': /^[^\s>\/:]+:/
|
|
3200
|
-
}
|
|
3201
|
-
},
|
|
3202
|
-
'special-attr': [],
|
|
3203
|
-
'attr-value': {
|
|
3204
|
-
pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
|
|
3205
|
-
inside: {
|
|
3206
|
-
'punctuation': [
|
|
3207
|
-
{
|
|
3208
|
-
pattern: /^=/,
|
|
3209
|
-
alias: 'attr-equals'
|
|
3210
|
-
},
|
|
3211
|
-
{
|
|
3212
|
-
pattern: /^(\s*)["']|["']$/,
|
|
3213
|
-
lookbehind: true
|
|
3214
|
-
}
|
|
3215
|
-
]
|
|
3216
|
-
}
|
|
3217
|
-
},
|
|
3218
|
-
'punctuation': /\/?>/,
|
|
3219
|
-
'attr-name': {
|
|
3220
|
-
pattern: /[^\s>\/]+/,
|
|
3221
|
-
inside: {
|
|
3222
|
-
'namespace': /^[^\s>\/:]+:/
|
|
3223
|
-
}
|
|
3224
|
-
}
|
|
3225
|
-
|
|
3226
|
-
}
|
|
3227
|
-
},
|
|
3228
|
-
'entity': [
|
|
3229
|
-
{
|
|
3230
|
-
pattern: /&[\da-z]{1,8};/i,
|
|
3231
|
-
alias: 'named-entity'
|
|
3232
|
-
},
|
|
3233
|
-
/&#x?[\da-f]{1,8};/i
|
|
3234
|
-
]
|
|
1507
|
+
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
1508
|
+
var t = {};
|
|
1509
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
1510
|
+
t[p] = s[p];
|
|
1511
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
1512
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
1513
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
1514
|
+
t[p[i]] = s[p[i]];
|
|
1515
|
+
}
|
|
1516
|
+
return t;
|
|
3235
1517
|
};
|
|
1518
|
+
/**
|
|
1519
|
+
* Grammar definition for TypeScript syntax highlighting.
|
|
1520
|
+
* Extends JavaScript grammar with TypeScript-specific constructs such as
|
|
1521
|
+
* type annotations, generics, interfaces, enums, decorators, and access modifiers.
|
|
1522
|
+
*
|
|
1523
|
+
* Note: We destructure `keyword`, `function`, `operator`, and `punctuation` out
|
|
1524
|
+
* of the JS grammar and re-add them in the correct order. This ensures:
|
|
1525
|
+
* - `builtin` is matched before `keyword` (both contain words like void, null, etc.)
|
|
1526
|
+
* - `function` is matched before `operator` and `punctuation` (the function
|
|
1527
|
+
* pattern uses a lookahead for `(` which must still be an unmatched string)
|
|
1528
|
+
*/
|
|
1529
|
+
const {
|
|
1530
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1531
|
+
keyword: _jsKeyword, function: jsFunction,
|
|
1532
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1533
|
+
operator: _jsOperator, punctuation: jsPunctuation } = javascriptGrammar, jsGrammarBase = __rest(javascriptGrammar, ["keyword", "function", "operator", "punctuation"]);
|
|
1534
|
+
const typescriptGrammar = Object.assign(Object.assign({}, jsGrammarBase), { 'class-name': [
|
|
1535
|
+
{
|
|
1536
|
+
pattern: /(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,
|
|
1537
|
+
lookbehind: true,
|
|
1538
|
+
greedy: true,
|
|
1539
|
+
inside: {
|
|
1540
|
+
punctuation: { pattern: /[<>.,]/ },
|
|
1541
|
+
},
|
|
1542
|
+
},
|
|
1543
|
+
], 'builtin': {
|
|
1544
|
+
pattern: /\b(?:Array|Boolean|Date|Function|Map|Number|Object|Promise|RegExp|Set|String|WeakMap|WeakSet|bigint|boolean|never|null|number|string|symbol|undefined|unknown|void)\b/,
|
|
1545
|
+
}, 'keyword': [
|
|
1546
|
+
{
|
|
1547
|
+
pattern: /\b(?:abstract|as|asserts|async|await|break|case|catch|class|const|constructor|continue|debugger|declare|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|infer|instanceof|interface|is|keyof|let|module|namespace|new|null|of|package|private|protected|public|readonly|return|require|set|static|super|switch|this|throw|try|type|typeof|undefined|var|void|while|with|yield)\b/,
|
|
1548
|
+
},
|
|
1549
|
+
], 'function': jsFunction, 'generic-function': {
|
|
1550
|
+
pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,
|
|
1551
|
+
greedy: true,
|
|
1552
|
+
inside: {
|
|
1553
|
+
function: {
|
|
1554
|
+
pattern: /^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,
|
|
1555
|
+
},
|
|
1556
|
+
generic: {
|
|
1557
|
+
pattern: /<[\s\S]+/,
|
|
1558
|
+
inside: {
|
|
1559
|
+
punctuation: { pattern: /[<>(),.]/ },
|
|
1560
|
+
keyword: { pattern: /\b(?:extends|infer|keyof)\b/ },
|
|
1561
|
+
builtin: {
|
|
1562
|
+
pattern: /\b(?:boolean|never|null|number|string|symbol|undefined|unknown|void)\b/,
|
|
1563
|
+
},
|
|
1564
|
+
},
|
|
1565
|
+
},
|
|
1566
|
+
},
|
|
1567
|
+
}, 'operator': {
|
|
1568
|
+
pattern: /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%|&^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]|!(?=\s*[^=])/,
|
|
1569
|
+
}, 'punctuation': jsPunctuation });
|
|
3236
1570
|
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
var def = {};
|
|
3282
|
-
def[tagName] = {
|
|
3283
|
-
pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function () { return tagName; }), 'i'),
|
|
3284
|
-
lookbehind: true,
|
|
3285
|
-
greedy: true,
|
|
3286
|
-
inside: inside
|
|
3287
|
-
};
|
|
3288
|
-
|
|
3289
|
-
Prism.languages.insertBefore('markup', 'cdata', def);
|
|
3290
|
-
}
|
|
3291
|
-
});
|
|
3292
|
-
Object.defineProperty(Prism.languages.markup.tag, 'addAttribute', {
|
|
3293
|
-
/**
|
|
3294
|
-
* Adds an pattern to highlight languages embedded in HTML attributes.
|
|
3295
|
-
*
|
|
3296
|
-
* An example of an inlined language is CSS with `style` attributes.
|
|
3297
|
-
*
|
|
3298
|
-
* @param {string} attrName The name of the tag that contains the inlined language. This name will be treated as
|
|
3299
|
-
* case insensitive.
|
|
3300
|
-
* @param {string} lang The language key.
|
|
3301
|
-
* @example
|
|
3302
|
-
* addAttribute('style', 'css');
|
|
3303
|
-
*/
|
|
3304
|
-
value: function (attrName, lang) {
|
|
3305
|
-
Prism.languages.markup.tag.inside['special-attr'].push({
|
|
3306
|
-
pattern: RegExp(
|
|
3307
|
-
/(^|["'\s])/.source + '(?:' + attrName + ')' + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
|
|
3308
|
-
'i'
|
|
3309
|
-
),
|
|
3310
|
-
lookbehind: true,
|
|
3311
|
-
inside: {
|
|
3312
|
-
'attr-name': /^[^\s=]+/,
|
|
3313
|
-
'attr-value': {
|
|
3314
|
-
pattern: /=[\s\S]+/,
|
|
3315
|
-
inside: {
|
|
3316
|
-
'value': {
|
|
3317
|
-
pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
|
|
3318
|
-
lookbehind: true,
|
|
3319
|
-
alias: [lang, 'language-' + lang],
|
|
3320
|
-
inside: Prism.languages[lang]
|
|
3321
|
-
},
|
|
3322
|
-
'punctuation': [
|
|
3323
|
-
{
|
|
3324
|
-
pattern: /^=/,
|
|
3325
|
-
alias: 'attr-equals'
|
|
3326
|
-
},
|
|
3327
|
-
/"|'/
|
|
3328
|
-
]
|
|
3329
|
-
}
|
|
3330
|
-
}
|
|
3331
|
-
}
|
|
3332
|
-
});
|
|
3333
|
-
}
|
|
3334
|
-
});
|
|
3335
|
-
|
|
3336
|
-
Prism.languages.html = Prism.languages.markup;
|
|
3337
|
-
Prism.languages.mathml = Prism.languages.markup;
|
|
3338
|
-
Prism.languages.svg = Prism.languages.markup;
|
|
3339
|
-
|
|
3340
|
-
Prism.languages.xml = Prism.languages.extend('markup', {});
|
|
3341
|
-
Prism.languages.ssml = Prism.languages.xml;
|
|
3342
|
-
Prism.languages.atom = Prism.languages.xml;
|
|
3343
|
-
Prism.languages.rss = Prism.languages.xml;
|
|
3344
|
-
|
|
3345
|
-
Prism.languages.c = Prism.languages.extend('clike', {
|
|
3346
|
-
'comment': {
|
|
3347
|
-
pattern: /\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,
|
|
3348
|
-
greedy: true
|
|
3349
|
-
},
|
|
3350
|
-
'string': {
|
|
3351
|
-
// https://en.cppreference.com/w/c/language/string_literal
|
|
3352
|
-
pattern: /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,
|
|
3353
|
-
greedy: true
|
|
3354
|
-
},
|
|
3355
|
-
'class-name': {
|
|
3356
|
-
pattern: /(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,
|
|
3357
|
-
lookbehind: true
|
|
3358
|
-
},
|
|
3359
|
-
'keyword': /\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/,
|
|
3360
|
-
'function': /\b[a-z_]\w*(?=\s*\()/i,
|
|
3361
|
-
'number': /(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,
|
|
3362
|
-
'operator': />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/
|
|
3363
|
-
});
|
|
3364
|
-
|
|
3365
|
-
Prism.languages.insertBefore('c', 'string', {
|
|
3366
|
-
'char': {
|
|
3367
|
-
// https://en.cppreference.com/w/c/language/character_constant
|
|
3368
|
-
pattern: /'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,
|
|
3369
|
-
greedy: true
|
|
3370
|
-
}
|
|
3371
|
-
});
|
|
3372
|
-
|
|
3373
|
-
Prism.languages.insertBefore('c', 'string', {
|
|
3374
|
-
'macro': {
|
|
3375
|
-
// allow for multiline macro definitions
|
|
3376
|
-
// spaces after the # character compile fine with gcc
|
|
3377
|
-
pattern: /(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,
|
|
3378
|
-
lookbehind: true,
|
|
3379
|
-
greedy: true,
|
|
3380
|
-
alias: 'property',
|
|
3381
|
-
inside: {
|
|
3382
|
-
'string': [
|
|
3383
|
-
{
|
|
3384
|
-
// highlight the path of the include statement as a string
|
|
3385
|
-
pattern: /^(#\s*include\s*)<[^>]+>/,
|
|
3386
|
-
lookbehind: true
|
|
3387
|
-
},
|
|
3388
|
-
Prism.languages.c['string']
|
|
3389
|
-
],
|
|
3390
|
-
'char': Prism.languages.c['char'],
|
|
3391
|
-
'comment': Prism.languages.c['comment'],
|
|
3392
|
-
'macro-name': [
|
|
3393
|
-
{
|
|
3394
|
-
pattern: /(^#\s*define\s+)\w+\b(?!\()/i,
|
|
3395
|
-
lookbehind: true
|
|
3396
|
-
},
|
|
3397
|
-
{
|
|
3398
|
-
pattern: /(^#\s*define\s+)\w+\b(?=\()/i,
|
|
3399
|
-
lookbehind: true,
|
|
3400
|
-
alias: 'function'
|
|
3401
|
-
}
|
|
3402
|
-
],
|
|
3403
|
-
// highlight macro directives as keywords
|
|
3404
|
-
'directive': {
|
|
3405
|
-
pattern: /^(#\s*)[a-z]+/,
|
|
3406
|
-
lookbehind: true,
|
|
3407
|
-
alias: 'keyword'
|
|
3408
|
-
},
|
|
3409
|
-
'directive-hash': /^#/,
|
|
3410
|
-
'punctuation': /##|\\(?=[\r\n])/,
|
|
3411
|
-
'expression': {
|
|
3412
|
-
pattern: /\S[\s\S]*/,
|
|
3413
|
-
inside: Prism.languages.c
|
|
3414
|
-
}
|
|
3415
|
-
}
|
|
3416
|
-
}
|
|
3417
|
-
});
|
|
3418
|
-
|
|
3419
|
-
Prism.languages.insertBefore('c', 'function', {
|
|
3420
|
-
// highlight predefined macros as constants
|
|
3421
|
-
'constant': /\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/
|
|
3422
|
-
});
|
|
3423
|
-
|
|
3424
|
-
delete Prism.languages.c['boolean'];
|
|
3425
|
-
|
|
3426
|
-
(function (Prism) {
|
|
3427
|
-
|
|
3428
|
-
var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
|
|
3429
|
-
|
|
3430
|
-
Prism.languages.css = {
|
|
3431
|
-
'comment': /\/\*[\s\S]*?\*\//,
|
|
3432
|
-
'atrule': {
|
|
3433
|
-
pattern: RegExp('@[\\w-](?:' + /[^;{\s"']|\s+(?!\s)/.source + '|' + string.source + ')*?' + /(?:;|(?=\s*\{))/.source),
|
|
3434
|
-
inside: {
|
|
3435
|
-
'rule': /^@[\w-]+/,
|
|
3436
|
-
'selector-function-argument': {
|
|
3437
|
-
pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
|
|
3438
|
-
lookbehind: true,
|
|
3439
|
-
alias: 'selector'
|
|
3440
|
-
},
|
|
3441
|
-
'keyword': {
|
|
3442
|
-
pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
|
|
3443
|
-
lookbehind: true
|
|
3444
|
-
}
|
|
3445
|
-
// See rest below
|
|
3446
|
-
}
|
|
3447
|
-
},
|
|
3448
|
-
'url': {
|
|
3449
|
-
// https://drafts.csswg.org/css-values-3/#urls
|
|
3450
|
-
pattern: RegExp('\\burl\\((?:' + string.source + '|' + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ')\\)', 'i'),
|
|
3451
|
-
greedy: true,
|
|
3452
|
-
inside: {
|
|
3453
|
-
'function': /^url/i,
|
|
3454
|
-
'punctuation': /^\(|\)$/,
|
|
3455
|
-
'string': {
|
|
3456
|
-
pattern: RegExp('^' + string.source + '$'),
|
|
3457
|
-
alias: 'url'
|
|
3458
|
-
}
|
|
3459
|
-
}
|
|
3460
|
-
},
|
|
3461
|
-
'selector': {
|
|
3462
|
-
pattern: RegExp('(^|[{}\\s])[^{}\\s](?:[^{};"\'\\s]|\\s+(?![\\s{])|' + string.source + ')*(?=\\s*\\{)'),
|
|
3463
|
-
lookbehind: true
|
|
3464
|
-
},
|
|
3465
|
-
'string': {
|
|
3466
|
-
pattern: string,
|
|
3467
|
-
greedy: true
|
|
3468
|
-
},
|
|
3469
|
-
'property': {
|
|
3470
|
-
pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
|
|
3471
|
-
lookbehind: true
|
|
3472
|
-
},
|
|
3473
|
-
'important': /!important\b/i,
|
|
3474
|
-
'function': {
|
|
3475
|
-
pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
|
|
3476
|
-
lookbehind: true
|
|
3477
|
-
},
|
|
3478
|
-
'punctuation': /[(){};:,]/
|
|
3479
|
-
};
|
|
3480
|
-
|
|
3481
|
-
Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
|
|
3482
|
-
|
|
3483
|
-
var markup = Prism.languages.markup;
|
|
3484
|
-
if (markup) {
|
|
3485
|
-
markup.tag.addInlined('style', 'css');
|
|
3486
|
-
markup.tag.addAttribute('style', 'css');
|
|
3487
|
-
}
|
|
3488
|
-
|
|
3489
|
-
}(Prism));
|
|
3490
|
-
|
|
3491
|
-
(function (Prism) {
|
|
3492
|
-
|
|
3493
|
-
Prism.languages.typescript = Prism.languages.extend('javascript', {
|
|
3494
|
-
'class-name': {
|
|
3495
|
-
pattern: /(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,
|
|
3496
|
-
lookbehind: true,
|
|
3497
|
-
greedy: true,
|
|
3498
|
-
inside: null // see below
|
|
3499
|
-
},
|
|
3500
|
-
'builtin': /\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/,
|
|
3501
|
-
});
|
|
3502
|
-
|
|
3503
|
-
// The keywords TypeScript adds to JavaScript
|
|
3504
|
-
Prism.languages.typescript.keyword.push(
|
|
3505
|
-
/\b(?:abstract|declare|is|keyof|readonly|require)\b/,
|
|
3506
|
-
// keywords that have to be followed by an identifier
|
|
3507
|
-
/\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,
|
|
3508
|
-
// This is for `import type *, {}`
|
|
3509
|
-
/\btype\b(?=\s*(?:[\{*]|$))/
|
|
3510
|
-
);
|
|
3511
|
-
|
|
3512
|
-
// doesn't work with TS because TS is too complex
|
|
3513
|
-
delete Prism.languages.typescript['parameter'];
|
|
3514
|
-
delete Prism.languages.typescript['literal-property'];
|
|
3515
|
-
|
|
3516
|
-
// a version of typescript specifically for highlighting types
|
|
3517
|
-
var typeInside = Prism.languages.extend('typescript', {});
|
|
3518
|
-
delete typeInside['class-name'];
|
|
3519
|
-
|
|
3520
|
-
Prism.languages.typescript['class-name'].inside = typeInside;
|
|
3521
|
-
|
|
3522
|
-
Prism.languages.insertBefore('typescript', 'function', {
|
|
3523
|
-
'decorator': {
|
|
3524
|
-
pattern: /@[$\w\xA0-\uFFFF]+/,
|
|
3525
|
-
inside: {
|
|
3526
|
-
'at': {
|
|
3527
|
-
pattern: /^@/,
|
|
3528
|
-
alias: 'operator'
|
|
3529
|
-
},
|
|
3530
|
-
'function': /^[\s\S]+/
|
|
3531
|
-
}
|
|
3532
|
-
},
|
|
3533
|
-
'generic-function': {
|
|
3534
|
-
// e.g. foo<T extends "bar" | "baz">( ...
|
|
3535
|
-
pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,
|
|
3536
|
-
greedy: true,
|
|
3537
|
-
inside: {
|
|
3538
|
-
'function': /^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,
|
|
3539
|
-
'generic': {
|
|
3540
|
-
pattern: /<[\s\S]+/, // everything after the first <
|
|
3541
|
-
alias: 'class-name',
|
|
3542
|
-
inside: typeInside
|
|
3543
|
-
}
|
|
3544
|
-
}
|
|
3545
|
-
}
|
|
3546
|
-
});
|
|
3547
|
-
|
|
3548
|
-
Prism.languages.ts = Prism.languages.typescript;
|
|
3549
|
-
|
|
3550
|
-
}(Prism));
|
|
3551
|
-
|
|
3552
|
-
(function (Prism) {
|
|
3553
|
-
|
|
3554
|
-
var javascript = Prism.util.clone(Prism.languages.javascript);
|
|
3555
|
-
|
|
3556
|
-
var space = /(?:\s|\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))\*\/)/.source;
|
|
3557
|
-
var braces = /(?:\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])*\})/.source;
|
|
3558
|
-
var spread = /(?:\{<S>*\.{3}(?:[^{}]|<BRACES>)*\})/.source;
|
|
3559
|
-
|
|
3560
|
-
/**
|
|
3561
|
-
* @param {string} source
|
|
3562
|
-
* @param {string} [flags]
|
|
3563
|
-
*/
|
|
3564
|
-
function re(source, flags) {
|
|
3565
|
-
source = source
|
|
3566
|
-
.replace(/<S>/g, function () { return space; })
|
|
3567
|
-
.replace(/<BRACES>/g, function () { return braces; })
|
|
3568
|
-
.replace(/<SPREAD>/g, function () { return spread; });
|
|
3569
|
-
return RegExp(source, flags);
|
|
3570
|
-
}
|
|
3571
|
-
|
|
3572
|
-
spread = re(spread).source;
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
Prism.languages.jsx = Prism.languages.extend('markup', javascript);
|
|
3576
|
-
Prism.languages.jsx.tag.pattern = re(
|
|
3577
|
-
/<\/?(?:[\w.:-]+(?:<S>+(?:[\w.:$-]+(?:=(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s{'"/>=]+|<BRACES>))?|<SPREAD>))*<S>*\/?)?>/.source
|
|
3578
|
-
);
|
|
3579
|
-
|
|
3580
|
-
Prism.languages.jsx.tag.inside['tag'].pattern = /^<\/?[^\s>\/]*/;
|
|
3581
|
-
Prism.languages.jsx.tag.inside['attr-value'].pattern = /=(?!\{)(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s'">]+)/;
|
|
3582
|
-
Prism.languages.jsx.tag.inside['tag'].inside['class-name'] = /^[A-Z]\w*(?:\.[A-Z]\w*)*$/;
|
|
3583
|
-
Prism.languages.jsx.tag.inside['comment'] = javascript['comment'];
|
|
3584
|
-
|
|
3585
|
-
Prism.languages.insertBefore('inside', 'attr-name', {
|
|
3586
|
-
'spread': {
|
|
3587
|
-
pattern: re(/<SPREAD>/.source),
|
|
3588
|
-
inside: Prism.languages.jsx
|
|
3589
|
-
}
|
|
3590
|
-
}, Prism.languages.jsx.tag);
|
|
3591
|
-
|
|
3592
|
-
Prism.languages.insertBefore('inside', 'special-attr', {
|
|
3593
|
-
'script': {
|
|
3594
|
-
// Allow for two levels of nesting
|
|
3595
|
-
pattern: re(/=<BRACES>/.source),
|
|
3596
|
-
alias: 'language-javascript',
|
|
3597
|
-
inside: {
|
|
3598
|
-
'script-punctuation': {
|
|
3599
|
-
pattern: /^=(?=\{)/,
|
|
3600
|
-
alias: 'punctuation'
|
|
3601
|
-
},
|
|
3602
|
-
rest: Prism.languages.jsx
|
|
3603
|
-
},
|
|
3604
|
-
}
|
|
3605
|
-
}, Prism.languages.jsx.tag);
|
|
3606
|
-
|
|
3607
|
-
// The following will handle plain text inside tags
|
|
3608
|
-
var stringifyToken = function (token) {
|
|
3609
|
-
if (!token) {
|
|
3610
|
-
return '';
|
|
3611
|
-
}
|
|
3612
|
-
if (typeof token === 'string') {
|
|
3613
|
-
return token;
|
|
3614
|
-
}
|
|
3615
|
-
if (typeof token.content === 'string') {
|
|
3616
|
-
return token.content;
|
|
3617
|
-
}
|
|
3618
|
-
return token.content.map(stringifyToken).join('');
|
|
3619
|
-
};
|
|
3620
|
-
|
|
3621
|
-
var walkTokens = function (tokens) {
|
|
3622
|
-
var openedTags = [];
|
|
3623
|
-
for (var i = 0; i < tokens.length; i++) {
|
|
3624
|
-
var token = tokens[i];
|
|
3625
|
-
var notTagNorBrace = false;
|
|
3626
|
-
|
|
3627
|
-
if (typeof token !== 'string') {
|
|
3628
|
-
if (token.type === 'tag' && token.content[0] && token.content[0].type === 'tag') {
|
|
3629
|
-
// We found a tag, now find its kind
|
|
3630
|
-
|
|
3631
|
-
if (token.content[0].content[0].content === '</') {
|
|
3632
|
-
// Closing tag
|
|
3633
|
-
if (openedTags.length > 0 && openedTags[openedTags.length - 1].tagName === stringifyToken(token.content[0].content[1])) {
|
|
3634
|
-
// Pop matching opening tag
|
|
3635
|
-
openedTags.pop();
|
|
3636
|
-
}
|
|
3637
|
-
} else {
|
|
3638
|
-
if (token.content[token.content.length - 1].content === '/>') ; else {
|
|
3639
|
-
// Opening tag
|
|
3640
|
-
openedTags.push({
|
|
3641
|
-
tagName: stringifyToken(token.content[0].content[1]),
|
|
3642
|
-
openedBraces: 0
|
|
3643
|
-
});
|
|
3644
|
-
}
|
|
3645
|
-
}
|
|
3646
|
-
} else if (openedTags.length > 0 && token.type === 'punctuation' && token.content === '{') {
|
|
3647
|
-
|
|
3648
|
-
// Here we might have entered a JSX context inside a tag
|
|
3649
|
-
openedTags[openedTags.length - 1].openedBraces++;
|
|
3650
|
-
|
|
3651
|
-
} else if (openedTags.length > 0 && openedTags[openedTags.length - 1].openedBraces > 0 && token.type === 'punctuation' && token.content === '}') {
|
|
3652
|
-
|
|
3653
|
-
// Here we might have left a JSX context inside a tag
|
|
3654
|
-
openedTags[openedTags.length - 1].openedBraces--;
|
|
3655
|
-
|
|
3656
|
-
} else {
|
|
3657
|
-
notTagNorBrace = true;
|
|
3658
|
-
}
|
|
3659
|
-
}
|
|
3660
|
-
if (notTagNorBrace || typeof token === 'string') {
|
|
3661
|
-
if (openedTags.length > 0 && openedTags[openedTags.length - 1].openedBraces === 0) {
|
|
3662
|
-
// Here we are inside a tag, and not inside a JSX context.
|
|
3663
|
-
// That's plain text: drop any tokens matched.
|
|
3664
|
-
var plainText = stringifyToken(token);
|
|
3665
|
-
|
|
3666
|
-
// And merge text with adjacent text
|
|
3667
|
-
if (i < tokens.length - 1 && (typeof tokens[i + 1] === 'string' || tokens[i + 1].type === 'plain-text')) {
|
|
3668
|
-
plainText += stringifyToken(tokens[i + 1]);
|
|
3669
|
-
tokens.splice(i + 1, 1);
|
|
3670
|
-
}
|
|
3671
|
-
if (i > 0 && (typeof tokens[i - 1] === 'string' || tokens[i - 1].type === 'plain-text')) {
|
|
3672
|
-
plainText = stringifyToken(tokens[i - 1]) + plainText;
|
|
3673
|
-
tokens.splice(i - 1, 1);
|
|
3674
|
-
i--;
|
|
3675
|
-
}
|
|
3676
|
-
|
|
3677
|
-
tokens[i] = new Prism.Token('plain-text', plainText, null, plainText);
|
|
3678
|
-
}
|
|
3679
|
-
}
|
|
3680
|
-
|
|
3681
|
-
if (token.content && typeof token.content !== 'string') {
|
|
3682
|
-
walkTokens(token.content);
|
|
3683
|
-
}
|
|
3684
|
-
}
|
|
3685
|
-
};
|
|
3686
|
-
|
|
3687
|
-
Prism.hooks.add('after-tokenize', function (env) {
|
|
3688
|
-
if (env.language !== 'jsx' && env.language !== 'tsx') {
|
|
3689
|
-
return;
|
|
3690
|
-
}
|
|
3691
|
-
walkTokens(env.tokens);
|
|
3692
|
-
});
|
|
3693
|
-
|
|
3694
|
-
}(Prism));
|
|
3695
|
-
|
|
3696
|
-
(function (Prism) {
|
|
3697
|
-
var typescript = Prism.util.clone(Prism.languages.typescript);
|
|
3698
|
-
Prism.languages.tsx = Prism.languages.extend('jsx', typescript);
|
|
1571
|
+
/**
|
|
1572
|
+
* Grammar definition for JSX syntax highlighting.
|
|
1573
|
+
* Extends JavaScript grammar with JSX tag syntax for React components,
|
|
1574
|
+
* including self-closing tags, expressions in braces, and embedded markup attributes.
|
|
1575
|
+
*/
|
|
1576
|
+
const jsxGrammar = Object.assign(Object.assign({
|
|
1577
|
+
// Tag must come before JS spread so operator pattern doesn't consume < and >
|
|
1578
|
+
tag: {
|
|
1579
|
+
pattern: /<\/?(?:[\w.:-]+(?:\s+(?:[\w.:$-]+(?:=(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])+\}))?|\{\.{3}[a-z_$][\w$]*(?:\.[\w$]+)*\}))*\s*\/?)?>/i,
|
|
1580
|
+
greedy: true,
|
|
1581
|
+
inside: {
|
|
1582
|
+
'tag': {
|
|
1583
|
+
pattern: /^<\/?[^\s>/]*/,
|
|
1584
|
+
inside: {
|
|
1585
|
+
punctuation: { pattern: /^<\/?/ },
|
|
1586
|
+
namespace: { pattern: /^[^\s>/:]+:/ },
|
|
1587
|
+
},
|
|
1588
|
+
},
|
|
1589
|
+
'attr-value': {
|
|
1590
|
+
pattern: /=\s*(?:"[^"]*"|'[^']*'|\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])+\})/,
|
|
1591
|
+
inside: {
|
|
1592
|
+
punctuation: [{ pattern: /^=/ }, { pattern: /^(\s*)["'{]|[}"']$/, lookbehind: true }],
|
|
1593
|
+
script: {
|
|
1594
|
+
pattern: /[\s\S]+/,
|
|
1595
|
+
inside: javascriptGrammar,
|
|
1596
|
+
},
|
|
1597
|
+
},
|
|
1598
|
+
},
|
|
1599
|
+
'spread': {
|
|
1600
|
+
pattern: /\{\.{3}[a-z_$][\w$]*(?:\.[\w$]+)*\}/,
|
|
1601
|
+
inside: {
|
|
1602
|
+
'punctuation': { pattern: /^\{\.{3}|\}$/ },
|
|
1603
|
+
'attr-name': { pattern: /[\s\S]+/ },
|
|
1604
|
+
},
|
|
1605
|
+
},
|
|
1606
|
+
'attr-name': {
|
|
1607
|
+
pattern: /[^\s>/]+/,
|
|
1608
|
+
inside: {
|
|
1609
|
+
namespace: { pattern: /^[^\s>/:]+:/ },
|
|
1610
|
+
},
|
|
1611
|
+
},
|
|
1612
|
+
'punctuation': { pattern: /\/?>/ },
|
|
1613
|
+
},
|
|
1614
|
+
} }, javascriptGrammar), { entity: markupGrammar.entity });
|
|
3699
1615
|
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
1616
|
+
/**
|
|
1617
|
+
* Grammar definition for TSX (TypeScript + JSX) syntax highlighting.
|
|
1618
|
+
* Merges TypeScript and JSX grammars, supporting both type annotations
|
|
1619
|
+
* and JSX tag syntax in the same file.
|
|
1620
|
+
*/
|
|
1621
|
+
const tsxGrammar = Object.assign(Object.assign({
|
|
1622
|
+
// Tag must come before TS spread so operator pattern doesn't consume < and >
|
|
1623
|
+
tag: jsxGrammar['tag'] }, typescriptGrammar), { entity: jsxGrammar['entity'] });
|
|
3703
1624
|
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
1625
|
+
/**
|
|
1626
|
+
* A registry that maps language identifiers to their grammar definitions.
|
|
1627
|
+
* Supports common aliases (e.g., 'html' -> markup, 'js' -> javascript).
|
|
1628
|
+
*
|
|
1629
|
+
* The registry provides grammars for:
|
|
1630
|
+
* - CSS
|
|
1631
|
+
* - HTML / Markup
|
|
1632
|
+
* - JavaScript (JS)
|
|
1633
|
+
* - TypeScript (TS)
|
|
1634
|
+
* - JSX
|
|
1635
|
+
* - TSX
|
|
1636
|
+
* - C / C-like (falls back to JavaScript grammar for basic C-family highlighting)
|
|
1637
|
+
*/
|
|
1638
|
+
const languageRegistry = {
|
|
1639
|
+
css: cssGrammar,
|
|
1640
|
+
html: markupGrammar,
|
|
1641
|
+
markup: markupGrammar,
|
|
1642
|
+
javascript: javascriptGrammar,
|
|
1643
|
+
js: javascriptGrammar,
|
|
1644
|
+
typescript: typescriptGrammar,
|
|
1645
|
+
ts: typescriptGrammar,
|
|
1646
|
+
jsx: jsxGrammar,
|
|
1647
|
+
tsx: tsxGrammar,
|
|
1648
|
+
c: javascriptGrammar,
|
|
1649
|
+
clike: javascriptGrammar,
|
|
1650
|
+
};
|
|
1651
|
+
/**
|
|
1652
|
+
* Retrieve the grammar for a given language identifier.
|
|
1653
|
+
*
|
|
1654
|
+
* @param {string} language - The language identifier (e.g., 'js', 'css', 'html', 'ts', 'jsx', 'tsx').
|
|
1655
|
+
* @returns {Grammar | undefined} The grammar definition, or undefined if the language is not registered.
|
|
1656
|
+
*/
|
|
1657
|
+
function getLanguageGrammar(language) {
|
|
1658
|
+
return languageRegistry[language];
|
|
1659
|
+
}
|
|
3711
1660
|
|
|
3712
1661
|
var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
3713
1662
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -3796,7 +1745,7 @@ __decorate$4([
|
|
|
3796
1745
|
], CodeHighlightParser.prototype, "value", void 0);
|
|
3797
1746
|
|
|
3798
1747
|
/**
|
|
3799
|
-
* Use the
|
|
1748
|
+
* Use the local syntax highlight tokenizer to highlight the code content.
|
|
3800
1749
|
*/
|
|
3801
1750
|
class PrismCodeHighlightParseController extends CodeHighlightParser {
|
|
3802
1751
|
/**
|
|
@@ -3809,15 +1758,15 @@ class PrismCodeHighlightParseController extends CodeHighlightParser {
|
|
|
3809
1758
|
return code && language && this.isHighlightLanguage(language);
|
|
3810
1759
|
}
|
|
3811
1760
|
/**
|
|
3812
|
-
* Use
|
|
1761
|
+
* Use tokenizer to parse the string code into an array of nodes with different keywords.
|
|
3813
1762
|
*
|
|
3814
1763
|
* @returns {CodeNodeType[]} - The object contains content and highlight type.
|
|
3815
1764
|
*/
|
|
3816
1765
|
parse() {
|
|
3817
1766
|
const { code, language } = this.value;
|
|
3818
1767
|
let result = [];
|
|
3819
|
-
const parseLanguage =
|
|
3820
|
-
const tokens =
|
|
1768
|
+
const parseLanguage = getLanguageGrammar(language);
|
|
1769
|
+
const tokens = tokenize(code, parseLanguage);
|
|
3821
1770
|
result = this.getHighlightNodes(tokens);
|
|
3822
1771
|
return this.markLineNumberNodes(result);
|
|
3823
1772
|
}
|
|
@@ -4238,10 +2187,10 @@ const VegaCodeBlock = class {
|
|
|
4238
2187
|
this.insertCompositionTextController = new InsertCompositionTextController();
|
|
4239
2188
|
this.focusController = new VegaCodeBlockFocusController();
|
|
4240
2189
|
this.historyController = new VegaCodeBlockHistoryController();
|
|
4241
|
-
this.changeEventEmitter = eventEmitSlimmer.createEventEmitSlimmer(VegaCodeBlock,
|
|
4242
|
-
this.removeEventEmitter = eventEmitSlimmer.createEventEmitSlimmer(VegaCodeBlock,
|
|
2190
|
+
this.changeEventEmitter = eventEmitSlimmer.createEventEmitSlimmer(VegaCodeBlock, vegaEventId.VegaChange);
|
|
2191
|
+
this.removeEventEmitter = eventEmitSlimmer.createEventEmitSlimmer(VegaCodeBlock, vegaEventId.VegaRemove);
|
|
4243
2192
|
this.codeBlockPasteController = new CodeBlockPasteController();
|
|
4244
|
-
this.eventPreventSlimmer = new childNodesEventPreventSlimmer.ChildNodesEventPreventSlimmer([
|
|
2193
|
+
this.eventPreventSlimmer = new childNodesEventPreventSlimmer.ChildNodesEventPreventSlimmer([vegaEventId.VegaChange], () => this.codeBlockRenderer.getToolbarContainerRef());
|
|
4245
2194
|
/**
|
|
4246
2195
|
* Specifies whether the code block editor is in read-only mode.
|
|
4247
2196
|
*
|