roamjs-components 0.53.2 → 0.53.5
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/LICENSE +21 -21
- package/README.md +154 -154
- package/backend/emailCatch.d.ts +4 -4
- package/backend/emailCatch.js +11 -11
- package/backend/emailError.d.ts +4 -4
- package/backend/emailError.js +56 -56
- package/backend/getRoamJSUser.d.ts +11 -11
- package/backend/getRoamJSUser.js +30 -30
- package/backend/headers.d.ts +5 -5
- package/backend/headers.js +7 -7
- package/backend/index.d.ts +6 -6
- package/backend/index.js +20 -20
- package/backend/meterRoamJSUser.d.ts +4 -4
- package/backend/meterRoamJSUser.js +14 -14
- package/backend/putRoamJSUser.d.ts +10 -10
- package/backend/putRoamJSUser.js +25 -25
- package/components/BlockErrorBoundary.d.ts +15 -15
- package/components/BlockErrorBoundary.js +27 -27
- package/components/BlockInput.d.ts +12 -12
- package/components/BlockInput.js +53 -53
- package/components/ComponentContainer.d.ts +9 -9
- package/components/ComponentContainer.js +46 -46
- package/components/ConfigPage.d.ts +99 -99
- package/components/ConfigPage.js +751 -751
- package/components/CursorMenu.d.ts +21 -21
- package/components/CursorMenu.js +181 -181
- package/components/Description.d.ts +5 -5
- package/components/Description.js +16 -16
- package/components/ExternalLogin.d.ts +18 -18
- package/components/ExternalLogin.js +131 -131
- package/components/Filter.d.ts +14 -14
- package/components/Filter.js +147 -147
- package/components/Loading.d.ts +4 -4
- package/components/Loading.js +33 -33
- package/components/MenuItemSelect.d.ts +10 -10
- package/components/MenuItemSelect.js +13 -13
- package/components/OauthSelect.d.ts +5 -5
- package/components/OauthSelect.js +25 -25
- package/components/PageInput.d.ts +10 -10
- package/components/PageInput.js +69 -69
- package/components/ServiceComponents.d.ts +49 -49
- package/components/ServiceComponents.js +277 -277
- package/components/SimpleAlert.d.ts +12 -12
- package/components/SimpleAlert.js +38 -38
- package/components/Toast.d.ts +10 -10
- package/components/Toast.js +41 -41
- package/components/TokenDialog.d.ts +11 -11
- package/components/TokenDialog.js +100 -100
- package/components/index.d.ts +15 -15
- package/components/index.js +60 -60
- package/date/constants.d.ts +2 -2
- package/date/constants.js +5 -5
- package/date/index.d.ts +5 -5
- package/date/index.js +13 -13
- package/date/parseRoamDate.d.ts +2 -2
- package/date/parseRoamDate.js +6 -6
- package/date/parseRoamDateUid.d.ts +2 -2
- package/date/parseRoamDateUid.js +6 -6
- package/date/toRoamDate.d.ts +2 -2
- package/date/toRoamDate.js +6 -6
- package/date/toRoamDateUid.d.ts +2 -2
- package/date/toRoamDateUid.js +6 -6
- package/dom/addBlockCommand.d.ts +5 -5
- package/dom/addBlockCommand.js +53 -53
- package/dom/addOldRoamJSDependency.d.ts +2 -2
- package/dom/addOldRoamJSDependency.js +10 -10
- package/dom/addRoamJSDependency.d.ts +2 -2
- package/dom/addRoamJSDependency.js +8 -8
- package/dom/addScriptAsDependency.d.ts +6 -6
- package/dom/addScriptAsDependency.js +16 -16
- package/dom/addStyle.d.ts +2 -2
- package/dom/addStyle.js +14 -14
- package/dom/constants.d.ts +1 -1
- package/dom/constants.js +4 -4
- package/dom/createBlockObserver.d.ts +7 -7
- package/dom/createBlockObserver.js +43 -43
- package/dom/createButtonObserver.d.ts +6 -6
- package/dom/createButtonObserver.js +21 -21
- package/dom/createDivObserver.d.ts +2 -2
- package/dom/createDivObserver.js +8 -8
- package/dom/createHTMLObserver.d.ts +8 -8
- package/dom/createHTMLObserver.js +24 -24
- package/dom/createHashtagObserver.d.ts +5 -5
- package/dom/createHashtagObserver.js +16 -16
- package/dom/createIconButton.d.ts +2 -2
- package/dom/createIconButton.js +12 -12
- package/dom/createObserver.d.ts +2 -2
- package/dom/createObserver.js +6 -6
- package/dom/createOverlayObserver.d.ts +2 -2
- package/dom/createOverlayObserver.js +6 -6
- package/dom/createPageObserver.d.ts +2 -2
- package/dom/createPageObserver.js +34 -34
- package/dom/createPageTitleObserver.d.ts +6 -6
- package/dom/createPageTitleObserver.js +29 -29
- package/dom/genericError.d.ts +4 -4
- package/dom/genericError.js +16 -16
- package/dom/getActiveUids.d.ts +3 -3
- package/dom/getActiveUids.js +6 -6
- package/dom/getBlockUidFromTarget.d.ts +2 -2
- package/dom/getBlockUidFromTarget.js +33 -33
- package/dom/getCurrentPageUid.d.ts +2 -2
- package/dom/getCurrentPageUid.js +6 -6
- package/dom/getDomRefs.d.ts +2 -2
- package/dom/getDomRefs.js +12 -12
- package/dom/getDropUidOffset.d.ts +5 -5
- package/dom/getDropUidOffset.js +27 -27
- package/dom/getMutatedNodes.d.ts +7 -7
- package/dom/getMutatedNodes.js +11 -11
- package/dom/getPageTitleByHtmlElement.d.ts +2 -2
- package/dom/getPageTitleByHtmlElement.js +12 -12
- package/dom/getPageTitleValueByHtmlElement.d.ts +2 -2
- package/dom/getPageTitleValueByHtmlElement.js +27 -27
- package/dom/getReferenceBlockUid.d.ts +2 -2
- package/dom/getReferenceBlockUid.js +18 -18
- package/dom/getRoamUrl.d.ts +2 -2
- package/dom/getRoamUrl.js +4 -4
- package/dom/getRoamUrlByPage.d.ts +2 -2
- package/dom/getRoamUrlByPage.js +10 -10
- package/dom/getUids.d.ts +3 -3
- package/dom/getUids.js +8 -8
- package/dom/getUidsFromButton.d.ts +3 -3
- package/dom/getUidsFromButton.js +9 -9
- package/dom/getUidsFromId.d.ts +5 -5
- package/dom/getUidsFromId.js +15 -15
- package/dom/index.d.ts +31 -31
- package/dom/index.js +65 -65
- package/dom/openBlock.d.ts +2 -2
- package/dom/openBlock.js +6 -6
- package/dom/openBlockElement.d.ts +2 -2
- package/dom/openBlockElement.js +16 -16
- package/dom/parseRoamBlocksToHtml.d.ts +9 -9
- package/dom/parseRoamBlocksToHtml.js +75 -75
- package/dom/resolveRefs.d.ts +2 -2
- package/dom/resolveRefs.js +24 -24
- package/events/index.d.ts +1 -1
- package/events/index.js +8 -8
- package/events/watchOnce.d.ts +3 -3
- package/events/watchOnce.js +11 -11
- package/hooks/index.d.ts +3 -3
- package/hooks/index.js +12 -12
- package/hooks/useArrowKeyDown.d.ts +8 -8
- package/hooks/useArrowKeyDown.js +31 -31
- package/hooks/useRoamJSTokenWarning.d.ts +2 -2
- package/hooks/useRoamJSTokenWarning.js +11 -11
- package/hooks/useSubTree.d.ts +3 -3
- package/hooks/useSubTree.js +11 -11
- package/index.d.ts +11 -11
- package/index.js +14 -14
- package/marked/index.d.ts +14 -14
- package/marked/index.js +518 -518
- package/package.json +86 -86
- package/queries/getAllBlockUids.d.ts +2 -2
- package/queries/getAllBlockUids.js +6 -6
- package/queries/getAllBlockUidsAndTexts.d.ts +5 -5
- package/queries/getAllBlockUidsAndTexts.js +6 -6
- package/queries/getAllPageNames.d.ts +2 -2
- package/queries/getAllPageNames.js +6 -6
- package/queries/getAttributeValueByBlockAndName.d.ts +5 -5
- package/queries/getAttributeValueByBlockAndName.js +11 -11
- package/queries/getBasicTreeByParentUid.d.ts +3 -3
- package/queries/getBasicTreeByParentUid.js +13 -13
- package/queries/getBlockUidAndTextIncludingText.d.ts +5 -5
- package/queries/getBlockUidAndTextIncludingText.js +6 -6
- package/queries/getBlockUidByTextOnPage.d.ts +5 -5
- package/queries/getBlockUidByTextOnPage.js +7 -7
- package/queries/getBlockUidsAndTextsReferencingPage.d.ts +5 -5
- package/queries/getBlockUidsAndTextsReferencingPage.js +11 -11
- package/queries/getBlockUidsByPageTitle.d.ts +2 -2
- package/queries/getBlockUidsByPageTitle.js +8 -8
- package/queries/getBlockUidsReferencingBlock.d.ts +2 -2
- package/queries/getBlockUidsReferencingBlock.js +6 -6
- package/queries/getBlockUidsReferencingPage.d.ts +2 -2
- package/queries/getBlockUidsReferencingPage.js +8 -8
- package/queries/getBlockUidsWithParentUid.d.ts +2 -2
- package/queries/getBlockUidsWithParentUid.js +6 -6
- package/queries/getChildrenLengthByPageUid.d.ts +2 -2
- package/queries/getChildrenLengthByPageUid.js +4 -4
- package/queries/getCreateTimeByBlockUid.d.ts +2 -2
- package/queries/getCreateTimeByBlockUid.js +7 -7
- package/queries/getCurrentUser.d.ts +2 -2
- package/queries/getCurrentUser.js +11 -11
- package/queries/getCurrentUserDisplayName.d.ts +2 -2
- package/queries/getCurrentUserDisplayName.js +13 -13
- package/queries/getCurrentUserEmail.d.ts +2 -2
- package/queries/getCurrentUserEmail.js +13 -13
- package/queries/getCurrentUserUid.d.ts +2 -2
- package/queries/getCurrentUserUid.js +13 -13
- package/queries/getDisplayNameByEmail.d.ts +2 -2
- package/queries/getDisplayNameByEmail.js +7 -7
- package/queries/getDisplayNameByUid.d.ts +2 -2
- package/queries/getDisplayNameByUid.js +7 -7
- package/queries/getEditTimeByBlockUid.d.ts +2 -2
- package/queries/getEditTimeByBlockUid.js +7 -7
- package/queries/getEditedUserEmailByBlockUid.d.ts +2 -2
- package/queries/getEditedUserEmailByBlockUid.js +7 -7
- package/queries/getFirstChildTextByBlockUid.d.ts +2 -2
- package/queries/getFirstChildTextByBlockUid.js +7 -7
- package/queries/getFirstChildUidByBlockUid.d.ts +2 -2
- package/queries/getFirstChildUidByBlockUid.js +5 -5
- package/queries/getFullTreeByParentUid.d.ts +3 -3
- package/queries/getFullTreeByParentUid.js +26 -26
- package/queries/getLinkedPageTitlesUnderUid.d.ts +2 -2
- package/queries/getLinkedPageTitlesUnderUid.js +6 -6
- package/queries/getNthChildUidByBlockUid.d.ts +5 -5
- package/queries/getNthChildUidByBlockUid.js +7 -7
- package/queries/getOrderByBlockUid.d.ts +2 -2
- package/queries/getOrderByBlockUid.js +7 -7
- package/queries/getPageTitleByBlockUid.d.ts +2 -2
- package/queries/getPageTitleByBlockUid.js +7 -7
- package/queries/getPageTitleByPageUid.d.ts +2 -2
- package/queries/getPageTitleByPageUid.js +9 -9
- package/queries/getPageTitleReferencesByPageTitle.d.ts +2 -2
- package/queries/getPageTitleReferencesByPageTitle.js +8 -8
- package/queries/getPageTitlesAndBlockUidsReferencingPage.d.ts +5 -5
- package/queries/getPageTitlesAndBlockUidsReferencingPage.js +8 -8
- package/queries/getPageTitlesAndUidsDirectlyReferencingPage.d.ts +5 -5
- package/queries/getPageTitlesAndUidsDirectlyReferencingPage.js +8 -8
- package/queries/getPageTitlesReferencingBlockUid.d.ts +2 -2
- package/queries/getPageTitlesReferencingBlockUid.js +6 -6
- package/queries/getPageTitlesStartingWithPrefix.d.ts +2 -2
- package/queries/getPageTitlesStartingWithPrefix.js +6 -6
- package/queries/getPageUidByPageTitle.d.ts +2 -2
- package/queries/getPageUidByPageTitle.js +9 -9
- package/queries/getPageViewType.d.ts +3 -3
- package/queries/getPageViewType.js +9 -9
- package/queries/getParentTextByBlockUid.d.ts +2 -2
- package/queries/getParentTextByBlockUid.js +7 -7
- package/queries/getParentTextByBlockUidAndTag.d.ts +5 -5
- package/queries/getParentTextByBlockUidAndTag.js +7 -7
- package/queries/getParentUidByBlockUid.d.ts +2 -2
- package/queries/getParentUidByBlockUid.js +7 -7
- package/queries/getParentUidsOfBlockUid.d.ts +2 -2
- package/queries/getParentUidsOfBlockUid.js +6 -6
- package/queries/getSettingsByEmail.d.ts +3 -3
- package/queries/getSettingsByEmail.js +7 -7
- package/queries/getShallowTreeByParentUid.d.ts +5 -5
- package/queries/getShallowTreeByParentUid.js +10 -10
- package/queries/getTextByBlockUid.d.ts +2 -2
- package/queries/getTextByBlockUid.js +7 -7
- package/queries/index.d.ts +45 -45
- package/queries/index.js +96 -96
- package/queries/isTagOnPage.d.ts +5 -5
- package/queries/isTagOnPage.js +9 -9
- package/queries/normalizePageTitle.d.ts +2 -2
- package/queries/normalizePageTitle.js +4 -4
- package/types/index.d.ts +461 -459
- package/types/index.js +2 -2
- package/types/query-builder.d.ts +16 -16
- package/types/query-builder.js +2 -2
- package/util/addInputSetting.d.ts +7 -7
- package/util/addInputSetting.js +25 -25
- package/util/apiDelete.d.ts +2 -2
- package/util/apiDelete.js +9 -9
- package/util/apiGet.d.ts +2 -2
- package/util/apiGet.js +9 -9
- package/util/apiPost.d.ts +2 -2
- package/util/apiPost.js +9 -9
- package/util/apiPut.d.ts +2 -2
- package/util/apiPut.js +9 -9
- package/util/createOverlayRender.d.ts +6 -6
- package/util/createOverlayRender.js +18 -18
- package/util/createTagRegex.d.ts +2 -2
- package/util/createTagRegex.js +4 -4
- package/util/extractRef.d.ts +2 -2
- package/util/extractRef.js +8 -8
- package/util/extractTag.d.ts +2 -2
- package/util/extractTag.js +12 -12
- package/util/getAuthorizationHeader.d.ts +2 -2
- package/util/getAuthorizationHeader.js +12 -12
- package/util/getGraph.d.ts +2 -2
- package/util/getGraph.js +8 -8
- package/util/getLocalStorageKey.d.ts +2 -2
- package/util/getLocalStorageKey.js +6 -6
- package/util/getOauth.d.ts +2 -2
- package/util/getOauth.js +50 -50
- package/util/getOauthAccounts.d.ts +2 -2
- package/util/getOauthAccounts.js +21 -21
- package/util/getRenderRoot.d.ts +2 -2
- package/util/getRenderRoot.js +11 -11
- package/util/getSettingIntFromTree.d.ts +7 -7
- package/util/getSettingIntFromTree.js +11 -11
- package/util/getSettingValueFromTree.d.ts +7 -7
- package/util/getSettingValueFromTree.js +13 -13
- package/util/getSettingValuesFromTree.d.ts +7 -7
- package/util/getSettingValuesFromTree.js +12 -12
- package/util/getSubTree.d.ts +8 -8
- package/util/getSubTree.js +19 -19
- package/util/getToken.d.ts +2 -2
- package/util/getToken.js +9 -9
- package/util/getTokenFromTree.d.ts +2 -2
- package/util/getTokenFromTree.js +5 -5
- package/util/idToTitle.d.ts +2 -2
- package/util/idToTitle.js +8 -8
- package/util/index.d.ts +23 -23
- package/util/index.js +52 -52
- package/util/isControl.d.ts +2 -2
- package/util/isControl.js +6 -6
- package/util/localStorageGet.d.ts +2 -2
- package/util/localStorageGet.js +8 -8
- package/util/localStorageRemove.d.ts +2 -2
- package/util/localStorageRemove.js +6 -6
- package/util/localStorageSet.d.ts +2 -2
- package/util/localStorageSet.js +8 -8
- package/util/registerSmartBlocksCommand.d.ts +8 -8
- package/util/registerSmartBlocksCommand.js +24 -24
- package/util/runExtension.d.ts +4 -4
- package/util/runExtension.js +40 -40
- package/util/setInputSetting.d.ts +7 -7
- package/util/setInputSetting.js +33 -33
- package/util/setInputSettings.d.ts +7 -7
- package/util/setInputSettings.js +28 -28
- package/util/toConfigPageName.d.ts +2 -2
- package/util/toConfigPageName.js +4 -4
- package/util/toFlexRegex.d.ts +2 -2
- package/util/toFlexRegex.js +4 -4
- package/writes/clearBlockById.d.ts +2 -2
- package/writes/clearBlockById.js +11 -11
- package/writes/clearBlockByUid.d.ts +2 -2
- package/writes/clearBlockByUid.js +9 -9
- package/writes/createBlock.d.ts +9 -9
- package/writes/createBlock.js +61 -61
- package/writes/createPage.d.ts +7 -7
- package/writes/createPage.js +18 -18
- package/writes/deleteBlock.d.ts +2 -2
- package/writes/deleteBlock.js +6 -6
- package/writes/index.d.ts +8 -8
- package/writes/index.js +22 -22
- package/writes/openBlockInSidebar.d.ts +2 -2
- package/writes/openBlockInSidebar.js +13 -13
- package/writes/updateActiveBlock.d.ts +2 -2
- package/writes/updateActiveBlock.js +11 -11
- package/writes/updateBlock.d.ts +5 -5
- package/writes/updateBlock.js +17 -17
package/marked/index.js
CHANGED
|
@@ -1,434 +1,434 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseInline = exports.lexer = exports.inlineLexer = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const marked_1 = (0, tslib_1.__importStar)(require("marked"));
|
|
6
|
-
const xregexp_1 = (0, tslib_1.__importDefault)(require("xregexp"));
|
|
7
|
-
const refractor_1 = (0, tslib_1.__importDefault)(require("refractor"));
|
|
8
|
-
const markdown_1 = (0, tslib_1.__importDefault)(require("refractor/lang/markdown"));
|
|
9
|
-
const yaml_1 = (0, tslib_1.__importDefault)(require("refractor/lang/yaml"));
|
|
10
|
-
const css_1 = (0, tslib_1.__importDefault)(require("refractor/lang/css"));
|
|
11
|
-
const bash_1 = (0, tslib_1.__importDefault)(require("refractor/lang/bash"));
|
|
12
|
-
const java_1 = (0, tslib_1.__importDefault)(require("refractor/lang/java"));
|
|
13
|
-
const rust_1 = (0, tslib_1.__importDefault)(require("refractor/lang/rust"));
|
|
14
|
-
const python_1 = (0, tslib_1.__importDefault)(require("refractor/lang/python"));
|
|
15
|
-
const csharp_1 = (0, tslib_1.__importDefault)(require("refractor/lang/csharp"));
|
|
16
|
-
const clojure_1 = (0, tslib_1.__importDefault)(require("refractor/lang/clojure"));
|
|
17
|
-
const hcl_1 = (0, tslib_1.__importDefault)(require("refractor/lang/hcl"));
|
|
18
|
-
const hast_util_to_html_1 = (0, tslib_1.__importDefault)(require("hast-util-to-html"));
|
|
19
|
-
refractor_1.default.register(markdown_1.default);
|
|
20
|
-
refractor_1.default.register(yaml_1.default);
|
|
21
|
-
refractor_1.default.register(css_1.default);
|
|
22
|
-
refractor_1.default.register(bash_1.default);
|
|
23
|
-
refractor_1.default.register(java_1.default);
|
|
24
|
-
refractor_1.default.register(rust_1.default);
|
|
25
|
-
refractor_1.default.register(python_1.default);
|
|
26
|
-
refractor_1.default.register(csharp_1.default);
|
|
27
|
-
refractor_1.default.register(clojure_1.default);
|
|
28
|
-
refractor_1.default.register(hcl_1.default);
|
|
29
|
-
const RENDERED_TODO = '<span><label class="check-container"><input type="checkbox" disabled=""><span class="checkmark"></span></label></span>';
|
|
30
|
-
const RENDERED_DONE = '<span><label class="check-container"><input type="checkbox" checked="" disabled=""><span class="checkmark"></span></label></span>';
|
|
31
|
-
const URL_REGEX = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=$]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=$,]*)/;
|
|
32
|
-
const TODO_REGEX = /^{{(?:\[\[)?TODO(?:\]\])?}}/;
|
|
33
|
-
const DONE_REGEX = /^{{(?:\[\[)?DONE(?:\]\])?}}/;
|
|
34
|
-
const IFRAME_REGEX = new RegExp(`^{{(?:\\[\\[)?iframe(?:\\]\\])?:\\s*(${URL_REGEX.source})}}`);
|
|
35
|
-
const BUTTON_REGEX = /^{{(?:\[\[)?((?:(?!}}[^}])[\w\s-/])*)(?:\]\])?(?::(.*))?}}/;
|
|
36
|
-
const TAG_REGEX = /^#?\[\[(.*?)\]\]/;
|
|
37
|
-
const BLOCK_REF_REGEX = /^\(\((.*?)\)\)/;
|
|
38
|
-
const toAlias = (r) => new RegExp(`^\\[([^\\]]*?)\\]\\(${r.source.substring(1)}\\)`);
|
|
39
|
-
const ALIAS_REGEX = toAlias(TAG_REGEX);
|
|
40
|
-
const ALIAS_REF_REGEX = toAlias(BLOCK_REF_REGEX);
|
|
41
|
-
const HASHTAG_REGEX = /^#([^\s]*)/;
|
|
42
|
-
const ATTRIBUTE_REGEX = /^(.*?)::/;
|
|
43
|
-
const BOLD_REGEX = /^\*\*(.*?)\*\*/;
|
|
44
|
-
const ITALICS_REGEX = /^__(.*?)__/;
|
|
45
|
-
const HIGHLIGHT_REGEX = /^\^\^([^^]*)\^\^/;
|
|
46
|
-
const INLINE_STOP_REGEX = /({{|\*\*([^*]+?)\*\*|__([^_]+?)__|\^\^([^^]+?)\^\^|#?\[\[(.*?)\]\]|#[^\s]|\(\(.*?\)\)|\[(.*?)\]\((.*?)\))/;
|
|
47
|
-
const HR_REGEX = /^---$/;
|
|
48
|
-
const BQ_REGEX = /^(?:>|\[\[>\]\]) (.*)$/s;
|
|
49
|
-
const TWEET_STATUS_REGEX = /\/status\/(.*?)(?:\?s=\d*)?$/;
|
|
50
|
-
const HTML_REGEXES = [BUTTON_REGEX, BLOCK_REF_REGEX, HR_REGEX];
|
|
51
|
-
const HTML_WITH_CHILD_REGEXES = [
|
|
52
|
-
{ rgx: BQ_REGEX, title: "blockquote" },
|
|
53
|
-
{ rgx: HIGHLIGHT_REGEX, title: "highlight" },
|
|
54
|
-
];
|
|
55
|
-
const CODESPAN_REGEX = new RegExp("^```([\\w]*)\n(.*)```$", "s");
|
|
56
|
-
const defaultComponents = (component, afterColon) => {
|
|
57
|
-
var _a;
|
|
58
|
-
const opts = ((_a = afterColon === null || afterColon === void 0 ? void 0 : afterColon.trim) === null || _a === void 0 ? void 0 : _a.call(afterColon)) || "";
|
|
59
|
-
switch (component) {
|
|
60
|
-
case "youtube":
|
|
61
|
-
case "video":
|
|
62
|
-
return `<div class="rm-iframe-container"><iframe src="${opts
|
|
63
|
-
.replace("youtu.be", "www.youtube.com/embed")
|
|
64
|
-
.replace("watch?v=", "embed/")
|
|
65
|
-
.replace("vimeo.com", "player.vimeo.com/video")}" class="rm-iframe rm-video-player"></iframe></div>`;
|
|
66
|
-
case "pdf":
|
|
67
|
-
return `<div class="rm-iframe-container"><iframe src="${opts}" class="rm-iframe"></iframe></div>`;
|
|
68
|
-
default:
|
|
69
|
-
return "";
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
let lastSrc = "";
|
|
73
|
-
// https://github.com/markedjs/marked/blob/d2347e9b9ae517d02138fa6a9844bd8d586acfeb/src/Tokenizer.js#L33-L59
|
|
74
|
-
function indentCodeCompensation(raw, text) {
|
|
75
|
-
const matchIndentToCode = raw.match(/^(\s+)(?:```)/);
|
|
76
|
-
if (matchIndentToCode === null) {
|
|
77
|
-
return text;
|
|
78
|
-
}
|
|
79
|
-
const indentToCode = matchIndentToCode[1];
|
|
80
|
-
return text
|
|
81
|
-
.split("\n")
|
|
82
|
-
.map((node) => {
|
|
83
|
-
const matchIndentInNode = node.match(/^\s+/);
|
|
84
|
-
if (matchIndentInNode === null) {
|
|
85
|
-
return node;
|
|
86
|
-
}
|
|
87
|
-
const [indentInNode] = matchIndentInNode;
|
|
88
|
-
if (indentInNode.length >= indentToCode.length) {
|
|
89
|
-
return node.slice(indentToCode.length);
|
|
90
|
-
}
|
|
91
|
-
return node;
|
|
92
|
-
})
|
|
93
|
-
.join("\n");
|
|
94
|
-
}
|
|
95
|
-
const opts = {
|
|
96
|
-
tokenizer: {
|
|
97
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
98
|
-
// @ts-ignore should accept boolean return value
|
|
99
|
-
tag(src) {
|
|
100
|
-
for (const r of HTML_REGEXES) {
|
|
101
|
-
const match = r.exec(src);
|
|
102
|
-
if (match) {
|
|
103
|
-
return {
|
|
104
|
-
type: "html",
|
|
105
|
-
raw: match[0],
|
|
106
|
-
text: match[0],
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
return false;
|
|
111
|
-
},
|
|
112
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
113
|
-
// @ts-ignore should accept boolean return value
|
|
114
|
-
del(src) {
|
|
115
|
-
const match = /^~[^~]/.exec(src);
|
|
116
|
-
if (match) {
|
|
117
|
-
return {
|
|
118
|
-
type: "text",
|
|
119
|
-
raw: "~",
|
|
120
|
-
text: "~",
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
return false;
|
|
124
|
-
},
|
|
125
|
-
emStrong(src) {
|
|
126
|
-
var _a, _b;
|
|
127
|
-
const match = BOLD_REGEX.exec(src);
|
|
128
|
-
if (match && ((_a = match[1]) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
129
|
-
return {
|
|
130
|
-
type: "strong",
|
|
131
|
-
raw: match[0],
|
|
132
|
-
text: match[1],
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
const emMatch = ITALICS_REGEX.exec(src);
|
|
136
|
-
if (emMatch && ((_b = emMatch[1]) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
137
|
-
return {
|
|
138
|
-
type: "em",
|
|
139
|
-
raw: emMatch[0],
|
|
140
|
-
text: emMatch[1],
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
return false;
|
|
144
|
-
},
|
|
145
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
146
|
-
// @ts-ignore should accept boolean return value
|
|
147
|
-
fences(src) {
|
|
148
|
-
const newSrc = src.replace(/```$/, "\n```");
|
|
149
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
150
|
-
// @ts-ignore should accept boolean return value
|
|
151
|
-
const rules = this.rules;
|
|
152
|
-
const cap = rules.block.fences.exec(newSrc);
|
|
153
|
-
if (cap) {
|
|
154
|
-
const raw = cap[0];
|
|
155
|
-
const text = indentCodeCompensation(raw, cap[3] || "");
|
|
156
|
-
return {
|
|
157
|
-
type: "code",
|
|
158
|
-
raw,
|
|
159
|
-
lang: cap[2] ? cap[2].trim() : cap[2],
|
|
160
|
-
text,
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
return false;
|
|
164
|
-
},
|
|
165
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
166
|
-
// @ts-ignore should accept boolean return value
|
|
167
|
-
inlineText(src) {
|
|
168
|
-
var _a, _b, _c;
|
|
169
|
-
if (src === lastSrc) {
|
|
170
|
-
throw new Error(`Infinite loop on byte: ${src.charCodeAt(0)} of string ${src}`);
|
|
171
|
-
}
|
|
172
|
-
lastSrc = src;
|
|
173
|
-
const match = INLINE_STOP_REGEX.exec(src);
|
|
174
|
-
if (match) {
|
|
175
|
-
const raw = src.substring(0, match.index);
|
|
176
|
-
const tickMatch = raw.match(/([^`]`|`[^`])/g);
|
|
177
|
-
const numberOfTicks = (tickMatch || []).length;
|
|
178
|
-
if (numberOfTicks % 2 === 0) {
|
|
179
|
-
const index = numberOfTicks > 0 ? (_a = /`/.exec(raw)) === null || _a === void 0 ? void 0 : _a.index : match.index;
|
|
180
|
-
return {
|
|
181
|
-
type: "text",
|
|
182
|
-
raw: src.substring(0, index),
|
|
183
|
-
text: src.substring(0, index),
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
const attribute = ATTRIBUTE_REGEX.exec(src);
|
|
188
|
-
if (attribute) {
|
|
189
|
-
const raw = attribute[0];
|
|
190
|
-
const numberOfTicks = (raw.match(/([^`]`|`[^`])/g) || []).length;
|
|
191
|
-
if (numberOfTicks % 2 === 0) {
|
|
192
|
-
const page = attribute[1];
|
|
193
|
-
const href = (_c = (_b = this.context()).pagesToHrefs) === null || _c === void 0 ? void 0 : _c.call(_b, page);
|
|
194
|
-
const text = `${page}:`;
|
|
195
|
-
if (href) {
|
|
196
|
-
return {
|
|
197
|
-
type: "strong",
|
|
198
|
-
raw,
|
|
199
|
-
text,
|
|
200
|
-
tokens: [
|
|
201
|
-
{
|
|
202
|
-
type: "link",
|
|
203
|
-
raw: text,
|
|
204
|
-
text,
|
|
205
|
-
href,
|
|
206
|
-
tokens: [
|
|
207
|
-
{
|
|
208
|
-
type: "text",
|
|
209
|
-
raw: text,
|
|
210
|
-
text,
|
|
211
|
-
},
|
|
212
|
-
],
|
|
213
|
-
},
|
|
214
|
-
],
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
else {
|
|
218
|
-
return {
|
|
219
|
-
type: "strong",
|
|
220
|
-
raw,
|
|
221
|
-
text,
|
|
222
|
-
tokens: [
|
|
223
|
-
{
|
|
224
|
-
type: "text",
|
|
225
|
-
raw: text,
|
|
226
|
-
text,
|
|
227
|
-
},
|
|
228
|
-
],
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
return false;
|
|
234
|
-
},
|
|
235
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
236
|
-
// @ts-ignore should accept boolean return value
|
|
237
|
-
codespan(src) {
|
|
238
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
239
|
-
// @ts-ignore should accept boolean return value
|
|
240
|
-
const cap = this.rules.inline.code.exec(src);
|
|
241
|
-
if (cap) {
|
|
242
|
-
if (cap[0].startsWith("```")) {
|
|
243
|
-
return {
|
|
244
|
-
type: "codespan",
|
|
245
|
-
raw: cap[0],
|
|
246
|
-
text: cap[0],
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
return false;
|
|
251
|
-
},
|
|
252
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
253
|
-
// @ts-ignore should accept boolean return value
|
|
254
|
-
link(src) {
|
|
255
|
-
var _a, _b, _c;
|
|
256
|
-
// hijacking link for html elements with tokens
|
|
257
|
-
for (const { rgx, title } of HTML_WITH_CHILD_REGEXES) {
|
|
258
|
-
const match = rgx.exec(src);
|
|
259
|
-
if (match) {
|
|
260
|
-
return {
|
|
261
|
-
type: "link",
|
|
262
|
-
raw: match[0],
|
|
263
|
-
text: match[1],
|
|
264
|
-
title,
|
|
265
|
-
};
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
const context = this.context();
|
|
269
|
-
if (TAG_REGEX.test(src)) {
|
|
270
|
-
const match = xregexp_1.default.matchRecursive(src, "#?\\[\\[", "\\]\\]", "i", {
|
|
271
|
-
valueNames: ["between", "left", "match", "right"],
|
|
272
|
-
});
|
|
273
|
-
const raw = match.map((m) => m.value).join("");
|
|
274
|
-
if (context.pagesToHrefs) {
|
|
275
|
-
const text = match[1].value;
|
|
276
|
-
const href = context.pagesToHrefs(text);
|
|
277
|
-
if (href) {
|
|
278
|
-
return {
|
|
279
|
-
type: "link",
|
|
280
|
-
raw,
|
|
281
|
-
href,
|
|
282
|
-
text,
|
|
283
|
-
title: `tag:${text}`,
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
else {
|
|
287
|
-
return {
|
|
288
|
-
type: "text",
|
|
289
|
-
raw,
|
|
290
|
-
text,
|
|
291
|
-
};
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
else {
|
|
295
|
-
return {
|
|
296
|
-
type: "text",
|
|
297
|
-
raw,
|
|
298
|
-
text: raw,
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
const hashMatch = HASHTAG_REGEX.exec(src);
|
|
303
|
-
if (hashMatch) {
|
|
304
|
-
const raw = hashMatch[0];
|
|
305
|
-
if (context.pagesToHrefs) {
|
|
306
|
-
const text = hashMatch[1];
|
|
307
|
-
const href = context.pagesToHrefs(text);
|
|
308
|
-
if (href) {
|
|
309
|
-
return {
|
|
310
|
-
type: "link",
|
|
311
|
-
raw,
|
|
312
|
-
href,
|
|
313
|
-
text,
|
|
314
|
-
title: `tag:${text}`,
|
|
315
|
-
};
|
|
316
|
-
}
|
|
317
|
-
else {
|
|
318
|
-
return {
|
|
319
|
-
type: "text",
|
|
320
|
-
raw,
|
|
321
|
-
text,
|
|
322
|
-
};
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
else {
|
|
326
|
-
return {
|
|
327
|
-
type: "text",
|
|
328
|
-
raw,
|
|
329
|
-
text: raw,
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
const aliasMatch = ALIAS_REGEX.exec(src);
|
|
334
|
-
if (aliasMatch) {
|
|
335
|
-
const raw = aliasMatch[0];
|
|
336
|
-
if (context.pagesToHrefs) {
|
|
337
|
-
const text = aliasMatch[1];
|
|
338
|
-
const href = context.pagesToHrefs(aliasMatch[2]);
|
|
339
|
-
if (href) {
|
|
340
|
-
return {
|
|
341
|
-
type: "link",
|
|
342
|
-
raw,
|
|
343
|
-
href,
|
|
344
|
-
text,
|
|
345
|
-
title: "alias",
|
|
346
|
-
};
|
|
347
|
-
}
|
|
348
|
-
else {
|
|
349
|
-
return {
|
|
350
|
-
type: "text",
|
|
351
|
-
raw,
|
|
352
|
-
text,
|
|
353
|
-
};
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
else {
|
|
357
|
-
return {
|
|
358
|
-
type: "text",
|
|
359
|
-
raw,
|
|
360
|
-
text: raw,
|
|
361
|
-
};
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
const aliasRefMatch = ALIAS_REF_REGEX.exec(src);
|
|
365
|
-
if (aliasRefMatch) {
|
|
366
|
-
const raw = aliasRefMatch[0];
|
|
367
|
-
const text = aliasRefMatch[1];
|
|
368
|
-
const ref = aliasRefMatch[2];
|
|
369
|
-
const href = (_a = context.pagesToHrefs) === null || _a === void 0 ? void 0 : _a.call(context, ((_c = (_b = context.blockReferences) === null || _b === void 0 ? void 0 : _b.call(context, ref)) === null || _c === void 0 ? void 0 : _c.page) || "", ref);
|
|
370
|
-
if (href) {
|
|
371
|
-
return {
|
|
372
|
-
type: "link",
|
|
373
|
-
raw,
|
|
374
|
-
href,
|
|
375
|
-
text,
|
|
376
|
-
title: "alias",
|
|
377
|
-
};
|
|
378
|
-
}
|
|
379
|
-
else {
|
|
380
|
-
return {
|
|
381
|
-
type: "text",
|
|
382
|
-
raw,
|
|
383
|
-
text,
|
|
384
|
-
};
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
return false;
|
|
388
|
-
},
|
|
389
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
390
|
-
// @ts-ignore should acce
|
|
391
|
-
context: () => ({}),
|
|
392
|
-
},
|
|
393
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
394
|
-
// @ts-ignore should be optional
|
|
395
|
-
renderer: {
|
|
396
|
-
link(href, title, text) {
|
|
397
|
-
var _a;
|
|
398
|
-
if (title === "alias") {
|
|
399
|
-
const html = this.link(href, undefined, text);
|
|
400
|
-
if (html) {
|
|
401
|
-
return html.replace("href=", 'class="rm-alias" href=');
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
else if (title === null || title === void 0 ? void 0 : title.startsWith("tag:")) {
|
|
405
|
-
const html = this.link(href, undefined, text);
|
|
406
|
-
if (html) {
|
|
407
|
-
return html.replace("href=", `class="rm-page-ref" data-tag="${title.substring(4)}" href=`);
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
else if (title === "highlight") {
|
|
411
|
-
return `<span class="rm-highlight">${text}</span>`;
|
|
412
|
-
}
|
|
413
|
-
else if (title === "blockquote") {
|
|
414
|
-
return `<blockquote class="rm-bq">${text}</blockquote>`;
|
|
415
|
-
}
|
|
416
|
-
else if (href.startsWith("https://twitter.com") && text === href) {
|
|
417
|
-
const tweetId = (_a = TWEET_STATUS_REGEX.exec(href)) === null || _a === void 0 ? void 0 : _a[1];
|
|
418
|
-
const options = {
|
|
419
|
-
dnt: false,
|
|
420
|
-
frame: false,
|
|
421
|
-
hideCard: false,
|
|
422
|
-
hideThread: true,
|
|
423
|
-
id: tweetId,
|
|
424
|
-
lang: "en",
|
|
425
|
-
theme: "light",
|
|
426
|
-
width: "550px",
|
|
427
|
-
};
|
|
428
|
-
if (tweetId) {
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseInline = exports.lexer = exports.inlineLexer = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const marked_1 = (0, tslib_1.__importStar)(require("marked"));
|
|
6
|
+
const xregexp_1 = (0, tslib_1.__importDefault)(require("xregexp"));
|
|
7
|
+
const refractor_1 = (0, tslib_1.__importDefault)(require("refractor"));
|
|
8
|
+
const markdown_1 = (0, tslib_1.__importDefault)(require("refractor/lang/markdown"));
|
|
9
|
+
const yaml_1 = (0, tslib_1.__importDefault)(require("refractor/lang/yaml"));
|
|
10
|
+
const css_1 = (0, tslib_1.__importDefault)(require("refractor/lang/css"));
|
|
11
|
+
const bash_1 = (0, tslib_1.__importDefault)(require("refractor/lang/bash"));
|
|
12
|
+
const java_1 = (0, tslib_1.__importDefault)(require("refractor/lang/java"));
|
|
13
|
+
const rust_1 = (0, tslib_1.__importDefault)(require("refractor/lang/rust"));
|
|
14
|
+
const python_1 = (0, tslib_1.__importDefault)(require("refractor/lang/python"));
|
|
15
|
+
const csharp_1 = (0, tslib_1.__importDefault)(require("refractor/lang/csharp"));
|
|
16
|
+
const clojure_1 = (0, tslib_1.__importDefault)(require("refractor/lang/clojure"));
|
|
17
|
+
const hcl_1 = (0, tslib_1.__importDefault)(require("refractor/lang/hcl"));
|
|
18
|
+
const hast_util_to_html_1 = (0, tslib_1.__importDefault)(require("hast-util-to-html"));
|
|
19
|
+
refractor_1.default.register(markdown_1.default);
|
|
20
|
+
refractor_1.default.register(yaml_1.default);
|
|
21
|
+
refractor_1.default.register(css_1.default);
|
|
22
|
+
refractor_1.default.register(bash_1.default);
|
|
23
|
+
refractor_1.default.register(java_1.default);
|
|
24
|
+
refractor_1.default.register(rust_1.default);
|
|
25
|
+
refractor_1.default.register(python_1.default);
|
|
26
|
+
refractor_1.default.register(csharp_1.default);
|
|
27
|
+
refractor_1.default.register(clojure_1.default);
|
|
28
|
+
refractor_1.default.register(hcl_1.default);
|
|
29
|
+
const RENDERED_TODO = '<span><label class="check-container"><input type="checkbox" disabled=""><span class="checkmark"></span></label></span>';
|
|
30
|
+
const RENDERED_DONE = '<span><label class="check-container"><input type="checkbox" checked="" disabled=""><span class="checkmark"></span></label></span>';
|
|
31
|
+
const URL_REGEX = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=$]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=$,]*)/;
|
|
32
|
+
const TODO_REGEX = /^{{(?:\[\[)?TODO(?:\]\])?}}/;
|
|
33
|
+
const DONE_REGEX = /^{{(?:\[\[)?DONE(?:\]\])?}}/;
|
|
34
|
+
const IFRAME_REGEX = new RegExp(`^{{(?:\\[\\[)?iframe(?:\\]\\])?:\\s*(${URL_REGEX.source})}}`);
|
|
35
|
+
const BUTTON_REGEX = /^{{(?:\[\[)?((?:(?!}}[^}])[\w\s-/])*)(?:\]\])?(?::(.*))?}}/;
|
|
36
|
+
const TAG_REGEX = /^#?\[\[(.*?)\]\]/;
|
|
37
|
+
const BLOCK_REF_REGEX = /^\(\((.*?)\)\)/;
|
|
38
|
+
const toAlias = (r) => new RegExp(`^\\[([^\\]]*?)\\]\\(${r.source.substring(1)}\\)`);
|
|
39
|
+
const ALIAS_REGEX = toAlias(TAG_REGEX);
|
|
40
|
+
const ALIAS_REF_REGEX = toAlias(BLOCK_REF_REGEX);
|
|
41
|
+
const HASHTAG_REGEX = /^#([^\s]*)/;
|
|
42
|
+
const ATTRIBUTE_REGEX = /^(.*?)::/;
|
|
43
|
+
const BOLD_REGEX = /^\*\*(.*?)\*\*/;
|
|
44
|
+
const ITALICS_REGEX = /^__(.*?)__/;
|
|
45
|
+
const HIGHLIGHT_REGEX = /^\^\^([^^]*)\^\^/;
|
|
46
|
+
const INLINE_STOP_REGEX = /({{|\*\*([^*]+?)\*\*|__([^_]+?)__|\^\^([^^]+?)\^\^|#?\[\[(.*?)\]\]|#[^\s]|\(\(.*?\)\)|\[(.*?)\]\((.*?)\))/;
|
|
47
|
+
const HR_REGEX = /^---$/;
|
|
48
|
+
const BQ_REGEX = /^(?:>|\[\[>\]\]) (.*)$/s;
|
|
49
|
+
const TWEET_STATUS_REGEX = /\/status\/(.*?)(?:\?s=\d*)?$/;
|
|
50
|
+
const HTML_REGEXES = [BUTTON_REGEX, BLOCK_REF_REGEX, HR_REGEX];
|
|
51
|
+
const HTML_WITH_CHILD_REGEXES = [
|
|
52
|
+
{ rgx: BQ_REGEX, title: "blockquote" },
|
|
53
|
+
{ rgx: HIGHLIGHT_REGEX, title: "highlight" },
|
|
54
|
+
];
|
|
55
|
+
const CODESPAN_REGEX = new RegExp("^```([\\w]*)\n(.*)```$", "s");
|
|
56
|
+
const defaultComponents = (component, afterColon) => {
|
|
57
|
+
var _a;
|
|
58
|
+
const opts = ((_a = afterColon === null || afterColon === void 0 ? void 0 : afterColon.trim) === null || _a === void 0 ? void 0 : _a.call(afterColon)) || "";
|
|
59
|
+
switch (component) {
|
|
60
|
+
case "youtube":
|
|
61
|
+
case "video":
|
|
62
|
+
return `<div class="rm-iframe-container"><iframe src="${opts
|
|
63
|
+
.replace("youtu.be", "www.youtube.com/embed")
|
|
64
|
+
.replace("watch?v=", "embed/")
|
|
65
|
+
.replace("vimeo.com", "player.vimeo.com/video")}" class="rm-iframe rm-video-player"></iframe></div>`;
|
|
66
|
+
case "pdf":
|
|
67
|
+
return `<div class="rm-iframe-container"><iframe src="${opts}" class="rm-iframe"></iframe></div>`;
|
|
68
|
+
default:
|
|
69
|
+
return "";
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
let lastSrc = "";
|
|
73
|
+
// https://github.com/markedjs/marked/blob/d2347e9b9ae517d02138fa6a9844bd8d586acfeb/src/Tokenizer.js#L33-L59
|
|
74
|
+
function indentCodeCompensation(raw, text) {
|
|
75
|
+
const matchIndentToCode = raw.match(/^(\s+)(?:```)/);
|
|
76
|
+
if (matchIndentToCode === null) {
|
|
77
|
+
return text;
|
|
78
|
+
}
|
|
79
|
+
const indentToCode = matchIndentToCode[1];
|
|
80
|
+
return text
|
|
81
|
+
.split("\n")
|
|
82
|
+
.map((node) => {
|
|
83
|
+
const matchIndentInNode = node.match(/^\s+/);
|
|
84
|
+
if (matchIndentInNode === null) {
|
|
85
|
+
return node;
|
|
86
|
+
}
|
|
87
|
+
const [indentInNode] = matchIndentInNode;
|
|
88
|
+
if (indentInNode.length >= indentToCode.length) {
|
|
89
|
+
return node.slice(indentToCode.length);
|
|
90
|
+
}
|
|
91
|
+
return node;
|
|
92
|
+
})
|
|
93
|
+
.join("\n");
|
|
94
|
+
}
|
|
95
|
+
const opts = {
|
|
96
|
+
tokenizer: {
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
98
|
+
// @ts-ignore should accept boolean return value
|
|
99
|
+
tag(src) {
|
|
100
|
+
for (const r of HTML_REGEXES) {
|
|
101
|
+
const match = r.exec(src);
|
|
102
|
+
if (match) {
|
|
103
|
+
return {
|
|
104
|
+
type: "html",
|
|
105
|
+
raw: match[0],
|
|
106
|
+
text: match[0],
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return false;
|
|
111
|
+
},
|
|
112
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
113
|
+
// @ts-ignore should accept boolean return value
|
|
114
|
+
del(src) {
|
|
115
|
+
const match = /^~[^~]/.exec(src);
|
|
116
|
+
if (match) {
|
|
117
|
+
return {
|
|
118
|
+
type: "text",
|
|
119
|
+
raw: "~",
|
|
120
|
+
text: "~",
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
return false;
|
|
124
|
+
},
|
|
125
|
+
emStrong(src) {
|
|
126
|
+
var _a, _b;
|
|
127
|
+
const match = BOLD_REGEX.exec(src);
|
|
128
|
+
if (match && ((_a = match[1]) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
129
|
+
return {
|
|
130
|
+
type: "strong",
|
|
131
|
+
raw: match[0],
|
|
132
|
+
text: match[1],
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
const emMatch = ITALICS_REGEX.exec(src);
|
|
136
|
+
if (emMatch && ((_b = emMatch[1]) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
137
|
+
return {
|
|
138
|
+
type: "em",
|
|
139
|
+
raw: emMatch[0],
|
|
140
|
+
text: emMatch[1],
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
return false;
|
|
144
|
+
},
|
|
145
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
146
|
+
// @ts-ignore should accept boolean return value
|
|
147
|
+
fences(src) {
|
|
148
|
+
const newSrc = src.replace(/```$/, "\n```");
|
|
149
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
150
|
+
// @ts-ignore should accept boolean return value
|
|
151
|
+
const rules = this.rules;
|
|
152
|
+
const cap = rules.block.fences.exec(newSrc);
|
|
153
|
+
if (cap) {
|
|
154
|
+
const raw = cap[0];
|
|
155
|
+
const text = indentCodeCompensation(raw, cap[3] || "");
|
|
156
|
+
return {
|
|
157
|
+
type: "code",
|
|
158
|
+
raw,
|
|
159
|
+
lang: cap[2] ? cap[2].trim() : cap[2],
|
|
160
|
+
text,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
return false;
|
|
164
|
+
},
|
|
165
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
166
|
+
// @ts-ignore should accept boolean return value
|
|
167
|
+
inlineText(src) {
|
|
168
|
+
var _a, _b, _c;
|
|
169
|
+
if (src === lastSrc) {
|
|
170
|
+
throw new Error(`Infinite loop on byte: ${src.charCodeAt(0)} of string ${src}`);
|
|
171
|
+
}
|
|
172
|
+
lastSrc = src;
|
|
173
|
+
const match = INLINE_STOP_REGEX.exec(src);
|
|
174
|
+
if (match) {
|
|
175
|
+
const raw = src.substring(0, match.index);
|
|
176
|
+
const tickMatch = raw.match(/([^`]`|`[^`])/g);
|
|
177
|
+
const numberOfTicks = (tickMatch || []).length;
|
|
178
|
+
if (numberOfTicks % 2 === 0) {
|
|
179
|
+
const index = numberOfTicks > 0 ? (_a = /`/.exec(raw)) === null || _a === void 0 ? void 0 : _a.index : match.index;
|
|
180
|
+
return {
|
|
181
|
+
type: "text",
|
|
182
|
+
raw: src.substring(0, index),
|
|
183
|
+
text: src.substring(0, index),
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
const attribute = ATTRIBUTE_REGEX.exec(src);
|
|
188
|
+
if (attribute) {
|
|
189
|
+
const raw = attribute[0];
|
|
190
|
+
const numberOfTicks = (raw.match(/([^`]`|`[^`])/g) || []).length;
|
|
191
|
+
if (numberOfTicks % 2 === 0) {
|
|
192
|
+
const page = attribute[1];
|
|
193
|
+
const href = (_c = (_b = this.context()).pagesToHrefs) === null || _c === void 0 ? void 0 : _c.call(_b, page);
|
|
194
|
+
const text = `${page}:`;
|
|
195
|
+
if (href) {
|
|
196
|
+
return {
|
|
197
|
+
type: "strong",
|
|
198
|
+
raw,
|
|
199
|
+
text,
|
|
200
|
+
tokens: [
|
|
201
|
+
{
|
|
202
|
+
type: "link",
|
|
203
|
+
raw: text,
|
|
204
|
+
text,
|
|
205
|
+
href,
|
|
206
|
+
tokens: [
|
|
207
|
+
{
|
|
208
|
+
type: "text",
|
|
209
|
+
raw: text,
|
|
210
|
+
text,
|
|
211
|
+
},
|
|
212
|
+
],
|
|
213
|
+
},
|
|
214
|
+
],
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
return {
|
|
219
|
+
type: "strong",
|
|
220
|
+
raw,
|
|
221
|
+
text,
|
|
222
|
+
tokens: [
|
|
223
|
+
{
|
|
224
|
+
type: "text",
|
|
225
|
+
raw: text,
|
|
226
|
+
text,
|
|
227
|
+
},
|
|
228
|
+
],
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return false;
|
|
234
|
+
},
|
|
235
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
236
|
+
// @ts-ignore should accept boolean return value
|
|
237
|
+
codespan(src) {
|
|
238
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
239
|
+
// @ts-ignore should accept boolean return value
|
|
240
|
+
const cap = this.rules.inline.code.exec(src);
|
|
241
|
+
if (cap) {
|
|
242
|
+
if (cap[0].startsWith("```")) {
|
|
243
|
+
return {
|
|
244
|
+
type: "codespan",
|
|
245
|
+
raw: cap[0],
|
|
246
|
+
text: cap[0],
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return false;
|
|
251
|
+
},
|
|
252
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
253
|
+
// @ts-ignore should accept boolean return value
|
|
254
|
+
link(src) {
|
|
255
|
+
var _a, _b, _c;
|
|
256
|
+
// hijacking link for html elements with tokens
|
|
257
|
+
for (const { rgx, title } of HTML_WITH_CHILD_REGEXES) {
|
|
258
|
+
const match = rgx.exec(src);
|
|
259
|
+
if (match) {
|
|
260
|
+
return {
|
|
261
|
+
type: "link",
|
|
262
|
+
raw: match[0],
|
|
263
|
+
text: match[1],
|
|
264
|
+
title,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
const context = this.context();
|
|
269
|
+
if (TAG_REGEX.test(src)) {
|
|
270
|
+
const match = xregexp_1.default.matchRecursive(src, "#?\\[\\[", "\\]\\]", "i", {
|
|
271
|
+
valueNames: ["between", "left", "match", "right"],
|
|
272
|
+
});
|
|
273
|
+
const raw = match.map((m) => m.value).join("");
|
|
274
|
+
if (context.pagesToHrefs) {
|
|
275
|
+
const text = match[1].value;
|
|
276
|
+
const href = context.pagesToHrefs(text);
|
|
277
|
+
if (href) {
|
|
278
|
+
return {
|
|
279
|
+
type: "link",
|
|
280
|
+
raw,
|
|
281
|
+
href,
|
|
282
|
+
text,
|
|
283
|
+
title: `tag:${text}`,
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
return {
|
|
288
|
+
type: "text",
|
|
289
|
+
raw,
|
|
290
|
+
text,
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
return {
|
|
296
|
+
type: "text",
|
|
297
|
+
raw,
|
|
298
|
+
text: raw,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
const hashMatch = HASHTAG_REGEX.exec(src);
|
|
303
|
+
if (hashMatch) {
|
|
304
|
+
const raw = hashMatch[0];
|
|
305
|
+
if (context.pagesToHrefs) {
|
|
306
|
+
const text = hashMatch[1];
|
|
307
|
+
const href = context.pagesToHrefs(text);
|
|
308
|
+
if (href) {
|
|
309
|
+
return {
|
|
310
|
+
type: "link",
|
|
311
|
+
raw,
|
|
312
|
+
href,
|
|
313
|
+
text,
|
|
314
|
+
title: `tag:${text}`,
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
return {
|
|
319
|
+
type: "text",
|
|
320
|
+
raw,
|
|
321
|
+
text,
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
return {
|
|
327
|
+
type: "text",
|
|
328
|
+
raw,
|
|
329
|
+
text: raw,
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
const aliasMatch = ALIAS_REGEX.exec(src);
|
|
334
|
+
if (aliasMatch) {
|
|
335
|
+
const raw = aliasMatch[0];
|
|
336
|
+
if (context.pagesToHrefs) {
|
|
337
|
+
const text = aliasMatch[1];
|
|
338
|
+
const href = context.pagesToHrefs(aliasMatch[2]);
|
|
339
|
+
if (href) {
|
|
340
|
+
return {
|
|
341
|
+
type: "link",
|
|
342
|
+
raw,
|
|
343
|
+
href,
|
|
344
|
+
text,
|
|
345
|
+
title: "alias",
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
return {
|
|
350
|
+
type: "text",
|
|
351
|
+
raw,
|
|
352
|
+
text,
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
return {
|
|
358
|
+
type: "text",
|
|
359
|
+
raw,
|
|
360
|
+
text: raw,
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
const aliasRefMatch = ALIAS_REF_REGEX.exec(src);
|
|
365
|
+
if (aliasRefMatch) {
|
|
366
|
+
const raw = aliasRefMatch[0];
|
|
367
|
+
const text = aliasRefMatch[1];
|
|
368
|
+
const ref = aliasRefMatch[2];
|
|
369
|
+
const href = (_a = context.pagesToHrefs) === null || _a === void 0 ? void 0 : _a.call(context, ((_c = (_b = context.blockReferences) === null || _b === void 0 ? void 0 : _b.call(context, ref)) === null || _c === void 0 ? void 0 : _c.page) || "", ref);
|
|
370
|
+
if (href) {
|
|
371
|
+
return {
|
|
372
|
+
type: "link",
|
|
373
|
+
raw,
|
|
374
|
+
href,
|
|
375
|
+
text,
|
|
376
|
+
title: "alias",
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
return {
|
|
381
|
+
type: "text",
|
|
382
|
+
raw,
|
|
383
|
+
text,
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
return false;
|
|
388
|
+
},
|
|
389
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
390
|
+
// @ts-ignore should acce
|
|
391
|
+
context: () => ({}),
|
|
392
|
+
},
|
|
393
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
394
|
+
// @ts-ignore should be optional
|
|
395
|
+
renderer: {
|
|
396
|
+
link(href, title, text) {
|
|
397
|
+
var _a;
|
|
398
|
+
if (title === "alias") {
|
|
399
|
+
const html = this.link(href, undefined, text);
|
|
400
|
+
if (html) {
|
|
401
|
+
return html.replace("href=", 'class="rm-alias" href=');
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
else if (title === null || title === void 0 ? void 0 : title.startsWith("tag:")) {
|
|
405
|
+
const html = this.link(href, undefined, text);
|
|
406
|
+
if (html) {
|
|
407
|
+
return html.replace("href=", `class="rm-page-ref" data-tag="${title.substring(4)}" href=`);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
else if (title === "highlight") {
|
|
411
|
+
return `<span class="rm-highlight">${text}</span>`;
|
|
412
|
+
}
|
|
413
|
+
else if (title === "blockquote") {
|
|
414
|
+
return `<blockquote class="rm-bq">${text}</blockquote>`;
|
|
415
|
+
}
|
|
416
|
+
else if (href.startsWith("https://twitter.com") && text === href) {
|
|
417
|
+
const tweetId = (_a = TWEET_STATUS_REGEX.exec(href)) === null || _a === void 0 ? void 0 : _a[1];
|
|
418
|
+
const options = {
|
|
419
|
+
dnt: false,
|
|
420
|
+
frame: false,
|
|
421
|
+
hideCard: false,
|
|
422
|
+
hideThread: true,
|
|
423
|
+
id: tweetId,
|
|
424
|
+
lang: "en",
|
|
425
|
+
theme: "light",
|
|
426
|
+
width: "550px",
|
|
427
|
+
};
|
|
428
|
+
if (tweetId) {
|
|
429
429
|
return `<div>
|
|
430
|
-
<iframe scrolling="no" frameborder="0" allowtransparency="true" allowfullscreen="true" class="" style="position: static; visibility: visible; width: ${options.width}; height: ${options.width}; display: block; flex-grow: 1; pointer-events: auto;" title="Twitter Tweet" src="https://platform.twitter.com/embed/Tweet.html?${new URLSearchParams(Object.fromEntries(Object.entries(options).map(([k, v]) => [k, `${v}`])))
|
|
431
|
-
.toString()
|
|
430
|
+
<iframe scrolling="no" frameborder="0" allowtransparency="true" allowfullscreen="true" class="" style="position: static; visibility: visible; width: ${options.width}; height: ${options.width}; display: block; flex-grow: 1; pointer-events: auto;" title="Twitter Tweet" src="https://platform.twitter.com/embed/Tweet.html?${new URLSearchParams(Object.fromEntries(Object.entries(options).map(([k, v]) => [k, `${v}`])))
|
|
431
|
+
.toString()
|
|
432
432
|
.replace(/&/g, "&")}" data-tweet-id="${tweetId}"></iframe>
|
|
433
433
|
<script>const cs = document.currentScript;
|
|
434
434
|
const iframe = cs.previousElementSibling;
|
|
@@ -453,92 +453,92 @@ if (!(twttr && twttr.ready)) {
|
|
|
453
453
|
renderTweet()
|
|
454
454
|
}
|
|
455
455
|
</script>
|
|
456
|
-
</div>`;
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
return false;
|
|
460
|
-
},
|
|
461
|
-
codespan(code) {
|
|
462
|
-
const match = CODESPAN_REGEX.exec(code);
|
|
463
|
-
if (match) {
|
|
464
|
-
const nodes = refractor_1.default.highlight(match[2], match[1]);
|
|
465
|
-
return `<pre><code class="language-${match[1]}">${(0, hast_util_to_html_1.default)(
|
|
466
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
467
|
-
//@ts-ignore
|
|
468
|
-
nodes)}</code></pre>`;
|
|
469
|
-
}
|
|
470
|
-
return false;
|
|
471
|
-
},
|
|
472
|
-
strong: (text) => `<span class="rm-bold">${text}</span>`,
|
|
473
|
-
em: (text) => `<em class="rm-italics">${text}</em>`,
|
|
474
|
-
html(text) {
|
|
475
|
-
var _a, _b, _c, _d, _e, _f;
|
|
476
|
-
if (TODO_REGEX.test(text)) {
|
|
477
|
-
return RENDERED_TODO;
|
|
478
|
-
}
|
|
479
|
-
else if (DONE_REGEX.test(text)) {
|
|
480
|
-
return RENDERED_DONE;
|
|
481
|
-
}
|
|
482
|
-
else if (HR_REGEX.test(text)) {
|
|
483
|
-
return "<hr>";
|
|
484
|
-
}
|
|
485
|
-
else if (IFRAME_REGEX.test(text)) {
|
|
486
|
-
const match = IFRAME_REGEX.exec(text);
|
|
487
|
-
return `<div class="rm-iframe-container"><iframe src="${match === null || match === void 0 ? void 0 : match[1]}" frameborder="0" class="rm-iframe"></iframe></div>`;
|
|
488
|
-
}
|
|
489
|
-
else if (HIGHLIGHT_REGEX.test(text)) {
|
|
490
|
-
const match = HIGHLIGHT_REGEX.exec(text);
|
|
491
|
-
return `<span class="rm-highlight">${match === null || match === void 0 ? void 0 : match[1]}</span>`;
|
|
492
|
-
}
|
|
493
|
-
else if (BUTTON_REGEX.test(text)) {
|
|
494
|
-
const match = ((_a = BUTTON_REGEX.exec(text)) === null || _a === void 0 ? void 0 : _a[1]) || "";
|
|
495
|
-
const afterColon = (_b = BUTTON_REGEX.exec(text)) === null || _b === void 0 ? void 0 : _b[2];
|
|
496
|
-
const context = this.context();
|
|
497
|
-
return (((_c = context.components) === null || _c === void 0 ? void 0 : _c.call(context, match, afterColon)) ||
|
|
498
|
-
defaultComponents(match, afterColon) ||
|
|
499
|
-
`<button class="bp3-button">${match}</button>`);
|
|
500
|
-
}
|
|
501
|
-
else if (BLOCK_REF_REGEX.test(text)) {
|
|
502
|
-
const match = ((_d = BLOCK_REF_REGEX.exec(text)) === null || _d === void 0 ? void 0 : _d[1]) || "";
|
|
503
|
-
const context = this.context();
|
|
504
|
-
const blockRefInfo = (_e = context.blockReferences) === null || _e === void 0 ? void 0 : _e.call(context, match);
|
|
505
|
-
if (!blockRefInfo) {
|
|
506
|
-
return text;
|
|
507
|
-
}
|
|
508
|
-
const page = blockRefInfo.page || "";
|
|
509
|
-
const blockText = (0, exports.parseInline)(blockRefInfo.text || "", context);
|
|
510
|
-
if (!page)
|
|
511
|
-
return blockText;
|
|
512
|
-
const href = (_f = context.pagesToHrefs) === null || _f === void 0 ? void 0 : _f.call(context, page, match);
|
|
513
|
-
return `<a class="rm-block-ref" href="${href}">${blockText}</a>`;
|
|
514
|
-
}
|
|
515
|
-
else if (BQ_REGEX.test(text)) {
|
|
516
|
-
const match = BQ_REGEX.exec(text);
|
|
517
|
-
return `<blockquote class="rm-bq">${match === null || match === void 0 ? void 0 : match[1]}</blockquote>`;
|
|
518
|
-
}
|
|
519
|
-
else {
|
|
520
|
-
return text;
|
|
521
|
-
}
|
|
522
|
-
},
|
|
523
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
524
|
-
// @ts-ignore should acce
|
|
525
|
-
context: () => ({}),
|
|
526
|
-
},
|
|
527
|
-
};
|
|
528
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
529
|
-
// @ts-ignore should accept boolean return value
|
|
530
|
-
marked_1.default.use(opts);
|
|
531
|
-
const contextualize = (method) => (text, context) => {
|
|
532
|
-
opts.tokenizer.context = () => (Object.assign({}, context));
|
|
533
|
-
opts.renderer.context = () => (Object.assign({}, context));
|
|
534
|
-
lastSrc = "";
|
|
535
|
-
return method(text);
|
|
536
|
-
};
|
|
537
|
-
exports.inlineLexer = contextualize((s) =>
|
|
538
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
539
|
-
//@ts-ignore types are out of date
|
|
540
|
-
marked_1.Lexer.lexInline(s));
|
|
541
|
-
exports.lexer = contextualize(marked_1.default.lexer);
|
|
542
|
-
exports.parseInline = contextualize(marked_1.default.parseInline);
|
|
543
|
-
exports.default = contextualize(marked_1.default);
|
|
456
|
+
</div>`;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
return false;
|
|
460
|
+
},
|
|
461
|
+
codespan(code) {
|
|
462
|
+
const match = CODESPAN_REGEX.exec(code);
|
|
463
|
+
if (match) {
|
|
464
|
+
const nodes = refractor_1.default.highlight(match[2], match[1]);
|
|
465
|
+
return `<pre><code class="language-${match[1]}">${(0, hast_util_to_html_1.default)(
|
|
466
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
467
|
+
//@ts-ignore
|
|
468
|
+
nodes)}</code></pre>`;
|
|
469
|
+
}
|
|
470
|
+
return false;
|
|
471
|
+
},
|
|
472
|
+
strong: (text) => `<span class="rm-bold">${text}</span>`,
|
|
473
|
+
em: (text) => `<em class="rm-italics">${text}</em>`,
|
|
474
|
+
html(text) {
|
|
475
|
+
var _a, _b, _c, _d, _e, _f;
|
|
476
|
+
if (TODO_REGEX.test(text)) {
|
|
477
|
+
return RENDERED_TODO;
|
|
478
|
+
}
|
|
479
|
+
else if (DONE_REGEX.test(text)) {
|
|
480
|
+
return RENDERED_DONE;
|
|
481
|
+
}
|
|
482
|
+
else if (HR_REGEX.test(text)) {
|
|
483
|
+
return "<hr>";
|
|
484
|
+
}
|
|
485
|
+
else if (IFRAME_REGEX.test(text)) {
|
|
486
|
+
const match = IFRAME_REGEX.exec(text);
|
|
487
|
+
return `<div class="rm-iframe-container"><iframe src="${match === null || match === void 0 ? void 0 : match[1]}" frameborder="0" class="rm-iframe"></iframe></div>`;
|
|
488
|
+
}
|
|
489
|
+
else if (HIGHLIGHT_REGEX.test(text)) {
|
|
490
|
+
const match = HIGHLIGHT_REGEX.exec(text);
|
|
491
|
+
return `<span class="rm-highlight">${match === null || match === void 0 ? void 0 : match[1]}</span>`;
|
|
492
|
+
}
|
|
493
|
+
else if (BUTTON_REGEX.test(text)) {
|
|
494
|
+
const match = ((_a = BUTTON_REGEX.exec(text)) === null || _a === void 0 ? void 0 : _a[1]) || "";
|
|
495
|
+
const afterColon = (_b = BUTTON_REGEX.exec(text)) === null || _b === void 0 ? void 0 : _b[2];
|
|
496
|
+
const context = this.context();
|
|
497
|
+
return (((_c = context.components) === null || _c === void 0 ? void 0 : _c.call(context, match, afterColon)) ||
|
|
498
|
+
defaultComponents(match, afterColon) ||
|
|
499
|
+
`<button class="bp3-button">${match}</button>`);
|
|
500
|
+
}
|
|
501
|
+
else if (BLOCK_REF_REGEX.test(text)) {
|
|
502
|
+
const match = ((_d = BLOCK_REF_REGEX.exec(text)) === null || _d === void 0 ? void 0 : _d[1]) || "";
|
|
503
|
+
const context = this.context();
|
|
504
|
+
const blockRefInfo = (_e = context.blockReferences) === null || _e === void 0 ? void 0 : _e.call(context, match);
|
|
505
|
+
if (!blockRefInfo) {
|
|
506
|
+
return text;
|
|
507
|
+
}
|
|
508
|
+
const page = blockRefInfo.page || "";
|
|
509
|
+
const blockText = (0, exports.parseInline)(blockRefInfo.text || "", context);
|
|
510
|
+
if (!page)
|
|
511
|
+
return blockText;
|
|
512
|
+
const href = (_f = context.pagesToHrefs) === null || _f === void 0 ? void 0 : _f.call(context, page, match);
|
|
513
|
+
return `<a class="rm-block-ref" href="${href}">${blockText}</a>`;
|
|
514
|
+
}
|
|
515
|
+
else if (BQ_REGEX.test(text)) {
|
|
516
|
+
const match = BQ_REGEX.exec(text);
|
|
517
|
+
return `<blockquote class="rm-bq">${match === null || match === void 0 ? void 0 : match[1]}</blockquote>`;
|
|
518
|
+
}
|
|
519
|
+
else {
|
|
520
|
+
return text;
|
|
521
|
+
}
|
|
522
|
+
},
|
|
523
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
524
|
+
// @ts-ignore should acce
|
|
525
|
+
context: () => ({}),
|
|
526
|
+
},
|
|
527
|
+
};
|
|
528
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
529
|
+
// @ts-ignore should accept boolean return value
|
|
530
|
+
marked_1.default.use(opts);
|
|
531
|
+
const contextualize = (method) => (text, context) => {
|
|
532
|
+
opts.tokenizer.context = () => (Object.assign({}, context));
|
|
533
|
+
opts.renderer.context = () => (Object.assign({}, context));
|
|
534
|
+
lastSrc = "";
|
|
535
|
+
return method(text);
|
|
536
|
+
};
|
|
537
|
+
exports.inlineLexer = contextualize((s) =>
|
|
538
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
539
|
+
//@ts-ignore types are out of date
|
|
540
|
+
marked_1.Lexer.lexInline(s));
|
|
541
|
+
exports.lexer = contextualize(marked_1.default.lexer);
|
|
542
|
+
exports.parseInline = contextualize(marked_1.default.parseInline);
|
|
543
|
+
exports.default = contextualize(marked_1.default);
|
|
544
544
|
//# sourceMappingURL=index.js.map
|