@plotday/twister 0.62.0 → 0.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert Markdown to an HTML fragment suitable for an email body.
|
|
3
|
+
*
|
|
4
|
+
* - Plot mentions `[Name](#@UUID)` render as plain `@Name` text rather than a
|
|
5
|
+
* broken link to the internal `#@UUID` href.
|
|
6
|
+
* - GitHub-flavoured Markdown is enabled, and single newlines become `<br>`
|
|
7
|
+
* (`breaks: true`) so a message reads the way the author wrote it — the same
|
|
8
|
+
* convention chat-style products (Slack, GitHub comments) use.
|
|
9
|
+
*
|
|
10
|
+
* Returns an HTML fragment (e.g. `<p>…</p>`), not a full document; the caller
|
|
11
|
+
* wraps it for its transport (a `text/html` MIME part, a Graph `body`, etc.).
|
|
12
|
+
* Empty/blank input yields an empty string.
|
|
13
|
+
*/
|
|
14
|
+
export declare function markdownToHtml(markdown: string | null | undefined): string;
|
|
15
|
+
//# sourceMappingURL=markdown-html.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-html.d.ts","sourceRoot":"","sources":["../../src/utils/markdown-html.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAiB1E"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Render Plot Markdown note content to HTML, for connectors that send the
|
|
3
|
+
* note out to a system whose native format is HTML email (Gmail, Outlook
|
|
4
|
+
* Mail). Kept separate from {@link markdownToPlainText} so connectors that
|
|
5
|
+
* only need the plain-text path don't pull the Markdown parser into their
|
|
6
|
+
* bundle (`sideEffects: false` lets the unused module tree-shake away).
|
|
7
|
+
*/
|
|
8
|
+
import { marked } from "marked";
|
|
9
|
+
/**
|
|
10
|
+
* Convert Markdown to an HTML fragment suitable for an email body.
|
|
11
|
+
*
|
|
12
|
+
* - Plot mentions `[Name](#@UUID)` render as plain `@Name` text rather than a
|
|
13
|
+
* broken link to the internal `#@UUID` href.
|
|
14
|
+
* - GitHub-flavoured Markdown is enabled, and single newlines become `<br>`
|
|
15
|
+
* (`breaks: true`) so a message reads the way the author wrote it — the same
|
|
16
|
+
* convention chat-style products (Slack, GitHub comments) use.
|
|
17
|
+
*
|
|
18
|
+
* Returns an HTML fragment (e.g. `<p>…</p>`), not a full document; the caller
|
|
19
|
+
* wraps it for its transport (a `text/html` MIME part, a Graph `body`, etc.).
|
|
20
|
+
* Empty/blank input yields an empty string.
|
|
21
|
+
*/
|
|
22
|
+
export function markdownToHtml(markdown) {
|
|
23
|
+
if (!markdown || markdown.trim() === "")
|
|
24
|
+
return "";
|
|
25
|
+
// Render mentions as "@Name" text before parsing so marked doesn't emit an
|
|
26
|
+
// anchor pointing at the internal "#@UUID" href.
|
|
27
|
+
const withMentions = markdown.replace(/\[([^\]]+)\]\(#@[^)]+\)/g, (_m, name) => `@${name}`);
|
|
28
|
+
const html = marked.parse(withMentions, {
|
|
29
|
+
async: false,
|
|
30
|
+
gfm: true,
|
|
31
|
+
breaks: true,
|
|
32
|
+
});
|
|
33
|
+
return html.trim();
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=markdown-html.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-html.js","sourceRoot":"","sources":["../../src/utils/markdown-html.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,cAAc,CAAC,QAAmC;IAChE,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,OAAO,EAAE,CAAC;IAEnD,2EAA2E;IAC3E,iDAAiD;IACjD,MAAM,YAAY,GAAG,QAAQ,CAAC,OAAO,CACnC,0BAA0B,EAC1B,CAAC,EAAE,EAAE,IAAY,EAAE,EAAE,CAAC,IAAI,IAAI,EAAE,CACjC,CAAC;IAEF,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,YAAY,EAAE;QACtC,KAAK,EAAE,KAAK;QACZ,GAAG,EAAE,IAAI;QACT,MAAM,EAAE,IAAI;KACb,CAAC,CAAC;IAEH,OAAQ,IAAe,CAAC,IAAI,EAAE,CAAC;AACjC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plotday/twister",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.63.0",
|
|
4
4
|
"description": "Plot Twist Creator - Build intelligent extensions that integrate and automate",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -124,6 +124,11 @@
|
|
|
124
124
|
"types": "./dist/utils/markdown.d.ts",
|
|
125
125
|
"default": "./dist/utils/markdown.js"
|
|
126
126
|
},
|
|
127
|
+
"./utils/markdown-html": {
|
|
128
|
+
"@plotday/connector": "./src/utils/markdown-html.ts",
|
|
129
|
+
"types": "./dist/utils/markdown-html.d.ts",
|
|
130
|
+
"default": "./dist/utils/markdown-html.js"
|
|
131
|
+
},
|
|
127
132
|
"./utils/uuid": {
|
|
128
133
|
"@plotday/connector": "./src/utils/uuid.ts",
|
|
129
134
|
"types": "./dist/utils/uuid.d.ts",
|
|
@@ -231,6 +236,7 @@
|
|
|
231
236
|
"commander": "^12.0.0",
|
|
232
237
|
"dotenv": "^16.4.5",
|
|
233
238
|
"esbuild": "^0.24.0",
|
|
239
|
+
"marked": "^18.0.5",
|
|
234
240
|
"prompts": "^2.4.2",
|
|
235
241
|
"typebox": "^1.0.35",
|
|
236
242
|
"uuid": "^11.0.5"
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Render Plot Markdown note content to HTML, for connectors that send the
|
|
3
|
+
* note out to a system whose native format is HTML email (Gmail, Outlook
|
|
4
|
+
* Mail). Kept separate from {@link markdownToPlainText} so connectors that
|
|
5
|
+
* only need the plain-text path don't pull the Markdown parser into their
|
|
6
|
+
* bundle (`sideEffects: false` lets the unused module tree-shake away).
|
|
7
|
+
*/
|
|
8
|
+
import { marked } from "marked";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Convert Markdown to an HTML fragment suitable for an email body.
|
|
12
|
+
*
|
|
13
|
+
* - Plot mentions `[Name](#@UUID)` render as plain `@Name` text rather than a
|
|
14
|
+
* broken link to the internal `#@UUID` href.
|
|
15
|
+
* - GitHub-flavoured Markdown is enabled, and single newlines become `<br>`
|
|
16
|
+
* (`breaks: true`) so a message reads the way the author wrote it — the same
|
|
17
|
+
* convention chat-style products (Slack, GitHub comments) use.
|
|
18
|
+
*
|
|
19
|
+
* Returns an HTML fragment (e.g. `<p>…</p>`), not a full document; the caller
|
|
20
|
+
* wraps it for its transport (a `text/html` MIME part, a Graph `body`, etc.).
|
|
21
|
+
* Empty/blank input yields an empty string.
|
|
22
|
+
*/
|
|
23
|
+
export function markdownToHtml(markdown: string | null | undefined): string {
|
|
24
|
+
if (!markdown || markdown.trim() === "") return "";
|
|
25
|
+
|
|
26
|
+
// Render mentions as "@Name" text before parsing so marked doesn't emit an
|
|
27
|
+
// anchor pointing at the internal "#@UUID" href.
|
|
28
|
+
const withMentions = markdown.replace(
|
|
29
|
+
/\[([^\]]+)\]\(#@[^)]+\)/g,
|
|
30
|
+
(_m, name: string) => `@${name}`
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const html = marked.parse(withMentions, {
|
|
34
|
+
async: false,
|
|
35
|
+
gfm: true,
|
|
36
|
+
breaks: true,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
return (html as string).trim();
|
|
40
|
+
}
|