@intlayer/core 8.1.2 → 8.1.3
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/_virtual/_rolldown/runtime.cjs +1 -29
- package/dist/cjs/deepTransformPlugins/getFilterMissingTranslationsContent.cjs +1 -212
- package/dist/cjs/deepTransformPlugins/getFilterMissingTranslationsContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getFilterTranslationsOnlyContent.cjs +1 -94
- package/dist/cjs/deepTransformPlugins/getFilterTranslationsOnlyContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getFilteredLocalesContent.cjs +1 -45
- package/dist/cjs/deepTransformPlugins/getFilteredLocalesContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getLocalizedContent.cjs +1 -33
- package/dist/cjs/deepTransformPlugins/getLocalizedContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getMaskContent.cjs +1 -27
- package/dist/cjs/deepTransformPlugins/getMaskContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getMissingLocalesContent.cjs +1 -82
- package/dist/cjs/deepTransformPlugins/getMissingLocalesContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getMultilingualDictionary.cjs +1 -87
- package/dist/cjs/deepTransformPlugins/getMultilingualDictionary.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getReplacedValuesContent.cjs +1 -60
- package/dist/cjs/deepTransformPlugins/getReplacedValuesContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getSplittedContent.cjs +1 -122
- package/dist/cjs/deepTransformPlugins/getSplittedContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/index.cjs +1 -32
- package/dist/cjs/deepTransformPlugins/insertContentInDictionary.cjs +1 -106
- package/dist/cjs/deepTransformPlugins/insertContentInDictionary.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs +1 -64
- package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs +1 -18
- package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs +1 -55
- package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs +1 -26
- package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs +1 -23
- package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/getNodeType.cjs +1 -36
- package/dist/cjs/dictionaryManipulator/getNodeType.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/index.cjs +1 -27
- package/dist/cjs/dictionaryManipulator/mergeDictionaries.cjs +1 -69
- package/dist/cjs/dictionaryManipulator/mergeDictionaries.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/normalizeDictionary.cjs +1 -30
- package/dist/cjs/dictionaryManipulator/normalizeDictionary.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/orderDictionaries.cjs +1 -48
- package/dist/cjs/dictionaryManipulator/orderDictionaries.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs +1 -31
- package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs +1 -39
- package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/updateNodeChildren.cjs +1 -38
- package/dist/cjs/dictionaryManipulator/updateNodeChildren.cjs.map +1 -1
- package/dist/cjs/formatters/compact.cjs +1 -25
- package/dist/cjs/formatters/compact.cjs.map +1 -1
- package/dist/cjs/formatters/currency.cjs +1 -29
- package/dist/cjs/formatters/currency.cjs.map +1 -1
- package/dist/cjs/formatters/date.cjs +1 -60
- package/dist/cjs/formatters/date.cjs.map +1 -1
- package/dist/cjs/formatters/index.cjs +1 -18
- package/dist/cjs/formatters/list.cjs +1 -30
- package/dist/cjs/formatters/list.cjs.map +1 -1
- package/dist/cjs/formatters/number.cjs +1 -18
- package/dist/cjs/formatters/number.cjs.map +1 -1
- package/dist/cjs/formatters/percentage.cjs +1 -25
- package/dist/cjs/formatters/percentage.cjs.map +1 -1
- package/dist/cjs/formatters/relativeTime.cjs +1 -33
- package/dist/cjs/formatters/relativeTime.cjs.map +1 -1
- package/dist/cjs/formatters/units.cjs +1 -23
- package/dist/cjs/formatters/units.cjs.map +1 -1
- package/dist/cjs/getStorageAttributes.cjs +1 -134
- package/dist/cjs/getStorageAttributes.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -300
- package/dist/cjs/interpreter/getCondition.cjs +1 -27
- package/dist/cjs/interpreter/getCondition.cjs.map +1 -1
- package/dist/cjs/interpreter/getContent/deepTransform.cjs +1 -41
- package/dist/cjs/interpreter/getContent/deepTransform.cjs.map +1 -1
- package/dist/cjs/interpreter/getContent/getContent.cjs +1 -34
- package/dist/cjs/interpreter/getContent/getContent.cjs.map +1 -1
- package/dist/cjs/interpreter/getContent/index.cjs +1 -14
- package/dist/cjs/interpreter/getContent/plugins.cjs +1 -161
- package/dist/cjs/interpreter/getContent/plugins.cjs.map +1 -1
- package/dist/cjs/interpreter/getDictionary.cjs +1 -24
- package/dist/cjs/interpreter/getDictionary.cjs.map +1 -1
- package/dist/cjs/interpreter/getEnumeration.cjs +1 -72
- package/dist/cjs/interpreter/getEnumeration.cjs.map +1 -1
- package/dist/cjs/interpreter/getGender.cjs +1 -38
- package/dist/cjs/interpreter/getGender.cjs.map +1 -1
- package/dist/cjs/interpreter/getHTML.cjs +1 -121
- package/dist/cjs/interpreter/getHTML.cjs.map +1 -1
- package/dist/cjs/interpreter/getInsertion.cjs +1 -22
- package/dist/cjs/interpreter/getInsertion.cjs.map +1 -1
- package/dist/cjs/interpreter/getIntlayer.cjs +1 -40
- package/dist/cjs/interpreter/getIntlayer.cjs.map +1 -1
- package/dist/cjs/interpreter/getNesting.cjs +1 -36
- package/dist/cjs/interpreter/getNesting.cjs.map +1 -1
- package/dist/cjs/interpreter/getTranslation.cjs +1 -112
- package/dist/cjs/interpreter/getTranslation.cjs.map +1 -1
- package/dist/cjs/interpreter/index.cjs +1 -31
- package/dist/cjs/interpreter/splitAndJoinInsertion.cjs +1 -55
- package/dist/cjs/interpreter/splitAndJoinInsertion.cjs.map +1 -1
- package/dist/cjs/localization/getBrowserLocale.cjs +1 -143
- package/dist/cjs/localization/getBrowserLocale.cjs.map +1 -1
- package/dist/cjs/localization/getHTMLTextDir.cjs +1 -64
- package/dist/cjs/localization/getHTMLTextDir.cjs.map +1 -1
- package/dist/cjs/localization/getLocale.cjs +1 -27
- package/dist/cjs/localization/getLocale.cjs.map +1 -1
- package/dist/cjs/localization/getLocaleFromPath.cjs +1 -45
- package/dist/cjs/localization/getLocaleFromPath.cjs.map +1 -1
- package/dist/cjs/localization/getLocaleLang.cjs +1 -20
- package/dist/cjs/localization/getLocaleLang.cjs.map +1 -1
- package/dist/cjs/localization/getLocaleName.cjs +1 -10
- package/dist/cjs/localization/getLocaleName.cjs.map +1 -1
- package/dist/cjs/localization/getLocalizedUrl.cjs +1 -82
- package/dist/cjs/localization/getLocalizedUrl.cjs.map +1 -1
- package/dist/cjs/localization/getMultilingualUrls.cjs +1 -63
- package/dist/cjs/localization/getMultilingualUrls.cjs.map +1 -1
- package/dist/cjs/localization/getPathWithoutLocale.cjs +1 -55
- package/dist/cjs/localization/getPathWithoutLocale.cjs.map +1 -1
- package/dist/cjs/localization/getPrefix.cjs +1 -63
- package/dist/cjs/localization/getPrefix.cjs.map +1 -1
- package/dist/cjs/localization/index.cjs +1 -39
- package/dist/cjs/localization/localeDetector.cjs +1 -133
- package/dist/cjs/localization/localeDetector.cjs.map +1 -1
- package/dist/cjs/localization/localeMapper.cjs +1 -119
- package/dist/cjs/localization/localeMapper.cjs.map +1 -1
- package/dist/cjs/localization/localeResolver.cjs +1 -28
- package/dist/cjs/localization/localeResolver.cjs.map +1 -1
- package/dist/cjs/localization/rewriteUtils.cjs +1 -110
- package/dist/cjs/localization/rewriteUtils.cjs.map +1 -1
- package/dist/cjs/localization/validatePrefix.cjs +1 -54
- package/dist/cjs/localization/validatePrefix.cjs.map +1 -1
- package/dist/cjs/markdown/compiler.cjs +10 -810
- package/dist/cjs/markdown/compiler.cjs.map +1 -1
- package/dist/cjs/markdown/constants.cjs +1 -328
- package/dist/cjs/markdown/constants.cjs.map +1 -1
- package/dist/cjs/markdown/index.cjs +1 -120
- package/dist/cjs/markdown/parser.cjs +1 -66
- package/dist/cjs/markdown/parser.cjs.map +1 -1
- package/dist/cjs/markdown/renderer.cjs +1 -61
- package/dist/cjs/markdown/renderer.cjs.map +1 -1
- package/dist/cjs/markdown/utils.cjs +6 -391
- package/dist/cjs/markdown/utils.cjs.map +1 -1
- package/dist/cjs/messageFormat/ICU.cjs +1 -319
- package/dist/cjs/messageFormat/ICU.cjs.map +1 -1
- package/dist/cjs/messageFormat/i18next.cjs +1 -330
- package/dist/cjs/messageFormat/i18next.cjs.map +1 -1
- package/dist/cjs/messageFormat/index.cjs +1 -11
- package/dist/cjs/messageFormat/verify-icu-format.cjs +2 -64
- package/dist/cjs/messageFormat/verify-icu-format.cjs.map +1 -1
- package/dist/cjs/messageFormat/vue-i18n.cjs +1 -166
- package/dist/cjs/messageFormat/vue-i18n.cjs.map +1 -1
- package/dist/cjs/transpiler/condition/condition.cjs +1 -26
- package/dist/cjs/transpiler/condition/condition.cjs.map +1 -1
- package/dist/cjs/transpiler/condition/index.cjs +1 -4
- package/dist/cjs/transpiler/enumeration/enumeration.cjs +1 -28
- package/dist/cjs/transpiler/enumeration/enumeration.cjs.map +1 -1
- package/dist/cjs/transpiler/enumeration/index.cjs +1 -4
- package/dist/cjs/transpiler/file/file.cjs +1 -52
- package/dist/cjs/transpiler/file/file.cjs.map +1 -1
- package/dist/cjs/transpiler/file/fileBrowser.cjs +1 -25
- package/dist/cjs/transpiler/file/fileBrowser.cjs.map +1 -1
- package/dist/cjs/transpiler/file/index.cjs +1 -5
- package/dist/cjs/transpiler/gender/gender.cjs +1 -26
- package/dist/cjs/transpiler/gender/gender.cjs.map +1 -1
- package/dist/cjs/transpiler/gender/index.cjs +1 -4
- package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs +1 -44
- package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs.map +1 -1
- package/dist/cjs/transpiler/html/html.cjs +1 -37
- package/dist/cjs/transpiler/html/html.cjs.map +1 -1
- package/dist/cjs/transpiler/html/htmlTags.cjs +1 -116
- package/dist/cjs/transpiler/html/htmlTags.cjs.map +1 -1
- package/dist/cjs/transpiler/html/index.cjs +1 -6
- package/dist/cjs/transpiler/index.cjs +1 -24
- package/dist/cjs/transpiler/insertion/getInsertionValues.cjs +1 -11
- package/dist/cjs/transpiler/insertion/getInsertionValues.cjs.map +1 -1
- package/dist/cjs/transpiler/insertion/index.cjs +1 -6
- package/dist/cjs/transpiler/insertion/insertion.cjs +1 -36
- package/dist/cjs/transpiler/insertion/insertion.cjs.map +1 -1
- package/dist/cjs/transpiler/markdown/getMarkdownMetadata.cjs +2 -23
- package/dist/cjs/transpiler/markdown/getMarkdownMetadata.cjs.map +1 -1
- package/dist/cjs/transpiler/markdown/index.cjs +1 -6
- package/dist/cjs/transpiler/markdown/markdown.cjs +1 -54
- package/dist/cjs/transpiler/markdown/markdown.cjs.map +1 -1
- package/dist/cjs/transpiler/nesting/index.cjs +1 -4
- package/dist/cjs/transpiler/nesting/nesting.cjs +1 -27
- package/dist/cjs/transpiler/nesting/nesting.cjs.map +1 -1
- package/dist/cjs/transpiler/translation/index.cjs +1 -4
- package/dist/cjs/transpiler/translation/translation.cjs +1 -29
- package/dist/cjs/transpiler/translation/translation.cjs.map +1 -1
- package/dist/cjs/utils/checkIsURLAbsolute.cjs +1 -7
- package/dist/cjs/utils/checkIsURLAbsolute.cjs.map +1 -1
- package/dist/cjs/utils/getCookie.cjs +1 -32
- package/dist/cjs/utils/getCookie.cjs.map +1 -1
- package/dist/cjs/utils/index.cjs +1 -0
- package/dist/cjs/utils/intl.cjs +1 -91
- package/dist/cjs/utils/intl.cjs.map +1 -1
- package/dist/cjs/utils/isSameKeyPath.cjs +1 -7
- package/dist/cjs/utils/isSameKeyPath.cjs.map +1 -1
- package/dist/cjs/utils/isValidReactElement.cjs +1 -14
- package/dist/cjs/utils/isValidReactElement.cjs.map +1 -1
- package/dist/cjs/utils/localeStorage.cjs +1 -140
- package/dist/cjs/utils/localeStorage.cjs.map +1 -1
- package/dist/cjs/utils/parseYaml.cjs +16 -322
- package/dist/cjs/utils/parseYaml.cjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getFilterMissingTranslationsContent.mjs +1 -207
- package/dist/esm/deepTransformPlugins/getFilterMissingTranslationsContent.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getFilterTranslationsOnlyContent.mjs +1 -89
- package/dist/esm/deepTransformPlugins/getFilterTranslationsOnlyContent.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs +1 -42
- package/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getLocalizedContent.mjs +1 -31
- package/dist/esm/deepTransformPlugins/getLocalizedContent.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getMaskContent.mjs +1 -25
- package/dist/esm/deepTransformPlugins/getMaskContent.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getMissingLocalesContent.mjs +1 -77
- package/dist/esm/deepTransformPlugins/getMissingLocalesContent.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getMultilingualDictionary.mjs +1 -86
- package/dist/esm/deepTransformPlugins/getMultilingualDictionary.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getReplacedValuesContent.mjs +1 -59
- package/dist/esm/deepTransformPlugins/getReplacedValuesContent.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getSplittedContent.mjs +1 -119
- package/dist/esm/deepTransformPlugins/getSplittedContent.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/index.mjs +1 -12
- package/dist/esm/deepTransformPlugins/insertContentInDictionary.mjs +1 -104
- package/dist/esm/deepTransformPlugins/insertContentInDictionary.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/editDictionaryByKeyPath.mjs +1 -62
- package/dist/esm/dictionaryManipulator/editDictionaryByKeyPath.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs +1 -16
- package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/getDefaultNode.mjs +1 -53
- package/dist/esm/dictionaryManipulator/getDefaultNode.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/getEmptyNode.mjs +1 -24
- package/dist/esm/dictionaryManipulator/getEmptyNode.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/getNodeChildren.mjs +1 -21
- package/dist/esm/dictionaryManipulator/getNodeChildren.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/getNodeType.mjs +1 -34
- package/dist/esm/dictionaryManipulator/getNodeType.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/index.mjs +1 -14
- package/dist/esm/dictionaryManipulator/mergeDictionaries.mjs +1 -66
- package/dist/esm/dictionaryManipulator/mergeDictionaries.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/normalizeDictionary.mjs +1 -28
- package/dist/esm/dictionaryManipulator/normalizeDictionary.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/orderDictionaries.mjs +1 -45
- package/dist/esm/dictionaryManipulator/orderDictionaries.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/removeContentNodeByKeyPath.mjs +1 -29
- package/dist/esm/dictionaryManipulator/removeContentNodeByKeyPath.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/renameContentNodeByKeyPath.mjs +1 -37
- package/dist/esm/dictionaryManipulator/renameContentNodeByKeyPath.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/updateNodeChildren.mjs +1 -36
- package/dist/esm/dictionaryManipulator/updateNodeChildren.mjs.map +1 -1
- package/dist/esm/formatters/compact.mjs +1 -22
- package/dist/esm/formatters/compact.mjs.map +1 -1
- package/dist/esm/formatters/currency.mjs +1 -26
- package/dist/esm/formatters/currency.mjs.map +1 -1
- package/dist/esm/formatters/date.mjs +1 -57
- package/dist/esm/formatters/date.mjs.map +1 -1
- package/dist/esm/formatters/index.mjs +1 -10
- package/dist/esm/formatters/list.mjs +1 -27
- package/dist/esm/formatters/list.mjs.map +1 -1
- package/dist/esm/formatters/number.mjs +1 -15
- package/dist/esm/formatters/number.mjs.map +1 -1
- package/dist/esm/formatters/percentage.mjs +1 -22
- package/dist/esm/formatters/percentage.mjs.map +1 -1
- package/dist/esm/formatters/relativeTime.mjs +1 -30
- package/dist/esm/formatters/relativeTime.mjs.map +1 -1
- package/dist/esm/formatters/units.mjs +1 -20
- package/dist/esm/formatters/units.mjs.map +1 -1
- package/dist/esm/getStorageAttributes.mjs +1 -132
- package/dist/esm/getStorageAttributes.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -82
- package/dist/esm/interpreter/getCondition.mjs +1 -25
- package/dist/esm/interpreter/getCondition.mjs.map +1 -1
- package/dist/esm/interpreter/getContent/deepTransform.mjs +1 -39
- package/dist/esm/interpreter/getContent/deepTransform.mjs.map +1 -1
- package/dist/esm/interpreter/getContent/getContent.mjs +1 -31
- package/dist/esm/interpreter/getContent/getContent.mjs.map +1 -1
- package/dist/esm/interpreter/getContent/index.mjs +1 -5
- package/dist/esm/interpreter/getContent/plugins.mjs +1 -153
- package/dist/esm/interpreter/getContent/plugins.mjs.map +1 -1
- package/dist/esm/interpreter/getDictionary.mjs +1 -23
- package/dist/esm/interpreter/getDictionary.mjs.map +1 -1
- package/dist/esm/interpreter/getEnumeration.mjs +1 -69
- package/dist/esm/interpreter/getEnumeration.mjs.map +1 -1
- package/dist/esm/interpreter/getGender.mjs +1 -36
- package/dist/esm/interpreter/getGender.mjs.map +1 -1
- package/dist/esm/interpreter/getHTML.mjs +1 -119
- package/dist/esm/interpreter/getHTML.mjs.map +1 -1
- package/dist/esm/interpreter/getInsertion.mjs +1 -20
- package/dist/esm/interpreter/getInsertion.mjs.map +1 -1
- package/dist/esm/interpreter/getIntlayer.mjs +1 -36
- package/dist/esm/interpreter/getIntlayer.mjs.map +1 -1
- package/dist/esm/interpreter/getNesting.mjs +1 -35
- package/dist/esm/interpreter/getNesting.mjs.map +1 -1
- package/dist/esm/interpreter/getTranslation.mjs +1 -110
- package/dist/esm/interpreter/getTranslation.mjs.map +1 -1
- package/dist/esm/interpreter/index.mjs +1 -13
- package/dist/esm/interpreter/splitAndJoinInsertion.mjs +1 -53
- package/dist/esm/interpreter/splitAndJoinInsertion.mjs.map +1 -1
- package/dist/esm/localization/getBrowserLocale.mjs +1 -138
- package/dist/esm/localization/getBrowserLocale.mjs.map +1 -1
- package/dist/esm/localization/getHTMLTextDir.mjs +1 -62
- package/dist/esm/localization/getHTMLTextDir.mjs.map +1 -1
- package/dist/esm/localization/getLocale.mjs +1 -24
- package/dist/esm/localization/getLocale.mjs.map +1 -1
- package/dist/esm/localization/getLocaleFromPath.mjs +1 -42
- package/dist/esm/localization/getLocaleFromPath.mjs.map +1 -1
- package/dist/esm/localization/getLocaleLang.mjs +1 -18
- package/dist/esm/localization/getLocaleLang.mjs.map +1 -1
- package/dist/esm/localization/getLocaleName.mjs +1 -9
- package/dist/esm/localization/getLocaleName.mjs.map +1 -1
- package/dist/esm/localization/getLocalizedUrl.mjs +1 -79
- package/dist/esm/localization/getLocalizedUrl.mjs.map +1 -1
- package/dist/esm/localization/getMultilingualUrls.mjs +1 -60
- package/dist/esm/localization/getMultilingualUrls.mjs.map +1 -1
- package/dist/esm/localization/getPathWithoutLocale.mjs +1 -52
- package/dist/esm/localization/getPathWithoutLocale.mjs.map +1 -1
- package/dist/esm/localization/getPrefix.mjs +1 -60
- package/dist/esm/localization/getPrefix.mjs.map +1 -1
- package/dist/esm/localization/index.mjs +1 -17
- package/dist/esm/localization/localeDetector.mjs +1 -131
- package/dist/esm/localization/localeDetector.mjs.map +1 -1
- package/dist/esm/localization/localeMapper.mjs +1 -114
- package/dist/esm/localization/localeMapper.mjs.map +1 -1
- package/dist/esm/localization/localeResolver.mjs +1 -25
- package/dist/esm/localization/localeResolver.mjs.map +1 -1
- package/dist/esm/localization/rewriteUtils.mjs +1 -104
- package/dist/esm/localization/rewriteUtils.mjs.map +1 -1
- package/dist/esm/localization/validatePrefix.mjs +1 -51
- package/dist/esm/localization/validatePrefix.mjs.map +1 -1
- package/dist/esm/markdown/compiler.mjs +10 -786
- package/dist/esm/markdown/compiler.mjs.map +1 -1
- package/dist/esm/markdown/constants.mjs +1 -247
- package/dist/esm/markdown/constants.mjs.map +1 -1
- package/dist/esm/markdown/index.mjs +1 -7
- package/dist/esm/markdown/parser.mjs +1 -65
- package/dist/esm/markdown/parser.mjs.map +1 -1
- package/dist/esm/markdown/renderer.mjs +1 -59
- package/dist/esm/markdown/renderer.mjs.map +1 -1
- package/dist/esm/markdown/utils.mjs +6 -361
- package/dist/esm/markdown/utils.mjs.map +1 -1
- package/dist/esm/messageFormat/ICU.mjs +1 -316
- package/dist/esm/messageFormat/ICU.mjs.map +1 -1
- package/dist/esm/messageFormat/i18next.mjs +1 -327
- package/dist/esm/messageFormat/i18next.mjs.map +1 -1
- package/dist/esm/messageFormat/index.mjs +1 -5
- package/dist/esm/messageFormat/verify-icu-format.mjs +2 -64
- package/dist/esm/messageFormat/verify-icu-format.mjs.map +1 -1
- package/dist/esm/messageFormat/vue-i18n.mjs +1 -163
- package/dist/esm/messageFormat/vue-i18n.mjs.map +1 -1
- package/dist/esm/transpiler/condition/condition.mjs +1 -24
- package/dist/esm/transpiler/condition/condition.mjs.map +1 -1
- package/dist/esm/transpiler/condition/index.mjs +1 -3
- package/dist/esm/transpiler/enumeration/enumeration.mjs +1 -26
- package/dist/esm/transpiler/enumeration/enumeration.mjs.map +1 -1
- package/dist/esm/transpiler/enumeration/index.mjs +1 -3
- package/dist/esm/transpiler/file/file.mjs +1 -49
- package/dist/esm/transpiler/file/file.mjs.map +1 -1
- package/dist/esm/transpiler/file/fileBrowser.mjs +1 -24
- package/dist/esm/transpiler/file/fileBrowser.mjs.map +1 -1
- package/dist/esm/transpiler/file/index.mjs +1 -3
- package/dist/esm/transpiler/gender/gender.mjs +1 -24
- package/dist/esm/transpiler/gender/gender.mjs.map +1 -1
- package/dist/esm/transpiler/gender/index.mjs +1 -3
- package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs +1 -43
- package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs.map +1 -1
- package/dist/esm/transpiler/html/html.mjs +1 -35
- package/dist/esm/transpiler/html/html.mjs.map +1 -1
- package/dist/esm/transpiler/html/htmlTags.mjs +1 -114
- package/dist/esm/transpiler/html/htmlTags.mjs.map +1 -1
- package/dist/esm/transpiler/html/index.mjs +1 -4
- package/dist/esm/transpiler/index.mjs +1 -13
- package/dist/esm/transpiler/insertion/getInsertionValues.mjs +1 -9
- package/dist/esm/transpiler/insertion/getInsertionValues.mjs.map +1 -1
- package/dist/esm/transpiler/insertion/index.mjs +1 -4
- package/dist/esm/transpiler/insertion/insertion.mjs +1 -34
- package/dist/esm/transpiler/insertion/insertion.mjs.map +1 -1
- package/dist/esm/transpiler/markdown/getMarkdownMetadata.mjs +2 -22
- package/dist/esm/transpiler/markdown/getMarkdownMetadata.mjs.map +1 -1
- package/dist/esm/transpiler/markdown/index.mjs +1 -4
- package/dist/esm/transpiler/markdown/markdown.mjs +1 -52
- package/dist/esm/transpiler/markdown/markdown.mjs.map +1 -1
- package/dist/esm/transpiler/nesting/index.mjs +1 -3
- package/dist/esm/transpiler/nesting/nesting.mjs +1 -25
- package/dist/esm/transpiler/nesting/nesting.mjs.map +1 -1
- package/dist/esm/transpiler/translation/index.mjs +1 -3
- package/dist/esm/transpiler/translation/translation.mjs +1 -27
- package/dist/esm/transpiler/translation/translation.mjs.map +1 -1
- package/dist/esm/utils/checkIsURLAbsolute.mjs +1 -5
- package/dist/esm/utils/checkIsURLAbsolute.mjs.map +1 -1
- package/dist/esm/utils/getCookie.mjs +1 -30
- package/dist/esm/utils/getCookie.mjs.map +1 -1
- package/dist/esm/utils/index.mjs +1 -0
- package/dist/esm/utils/intl.mjs +1 -86
- package/dist/esm/utils/intl.mjs.map +1 -1
- package/dist/esm/utils/isSameKeyPath.mjs +1 -5
- package/dist/esm/utils/isSameKeyPath.mjs.map +1 -1
- package/dist/esm/utils/isValidReactElement.mjs +1 -12
- package/dist/esm/utils/isValidReactElement.mjs.map +1 -1
- package/dist/esm/utils/localeStorage.mjs +1 -135
- package/dist/esm/utils/localeStorage.mjs.map +1 -1
- package/dist/esm/utils/parseYaml.mjs +16 -320
- package/dist/esm/utils/parseYaml.mjs.map +1 -1
- package/dist/types/formatters/index.d.ts +2 -1
- package/dist/types/index.d.ts +8 -2
- package/dist/types/interpreter/getContent/plugins.d.ts +4 -4
- package/dist/types/interpreter/getContent/plugins.d.ts.map +1 -1
- package/dist/types/localization/index.d.ts +2 -1
- package/dist/types/markdown/index.d.ts +4 -1
- package/dist/types/markdown/types.d.ts +1 -1
- package/dist/types/markdown/types.d.ts.map +1 -1
- package/dist/types/transpiler/translation/translation.d.ts +1 -1
- package/dist/types/utils/index.d.ts +8 -0
- package/package.json +65 -11
|
@@ -1,789 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { parserFor } from "./parser.mjs";
|
|
4
|
-
import { createRenderer, renderFor } from "./renderer.mjs";
|
|
1
|
+
import{ATTRIBUTE_TO_NODE_PROP_MAP as e,ATTR_EXTRACTOR_R as t,BLOCKQUOTE_ALERT_R as n,BLOCKQUOTE_R as r,BLOCKQUOTE_TRIM_LEFT_MULTILINE_R as i,BLOCK_END_R as a,BREAK_LINE_R as o,BREAK_THEMATIC_R as s,CODE_BLOCK_FENCED_R as c,CODE_BLOCK_R as l,CODE_INLINE_R as u,CONSECUTIVE_NEWLINE_R as d,CUSTOM_COMPONENT_R as f,DO_NOT_PROCESS_HTML_ELEMENTS as p,FOOTNOTE_R as m,FOOTNOTE_REFERENCE_R as h,FRONT_MATTER_R as g,GFM_TASK_R as _,HEADING_ATX_COMPLIANT_R as ee,HEADING_R as te,HEADING_SETEXT_R as v,HTML_BLOCK_ELEMENT_R as y,HTML_CHAR_CODE_R as b,HTML_COMMENT_R as ne,HTML_LEFT_TRIM_AMOUNT_R as x,HTML_SELF_CLOSING_ELEMENT_R as S,LINK_AUTOLINK_BARE_URL_R as C,LINK_AUTOLINK_R as w,LIST_LOOKBEHIND_R as T,NAMED_CODES_TO_UNICODE as E,NP_TABLE_R as D,ORDERED as O,ORDERED_LIST_ITEM_PREFIX_R as re,ORDERED_LIST_ITEM_R as ie,ORDERED_LIST_R as ae,PARAGRAPH_R as oe,Priority as k,REFERENCE_IMAGE_OR_LINK as se,REFERENCE_IMAGE_R as ce,REFERENCE_LINK_R as le,RuleType as A,SHORTCODE_R as ue,SHOULD_RENDER_AS_BLOCK_R as j,TEXT_BOLD_R as de,TEXT_EMPHASIZED_R as fe,TEXT_ESCAPED_R as pe,TEXT_MARKED_R as me,TEXT_PLAIN_R as he,TEXT_STRIKETHROUGHED_R as ge,TRIM_STARTING_NEWLINES as M,UNORDERED as _e,UNORDERED_LIST_ITEM_PREFIX_R as ve,UNORDERED_LIST_ITEM_R as ye,UNORDERED_LIST_R as N}from"./constants.mjs";import{allowInline as P,anyScopeRegex as F,attributeValueToNodePropValue as I,blockRegex as L,captureNothing as R,cx as z,get as B,inlineRegex as V,normalizeAttributeKey as H,parseBlock as U,parseCaptureInline as W,parseInline as G,parseSimpleInline as be,parseTableAlign as xe,parseTableCells as Se,parseTableRow as Ce,renderNothing as K,sanitizer as we,simpleInlineRegex as q,slugify as J,some as Te,startsWith as Ee,trimEnd as Y,trimLeadingWhitespaceOutsideFences as X,unescapeString as Z,unquote as De}from"./utils.mjs";import{parserFor as Q}from"./parser.mjs";import{createRenderer as Oe,renderFor as ke}from"./renderer.mjs";const Ae=/^!\[(.*?)\]\( *((?:\([^)]*\)|[^() ])*) *"?([^)"]*)?"?\)/,je=RegExp(`^\\[((?:\\[[^\\[\\]]*(?:\\[[^\\[\\]]*\\][^\\[\\]]*)*\\]|[^\\[\\]])*)\\]\\(\\s*<?((?:\\([^)]*\\)|[^\\s\\\\]|\\\\.)*?)>?(?:\\s+['"]([\\s\\S]*?)['"])?\\s*\\)`),Me=(e,t)=>{if(typeof e!=`string`)return e;let n=B(t,e);if(!n&&typeof e==`string`){let r=e.toLowerCase(),i=Object.keys(t).find(e=>e.toLowerCase()===r);i&&(n=B(t,i))}return n||e},Ne=(e,t)=>{let{runtime:n,components:r={}}=e,i=t.tagfilter?[`title`,`textarea`,`style`,`xmp`,`iframe`,`noembed`,`noframes`,`script`,`plaintext`]:[];return(e,t,...a)=>{if(typeof e==`string`&&i.includes(e.toLowerCase()))return null;let o=typeof e==`string`,s=z(t?.className,t?.class),c={},l=!1;if(t)for(let e in t){let n=t[e];n!=null&&(e===`className`||e===`class`?l||=(s&&(c.className=s),!0):c[e]=n)}!l&&s&&(c.className=s);let u=c;n.normalizeProps&&o&&(u=n.normalizeProps(e,c));let d=Me(e,r);return n.createElement(d,u,...a.length===1?[a[0]]:a)}},Pe=(e,t,g,oe,j,M,I,z)=>{let B=e=>t.slugify?t.slugify(e,J):J(e),H=t.sanitizer??we,De=t.namedCodesToUnicode?{...E,...t.namedCodesToUnicode}:E,Q=t=>{let n=t===O,r=n?ae:N,i=n?ie:ye,o=n?re:ve;return{_qualify:e=>o.test(e),_match:P((e,t)=>{let n=T.exec(t.prevCapture??``),i=t.list??(!t.inline&&!t.simple);if(n&&i){let t=(n[1]||``)+e;return r.exec(t)}return null}),_order:k.HIGH,_parse(e,t,r){let s=e[2],c=n?+s.slice(0,-1):void 0,l=e[0].replace(a,`
|
|
2
|
+
`).match(i);if(!l)return{items:[],ordered:n,start:c};let u=!1;return{items:l.map((e,n)=>{let i=o.exec(e),a=i?i[0].length:0,s=RegExp(`^ {1,${a}}`,`gm`),c=e.replace(s,``).replace(o,``),d=n===l.length-1,f=c.indexOf(`
|
|
5
3
|
|
|
6
|
-
|
|
7
|
-
const IMAGE_R = /^!\[(.*?)\]\( *((?:\([^)]*\)|[^() ])*) *"?([^)"]*)?"?\)/;
|
|
8
|
-
const LINK_R = new RegExp(`^\\[((?:\\[[^\\[\\]]*(?:\\[[^\\[\\]]*\\][^\\[\\]]*)*\\]|[^\\[\\]])*)\\]\\(\\s*<?((?:\\([^)]*\\)|[^\\s\\\\]|\\\\.)*?)>?(?:\\s+['"]([\\s\\S]*?)['"])?\\s*\\)`);
|
|
9
|
-
const getTag = (tag, components) => {
|
|
10
|
-
if (typeof tag !== "string") return tag;
|
|
11
|
-
let override = get(components, tag);
|
|
12
|
-
if (!override && typeof tag === "string") {
|
|
13
|
-
const lowercaseTag = tag.toLowerCase();
|
|
14
|
-
const key = Object.keys(components).find((k) => k.toLowerCase() === lowercaseTag);
|
|
15
|
-
if (key) override = get(components, key);
|
|
16
|
-
}
|
|
17
|
-
if (!override) return tag;
|
|
18
|
-
return override;
|
|
19
|
-
};
|
|
20
|
-
const createElementFactory = (ctx, options) => {
|
|
21
|
-
const { runtime, components = {} } = ctx;
|
|
22
|
-
const filteredTags = options.tagfilter ? [
|
|
23
|
-
"title",
|
|
24
|
-
"textarea",
|
|
25
|
-
"style",
|
|
26
|
-
"xmp",
|
|
27
|
-
"iframe",
|
|
28
|
-
"noembed",
|
|
29
|
-
"noframes",
|
|
30
|
-
"script",
|
|
31
|
-
"plaintext"
|
|
32
|
-
] : [];
|
|
33
|
-
return (tag, props, ...children) => {
|
|
34
|
-
if (typeof tag === "string" && filteredTags.includes(tag.toLowerCase())) return null;
|
|
35
|
-
const isStringTag = typeof tag === "string";
|
|
36
|
-
const className = cx(props?.className, props?.class);
|
|
37
|
-
const mergedProps = {};
|
|
38
|
-
let classNameHandled = false;
|
|
39
|
-
if (props) for (const key in props) {
|
|
40
|
-
const value = props[key];
|
|
41
|
-
if (value === void 0 || value === null) continue;
|
|
42
|
-
if (key === "className" || key === "class") {
|
|
43
|
-
if (!classNameHandled) {
|
|
44
|
-
if (className) mergedProps.className = className;
|
|
45
|
-
classNameHandled = true;
|
|
46
|
-
}
|
|
47
|
-
} else mergedProps[key] = value;
|
|
48
|
-
}
|
|
49
|
-
if (!classNameHandled && className) mergedProps.className = className;
|
|
50
|
-
let finalProps = mergedProps;
|
|
51
|
-
if (runtime.normalizeProps && isStringTag) finalProps = runtime.normalizeProps(tag, mergedProps);
|
|
52
|
-
const component = getTag(tag, components);
|
|
53
|
-
return runtime.createElement(component, finalProps, ...children.length === 1 ? [children[0]] : children);
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
const createRules = (createElement, ctx, options, footnotes, refs, attrStringToMap, containsBlockSyntax, nonParagraphBlockSyntaxes) => {
|
|
57
|
-
const slug = (input) => {
|
|
58
|
-
return ctx.slugify ? ctx.slugify(input, slugify) : slugify(input);
|
|
59
|
-
};
|
|
60
|
-
const sanitize = ctx.sanitizer ?? sanitizer;
|
|
61
|
-
const namedCodesToUnicode = ctx.namedCodesToUnicode ? {
|
|
62
|
-
...NAMED_CODES_TO_UNICODE,
|
|
63
|
-
...ctx.namedCodesToUnicode
|
|
64
|
-
} : NAMED_CODES_TO_UNICODE;
|
|
65
|
-
const generateListRule = (type) => {
|
|
66
|
-
const ordered = type === ORDERED;
|
|
67
|
-
const LIST_R = ordered ? ORDERED_LIST_R : UNORDERED_LIST_R;
|
|
68
|
-
const LIST_ITEM_R = ordered ? ORDERED_LIST_ITEM_R : UNORDERED_LIST_ITEM_R;
|
|
69
|
-
const LIST_ITEM_PREFIX_R = ordered ? ORDERED_LIST_ITEM_PREFIX_R : UNORDERED_LIST_ITEM_PREFIX_R;
|
|
70
|
-
return {
|
|
71
|
-
_qualify: (source) => LIST_ITEM_PREFIX_R.test(source),
|
|
72
|
-
_match: allowInline((source, state) => {
|
|
73
|
-
const isStartOfLine = LIST_LOOKBEHIND_R.exec(state.prevCapture ?? "");
|
|
74
|
-
const isListAllowed = state.list ?? (!state.inline && !state.simple);
|
|
75
|
-
if (isStartOfLine && isListAllowed) {
|
|
76
|
-
const matchSource = (isStartOfLine[1] || "") + source;
|
|
77
|
-
return LIST_R.exec(matchSource);
|
|
78
|
-
}
|
|
79
|
-
return null;
|
|
80
|
-
}),
|
|
81
|
-
_order: Priority.HIGH,
|
|
82
|
-
_parse(capture, parse, state) {
|
|
83
|
-
const bullet = capture[2];
|
|
84
|
-
const startValue = ordered ? +bullet.slice(0, -1) : void 0;
|
|
85
|
-
const items = capture[0].replace(BLOCK_END_R, "\n").match(LIST_ITEM_R);
|
|
86
|
-
if (!items) return {
|
|
87
|
-
items: [],
|
|
88
|
-
ordered,
|
|
89
|
-
start: startValue
|
|
90
|
-
};
|
|
91
|
-
let lastItemWasAParagraph = false;
|
|
92
|
-
return {
|
|
93
|
-
items: items.map((item, i) => {
|
|
94
|
-
const prefixCapture = LIST_ITEM_PREFIX_R.exec(item);
|
|
95
|
-
const space = prefixCapture ? prefixCapture[0].length : 0;
|
|
96
|
-
const spaceRegex = new RegExp(`^ {1,${space}}`, "gm");
|
|
97
|
-
const content = item.replace(spaceRegex, "").replace(LIST_ITEM_PREFIX_R, "");
|
|
98
|
-
const isLastItem = i === items.length - 1;
|
|
99
|
-
const thisItemIsAParagraph = content.indexOf("\n\n") !== -1 || isLastItem && lastItemWasAParagraph;
|
|
100
|
-
lastItemWasAParagraph = thisItemIsAParagraph;
|
|
101
|
-
const oldStateInline = state.inline;
|
|
102
|
-
const oldStateList = state.list;
|
|
103
|
-
state.list = true;
|
|
104
|
-
let adjustedContent;
|
|
105
|
-
if (thisItemIsAParagraph) {
|
|
106
|
-
state.inline = false;
|
|
107
|
-
adjustedContent = `${trimEnd(content)}\n\n`;
|
|
108
|
-
} else {
|
|
109
|
-
state.inline = true;
|
|
110
|
-
adjustedContent = trimEnd(content);
|
|
111
|
-
}
|
|
112
|
-
const parsed = parse(adjustedContent, state);
|
|
113
|
-
state.inline = oldStateInline;
|
|
114
|
-
state.list = oldStateList;
|
|
115
|
-
return parsed;
|
|
116
|
-
}),
|
|
117
|
-
ordered,
|
|
118
|
-
start: startValue
|
|
119
|
-
};
|
|
120
|
-
},
|
|
121
|
-
_render(node, output, state = {}) {
|
|
122
|
-
const Tag = node.ordered ? "ol" : "ul";
|
|
123
|
-
const props = { key: state.key };
|
|
124
|
-
if (node.ordered && node.start != null) props.start = node.start;
|
|
125
|
-
return createElement(Tag, props, ...node.items.map((item, i) => createElement("li", { key: i }, output(item, state))));
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
};
|
|
129
|
-
const matchParagraph = (source, state) => {
|
|
130
|
-
if (state.inline || state.simple || state.inHTML && source.indexOf("\n\n") === -1 && state.prevCapture?.indexOf("\n\n") === -1) return null;
|
|
131
|
-
let start = 0;
|
|
132
|
-
while (true) {
|
|
133
|
-
const newlineIndex = source.indexOf("\n", start);
|
|
134
|
-
const line = source.slice(start, newlineIndex === -1 ? void 0 : newlineIndex + 1);
|
|
135
|
-
if (some(nonParagraphBlockSyntaxes, line)) break;
|
|
136
|
-
if (newlineIndex === -1 || !line.trim()) break;
|
|
137
|
-
start = newlineIndex + 1;
|
|
138
|
-
}
|
|
139
|
-
const match = source.slice(0, start);
|
|
140
|
-
if (match === "") return null;
|
|
141
|
-
const captured = trimEnd(match);
|
|
142
|
-
if (captured === "") return null;
|
|
143
|
-
return [
|
|
144
|
-
match,
|
|
145
|
-
void 0,
|
|
146
|
-
captured
|
|
147
|
-
];
|
|
148
|
-
};
|
|
149
|
-
return {
|
|
150
|
-
[RuleType.blockQuote]: {
|
|
151
|
-
_qualify: [">"],
|
|
152
|
-
_match: blockRegex(BLOCKQUOTE_R),
|
|
153
|
-
_order: Priority.HIGH,
|
|
154
|
-
_parse(capture, parse, state) {
|
|
155
|
-
const matchAlert = capture[0].replace(BLOCKQUOTE_TRIM_LEFT_MULTILINE_R, "").match(BLOCKQUOTE_ALERT_R);
|
|
156
|
-
const alert = matchAlert?.[1];
|
|
157
|
-
const content = matchAlert?.[2] ?? "";
|
|
158
|
-
return {
|
|
159
|
-
alert,
|
|
160
|
-
children: content.indexOf("\n") !== -1 ? parseBlock(parse, content, state) : parseInline(parse, content, state)
|
|
161
|
-
};
|
|
162
|
-
},
|
|
163
|
-
_render(node, output, state = {}) {
|
|
164
|
-
const props = { key: state.key };
|
|
165
|
-
if (node.alert) {
|
|
166
|
-
props.className = `markdown-alert-${slug(node.alert.toLowerCase())}`;
|
|
167
|
-
node.children.unshift({
|
|
168
|
-
attrs: {},
|
|
169
|
-
children: [{
|
|
170
|
-
type: RuleType.text,
|
|
171
|
-
text: node.alert
|
|
172
|
-
}],
|
|
173
|
-
noInnerParse: true,
|
|
174
|
-
type: RuleType.htmlBlock,
|
|
175
|
-
tag: "header"
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
return createElement("blockquote", props, output(node.children, state));
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
[RuleType.breakLine]: {
|
|
182
|
-
_qualify: [" "],
|
|
183
|
-
_match: anyScopeRegex(BREAK_LINE_R),
|
|
184
|
-
_order: Priority.HIGH,
|
|
185
|
-
_parse: captureNothing,
|
|
186
|
-
_render(_, __, state = {}) {
|
|
187
|
-
return createElement("br", { key: state.key });
|
|
188
|
-
}
|
|
189
|
-
},
|
|
190
|
-
[RuleType.breakThematic]: {
|
|
191
|
-
_qualify: [
|
|
192
|
-
"--",
|
|
193
|
-
"__",
|
|
194
|
-
"**",
|
|
195
|
-
"- ",
|
|
196
|
-
"* ",
|
|
197
|
-
"_ "
|
|
198
|
-
],
|
|
199
|
-
_match: blockRegex(BREAK_THEMATIC_R),
|
|
200
|
-
_order: Priority.HIGH,
|
|
201
|
-
_parse: captureNothing,
|
|
202
|
-
_render(_, __, state = {}) {
|
|
203
|
-
return createElement("hr", { key: state.key });
|
|
204
|
-
}
|
|
205
|
-
},
|
|
206
|
-
[RuleType.codeBlock]: {
|
|
207
|
-
_qualify: [" "],
|
|
208
|
-
_match: blockRegex(CODE_BLOCK_R),
|
|
209
|
-
_order: Priority.MAX,
|
|
210
|
-
_parse(capture) {
|
|
211
|
-
return {
|
|
212
|
-
type: RuleType.codeBlock,
|
|
213
|
-
lang: void 0,
|
|
214
|
-
text: unescapeString(trimEnd(capture[0].replace(/^ {4}/gm, "")))
|
|
215
|
-
};
|
|
216
|
-
},
|
|
217
|
-
_render(node, _, state = {}) {
|
|
218
|
-
const attrs = { ...node.attrs ?? {} };
|
|
219
|
-
const langClass = node.lang ? `lang-${node.lang}` : "lang-plaintext";
|
|
220
|
-
attrs.className = attrs.className ? `${attrs.className} ${langClass}` : langClass;
|
|
221
|
-
if (node.lang && !attrs.lang) attrs.lang = node.lang;
|
|
222
|
-
return createElement("pre", { key: state.key }, createElement("code", attrs, node.text));
|
|
223
|
-
}
|
|
224
|
-
},
|
|
225
|
-
[RuleType.codeFenced]: {
|
|
226
|
-
_qualify: ["```", "~~~"],
|
|
227
|
-
_match: blockRegex(CODE_BLOCK_FENCED_R),
|
|
228
|
-
_order: Priority.MAX,
|
|
229
|
-
_parse(capture) {
|
|
230
|
-
return {
|
|
231
|
-
attrs: attrStringToMap("code", capture[3] ?? ""),
|
|
232
|
-
lang: capture[2] || void 0,
|
|
233
|
-
text: capture[4],
|
|
234
|
-
type: RuleType.codeBlock
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
},
|
|
238
|
-
[RuleType.codeInline]: {
|
|
239
|
-
_qualify: ["`"],
|
|
240
|
-
_match: simpleInlineRegex(CODE_INLINE_R),
|
|
241
|
-
_order: Priority.LOW,
|
|
242
|
-
_parse(capture) {
|
|
243
|
-
return { text: unescapeString(capture[2]) };
|
|
244
|
-
},
|
|
245
|
-
_render(node, _, state = {}) {
|
|
246
|
-
return createElement("code", { key: state.key }, node.text);
|
|
247
|
-
}
|
|
248
|
-
},
|
|
249
|
-
[RuleType.footnote]: {
|
|
250
|
-
_qualify: ["[^"],
|
|
251
|
-
_match: blockRegex(FOOTNOTE_R),
|
|
252
|
-
_order: Priority.MAX,
|
|
253
|
-
_parse(capture) {
|
|
254
|
-
footnotes.push({
|
|
255
|
-
footnote: capture[2],
|
|
256
|
-
identifier: capture[1]
|
|
257
|
-
});
|
|
258
|
-
return {};
|
|
259
|
-
},
|
|
260
|
-
_render: renderNothing
|
|
261
|
-
},
|
|
262
|
-
[RuleType.footnoteReference]: {
|
|
263
|
-
_qualify: ["[^"],
|
|
264
|
-
_match: inlineRegex(FOOTNOTE_REFERENCE_R),
|
|
265
|
-
_order: Priority.HIGH,
|
|
266
|
-
_parse(capture) {
|
|
267
|
-
return {
|
|
268
|
-
target: `#${slug(capture[1])}`,
|
|
269
|
-
text: capture[1]
|
|
270
|
-
};
|
|
271
|
-
},
|
|
272
|
-
_render(node, _, state = {}) {
|
|
273
|
-
return createElement("a", {
|
|
274
|
-
key: state.key,
|
|
275
|
-
href: sanitize(node.target, "a", "href") ?? void 0
|
|
276
|
-
}, createElement("sup", { key: state.key }, node.text));
|
|
277
|
-
}
|
|
278
|
-
},
|
|
279
|
-
[RuleType.gfmTask]: {
|
|
280
|
-
_qualify: ["[ ]", "[x]"],
|
|
281
|
-
_match: inlineRegex(GFM_TASK_R),
|
|
282
|
-
_order: Priority.HIGH,
|
|
283
|
-
_parse(capture) {
|
|
284
|
-
return { completed: capture[1].toLowerCase() === "x" };
|
|
285
|
-
},
|
|
286
|
-
_render(node, _, state = {}) {
|
|
287
|
-
return createElement("input", {
|
|
288
|
-
checked: node.completed,
|
|
289
|
-
key: state.key,
|
|
290
|
-
readOnly: true,
|
|
291
|
-
type: "checkbox"
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
},
|
|
295
|
-
[RuleType.heading]: {
|
|
296
|
-
_qualify: ["#"],
|
|
297
|
-
_match: blockRegex(options.enforceAtxHeadings ? HEADING_ATX_COMPLIANT_R : HEADING_R),
|
|
298
|
-
_order: Priority.HIGH,
|
|
299
|
-
_parse(capture, parse, state) {
|
|
300
|
-
return {
|
|
301
|
-
children: parseInline(parse, capture[2], state),
|
|
302
|
-
id: slug(capture[2]),
|
|
303
|
-
level: capture[1].length
|
|
304
|
-
};
|
|
305
|
-
},
|
|
306
|
-
_render(node, output, state = {}) {
|
|
307
|
-
return createElement(`h${node.level}`, {
|
|
308
|
-
id: node.id,
|
|
309
|
-
key: state.key
|
|
310
|
-
}, output(node.children, state));
|
|
311
|
-
}
|
|
312
|
-
},
|
|
313
|
-
[RuleType.headingSetext]: {
|
|
314
|
-
_qualify: (source) => {
|
|
315
|
-
const nlIndex = source.indexOf("\n");
|
|
316
|
-
return nlIndex > 0 && nlIndex < source.length - 1 && (source[nlIndex + 1] === "=" || source[nlIndex + 1] === "-");
|
|
317
|
-
},
|
|
318
|
-
_match: blockRegex(HEADING_SETEXT_R),
|
|
319
|
-
_order: Priority.MAX,
|
|
320
|
-
_parse(capture, parse, state) {
|
|
321
|
-
return {
|
|
322
|
-
children: parseInline(parse, capture[1], state),
|
|
323
|
-
level: capture[2] === "=" ? 1 : 2,
|
|
324
|
-
type: RuleType.heading
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
},
|
|
328
|
-
[RuleType.htmlBlock]: {
|
|
329
|
-
_qualify: (source) => {
|
|
330
|
-
if (options.disableParsingRawHTML) return false;
|
|
331
|
-
const match = source.match(/^ *<([a-z][a-z0-9:-]*)\b/i);
|
|
332
|
-
if (!match) return false;
|
|
333
|
-
const tag = match[1];
|
|
334
|
-
return source.toLowerCase().indexOf(`</${tag.toLowerCase()}>`) !== -1;
|
|
335
|
-
},
|
|
336
|
-
_match: anyScopeRegex(HTML_BLOCK_ELEMENT_R),
|
|
337
|
-
_order: Priority.HIGH,
|
|
338
|
-
_parse(capture, parse, state) {
|
|
339
|
-
const whitespace = capture[3].match(HTML_LEFT_TRIM_AMOUNT_R)?.[1] ?? "";
|
|
340
|
-
const trimmed = trimLeadingWhitespaceOutsideFences(capture[3], whitespace);
|
|
341
|
-
const parseFunc = containsBlockSyntax(trimmed) ? parseBlock : parseInline;
|
|
342
|
-
const tagName = capture[1].trim();
|
|
343
|
-
const noInnerParse = DO_NOT_PROCESS_HTML_ELEMENTS.indexOf(tagName.toLowerCase()) !== -1;
|
|
344
|
-
const tag = noInnerParse ? tagName.toLowerCase() : tagName;
|
|
345
|
-
const ast = {
|
|
346
|
-
attrs: attrStringToMap(tag, capture[2] ?? ""),
|
|
347
|
-
noInnerParse,
|
|
348
|
-
tag
|
|
349
|
-
};
|
|
350
|
-
state.inAnchor = state.inAnchor || tagName.toLowerCase() === "a";
|
|
351
|
-
if (noInnerParse) ast.text = capture[3];
|
|
352
|
-
else {
|
|
353
|
-
const prevInHTML = state.inHTML;
|
|
354
|
-
state.inHTML = true;
|
|
355
|
-
ast.children = parseFunc(parse, trimmed, state);
|
|
356
|
-
state.inHTML = prevInHTML;
|
|
357
|
-
}
|
|
358
|
-
state.inAnchor = false;
|
|
359
|
-
return ast;
|
|
360
|
-
},
|
|
361
|
-
_render(node, output, state = {}) {
|
|
362
|
-
return createElement(node.tag, {
|
|
363
|
-
key: state.key,
|
|
364
|
-
...node.attrs ?? {}
|
|
365
|
-
}, node.text ?? (node.children ? output(node.children, state) : ""));
|
|
366
|
-
}
|
|
367
|
-
},
|
|
368
|
-
[RuleType.htmlComment]: {
|
|
369
|
-
_qualify: ["<!"],
|
|
370
|
-
_match: anyScopeRegex(HTML_COMMENT_R),
|
|
371
|
-
_order: Priority.HIGH,
|
|
372
|
-
_parse: captureNothing,
|
|
373
|
-
_render: renderNothing
|
|
374
|
-
},
|
|
375
|
-
[RuleType.htmlSelfClosing]: {
|
|
376
|
-
_qualify: (source) => {
|
|
377
|
-
if (options.disableParsingRawHTML) return false;
|
|
378
|
-
return /^ *<([a-zA-Z][a-zA-Z0-9:]*)[\s>/]/.test(source);
|
|
379
|
-
},
|
|
380
|
-
_match: anyScopeRegex(HTML_SELF_CLOSING_ELEMENT_R),
|
|
381
|
-
_order: Priority.HIGH,
|
|
382
|
-
_parse(capture) {
|
|
383
|
-
const tag = capture[1].trim();
|
|
384
|
-
return {
|
|
385
|
-
attrs: attrStringToMap(tag, capture[2] || ""),
|
|
386
|
-
tag
|
|
387
|
-
};
|
|
388
|
-
},
|
|
389
|
-
_render(node, _, state = {}) {
|
|
390
|
-
return createElement(node.tag, {
|
|
391
|
-
key: state.key,
|
|
392
|
-
...node.attrs ?? {}
|
|
393
|
-
});
|
|
394
|
-
}
|
|
395
|
-
},
|
|
396
|
-
[RuleType.customComponent]: {
|
|
397
|
-
_qualify: (source) => /^ *<([A-Z][a-zA-Z0-9]*)/.test(source),
|
|
398
|
-
_match: anyScopeRegex(CUSTOM_COMPONENT_R),
|
|
399
|
-
_order: Priority.MAX,
|
|
400
|
-
_parse(capture, parse, state) {
|
|
401
|
-
const whitespace = capture[3].match(HTML_LEFT_TRIM_AMOUNT_R)?.[1] ?? "";
|
|
402
|
-
const trimmed = trimLeadingWhitespaceOutsideFences(capture[3], whitespace);
|
|
403
|
-
const parseFunc = containsBlockSyntax(trimmed) ? parseBlock : parseInline;
|
|
404
|
-
const tag = capture[1].trim();
|
|
405
|
-
const ast = {
|
|
406
|
-
attrs: attrStringToMap(tag, capture[2] ?? ""),
|
|
407
|
-
noInnerParse: false,
|
|
408
|
-
tag
|
|
409
|
-
};
|
|
410
|
-
const prevInHTML = state.inHTML;
|
|
411
|
-
state.inHTML = true;
|
|
412
|
-
ast.children = parseFunc(parse, trimmed, state);
|
|
413
|
-
state.inHTML = prevInHTML;
|
|
414
|
-
return ast;
|
|
415
|
-
},
|
|
416
|
-
_render(node, output, state = {}) {
|
|
417
|
-
return createElement(node.tag, {
|
|
418
|
-
key: state.key,
|
|
419
|
-
...node.attrs ?? {}
|
|
420
|
-
}, node.text ?? (node.children ? output(node.children, state) : ""));
|
|
421
|
-
}
|
|
422
|
-
},
|
|
423
|
-
[RuleType.paragraph]: {
|
|
424
|
-
_match: matchParagraph,
|
|
425
|
-
_order: Priority.LOW,
|
|
426
|
-
_parse: parseCaptureInline,
|
|
427
|
-
_render(node, output, state = {}) {
|
|
428
|
-
return createElement("p", { key: state.key }, output(node.children, state));
|
|
429
|
-
}
|
|
430
|
-
},
|
|
431
|
-
[RuleType.image]: {
|
|
432
|
-
_qualify: ["!["],
|
|
433
|
-
_match: simpleInlineRegex(IMAGE_R),
|
|
434
|
-
_order: Priority.HIGH,
|
|
435
|
-
_parse(capture) {
|
|
436
|
-
return {
|
|
437
|
-
alt: unescapeString(capture[1]),
|
|
438
|
-
target: unescapeString(capture[2]),
|
|
439
|
-
title: unescapeString(capture[3])
|
|
440
|
-
};
|
|
441
|
-
},
|
|
442
|
-
_render(node, _, state = {}) {
|
|
443
|
-
return createElement("img", {
|
|
444
|
-
key: state.key,
|
|
445
|
-
alt: node.alt ?? void 0,
|
|
446
|
-
title: node.title ?? void 0,
|
|
447
|
-
src: sanitize(node.target, "img", "src") ?? void 0
|
|
448
|
-
});
|
|
449
|
-
}
|
|
450
|
-
},
|
|
451
|
-
[RuleType.link]: {
|
|
452
|
-
_qualify: ["["],
|
|
453
|
-
_match: inlineRegex(LINK_R),
|
|
454
|
-
_order: Priority.LOW,
|
|
455
|
-
_parse(capture, parse, state) {
|
|
456
|
-
return {
|
|
457
|
-
children: parseSimpleInline(parse, capture[1], state),
|
|
458
|
-
target: unescapeString(capture[2]),
|
|
459
|
-
title: unescapeString(capture[3])
|
|
460
|
-
};
|
|
461
|
-
},
|
|
462
|
-
_render(node, output, state = {}) {
|
|
463
|
-
const sanitizedHref = sanitize(node.target, "a", "href");
|
|
464
|
-
return createElement("a", {
|
|
465
|
-
key: state.key,
|
|
466
|
-
href: sanitizedHref ?? void 0,
|
|
467
|
-
title: node.title ?? void 0
|
|
468
|
-
}, output(node.children, state));
|
|
469
|
-
}
|
|
470
|
-
},
|
|
471
|
-
[RuleType.linkAngleBraceStyleDetector]: {
|
|
472
|
-
_qualify: ["<"],
|
|
473
|
-
_match: inlineRegex(LINK_AUTOLINK_R),
|
|
474
|
-
_order: Priority.MAX,
|
|
475
|
-
_parse(capture) {
|
|
476
|
-
let target = capture[1];
|
|
477
|
-
let isEmail = false;
|
|
478
|
-
if (target.indexOf("@") !== -1 && target.indexOf("//") === -1) {
|
|
479
|
-
isEmail = true;
|
|
480
|
-
target = target.replace("mailto:", "");
|
|
481
|
-
}
|
|
482
|
-
return {
|
|
483
|
-
children: [{
|
|
484
|
-
text: target,
|
|
485
|
-
type: RuleType.text
|
|
486
|
-
}],
|
|
487
|
-
target: isEmail ? `mailto:${target}` : target,
|
|
488
|
-
type: RuleType.link
|
|
489
|
-
};
|
|
490
|
-
}
|
|
491
|
-
},
|
|
492
|
-
[RuleType.linkBareUrlDetector]: {
|
|
493
|
-
_qualify: (source, state) => !!(state.inline && !state.inAnchor && !options.disableAutoLink && (startsWith(source, "http://") || startsWith(source, "https://"))),
|
|
494
|
-
_match: inlineRegex(LINK_AUTOLINK_BARE_URL_R),
|
|
495
|
-
_order: Priority.MAX,
|
|
496
|
-
_parse(capture) {
|
|
497
|
-
return {
|
|
498
|
-
children: [{
|
|
499
|
-
text: capture[1],
|
|
500
|
-
type: RuleType.text
|
|
501
|
-
}],
|
|
502
|
-
target: capture[1],
|
|
503
|
-
type: RuleType.link
|
|
504
|
-
};
|
|
505
|
-
}
|
|
506
|
-
},
|
|
507
|
-
[RuleType.newlineCoalescer]: {
|
|
508
|
-
_match: blockRegex(CONSECUTIVE_NEWLINE_R),
|
|
509
|
-
_order: Priority.LOW,
|
|
510
|
-
_parse: captureNothing,
|
|
511
|
-
_render() {
|
|
512
|
-
return "\n";
|
|
513
|
-
}
|
|
514
|
-
},
|
|
515
|
-
[RuleType.orderedList]: generateListRule(ORDERED),
|
|
516
|
-
[RuleType.unorderedList]: generateListRule(UNORDERED),
|
|
517
|
-
[RuleType.ref]: {
|
|
518
|
-
_qualify: ["["],
|
|
519
|
-
_match: anyScopeRegex(REFERENCE_IMAGE_OR_LINK),
|
|
520
|
-
_order: Priority.MAX,
|
|
521
|
-
_parse(capture) {
|
|
522
|
-
refs[capture[1]] = {
|
|
523
|
-
target: capture[2],
|
|
524
|
-
title: capture[4]
|
|
525
|
-
};
|
|
526
|
-
return {};
|
|
527
|
-
},
|
|
528
|
-
_render: renderNothing
|
|
529
|
-
},
|
|
530
|
-
[RuleType.refImage]: {
|
|
531
|
-
_qualify: ["!["],
|
|
532
|
-
_match: simpleInlineRegex(REFERENCE_IMAGE_R),
|
|
533
|
-
_order: Priority.MAX,
|
|
534
|
-
_parse(capture) {
|
|
535
|
-
return {
|
|
536
|
-
alt: capture[1] ? unescapeString(capture[1]) : void 0,
|
|
537
|
-
ref: capture[2]
|
|
538
|
-
};
|
|
539
|
-
},
|
|
540
|
-
_render(node, _, state = {}) {
|
|
541
|
-
const ref = refs[node.ref];
|
|
542
|
-
if (!ref) return null;
|
|
543
|
-
return createElement("img", {
|
|
544
|
-
key: state.key,
|
|
545
|
-
alt: node.alt,
|
|
546
|
-
src: sanitize(ref.target, "img", "src") ?? void 0,
|
|
547
|
-
title: ref.title
|
|
548
|
-
});
|
|
549
|
-
}
|
|
550
|
-
},
|
|
551
|
-
[RuleType.refLink]: {
|
|
552
|
-
_qualify: (source) => source[0] === "[" && source.indexOf("](") === -1,
|
|
553
|
-
_match: inlineRegex(REFERENCE_LINK_R),
|
|
554
|
-
_order: Priority.MAX,
|
|
555
|
-
_parse(capture, parse, state) {
|
|
556
|
-
return {
|
|
557
|
-
children: parseSimpleInline(parse, capture[1], state),
|
|
558
|
-
fallbackChildren: capture[0],
|
|
559
|
-
ref: capture[2]
|
|
560
|
-
};
|
|
561
|
-
},
|
|
562
|
-
_render(node, output, state = {}) {
|
|
563
|
-
const ref = refs[node.ref];
|
|
564
|
-
if (!ref) return createElement("span", { key: state.key }, node.fallbackChildren);
|
|
565
|
-
return createElement("a", {
|
|
566
|
-
key: state.key,
|
|
567
|
-
href: sanitize(ref.target, "a", "href") ?? void 0,
|
|
568
|
-
title: ref.title
|
|
569
|
-
}, output(node.children, state));
|
|
570
|
-
}
|
|
571
|
-
},
|
|
572
|
-
[RuleType.table]: {
|
|
573
|
-
_qualify: ["|"],
|
|
574
|
-
_match: blockRegex(NP_TABLE_R),
|
|
575
|
-
_order: Priority.HIGH,
|
|
576
|
-
_parse(capture, parse, state) {
|
|
577
|
-
state.inline = true;
|
|
578
|
-
const align = capture[2] ? parseTableAlign(capture[2]) : [];
|
|
579
|
-
const cells = capture[3] ? parseTableCells(capture[3], parse, state) : [];
|
|
580
|
-
const header = parseTableRow(capture[1], parse, state, !!cells.length);
|
|
581
|
-
state.inline = false;
|
|
582
|
-
return cells.length ? {
|
|
583
|
-
align,
|
|
584
|
-
cells,
|
|
585
|
-
header,
|
|
586
|
-
type: RuleType.table
|
|
587
|
-
} : {
|
|
588
|
-
children: header.flat(),
|
|
589
|
-
type: RuleType.paragraph
|
|
590
|
-
};
|
|
591
|
-
},
|
|
592
|
-
_render(node, output, state = {}) {
|
|
593
|
-
const table = node;
|
|
594
|
-
const getStyle = (i) => table.align[i] ? { textAlign: table.align[i] } : {};
|
|
595
|
-
return createElement("table", { key: state.key }, createElement("thead", null, createElement("tr", null, ...table.header.map((c, i) => createElement("th", {
|
|
596
|
-
key: i,
|
|
597
|
-
style: getStyle(i)
|
|
598
|
-
}, output(c, state))))), createElement("tbody", null, ...table.cells.map((row, i) => createElement("tr", { key: i }, ...row.map((c, j) => createElement("td", {
|
|
599
|
-
key: j,
|
|
600
|
-
style: getStyle(j)
|
|
601
|
-
}, output(c, state)))))));
|
|
602
|
-
}
|
|
603
|
-
},
|
|
604
|
-
[RuleType.tableSeparator]: {
|
|
605
|
-
_match: (source, state) => state.inTable && source[0] === "|" ? /^\|/.exec(source) : null,
|
|
606
|
-
_order: Priority.HIGH,
|
|
607
|
-
_parse() {
|
|
608
|
-
return { type: RuleType.tableSeparator };
|
|
609
|
-
},
|
|
610
|
-
_render() {
|
|
611
|
-
return " | ";
|
|
612
|
-
}
|
|
613
|
-
},
|
|
614
|
-
[RuleType.text]: {
|
|
615
|
-
_match: allowInline((source, _state) => {
|
|
616
|
-
const shortMatch = SHORTCODE_R.exec(source);
|
|
617
|
-
if (shortMatch) return shortMatch;
|
|
618
|
-
return TEXT_PLAIN_R.exec(source) || /^[\s\S]/.exec(source);
|
|
619
|
-
}),
|
|
620
|
-
_order: Priority.MIN,
|
|
621
|
-
_parse(capture) {
|
|
622
|
-
const text = capture[0];
|
|
623
|
-
return { text: text.indexOf("&") === -1 ? text : text.replace(HTML_CHAR_CODE_R, (f, i) => namedCodesToUnicode[i] || f) };
|
|
624
|
-
},
|
|
625
|
-
_render(node) {
|
|
626
|
-
return node.text;
|
|
627
|
-
}
|
|
628
|
-
},
|
|
629
|
-
[RuleType.textBolded]: {
|
|
630
|
-
_qualify: ["**", "__"],
|
|
631
|
-
_match: simpleInlineRegex(TEXT_BOLD_R),
|
|
632
|
-
_order: Priority.MED,
|
|
633
|
-
_parse(capture, parse, state) {
|
|
634
|
-
return { children: parse(capture[2], state) };
|
|
635
|
-
},
|
|
636
|
-
_render(node, output, state = {}) {
|
|
637
|
-
return createElement("strong", { key: state.key }, output(node.children, state));
|
|
638
|
-
}
|
|
639
|
-
},
|
|
640
|
-
[RuleType.textEmphasized]: {
|
|
641
|
-
_qualify: ["*", "_"],
|
|
642
|
-
_match: simpleInlineRegex(TEXT_EMPHASIZED_R),
|
|
643
|
-
_order: Priority.LOW,
|
|
644
|
-
_parse(capture, parse, state) {
|
|
645
|
-
return { children: parse(capture[2], state) };
|
|
646
|
-
},
|
|
647
|
-
_render(node, output, state = {}) {
|
|
648
|
-
return createElement("em", { key: state.key }, output(node.children, state));
|
|
649
|
-
}
|
|
650
|
-
},
|
|
651
|
-
[RuleType.textEscaped]: {
|
|
652
|
-
_qualify: ["\\"],
|
|
653
|
-
_match: simpleInlineRegex(TEXT_ESCAPED_R),
|
|
654
|
-
_order: Priority.HIGH,
|
|
655
|
-
_parse(capture) {
|
|
656
|
-
return {
|
|
657
|
-
text: capture[1],
|
|
658
|
-
type: RuleType.text
|
|
659
|
-
};
|
|
660
|
-
}
|
|
661
|
-
},
|
|
662
|
-
[RuleType.textMarked]: {
|
|
663
|
-
_qualify: ["=="],
|
|
664
|
-
_match: simpleInlineRegex(TEXT_MARKED_R),
|
|
665
|
-
_order: Priority.LOW,
|
|
666
|
-
_parse: parseCaptureInline,
|
|
667
|
-
_render(node, output, state = {}) {
|
|
668
|
-
return createElement("mark", { key: state.key }, output(node.children, state));
|
|
669
|
-
}
|
|
670
|
-
},
|
|
671
|
-
[RuleType.textStrikethroughed]: {
|
|
672
|
-
_qualify: ["~~"],
|
|
673
|
-
_match: simpleInlineRegex(TEXT_STRIKETHROUGHED_R),
|
|
674
|
-
_order: Priority.LOW,
|
|
675
|
-
_parse: parseCaptureInline,
|
|
676
|
-
_render(node, output, state = {}) {
|
|
677
|
-
return createElement("del", { key: state.key }, output(node.children, state));
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
};
|
|
681
|
-
};
|
|
682
|
-
const compile = (markdown = "", ctx, options = {}) => {
|
|
683
|
-
const components = ctx.components ?? {};
|
|
684
|
-
const slug = (input) => {
|
|
685
|
-
return ctx.slugify ? ctx.slugify(input, slugify) : slugify(input);
|
|
686
|
-
};
|
|
687
|
-
const createElement = createElementFactory(ctx, options);
|
|
688
|
-
const footnotes = [];
|
|
689
|
-
const refs = {};
|
|
690
|
-
const attrStringToMap = (tag, str) => {
|
|
691
|
-
if (!str || !str.trim()) return null;
|
|
692
|
-
const attributes = str.match(ATTR_EXTRACTOR_R);
|
|
693
|
-
if (!attributes) return null;
|
|
694
|
-
return attributes.reduce((map, raw) => {
|
|
695
|
-
const delimiterIdx = raw.indexOf("=");
|
|
696
|
-
if (delimiterIdx !== -1) {
|
|
697
|
-
const key = normalizeAttributeKey(raw.slice(0, delimiterIdx)).trim();
|
|
698
|
-
const value = unquote(raw.slice(delimiterIdx + 1).trim());
|
|
699
|
-
const mappedKey = ATTRIBUTE_TO_NODE_PROP_MAP[key] ?? key;
|
|
700
|
-
if (mappedKey === "ref") return map;
|
|
701
|
-
map[mappedKey] = attributeValueToNodePropValue(tag, key, value, ctx.sanitizer ?? sanitizer);
|
|
702
|
-
if (typeof map[mappedKey] === "string" && (HTML_BLOCK_ELEMENT_R.test(map[mappedKey]) || HTML_SELF_CLOSING_ELEMENT_R.test(map[mappedKey]))) map[mappedKey] = compileInner(map[mappedKey].trim());
|
|
703
|
-
} else if (raw !== "style") map[ATTRIBUTE_TO_NODE_PROP_MAP[raw] ?? raw] = true;
|
|
704
|
-
return map;
|
|
705
|
-
}, {});
|
|
706
|
-
};
|
|
707
|
-
const nonParagraphBlockSyntaxes = [
|
|
708
|
-
BLOCKQUOTE_R,
|
|
709
|
-
CODE_BLOCK_FENCED_R,
|
|
710
|
-
CODE_BLOCK_R,
|
|
711
|
-
options.enforceAtxHeadings ? HEADING_ATX_COMPLIANT_R : HEADING_R,
|
|
712
|
-
HEADING_SETEXT_R,
|
|
713
|
-
NP_TABLE_R,
|
|
714
|
-
ORDERED_LIST_R,
|
|
715
|
-
UNORDERED_LIST_R,
|
|
716
|
-
CUSTOM_COMPONENT_R
|
|
717
|
-
];
|
|
718
|
-
const containsBlockSyntax = (input) => {
|
|
719
|
-
const cleaned = input.replace(TRIM_STARTING_NEWLINES, "");
|
|
720
|
-
const slice = cleaned.length > 2048 ? cleaned.slice(0, 2048) : cleaned;
|
|
721
|
-
return some(options.disableParsingRawHTML ? nonParagraphBlockSyntaxes : [
|
|
722
|
-
...nonParagraphBlockSyntaxes,
|
|
723
|
-
PARAGRAPH_R,
|
|
724
|
-
HTML_BLOCK_ELEMENT_R,
|
|
725
|
-
HTML_COMMENT_R,
|
|
726
|
-
HTML_SELF_CLOSING_ELEMENT_R,
|
|
727
|
-
CUSTOM_COMPONENT_R
|
|
728
|
-
], slice);
|
|
729
|
-
};
|
|
730
|
-
const baseRules = createRules(createElement, ctx, options, footnotes, refs, attrStringToMap, containsBlockSyntax, nonParagraphBlockSyntaxes);
|
|
731
|
-
const rules = options.disableParsingRawHTML ? Object.keys(baseRules).reduce((acc, key) => {
|
|
732
|
-
if (key !== RuleType.htmlBlock && key !== RuleType.htmlSelfClosing) acc[key] = baseRules[key];
|
|
733
|
-
return acc;
|
|
734
|
-
}, {}) : baseRules;
|
|
735
|
-
const parser = parserFor(rules);
|
|
736
|
-
const emitter = renderFor(createRenderer(rules, options.renderRule));
|
|
737
|
-
const compileInner = (input) => {
|
|
738
|
-
const result = options.preserveFrontmatter ? input : input.replace(FRONT_MATTER_R, "");
|
|
739
|
-
const inline = options.forceInline || !options.forceBlock && SHOULD_RENDER_AS_BLOCK_R.test(result.replace(TRIM_STARTING_NEWLINES, "")) === false;
|
|
740
|
-
const arr = emitter(parser(inline ? result : `${trimEnd(result).replace(TRIM_STARTING_NEWLINES, "")}\n\n`, { inline }), { inline });
|
|
741
|
-
while (typeof arr[arr.length - 1] === "string" && !arr[arr.length - 1].trim()) arr.pop();
|
|
742
|
-
if (options.wrapper === null) return arr;
|
|
743
|
-
const wrapper = options.wrapper ?? (inline ? "span" : "div");
|
|
744
|
-
if (arr.length > 1 || options.forceWrapper) return createElement(wrapper, { key: "outer" }, arr);
|
|
745
|
-
if (arr.length === 1) {
|
|
746
|
-
const node = arr[0];
|
|
747
|
-
if (typeof node === "string") {
|
|
748
|
-
const spanProps = { key: "outer" };
|
|
749
|
-
if (!inline && components) {
|
|
750
|
-
const pOverrideProps = get(components, "p.props", {}) ?? {};
|
|
751
|
-
const mergedClassName = cx(spanProps.className, pOverrideProps.className);
|
|
752
|
-
const finalSpanProps = {
|
|
753
|
-
...spanProps,
|
|
754
|
-
...pOverrideProps
|
|
755
|
-
};
|
|
756
|
-
if (mergedClassName) finalSpanProps.className = mergedClassName;
|
|
757
|
-
return createElement("span", finalSpanProps, node);
|
|
758
|
-
}
|
|
759
|
-
return createElement("span", spanProps, node);
|
|
760
|
-
}
|
|
761
|
-
return node;
|
|
762
|
-
}
|
|
763
|
-
return createElement(wrapper, { key: "outer" }, null);
|
|
764
|
-
};
|
|
765
|
-
if (typeof markdown !== "string") {
|
|
766
|
-
console.error("intlayer: the first argument must be a string. Received", typeof markdown);
|
|
767
|
-
throw new Error("intlayer: the first argument must be a string");
|
|
768
|
-
}
|
|
769
|
-
const node = compileInner(markdown);
|
|
770
|
-
return footnotes.length ? createElement("div", null, node, createElement("footer", { key: "footer" }, ...footnotes.map((def) => createElement("div", {
|
|
771
|
-
id: slug(def.identifier),
|
|
772
|
-
key: def.identifier
|
|
773
|
-
}, def.identifier, emitter(parser(def.footnote, { inline: true }), { inline: true }))))) : node;
|
|
774
|
-
};
|
|
775
|
-
const createCompiler = (ctx) => (markdown, options) => compile(markdown, ctx, options);
|
|
776
|
-
const compileWithOptions = (markdown, runtime, options = {}) => {
|
|
777
|
-
const { components, namedCodesToUnicode, sanitizer, slugify, ...compilerOptions } = options;
|
|
778
|
-
return compile(markdown, {
|
|
779
|
-
runtime,
|
|
780
|
-
components,
|
|
781
|
-
namedCodesToUnicode,
|
|
782
|
-
sanitizer,
|
|
783
|
-
slugify
|
|
784
|
-
}, compilerOptions);
|
|
785
|
-
};
|
|
4
|
+
`)!==-1||d&&u;u=f;let p=r.inline,m=r.list;r.list=!0;let h;f?(r.inline=!1,h=`${Y(c)}\n\n`):(r.inline=!0,h=Y(c));let g=t(h,r);return r.inline=p,r.list=m,g}),ordered:n,start:c}},_render(t,n,r={}){let i=t.ordered?`ol`:`ul`,a={key:r.key};return t.ordered&&t.start!=null&&(a.start=t.start),e(i,a,...t.items.map((t,i)=>e(`li`,{key:i},n(t,r))))}}},Oe=(e,t)=>{if(t.inline||t.simple||t.inHTML&&e.indexOf(`
|
|
786
5
|
|
|
787
|
-
|
|
788
|
-
|
|
6
|
+
`)===-1&&t.prevCapture?.indexOf(`
|
|
7
|
+
|
|
8
|
+
`)===-1)return null;let n=0;for(;;){let t=e.indexOf(`
|
|
9
|
+
`,n),r=e.slice(n,t===-1?void 0:t+1);if(Te(z,r)||t===-1||!r.trim())break;n=t+1}let r=e.slice(0,n);if(r===``)return null;let i=Y(r);return i===``?null:[r,void 0,i]};return{[A.blockQuote]:{_qualify:[`>`],_match:L(r),_order:k.HIGH,_parse(e,t,r){let a=e[0].replace(i,``).match(n),o=a?.[1],s=a?.[2]??``;return{alert:o,children:s.indexOf(`
|
|
10
|
+
`)===-1?G(t,s,r):U(t,s,r)}},_render(t,n,r={}){let i={key:r.key};return t.alert&&(i.className=`markdown-alert-${B(t.alert.toLowerCase())}`,t.children.unshift({attrs:{},children:[{type:A.text,text:t.alert}],noInnerParse:!0,type:A.htmlBlock,tag:`header`})),e(`blockquote`,i,n(t.children,r))}},[A.breakLine]:{_qualify:[` `],_match:F(o),_order:k.HIGH,_parse:R,_render(t,n,r={}){return e(`br`,{key:r.key})}},[A.breakThematic]:{_qualify:[`--`,`__`,`**`,`- `,`* `,`_ `],_match:L(s),_order:k.HIGH,_parse:R,_render(t,n,r={}){return e(`hr`,{key:r.key})}},[A.codeBlock]:{_qualify:[` `],_match:L(l),_order:k.MAX,_parse(e){return{type:A.codeBlock,lang:void 0,text:Z(Y(e[0].replace(/^ {4}/gm,``)))}},_render(t,n,r={}){let i={...t.attrs??{}},a=t.lang?`lang-${t.lang}`:`lang-plaintext`;return i.className=i.className?`${i.className} ${a}`:a,t.lang&&!i.lang&&(i.lang=t.lang),e(`pre`,{key:r.key},e(`code`,i,t.text))}},[A.codeFenced]:{_qualify:["```",`~~~`],_match:L(c),_order:k.MAX,_parse(e){return{attrs:M(`code`,e[3]??``),lang:e[2]||void 0,text:e[4],type:A.codeBlock}}},[A.codeInline]:{_qualify:["`"],_match:q(u),_order:k.LOW,_parse(e){return{text:Z(e[2])}},_render(t,n,r={}){return e(`code`,{key:r.key},t.text)}},[A.footnote]:{_qualify:[`[^`],_match:L(m),_order:k.MAX,_parse(e){return oe.push({footnote:e[2],identifier:e[1]}),{}},_render:K},[A.footnoteReference]:{_qualify:[`[^`],_match:V(h),_order:k.HIGH,_parse(e){return{target:`#${B(e[1])}`,text:e[1]}},_render(t,n,r={}){return e(`a`,{key:r.key,href:H(t.target,`a`,`href`)??void 0},e(`sup`,{key:r.key},t.text))}},[A.gfmTask]:{_qualify:[`[ ]`,`[x]`],_match:V(_),_order:k.HIGH,_parse(e){return{completed:e[1].toLowerCase()===`x`}},_render(t,n,r={}){return e(`input`,{checked:t.completed,key:r.key,readOnly:!0,type:`checkbox`})}},[A.heading]:{_qualify:[`#`],_match:L(g.enforceAtxHeadings?ee:te),_order:k.HIGH,_parse(e,t,n){return{children:G(t,e[2],n),id:B(e[2]),level:e[1].length}},_render(t,n,r={}){return e(`h${t.level}`,{id:t.id,key:r.key},n(t.children,r))}},[A.headingSetext]:{_qualify:e=>{let t=e.indexOf(`
|
|
11
|
+
`);return t>0&&t<e.length-1&&(e[t+1]===`=`||e[t+1]===`-`)},_match:L(v),_order:k.MAX,_parse(e,t,n){return{children:G(t,e[1],n),level:e[2]===`=`?1:2,type:A.heading}}},[A.htmlBlock]:{_qualify:e=>{if(g.disableParsingRawHTML)return!1;let t=e.match(/^ *<([a-z][a-z0-9:-]*)\b/i);if(!t)return!1;let n=t[1];return e.toLowerCase().indexOf(`</${n.toLowerCase()}>`)!==-1},_match:F(y),_order:k.HIGH,_parse(e,t,n){let r=e[3].match(x)?.[1]??``,i=X(e[3],r),a=I(i)?U:G,o=e[1].trim(),s=p.indexOf(o.toLowerCase())!==-1,c=s?o.toLowerCase():o,l={attrs:M(c,e[2]??``),noInnerParse:s,tag:c};if(n.inAnchor=n.inAnchor||o.toLowerCase()===`a`,s)l.text=e[3];else{let e=n.inHTML;n.inHTML=!0,l.children=a(t,i,n),n.inHTML=e}return n.inAnchor=!1,l},_render(t,n,r={}){return e(t.tag,{key:r.key,...t.attrs??{}},t.text??(t.children?n(t.children,r):``))}},[A.htmlComment]:{_qualify:[`<!`],_match:F(ne),_order:k.HIGH,_parse:R,_render:K},[A.htmlSelfClosing]:{_qualify:e=>g.disableParsingRawHTML?!1:/^ *<([a-zA-Z][a-zA-Z0-9:]*)[\s>/]/.test(e),_match:F(S),_order:k.HIGH,_parse(e){let t=e[1].trim();return{attrs:M(t,e[2]||``),tag:t}},_render(t,n,r={}){return e(t.tag,{key:r.key,...t.attrs??{}})}},[A.customComponent]:{_qualify:e=>/^ *<([A-Z][a-zA-Z0-9]*)/.test(e),_match:F(f),_order:k.MAX,_parse(e,t,n){let r=e[3].match(x)?.[1]??``,i=X(e[3],r),a=I(i)?U:G,o=e[1].trim(),s={attrs:M(o,e[2]??``),noInnerParse:!1,tag:o},c=n.inHTML;return n.inHTML=!0,s.children=a(t,i,n),n.inHTML=c,s},_render(t,n,r={}){return e(t.tag,{key:r.key,...t.attrs??{}},t.text??(t.children?n(t.children,r):``))}},[A.paragraph]:{_match:Oe,_order:k.LOW,_parse:W,_render(t,n,r={}){return e(`p`,{key:r.key},n(t.children,r))}},[A.image]:{_qualify:[`![`],_match:q(Ae),_order:k.HIGH,_parse(e){return{alt:Z(e[1]),target:Z(e[2]),title:Z(e[3])}},_render(t,n,r={}){return e(`img`,{key:r.key,alt:t.alt??void 0,title:t.title??void 0,src:H(t.target,`img`,`src`)??void 0})}},[A.link]:{_qualify:[`[`],_match:V(je),_order:k.LOW,_parse(e,t,n){return{children:be(t,e[1],n),target:Z(e[2]),title:Z(e[3])}},_render(t,n,r={}){let i=H(t.target,`a`,`href`);return e(`a`,{key:r.key,href:i??void 0,title:t.title??void 0},n(t.children,r))}},[A.linkAngleBraceStyleDetector]:{_qualify:[`<`],_match:V(w),_order:k.MAX,_parse(e){let t=e[1],n=!1;return t.indexOf(`@`)!==-1&&t.indexOf(`//`)===-1&&(n=!0,t=t.replace(`mailto:`,``)),{children:[{text:t,type:A.text}],target:n?`mailto:${t}`:t,type:A.link}}},[A.linkBareUrlDetector]:{_qualify:(e,t)=>!!(t.inline&&!t.inAnchor&&!g.disableAutoLink&&(Ee(e,`http://`)||Ee(e,`https://`))),_match:V(C),_order:k.MAX,_parse(e){return{children:[{text:e[1],type:A.text}],target:e[1],type:A.link}}},[A.newlineCoalescer]:{_match:L(d),_order:k.LOW,_parse:R,_render(){return`
|
|
12
|
+
`}},[A.orderedList]:Q(O),[A.unorderedList]:Q(_e),[A.ref]:{_qualify:[`[`],_match:F(se),_order:k.MAX,_parse(e){return j[e[1]]={target:e[2],title:e[4]},{}},_render:K},[A.refImage]:{_qualify:[`![`],_match:q(ce),_order:k.MAX,_parse(e){return{alt:e[1]?Z(e[1]):void 0,ref:e[2]}},_render(t,n,r={}){let i=j[t.ref];return i?e(`img`,{key:r.key,alt:t.alt,src:H(i.target,`img`,`src`)??void 0,title:i.title}):null}},[A.refLink]:{_qualify:e=>e[0]===`[`&&e.indexOf(`](`)===-1,_match:V(le),_order:k.MAX,_parse(e,t,n){return{children:be(t,e[1],n),fallbackChildren:e[0],ref:e[2]}},_render(t,n,r={}){let i=j[t.ref];return i?e(`a`,{key:r.key,href:H(i.target,`a`,`href`)??void 0,title:i.title},n(t.children,r)):e(`span`,{key:r.key},t.fallbackChildren)}},[A.table]:{_qualify:[`|`],_match:L(D),_order:k.HIGH,_parse(e,t,n){n.inline=!0;let r=e[2]?xe(e[2]):[],i=e[3]?Se(e[3],t,n):[],a=Ce(e[1],t,n,!!i.length);return n.inline=!1,i.length?{align:r,cells:i,header:a,type:A.table}:{children:a.flat(),type:A.paragraph}},_render(t,n,r={}){let i=t,a=e=>i.align[e]?{textAlign:i.align[e]}:{};return e(`table`,{key:r.key},e(`thead`,null,e(`tr`,null,...i.header.map((t,i)=>e(`th`,{key:i,style:a(i)},n(t,r))))),e(`tbody`,null,...i.cells.map((t,i)=>e(`tr`,{key:i},...t.map((t,i)=>e(`td`,{key:i,style:a(i)},n(t,r)))))))}},[A.tableSeparator]:{_match:(e,t)=>t.inTable&&e[0]===`|`?/^\|/.exec(e):null,_order:k.HIGH,_parse(){return{type:A.tableSeparator}},_render(){return` | `}},[A.text]:{_match:P((e,t)=>ue.exec(e)||he.exec(e)||/^[\s\S]/.exec(e)),_order:k.MIN,_parse(e){let t=e[0];return{text:t.indexOf(`&`)===-1?t:t.replace(b,(e,t)=>De[t]||e)}},_render(e){return e.text}},[A.textBolded]:{_qualify:[`**`,`__`],_match:q(de),_order:k.MED,_parse(e,t,n){return{children:t(e[2],n)}},_render(t,n,r={}){return e(`strong`,{key:r.key},n(t.children,r))}},[A.textEmphasized]:{_qualify:[`*`,`_`],_match:q(fe),_order:k.LOW,_parse(e,t,n){return{children:t(e[2],n)}},_render(t,n,r={}){return e(`em`,{key:r.key},n(t.children,r))}},[A.textEscaped]:{_qualify:[`\\`],_match:q(pe),_order:k.HIGH,_parse(e){return{text:e[1],type:A.text}}},[A.textMarked]:{_qualify:[`==`],_match:q(me),_order:k.LOW,_parse:W,_render(t,n,r={}){return e(`mark`,{key:r.key},n(t.children,r))}},[A.textStrikethroughed]:{_qualify:[`~~`],_match:q(ge),_order:k.LOW,_parse:W,_render(t,n,r={}){return e(`del`,{key:r.key},n(t.children,r))}}}},$=(n=``,i,a={})=>{let o=i.components??{},s=e=>i.slugify?i.slugify(e,J):J(e),u=Ne(i,a),d=[],p={},m=(n,r)=>{if(!r||!r.trim())return null;let a=r.match(t);return a?a.reduce((t,r)=>{let a=r.indexOf(`=`);if(a!==-1){let o=H(r.slice(0,a)).trim(),s=De(r.slice(a+1).trim()),c=e[o]??o;if(c===`ref`)return t;t[c]=I(n,o,s,i.sanitizer??we),typeof t[c]==`string`&&(y.test(t[c])||S.test(t[c]))&&(t[c]=w(t[c].trim()))}else r!==`style`&&(t[e[r]??r]=!0);return t},{}):null},h=[r,c,l,a.enforceAtxHeadings?ee:te,v,D,ae,N,f],_=Pe(u,i,a,d,p,m,e=>{let t=e.replace(M,``),n=t.length>2048?t.slice(0,2048):t;return Te(a.disableParsingRawHTML?h:[...h,oe,y,ne,S,f],n)},h),b=a.disableParsingRawHTML?Object.keys(_).reduce((e,t)=>(t!==A.htmlBlock&&t!==A.htmlSelfClosing&&(e[t]=_[t]),e),{}):_,x=Q(b),C=ke(Oe(b,a.renderRule)),w=e=>{let t=a.preserveFrontmatter?e:e.replace(g,``),n=a.forceInline||!a.forceBlock&&j.test(t.replace(M,``))===!1,r=C(x(n?t:`${Y(t).replace(M,``)}\n\n`,{inline:n}),{inline:n});for(;typeof r[r.length-1]==`string`&&!r[r.length-1].trim();)r.pop();if(a.wrapper===null)return r;let i=a.wrapper??(n?`span`:`div`);if(r.length>1||a.forceWrapper)return u(i,{key:`outer`},r);if(r.length===1){let e=r[0];if(typeof e==`string`){let t={key:`outer`};if(!n&&o){let n=B(o,`p.props`,{})??{},r=z(t.className,n.className),i={...t,...n};return r&&(i.className=r),u(`span`,i,e)}return u(`span`,t,e)}return e}return u(i,{key:`outer`},null)};if(typeof n!=`string`)throw Error(`intlayer: the first argument must be a string`);let T=w(n);return d.length?u(`div`,null,T,u(`footer`,{key:`footer`},...d.map(e=>u(`div`,{id:s(e.identifier),key:e.identifier},e.identifier,C(x(e.footnote,{inline:!0}),{inline:!0}))))):T},Fe=e=>(t,n)=>$(t,e,n),Ie=(e,t,n={})=>{let{components:r,namedCodesToUnicode:i,sanitizer:a,slugify:o,...s}=n;return $(e,{runtime:t,components:r,namedCodesToUnicode:i,sanitizer:a,slugify:o},s)};export{$ as compile,Ie as compileWithOptions,Fe as createCompiler};
|
|
789
13
|
//# sourceMappingURL=compiler.mjs.map
|