@qodalis/cli-markdown 2.0.0-beta.1
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/package.json +34 -0
- package/public-api.d.mts +21 -0
- package/public-api.d.ts +21 -0
- package/public-api.js +145 -0
- package/public-api.js.map +1 -0
- package/public-api.mjs +140 -0
- package/public-api.mjs.map +1 -0
- package/umd/cli-entrypoint.global.js +2918 -0
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@qodalis/cli-markdown",
|
|
3
|
+
"version": "2.0.0-beta.1",
|
|
4
|
+
"description": "Render Markdown in the terminal",
|
|
5
|
+
"author": "Qodalis Solutions",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/qodalis-solutions/web-cli"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://qodalis.com",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"cli",
|
|
14
|
+
"qodalis",
|
|
15
|
+
"terminal",
|
|
16
|
+
"markdown"
|
|
17
|
+
],
|
|
18
|
+
"umd": "./umd/index.js",
|
|
19
|
+
"unpkg": "./umd/index.js",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@qodalis/cli-core": "2.0.0-beta.1"
|
|
22
|
+
},
|
|
23
|
+
"sideEffects": false,
|
|
24
|
+
"main": "./public-api.js",
|
|
25
|
+
"module": "./public-api.mjs",
|
|
26
|
+
"types": "./public-api.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./public-api.d.ts",
|
|
30
|
+
"import": "./public-api.mjs",
|
|
31
|
+
"require": "./public-api.js"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
package/public-api.d.mts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as _qodalis_cli_core from '@qodalis/cli-core';
|
|
2
|
+
import { ICliCommandProcessor, CliIcon, ICliCommandChildProcessor, CliProcessCommand, ICliExecutionContext, ICliModule } from '@qodalis/cli-core';
|
|
3
|
+
|
|
4
|
+
declare class CliMarkdownCommandProcessor implements ICliCommandProcessor {
|
|
5
|
+
command: string;
|
|
6
|
+
description: string;
|
|
7
|
+
aliases: string[];
|
|
8
|
+
author: _qodalis_cli_core.ICliCommandAuthor;
|
|
9
|
+
metadata: {
|
|
10
|
+
icon: CliIcon;
|
|
11
|
+
};
|
|
12
|
+
processors: ICliCommandChildProcessor[];
|
|
13
|
+
processCommand(_: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
declare const LIBRARY_VERSION = "2.0.0-beta.1";
|
|
17
|
+
declare const API_VERSION = 2;
|
|
18
|
+
|
|
19
|
+
declare const markdownModule: ICliModule;
|
|
20
|
+
|
|
21
|
+
export { API_VERSION, CliMarkdownCommandProcessor, LIBRARY_VERSION, markdownModule };
|
package/public-api.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as _qodalis_cli_core from '@qodalis/cli-core';
|
|
2
|
+
import { ICliCommandProcessor, CliIcon, ICliCommandChildProcessor, CliProcessCommand, ICliExecutionContext, ICliModule } from '@qodalis/cli-core';
|
|
3
|
+
|
|
4
|
+
declare class CliMarkdownCommandProcessor implements ICliCommandProcessor {
|
|
5
|
+
command: string;
|
|
6
|
+
description: string;
|
|
7
|
+
aliases: string[];
|
|
8
|
+
author: _qodalis_cli_core.ICliCommandAuthor;
|
|
9
|
+
metadata: {
|
|
10
|
+
icon: CliIcon;
|
|
11
|
+
};
|
|
12
|
+
processors: ICliCommandChildProcessor[];
|
|
13
|
+
processCommand(_: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
declare const LIBRARY_VERSION = "2.0.0-beta.1";
|
|
17
|
+
declare const API_VERSION = 2;
|
|
18
|
+
|
|
19
|
+
declare const markdownModule: ICliModule;
|
|
20
|
+
|
|
21
|
+
export { API_VERSION, CliMarkdownCommandProcessor, LIBRARY_VERSION, markdownModule };
|
package/public-api.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var cliCore = require('@qodalis/cli-core');
|
|
4
|
+
|
|
5
|
+
// src/lib/processors/cli-markdown-command-processor.ts
|
|
6
|
+
|
|
7
|
+
// src/lib/markdown-renderer.ts
|
|
8
|
+
var RESET = "\x1B[0m";
|
|
9
|
+
var BOLD = "\x1B[1m";
|
|
10
|
+
var DIM = "\x1B[2m";
|
|
11
|
+
var ITALIC = "\x1B[3m";
|
|
12
|
+
var UNDERLINE = "\x1B[4m";
|
|
13
|
+
var FG_YELLOW = "\x1B[33m";
|
|
14
|
+
var FG_CYAN = "\x1B[36m";
|
|
15
|
+
var FG_GREEN = "\x1B[32m";
|
|
16
|
+
var FG_WHITE = "\x1B[97m";
|
|
17
|
+
var BG_DARK = "\x1B[48;5;236m";
|
|
18
|
+
function wrap(text, ...codes) {
|
|
19
|
+
return codes.join("") + text + RESET;
|
|
20
|
+
}
|
|
21
|
+
function renderMarkdown(input) {
|
|
22
|
+
if (!input.trim()) return [];
|
|
23
|
+
const rawLines = input.split("\n");
|
|
24
|
+
const output = [];
|
|
25
|
+
let inCodeBlock = false;
|
|
26
|
+
for (const line of rawLines) {
|
|
27
|
+
if (line.startsWith("```")) {
|
|
28
|
+
if (!inCodeBlock) {
|
|
29
|
+
inCodeBlock = true;
|
|
30
|
+
const lang = line.slice(3).trim();
|
|
31
|
+
output.push(wrap(` ${lang || "code"} `, DIM, BG_DARK));
|
|
32
|
+
} else {
|
|
33
|
+
inCodeBlock = false;
|
|
34
|
+
output.push(wrap("\u2500".repeat(40), DIM));
|
|
35
|
+
}
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (inCodeBlock) {
|
|
39
|
+
output.push(wrap(" " + line, FG_GREEN));
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (line.startsWith("### ")) {
|
|
43
|
+
output.push(wrap(line.slice(4), BOLD, FG_CYAN));
|
|
44
|
+
} else if (line.startsWith("## ")) {
|
|
45
|
+
const text = line.slice(3);
|
|
46
|
+
output.push(wrap(text, BOLD, FG_YELLOW));
|
|
47
|
+
output.push(wrap("\u2500".repeat(text.length), FG_YELLOW));
|
|
48
|
+
} else if (line.startsWith("# ")) {
|
|
49
|
+
const text = line.slice(2);
|
|
50
|
+
output.push(wrap(text, BOLD, UNDERLINE, FG_WHITE));
|
|
51
|
+
output.push("");
|
|
52
|
+
} else if (/^(-{3,}|\*{3,}|_{3,})$/.test(line.trim())) {
|
|
53
|
+
output.push(wrap("\u2500".repeat(60), DIM));
|
|
54
|
+
} else if (line.startsWith("> ")) {
|
|
55
|
+
output.push(wrap("\u2502 " + line.slice(2), DIM, ITALIC));
|
|
56
|
+
} else if (/^[-*+] /.test(line)) {
|
|
57
|
+
output.push(" \u2022 " + applyInline(line.slice(2)));
|
|
58
|
+
} else if (/^\d+\. /.test(line)) {
|
|
59
|
+
const match = line.match(/^(\d+\.) (.*)/);
|
|
60
|
+
if (match) {
|
|
61
|
+
output.push(` ${wrap(match[1], BOLD)} ${applyInline(match[2])}`);
|
|
62
|
+
}
|
|
63
|
+
} else if (line.trim() === "") {
|
|
64
|
+
output.push("");
|
|
65
|
+
} else {
|
|
66
|
+
output.push(applyInline(line));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return output;
|
|
70
|
+
}
|
|
71
|
+
function applyInline(text) {
|
|
72
|
+
text = text.replace(/\*\*(.+?)\*\*|__(.+?)__/g, (_, a, b) => wrap(a ?? b, BOLD));
|
|
73
|
+
text = text.replace(/(?<!\*)\*([^*]+)\*(?!\*)|(?<!_)_([^_]+)_(?!_)/g, (_, a, b) => wrap(a ?? b, ITALIC));
|
|
74
|
+
text = text.replace(/`([^`]+)`/g, (_, code) => wrap(code, FG_GREEN, BG_DARK));
|
|
75
|
+
text = text.replace(
|
|
76
|
+
/\[(.+?)\]\((.+?)\)/g,
|
|
77
|
+
(_, label, url) => wrap(label, UNDERLINE, FG_CYAN) + wrap(` (${url})`, DIM)
|
|
78
|
+
);
|
|
79
|
+
return text;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// src/lib/processors/cli-markdown-command-processor.ts
|
|
83
|
+
var CliMarkdownCommandProcessor = class {
|
|
84
|
+
constructor() {
|
|
85
|
+
this.command = "md";
|
|
86
|
+
this.description = "Render Markdown in the terminal";
|
|
87
|
+
this.aliases = ["markdown"];
|
|
88
|
+
this.author = cliCore.DefaultLibraryAuthor;
|
|
89
|
+
this.metadata = { icon: cliCore.CliIcon.File };
|
|
90
|
+
this.processors = [
|
|
91
|
+
{
|
|
92
|
+
command: "render",
|
|
93
|
+
description: "Render Markdown text. Pipe markdown or pass inline.",
|
|
94
|
+
aliases: ["preview", "view"],
|
|
95
|
+
acceptsRawInput: true,
|
|
96
|
+
valueRequired: true,
|
|
97
|
+
processCommand: async (cmd, context) => {
|
|
98
|
+
const input = cmd.value || (typeof cmd.data === "string" ? cmd.data : "") || "";
|
|
99
|
+
if (!input.trim()) {
|
|
100
|
+
context.writer.writeError("No markdown input. Pipe text or provide inline.");
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const lines = renderMarkdown(input);
|
|
104
|
+
for (const line of lines) {
|
|
105
|
+
context.writer.writeln(line);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
];
|
|
110
|
+
}
|
|
111
|
+
async processCommand(_, context) {
|
|
112
|
+
context.writer.writeln('Usage: echo "# Hello" | md render');
|
|
113
|
+
context.writer.writeln(' md render "## Title"');
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// src/lib/version.ts
|
|
118
|
+
var LIBRARY_VERSION = "2.0.0-beta.1";
|
|
119
|
+
var API_VERSION = 2;
|
|
120
|
+
|
|
121
|
+
// src/public-api.ts
|
|
122
|
+
var markdownModule = {
|
|
123
|
+
apiVersion: API_VERSION,
|
|
124
|
+
name: "@qodalis/cli-markdown",
|
|
125
|
+
processors: [new CliMarkdownCommandProcessor()],
|
|
126
|
+
translations: {
|
|
127
|
+
es: { "cli.md.description": "Renderizar Markdown en la terminal" },
|
|
128
|
+
fr: { "cli.md.description": "Afficher du Markdown dans le terminal" },
|
|
129
|
+
de: { "cli.md.description": "Markdown im Terminal rendern" },
|
|
130
|
+
pt: { "cli.md.description": "Renderizar Markdown no terminal" },
|
|
131
|
+
it: { "cli.md.description": "Renderizzare Markdown nel terminale" },
|
|
132
|
+
ja: { "cli.md.description": "\u30BF\u30FC\u30DF\u30CA\u30EB\u3067Markdown\u3092\u63CF\u753B" },
|
|
133
|
+
ko: { "cli.md.description": "\uD130\uBBF8\uB110\uC5D0\uC11C Markdown \uB80C\uB354\uB9C1" },
|
|
134
|
+
zh: { "cli.md.description": "\u5728\u7EC8\u7AEF\u4E2D\u6E32\u67D3 Markdown" },
|
|
135
|
+
ru: { "cli.md.description": "\u0420\u0435\u043D\u0434\u0435\u0440\u0438\u043D\u0433 Markdown \u0432 \u0442\u0435\u0440\u043C\u0438\u043D\u0430\u043B\u0435" },
|
|
136
|
+
ro: { "cli.md.description": "Redare Markdown \xEEn terminal" }
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
exports.API_VERSION = API_VERSION;
|
|
141
|
+
exports.CliMarkdownCommandProcessor = CliMarkdownCommandProcessor;
|
|
142
|
+
exports.LIBRARY_VERSION = LIBRARY_VERSION;
|
|
143
|
+
exports.markdownModule = markdownModule;
|
|
144
|
+
//# sourceMappingURL=public-api.js.map
|
|
145
|
+
//# sourceMappingURL=public-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../packages/plugins/markdown/src/lib/markdown-renderer.ts","../../packages/plugins/markdown/src/lib/processors/cli-markdown-command-processor.ts","../../packages/plugins/markdown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BAAA,EAAsB,+HAAA,EAAiC;AAAA,IAC7D,EAAA,EAAI,EAAE,oBAAA,EAAsB,gCAAA;AAA8B;AAElE","file":"public-api.js","sourcesContent":["const RESET = '\\x1b[0m';\nconst BOLD = '\\x1b[1m';\nconst DIM = '\\x1b[2m';\nconst ITALIC = '\\x1b[3m';\nconst UNDERLINE = '\\x1b[4m';\n\nconst FG_YELLOW = '\\x1b[33m';\nconst FG_CYAN = '\\x1b[36m';\nconst FG_GREEN = '\\x1b[32m';\nconst FG_WHITE = '\\x1b[97m';\nconst BG_DARK = '\\x1b[48;5;236m';\n\nfunction wrap(text: string, ...codes: string[]): string {\n return codes.join('') + text + RESET;\n}\n\nexport function renderMarkdown(input: string): string[] {\n if (!input.trim()) return [];\n\n const rawLines = input.split('\\n');\n const output: string[] = [];\n let inCodeBlock = false;\n\n for (const line of rawLines) {\n if (line.startsWith('```')) {\n if (!inCodeBlock) {\n inCodeBlock = true;\n const lang = line.slice(3).trim();\n output.push(wrap(` ${lang || 'code'} `, DIM, BG_DARK));\n } else {\n inCodeBlock = false;\n output.push(wrap('\\u2500'.repeat(40), DIM));\n }\n continue;\n }\n\n if (inCodeBlock) {\n output.push(wrap(' ' + line, FG_GREEN));\n continue;\n }\n\n if (line.startsWith('### ')) {\n output.push(wrap(line.slice(4), BOLD, FG_CYAN));\n } else if (line.startsWith('## ')) {\n const text = line.slice(3);\n output.push(wrap(text, BOLD, FG_YELLOW));\n output.push(wrap('\\u2500'.repeat(text.length), FG_YELLOW));\n } else if (line.startsWith('# ')) {\n const text = line.slice(2);\n output.push(wrap(text, BOLD, UNDERLINE, FG_WHITE));\n output.push('');\n } else if (/^(-{3,}|\\*{3,}|_{3,})$/.test(line.trim())) {\n output.push(wrap('\\u2500'.repeat(60), DIM));\n } else if (line.startsWith('> ')) {\n output.push(wrap('\\u2502 ' + line.slice(2), DIM, ITALIC));\n } else if (/^[-*+] /.test(line)) {\n output.push(' \\u2022 ' + applyInline(line.slice(2)));\n } else if (/^\\d+\\. /.test(line)) {\n const match = line.match(/^(\\d+\\.) (.*)/);\n if (match) {\n output.push(` ${wrap(match[1], BOLD)} ${applyInline(match[2])}`);\n }\n } else if (line.trim() === '') {\n output.push('');\n } else {\n output.push(applyInline(line));\n }\n }\n\n return output;\n}\n\nfunction applyInline(text: string): string {\n // Bold **text** or __text__\n text = text.replace(/\\*\\*(.+?)\\*\\*|__(.+?)__/g, (_, a, b) => wrap(a ?? b, BOLD));\n // Italic *text* or _text_\n text = text.replace(/(?<!\\*)\\*([^*]+)\\*(?!\\*)|(?<!_)_([^_]+)_(?!_)/g, (_, a, b) => wrap(a ?? b, ITALIC));\n // Inline code `text`\n text = text.replace(/`([^`]+)`/g, (_, code) => wrap(code, FG_GREEN, BG_DARK));\n // Links [text](url)\n text = text.replace(/\\[(.+?)\\]\\((.+?)\\)/g, (_, label, url) =>\n wrap(label, UNDERLINE, FG_CYAN) + wrap(` (${url})`, DIM),\n );\n return text;\n}\n","import {\n ICliCommandProcessor,\n ICliExecutionContext,\n CliProcessCommand,\n DefaultLibraryAuthor,\n CliIcon,\n ICliCommandChildProcessor,\n} from '@qodalis/cli-core';\nimport { renderMarkdown } from '../markdown-renderer';\n\nexport class CliMarkdownCommandProcessor implements ICliCommandProcessor {\n command = 'md';\n description = 'Render Markdown in the terminal';\n aliases = ['markdown'];\n author = DefaultLibraryAuthor;\n metadata = { icon: CliIcon.File };\n\n processors: ICliCommandChildProcessor[] = [\n {\n command: 'render',\n description: 'Render Markdown text. Pipe markdown or pass inline.',\n aliases: ['preview', 'view'],\n acceptsRawInput: true,\n valueRequired: true,\n processCommand: async (cmd: CliProcessCommand, context: ICliExecutionContext) => {\n const input = cmd.value || (typeof cmd.data === 'string' ? cmd.data : '') || '';\n if (!input.trim()) {\n context.writer.writeError('No markdown input. Pipe text or provide inline.');\n return;\n }\n const lines = renderMarkdown(input);\n for (const line of lines) {\n context.writer.writeln(line);\n }\n },\n },\n ];\n\n async processCommand(_: CliProcessCommand, context: ICliExecutionContext): Promise<void> {\n context.writer.writeln('Usage: echo \"# Hello\" | md render');\n context.writer.writeln(' md render \"## Title\"');\n }\n}\n","\n// Automatically generated during build\nexport const LIBRARY_VERSION = '2.0.0-beta.1';\nexport const API_VERSION = 2;\n ","/*\n * Public API Surface of markdown\n */\n\nexport * from './lib/processors/cli-markdown-command-processor';\nexport * from './lib/version';\n\nimport { ICliModule } from '@qodalis/cli-core';\nimport { CliMarkdownCommandProcessor } from './lib/processors/cli-markdown-command-processor';\nimport { API_VERSION } from './lib/version';\n\nexport const markdownModule: ICliModule = {\n apiVersion: API_VERSION,\n name: '@qodalis/cli-markdown',\n processors: [new CliMarkdownCommandProcessor()],\n translations: {\n es: { 'cli.md.description': 'Renderizar Markdown en la terminal' },\n fr: { 'cli.md.description': 'Afficher du Markdown dans le terminal' },\n de: { 'cli.md.description': 'Markdown im Terminal rendern' },\n pt: { 'cli.md.description': 'Renderizar Markdown no terminal' },\n it: { 'cli.md.description': 'Renderizzare Markdown nel terminale' },\n ja: { 'cli.md.description': 'ターミナルでMarkdownを描画' },\n ko: { 'cli.md.description': '터미널에서 Markdown 렌더링' },\n zh: { 'cli.md.description': '在终端中渲染 Markdown' },\n ru: { 'cli.md.description': 'Рендеринг Markdown в терминале' },\n ro: { 'cli.md.description': 'Redare Markdown în terminal' },\n },\n};\n"]}
|
package/public-api.mjs
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { DefaultLibraryAuthor, CliIcon } from '@qodalis/cli-core';
|
|
2
|
+
|
|
3
|
+
// src/lib/processors/cli-markdown-command-processor.ts
|
|
4
|
+
|
|
5
|
+
// src/lib/markdown-renderer.ts
|
|
6
|
+
var RESET = "\x1B[0m";
|
|
7
|
+
var BOLD = "\x1B[1m";
|
|
8
|
+
var DIM = "\x1B[2m";
|
|
9
|
+
var ITALIC = "\x1B[3m";
|
|
10
|
+
var UNDERLINE = "\x1B[4m";
|
|
11
|
+
var FG_YELLOW = "\x1B[33m";
|
|
12
|
+
var FG_CYAN = "\x1B[36m";
|
|
13
|
+
var FG_GREEN = "\x1B[32m";
|
|
14
|
+
var FG_WHITE = "\x1B[97m";
|
|
15
|
+
var BG_DARK = "\x1B[48;5;236m";
|
|
16
|
+
function wrap(text, ...codes) {
|
|
17
|
+
return codes.join("") + text + RESET;
|
|
18
|
+
}
|
|
19
|
+
function renderMarkdown(input) {
|
|
20
|
+
if (!input.trim()) return [];
|
|
21
|
+
const rawLines = input.split("\n");
|
|
22
|
+
const output = [];
|
|
23
|
+
let inCodeBlock = false;
|
|
24
|
+
for (const line of rawLines) {
|
|
25
|
+
if (line.startsWith("```")) {
|
|
26
|
+
if (!inCodeBlock) {
|
|
27
|
+
inCodeBlock = true;
|
|
28
|
+
const lang = line.slice(3).trim();
|
|
29
|
+
output.push(wrap(` ${lang || "code"} `, DIM, BG_DARK));
|
|
30
|
+
} else {
|
|
31
|
+
inCodeBlock = false;
|
|
32
|
+
output.push(wrap("\u2500".repeat(40), DIM));
|
|
33
|
+
}
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (inCodeBlock) {
|
|
37
|
+
output.push(wrap(" " + line, FG_GREEN));
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (line.startsWith("### ")) {
|
|
41
|
+
output.push(wrap(line.slice(4), BOLD, FG_CYAN));
|
|
42
|
+
} else if (line.startsWith("## ")) {
|
|
43
|
+
const text = line.slice(3);
|
|
44
|
+
output.push(wrap(text, BOLD, FG_YELLOW));
|
|
45
|
+
output.push(wrap("\u2500".repeat(text.length), FG_YELLOW));
|
|
46
|
+
} else if (line.startsWith("# ")) {
|
|
47
|
+
const text = line.slice(2);
|
|
48
|
+
output.push(wrap(text, BOLD, UNDERLINE, FG_WHITE));
|
|
49
|
+
output.push("");
|
|
50
|
+
} else if (/^(-{3,}|\*{3,}|_{3,})$/.test(line.trim())) {
|
|
51
|
+
output.push(wrap("\u2500".repeat(60), DIM));
|
|
52
|
+
} else if (line.startsWith("> ")) {
|
|
53
|
+
output.push(wrap("\u2502 " + line.slice(2), DIM, ITALIC));
|
|
54
|
+
} else if (/^[-*+] /.test(line)) {
|
|
55
|
+
output.push(" \u2022 " + applyInline(line.slice(2)));
|
|
56
|
+
} else if (/^\d+\. /.test(line)) {
|
|
57
|
+
const match = line.match(/^(\d+\.) (.*)/);
|
|
58
|
+
if (match) {
|
|
59
|
+
output.push(` ${wrap(match[1], BOLD)} ${applyInline(match[2])}`);
|
|
60
|
+
}
|
|
61
|
+
} else if (line.trim() === "") {
|
|
62
|
+
output.push("");
|
|
63
|
+
} else {
|
|
64
|
+
output.push(applyInline(line));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return output;
|
|
68
|
+
}
|
|
69
|
+
function applyInline(text) {
|
|
70
|
+
text = text.replace(/\*\*(.+?)\*\*|__(.+?)__/g, (_, a, b) => wrap(a ?? b, BOLD));
|
|
71
|
+
text = text.replace(/(?<!\*)\*([^*]+)\*(?!\*)|(?<!_)_([^_]+)_(?!_)/g, (_, a, b) => wrap(a ?? b, ITALIC));
|
|
72
|
+
text = text.replace(/`([^`]+)`/g, (_, code) => wrap(code, FG_GREEN, BG_DARK));
|
|
73
|
+
text = text.replace(
|
|
74
|
+
/\[(.+?)\]\((.+?)\)/g,
|
|
75
|
+
(_, label, url) => wrap(label, UNDERLINE, FG_CYAN) + wrap(` (${url})`, DIM)
|
|
76
|
+
);
|
|
77
|
+
return text;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// src/lib/processors/cli-markdown-command-processor.ts
|
|
81
|
+
var CliMarkdownCommandProcessor = class {
|
|
82
|
+
constructor() {
|
|
83
|
+
this.command = "md";
|
|
84
|
+
this.description = "Render Markdown in the terminal";
|
|
85
|
+
this.aliases = ["markdown"];
|
|
86
|
+
this.author = DefaultLibraryAuthor;
|
|
87
|
+
this.metadata = { icon: CliIcon.File };
|
|
88
|
+
this.processors = [
|
|
89
|
+
{
|
|
90
|
+
command: "render",
|
|
91
|
+
description: "Render Markdown text. Pipe markdown or pass inline.",
|
|
92
|
+
aliases: ["preview", "view"],
|
|
93
|
+
acceptsRawInput: true,
|
|
94
|
+
valueRequired: true,
|
|
95
|
+
processCommand: async (cmd, context) => {
|
|
96
|
+
const input = cmd.value || (typeof cmd.data === "string" ? cmd.data : "") || "";
|
|
97
|
+
if (!input.trim()) {
|
|
98
|
+
context.writer.writeError("No markdown input. Pipe text or provide inline.");
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const lines = renderMarkdown(input);
|
|
102
|
+
for (const line of lines) {
|
|
103
|
+
context.writer.writeln(line);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
];
|
|
108
|
+
}
|
|
109
|
+
async processCommand(_, context) {
|
|
110
|
+
context.writer.writeln('Usage: echo "# Hello" | md render');
|
|
111
|
+
context.writer.writeln(' md render "## Title"');
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// src/lib/version.ts
|
|
116
|
+
var LIBRARY_VERSION = "2.0.0-beta.1";
|
|
117
|
+
var API_VERSION = 2;
|
|
118
|
+
|
|
119
|
+
// src/public-api.ts
|
|
120
|
+
var markdownModule = {
|
|
121
|
+
apiVersion: API_VERSION,
|
|
122
|
+
name: "@qodalis/cli-markdown",
|
|
123
|
+
processors: [new CliMarkdownCommandProcessor()],
|
|
124
|
+
translations: {
|
|
125
|
+
es: { "cli.md.description": "Renderizar Markdown en la terminal" },
|
|
126
|
+
fr: { "cli.md.description": "Afficher du Markdown dans le terminal" },
|
|
127
|
+
de: { "cli.md.description": "Markdown im Terminal rendern" },
|
|
128
|
+
pt: { "cli.md.description": "Renderizar Markdown no terminal" },
|
|
129
|
+
it: { "cli.md.description": "Renderizzare Markdown nel terminale" },
|
|
130
|
+
ja: { "cli.md.description": "\u30BF\u30FC\u30DF\u30CA\u30EB\u3067Markdown\u3092\u63CF\u753B" },
|
|
131
|
+
ko: { "cli.md.description": "\uD130\uBBF8\uB110\uC5D0\uC11C Markdown \uB80C\uB354\uB9C1" },
|
|
132
|
+
zh: { "cli.md.description": "\u5728\u7EC8\u7AEF\u4E2D\u6E32\u67D3 Markdown" },
|
|
133
|
+
ru: { "cli.md.description": "\u0420\u0435\u043D\u0434\u0435\u0440\u0438\u043D\u0433 Markdown \u0432 \u0442\u0435\u0440\u043C\u0438\u043D\u0430\u043B\u0435" },
|
|
134
|
+
ro: { "cli.md.description": "Redare Markdown \xEEn terminal" }
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export { API_VERSION, CliMarkdownCommandProcessor, LIBRARY_VERSION, markdownModule };
|
|
139
|
+
//# sourceMappingURL=public-api.mjs.map
|
|
140
|
+
//# sourceMappingURL=public-api.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../packages/plugins/markdown/src/lib/markdown-renderer.ts","../../packages/plugins/markdown/src/lib/processors/cli-markdown-command-processor.ts","../../packages/plugins/markdown/src/lib/version.ts","../../packages/plugins/markdown/src/public-api.ts"],"names":[],"mappings":";;;;;AAAA,IAAM,KAAA,GAAQ,SAAA;AACd,IAAM,IAAA,GAAO,SAAA;AACb,IAAM,GAAA,GAAM,SAAA;AACZ,IAAM,MAAA,GAAS,SAAA;AACf,IAAM,SAAA,GAAY,SAAA;AAElB,IAAM,SAAA,GAAY,UAAA;AAClB,IAAM,OAAA,GAAU,UAAA;AAChB,IAAM,QAAA,GAAW,UAAA;AACjB,IAAM,QAAA,GAAW,UAAA;AACjB,IAAM,OAAA,GAAU,gBAAA;AAEhB,SAAS,IAAA,CAAK,SAAiB,KAAA,EAAyB;AACpD,EAAA,OAAO,KAAA,CAAM,IAAA,CAAK,EAAE,CAAA,GAAI,IAAA,GAAO,KAAA;AACnC;AAEO,SAAS,eAAe,KAAA,EAAyB;AACpD,EAAA,IAAI,CAAC,KAAA,CAAM,IAAA,EAAK,SAAU,EAAC;AAE3B,EAAA,MAAM,QAAA,GAAW,KAAA,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A;AAAA,EACN,UAAA,EAAY,CAAC,IAAI,2BAAA,EAA6B,CAAA;AAAA,EAC9C,YAAA,EAAc;AAAA,IACV,EAAA,EAAI,EAAE,oBAAA,EAAsB,oCAAA,EAAqC;AAAA,IACjE,EAAA,EAAI,EAAE,oBAAA,EAAsB,uCAAA,EAAwC;AAAA,IACpE,EAAA,EAAI,EAAE,oBAAA,EAAsB,8BAAA,EAA+B;AAAA,IAC3D,EAAA,EAAI,EAAE,oBAAA,EAAsB,iCAAA,EAAkC;AAAA,IAC9D,EAAA,EAAI,EAAE,oBAAA,EAAsB,qCAAA,EAAsC;AAAA,IAClE,EAAA,EAAI,EAAE,oBAAA,EAAsB,gEAAA,EAAoB;AAAA,IAChD,EAAA,EAAI,EAAE,oBAAA,EAAsB,4DAAA,EAAqB;AAAA,IACjD,EAAA,EAAI,EAAE,oBAAA,EAAsB,+CAAA,EAAkB;AAAA,IAC9C,EAAA,EAAI,EAAE,oBAAA,EAAsB,+HAAA,EAAiC;AAAA,IAC7D,EAAA,EAAI,EAAE,oBAAA,EAAsB,gCAAA;AAA8B;AAElE","file":"public-api.mjs","sourcesContent":["const RESET = '\\x1b[0m';\nconst BOLD = '\\x1b[1m';\nconst DIM = '\\x1b[2m';\nconst ITALIC = '\\x1b[3m';\nconst UNDERLINE = '\\x1b[4m';\n\nconst FG_YELLOW = '\\x1b[33m';\nconst FG_CYAN = '\\x1b[36m';\nconst FG_GREEN = '\\x1b[32m';\nconst FG_WHITE = '\\x1b[97m';\nconst BG_DARK = '\\x1b[48;5;236m';\n\nfunction wrap(text: string, ...codes: string[]): string {\n return codes.join('') + text + RESET;\n}\n\nexport function renderMarkdown(input: string): string[] {\n if (!input.trim()) return [];\n\n const rawLines = input.split('\\n');\n const output: string[] = [];\n let inCodeBlock = false;\n\n for (const line of rawLines) {\n if (line.startsWith('```')) {\n if (!inCodeBlock) {\n inCodeBlock = true;\n const lang = line.slice(3).trim();\n output.push(wrap(` ${lang || 'code'} `, DIM, BG_DARK));\n } else {\n inCodeBlock = false;\n output.push(wrap('\\u2500'.repeat(40), DIM));\n }\n continue;\n }\n\n if (inCodeBlock) {\n output.push(wrap(' ' + line, FG_GREEN));\n continue;\n }\n\n if (line.startsWith('### ')) {\n output.push(wrap(line.slice(4), BOLD, FG_CYAN));\n } else if (line.startsWith('## ')) {\n const text = line.slice(3);\n output.push(wrap(text, BOLD, FG_YELLOW));\n output.push(wrap('\\u2500'.repeat(text.length), FG_YELLOW));\n } else if (line.startsWith('# ')) {\n const text = line.slice(2);\n output.push(wrap(text, BOLD, UNDERLINE, FG_WHITE));\n output.push('');\n } else if (/^(-{3,}|\\*{3,}|_{3,})$/.test(line.trim())) {\n output.push(wrap('\\u2500'.repeat(60), DIM));\n } else if (line.startsWith('> ')) {\n output.push(wrap('\\u2502 ' + line.slice(2), DIM, ITALIC));\n } else if (/^[-*+] /.test(line)) {\n output.push(' \\u2022 ' + applyInline(line.slice(2)));\n } else if (/^\\d+\\. /.test(line)) {\n const match = line.match(/^(\\d+\\.) (.*)/);\n if (match) {\n output.push(` ${wrap(match[1], BOLD)} ${applyInline(match[2])}`);\n }\n } else if (line.trim() === '') {\n output.push('');\n } else {\n output.push(applyInline(line));\n }\n }\n\n return output;\n}\n\nfunction applyInline(text: string): string {\n // Bold **text** or __text__\n text = text.replace(/\\*\\*(.+?)\\*\\*|__(.+?)__/g, (_, a, b) => wrap(a ?? b, BOLD));\n // Italic *text* or _text_\n text = text.replace(/(?<!\\*)\\*([^*]+)\\*(?!\\*)|(?<!_)_([^_]+)_(?!_)/g, (_, a, b) => wrap(a ?? b, ITALIC));\n // Inline code `text`\n text = text.replace(/`([^`]+)`/g, (_, code) => wrap(code, FG_GREEN, BG_DARK));\n // Links [text](url)\n text = text.replace(/\\[(.+?)\\]\\((.+?)\\)/g, (_, label, url) =>\n wrap(label, UNDERLINE, FG_CYAN) + wrap(` (${url})`, DIM),\n );\n return text;\n}\n","import {\n ICliCommandProcessor,\n ICliExecutionContext,\n CliProcessCommand,\n DefaultLibraryAuthor,\n CliIcon,\n ICliCommandChildProcessor,\n} from '@qodalis/cli-core';\nimport { renderMarkdown } from '../markdown-renderer';\n\nexport class CliMarkdownCommandProcessor implements ICliCommandProcessor {\n command = 'md';\n description = 'Render Markdown in the terminal';\n aliases = ['markdown'];\n author = DefaultLibraryAuthor;\n metadata = { icon: CliIcon.File };\n\n processors: ICliCommandChildProcessor[] = [\n {\n command: 'render',\n description: 'Render Markdown text. Pipe markdown or pass inline.',\n aliases: ['preview', 'view'],\n acceptsRawInput: true,\n valueRequired: true,\n processCommand: async (cmd: CliProcessCommand, context: ICliExecutionContext) => {\n const input = cmd.value || (typeof cmd.data === 'string' ? cmd.data : '') || '';\n if (!input.trim()) {\n context.writer.writeError('No markdown input. Pipe text or provide inline.');\n return;\n }\n const lines = renderMarkdown(input);\n for (const line of lines) {\n context.writer.writeln(line);\n }\n },\n },\n ];\n\n async processCommand(_: CliProcessCommand, context: ICliExecutionContext): Promise<void> {\n context.writer.writeln('Usage: echo \"# Hello\" | md render');\n context.writer.writeln(' md render \"## Title\"');\n }\n}\n","\n// Automatically generated during build\nexport const LIBRARY_VERSION = '2.0.0-beta.1';\nexport const API_VERSION = 2;\n ","/*\n * Public API Surface of markdown\n */\n\nexport * from './lib/processors/cli-markdown-command-processor';\nexport * from './lib/version';\n\nimport { ICliModule } from '@qodalis/cli-core';\nimport { CliMarkdownCommandProcessor } from './lib/processors/cli-markdown-command-processor';\nimport { API_VERSION } from './lib/version';\n\nexport const markdownModule: ICliModule = {\n apiVersion: API_VERSION,\n name: '@qodalis/cli-markdown',\n processors: [new CliMarkdownCommandProcessor()],\n translations: {\n es: { 'cli.md.description': 'Renderizar Markdown en la terminal' },\n fr: { 'cli.md.description': 'Afficher du Markdown dans le terminal' },\n de: { 'cli.md.description': 'Markdown im Terminal rendern' },\n pt: { 'cli.md.description': 'Renderizar Markdown no terminal' },\n it: { 'cli.md.description': 'Renderizzare Markdown nel terminale' },\n ja: { 'cli.md.description': 'ターミナルでMarkdownを描画' },\n ko: { 'cli.md.description': '터미널에서 Markdown 렌더링' },\n zh: { 'cli.md.description': '在终端中渲染 Markdown' },\n ru: { 'cli.md.description': 'Рендеринг Markdown в терминале' },\n ro: { 'cli.md.description': 'Redare Markdown în terminal' },\n },\n};\n"]}
|