zenn-markdown-html 0.1.122-alpha.0 → 0.1.122

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.
@@ -84,6 +84,16 @@ const blockOptions = {
84
84
  return (0, _helper.generateEmbedIframe)('tweet', str);
85
85
  },
86
86
 
87
+ blueprintue(str) {
88
+ if (!(0, _urlMatcher.isBlueprintUEUrl)(str)) return '「https://blueprintue.com/render/」から始まる正しいURLを指定してください';
89
+ return `<div class="embed-blueprintue"><iframe src="${str}" width="100%" height="500px" scrolling="no" frameborder="no" loading="lazy" allowfullscreen></iframe></div>`;
90
+ },
91
+
92
+ figma(str) {
93
+ if (!(0, _urlMatcher.isFigmaUrl)(str)) return 'ファイルまたはプロトタイプのFigma URLを指定してください';
94
+ return `<div class="embed-figma"><iframe src="https://www.figma.com/embed?embed_host=zenn&url=${str}" scrolling="no" frameborder="no" loading="lazy" allowfullscreen width="100%" height="500px"></iframe></div>`;
95
+ },
96
+
87
97
  card(str) {
88
98
  if (!(0, _helper.isValidHttpUrl)(str)) return 'URLが不正です';
89
99
  return (0, _helper.generateEmbedIframe)('link-card', str);
@@ -88,9 +88,21 @@ function mdLinkifyToCard(md) {
88
88
  md.core.ruler.after('replacements', 'link-to-card', function ({
89
89
  tokens
90
90
  }) {
91
- // 本文内のすべてのtokenをチェック
91
+ // 埋め込みを許可するネストレベル
92
+ let allowLevel = 0; // 本文内のすべてのtokenをチェック
93
+
92
94
  tokens.forEach((token, i) => {
93
- // autolinkはinline内のchildrenにのみ存在
95
+ if (token.type === 'container_details_open') {
96
+ allowLevel++;
97
+ return;
98
+ }
99
+
100
+ if (token.type === 'container_details_close' && allowLevel > 0) {
101
+ allowLevel--;
102
+ return;
103
+ } // autolinkはinline内のchildrenにのみ存在
104
+
105
+
94
106
  if (token.type !== 'inline') return; // childrenが存在しない場合は変換しない
95
107
 
96
108
  const children = token.children;
@@ -100,7 +112,7 @@ function mdLinkifyToCard(md) {
100
112
  if (!hasAnyAutolink) return; // 親がコンテンツ直下のp要素の場合のみ変換
101
113
 
102
114
  const parentToken = tokens[i - 1];
103
- const isParentRootParagraph = parentToken && parentToken.type === 'paragraph_open' && parentToken.level === 0;
115
+ const isParentRootParagraph = parentToken && parentToken.type === 'paragraph_open' && parentToken.level === allowLevel;
104
116
  if (!isParentRootParagraph) return;
105
117
  token.children = convertAutolinkToEmbed(children);
106
118
  });
@@ -9,3 +9,12 @@ export declare function extractYoutubeVideoParameters(youtubeUrl: string): {
9
9
  start?: string;
10
10
  } | undefined;
11
11
  export declare function isYoutubeUrl(url: string): boolean;
12
+ /**
13
+ * 参考: https://blueprintue.com/
14
+ * 生成されるURLをもとに正規表現を定義した
15
+ */
16
+ export declare function isBlueprintUEUrl(url: string): boolean;
17
+ /**
18
+ * 参考: https://www.figma.com/developers/embed
19
+ */
20
+ export declare function isFigmaUrl(url: string): boolean;
@@ -4,8 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.extractYoutubeVideoParameters = extractYoutubeVideoParameters;
7
+ exports.isBlueprintUEUrl = isBlueprintUEUrl;
7
8
  exports.isCodepenUrl = isCodepenUrl;
8
9
  exports.isCodesandboxUrl = isCodesandboxUrl;
10
+ exports.isFigmaUrl = isFigmaUrl;
9
11
  exports.isGistUrl = isGistUrl;
10
12
  exports.isJsfiddleUrl = isJsfiddleUrl;
11
13
  exports.isStackblitzUrl = isStackblitzUrl;
@@ -57,4 +59,21 @@ function extractYoutubeVideoParameters(youtubeUrl) {
57
59
 
58
60
  function isYoutubeUrl(url) {
59
61
  return youtubeRegexp.test(url);
62
+ }
63
+ /**
64
+ * 参考: https://blueprintue.com/
65
+ * 生成されるURLをもとに正規表現を定義した
66
+ */
67
+
68
+
69
+ function isBlueprintUEUrl(url) {
70
+ return /^https:\/\/blueprintue\.com\/render\/.+\/$/.test(url);
71
+ }
72
+ /**
73
+ * 参考: https://www.figma.com/developers/embed
74
+ */
75
+
76
+
77
+ function isFigmaUrl(url) {
78
+ return /^https:\/\/([\w.-]+\.)?figma.com\/(file|proto)\/([0-9a-zA-Z]{22,128})(?:\/.*)?$/.test(url);
60
79
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zenn-markdown-html",
3
- "version": "0.1.122-alpha.0",
3
+ "version": "0.1.122",
4
4
  "license": "MIT",
5
5
  "description": "Convert markdown to zenn flavor html.",
6
6
  "main": "lib/index.js",
@@ -53,7 +53,7 @@
53
53
  "markdown-it-task-lists": "^2.1.1",
54
54
  "prismjs": "^1.27.0"
55
55
  },
56
- "gitHead": "e71f9dacb5b9aa53545aebb9820def8f289886ce",
56
+ "gitHead": "027fd1986a92a21385754700c32753c7644e5df8",
57
57
  "publishConfig": {
58
58
  "access": "public"
59
59
  }