@paperclover/markodown 1.0.0-rc.10
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 +15 -0
- package/README.md +298 -0
- package/_dist/esbuild.d.ts +14 -0
- package/_dist/esbuild.d.ts.map +1 -0
- package/_dist/mod.d.ts +139 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/rollup.d.ts +11 -0
- package/_dist/rollup.d.ts.map +1 -0
- package/bindgen/markodown.d.ts +42 -0
- package/bindgen/markodown.js +416 -0
- package/bindgen/wasm_bytes.d.ts +2 -0
- package/bindgen/wasm_bytes.js +2 -0
- package/clover.test.ts +343 -0
- package/esbuild.js +70 -0
- package/esbuild.js.map +1 -0
- package/esbuild.ts +88 -0
- package/mod.js +63 -0
- package/mod.js.map +1 -0
- package/mod.test.ts +127 -0
- package/mod.ts +252 -0
- package/package.json +39 -0
- package/rollup.js +54 -0
- package/rollup.js.map +1 -0
- package/rollup.ts +68 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright 2026 clover caruso
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
6
|
+
with or without fee is hereby granted, provided that the above copyright notice
|
|
7
|
+
and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
11
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
13
|
+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
14
|
+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
15
|
+
THIS SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
# Markodown
|
|
2
|
+
|
|
3
|
+
> STATUS: Markodown is not yet in use at paperclover.net. However, the API is
|
|
4
|
+
> complete and the library is functional. Give it a try!
|
|
5
|
+
|
|
6
|
+
This is a weird markup language that combines features of [Markdown] and
|
|
7
|
+
[Marko]. You can think of this as an alternative universe to MDX. Since Marko
|
|
8
|
+
components are really easy to write, it makes this a great tool for writing
|
|
9
|
+
interactive blog posts. Markdown is compiled directly into `.marko` syntax,
|
|
10
|
+
leveraging the existing ecosystem.
|
|
11
|
+
|
|
12
|
+
[Markdown]: https://en.wikipedia.org/wiki/Markdown
|
|
13
|
+
[Marko]: https://markojs.com/
|
|
14
|
+
|
|
15
|
+
> - [Usage](#usage)
|
|
16
|
+
> - [Components](#components)
|
|
17
|
+
> - [Outline / Table of Contents](#outline-table-of-contents)
|
|
18
|
+
> - [Frontmatter](#frontmatter)
|
|
19
|
+
> - [Comments](#comments)
|
|
20
|
+
> - [Paragraph Detection](#paragraph-detection)
|
|
21
|
+
> - [Static Statements](#static-statements)
|
|
22
|
+
> - [Config](#config)
|
|
23
|
+
> - [Frontmatter Layout Configuration](#frontmatter-layout-configuration)
|
|
24
|
+
|
|
25
|
+
Here's a glance at how things look. Complete example documents in <./examples>
|
|
26
|
+
|
|
27
|
+
````
|
|
28
|
+
---
|
|
29
|
+
// in `clover` static site generator, `export const meta` powers meta and
|
|
30
|
+
// open graph tags. frontmatter becomes exports and in-scope constants.
|
|
31
|
+
meta:
|
|
32
|
+
title: some interesting blog post
|
|
33
|
+
description: i could be really interesting
|
|
34
|
+
embed:
|
|
35
|
+
image: /something/fire.png
|
|
36
|
+
---
|
|
37
|
+
// this component will look for `blog-layout.marko`
|
|
38
|
+
<blog-layout title=meta.title description=meta.description>
|
|
39
|
+
|
|
40
|
+
# ${meta.title}
|
|
41
|
+
|
|
42
|
+
i'm a catgirl and i love to **meow**! <rainbow-text>meow meow meow!</>
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
function doMyFavoriteThing() {
|
|
46
|
+
return "meow! ".repeat(Math.floor(Math.random() * 1000)).trim();
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## photos of my favorite people
|
|
51
|
+
|
|
52
|
+
i love using Marko components because they're extremely concise to write.
|
|
53
|
+
a lot less brace hell for non-string attributes, and more treats!
|
|
54
|
+
|
|
55
|
+
<photo-grid
|
|
56
|
+
base="/friends"
|
|
57
|
+
cols=[40, 30, 30]
|
|
58
|
+
rows=[300, 400, 200]
|
|
59
|
+
>
|
|
60
|
+
<@img src="IMG_4831.jpeg" />
|
|
61
|
+
<@img src="IMG_4838.jpeg" w=2 />
|
|
62
|
+
<@img src="IMG_4839.jpeg" w=2 align="top" />
|
|
63
|
+
<@img src="IMG_4833.jpeg" h=2 />
|
|
64
|
+
<@img src="IMG_4832.jpeg" w=2 />
|
|
65
|
+
</>
|
|
66
|
+
|
|
67
|
+
## in conclusion
|
|
68
|
+
|
|
69
|
+
i love being alive. ${'<3'} from ${new Date().getFullYear()}.
|
|
70
|
+
|
|
71
|
+
</blog-layout>
|
|
72
|
+
````
|
|
73
|
+
|
|
74
|
+
## Usage
|
|
75
|
+
|
|
76
|
+
Markodown is distributed on
|
|
77
|
+
[NPM](https://npmjs.com/package/@paperclover/markodown) and
|
|
78
|
+
[JSR](https://jsr.io/@clo/markodown). The compiler runs anywhere JS+WASM runs.
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
# alias install
|
|
82
|
+
npm i @clo/markodown@npm:@paperclover/markodown
|
|
83
|
+
# or
|
|
84
|
+
npx jsr add @clo/markodown
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
The compiler can be directly used from `transform`, and there are also plugins
|
|
88
|
+
for Rollup/Rolldown/Vite and esbuild. For example, configure Markodown with
|
|
89
|
+
Marko Run:
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
import marko from "@marko/run/vite";
|
|
93
|
+
import markodown from "@clo/markodown";
|
|
94
|
+
import { defineConfig } from "vite";
|
|
95
|
+
|
|
96
|
+
export default defineConfig({
|
|
97
|
+
plugins: [
|
|
98
|
+
marko(),
|
|
99
|
+
markodown({
|
|
100
|
+
// optionally wrap all markdown files in a layout, this component is
|
|
101
|
+
// given a list of headers to construct a table of contents.
|
|
102
|
+
layoutImport: "../tags/markdown-layout.marko",
|
|
103
|
+
// ...more customization options are well-documented in the types.
|
|
104
|
+
}),
|
|
105
|
+
],
|
|
106
|
+
});
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Components
|
|
110
|
+
|
|
111
|
+
All Marko features are supported, such as [tag resolution], [attribute tags],
|
|
112
|
+
[class shorthands], and template expressions. This makes it so much easier to
|
|
113
|
+
add complex content to your pages.
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
## cool video
|
|
117
|
+
|
|
118
|
+
<clover-video src="/2025/in the summer/in the summer.mp4">
|
|
119
|
+
<@header>**music video**: in the summer</>
|
|
120
|
+
</clover-video>
|
|
121
|
+
|
|
122
|
+
<footer.copyright-info>
|
|
123
|
+
made with love... (c) ${new Date().getFullYear()}
|
|
124
|
+
</footer>
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
[tag resolution]: https://markojs.com/docs/reference/custom-tag#relative-custom-tags
|
|
128
|
+
[attribute tags]: https://markojs.com/docs/reference/language#attribute-tags
|
|
129
|
+
[class shorthands]: https://markojs.com/docs/reference/language#shorthand-class-and-id
|
|
130
|
+
|
|
131
|
+
### Outline / Table of Contents
|
|
132
|
+
|
|
133
|
+
You can use Markodown to write blogs and long documents, then extract a table of
|
|
134
|
+
contents. This is done with two mechanisms.
|
|
135
|
+
|
|
136
|
+
- `layoutImport` which wraps the entire document in a component, which is given
|
|
137
|
+
three attributes. (see typescript types on the plugin / `transform` function)
|
|
138
|
+
- `content`: the rendered content.
|
|
139
|
+
- `module`: the module namespace for the compiled Markodown file.
|
|
140
|
+
- `outline`: an array of `Heading` objects.
|
|
141
|
+
- `componentImports`, which can let you customize the rendering of the headers
|
|
142
|
+
themselves.
|
|
143
|
+
|
|
144
|
+
Using the basic heading tags is awesome, because you can very easily customize
|
|
145
|
+
the generated permalinks for each heading, and still use Markdown within the
|
|
146
|
+
heading titles.
|
|
147
|
+
|
|
148
|
+
```
|
|
149
|
+
# my blog post
|
|
150
|
+
|
|
151
|
+
<h2#markdown>about `markdown`</>
|
|
152
|
+
|
|
153
|
+
...
|
|
154
|
+
|
|
155
|
+
<h2#marko>about `marko`</>
|
|
156
|
+
|
|
157
|
+
...
|
|
158
|
+
|
|
159
|
+
<h3#marko-extras>some extra details</>
|
|
160
|
+
|
|
161
|
+
...
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Frontmatter
|
|
165
|
+
|
|
166
|
+
All frontmatter fields are converted into exports. For example, a framework that
|
|
167
|
+
reads the `meta` export for Open Graph can be easily satisfied with frontmatter.
|
|
168
|
+
|
|
169
|
+
```
|
|
170
|
+
---
|
|
171
|
+
meta:
|
|
172
|
+
title: I Love Modular Software
|
|
173
|
+
description: a very cute little post by me
|
|
174
|
+
author: clover caruso
|
|
175
|
+
embed:
|
|
176
|
+
thumbnail: /file/blog.png
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
// And since `export const` puts the value in scope, this works too:
|
|
180
|
+
|
|
181
|
+
# ${meta.title}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Comments
|
|
185
|
+
|
|
186
|
+
Line, Block, and HTML comments work like they do in Marko/JavaScript.
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
# My Blog
|
|
190
|
+
|
|
191
|
+
Text that is complete.
|
|
192
|
+
|
|
193
|
+
// ## An unfinished section of the blog
|
|
194
|
+
//
|
|
195
|
+
// TODO: we gotta finish it!
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Paragraph Detection
|
|
199
|
+
|
|
200
|
+
Like Markdown, you can place content between components, but you can also place
|
|
201
|
+
inline markdown anywhere between tags. Effectively, this means that text gets
|
|
202
|
+
wrapped in `<p>` tags if there is a blank line above and below it.
|
|
203
|
+
|
|
204
|
+
```
|
|
205
|
+
<div>not wrapped</div>
|
|
206
|
+
<div>
|
|
207
|
+
not wrapped either
|
|
208
|
+
</div>
|
|
209
|
+
|
|
210
|
+
<div>
|
|
211
|
+
|
|
212
|
+
this paragraph gets wrapped in a `<p>` tag!
|
|
213
|
+
|
|
214
|
+
</div>
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Static Statements
|
|
218
|
+
|
|
219
|
+
You can define module-level functions and variables,
|
|
220
|
+
[same as you can in Marko](https://markojs.com/docs/reference/language#statements).
|
|
221
|
+
|
|
222
|
+
```
|
|
223
|
+
static function sort(items: string[]) {
|
|
224
|
+
while (!isSorted()) {
|
|
225
|
+
shuffle(items);
|
|
226
|
+
}
|
|
227
|
+
return items;
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Note that this means writing a paragraph starting with the lowercase words
|
|
232
|
+
`static`, `export`, `import`, `server`, and `client` all must be escaped.
|
|
233
|
+
|
|
234
|
+
```
|
|
235
|
+
# All About RSC
|
|
236
|
+
|
|
237
|
+
\server components are a bad idea. (markdown backslash)
|
|
238
|
+
|
|
239
|
+
${"server"} components are a bad idea. (template literal)
|
|
240
|
+
|
|
241
|
+
Though you can say import as long as it's not the first item.
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## Config
|
|
245
|
+
|
|
246
|
+
You can configure Markodown globally via arguments to the `transform` function.
|
|
247
|
+
|
|
248
|
+
### Frontmatter Layout Configuration
|
|
249
|
+
|
|
250
|
+
If frontmatter defines a `layout` property, is acts as a component import that
|
|
251
|
+
wraps the page. (This can also be configured globally with the `layoutImport`
|
|
252
|
+
property to `transform`).
|
|
253
|
+
|
|
254
|
+
```
|
|
255
|
+
---
|
|
256
|
+
title: my amazing post
|
|
257
|
+
layout: ../layout.marko
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## my document
|
|
261
|
+
|
|
262
|
+
yap yap
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
In `layout.marko`, you can customize extensively how the document is formatted.
|
|
266
|
+
|
|
267
|
+
```marko
|
|
268
|
+
import { Heading } from "@clo/markodown";
|
|
269
|
+
|
|
270
|
+
export interface Input {
|
|
271
|
+
content: Marko.Body;
|
|
272
|
+
|
|
273
|
+
/** Markdown scans for headings (h1..h6) */
|
|
274
|
+
outline: Heading[];
|
|
275
|
+
/** This is the namespace import of the main document.
|
|
276
|
+
* You can reflect frontmatter, or do whatever with this. */
|
|
277
|
+
module: Record<string, unknown>;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
<main>
|
|
281
|
+
<h1>${input.module.title ?? "Blog Post"}</h1>
|
|
282
|
+
<aside>
|
|
283
|
+
<for|heading| of=input.outline>
|
|
284
|
+
// heading content includes formatting, even custom tags.
|
|
285
|
+
<li><a href=`#${heading.id}`><${heading.content}/></a></li>
|
|
286
|
+
</for>
|
|
287
|
+
</aside>
|
|
288
|
+
|
|
289
|
+
<${input.content} />
|
|
290
|
+
</main>
|
|
291
|
+
|
|
292
|
+
// Additionally, built-in components can be altered.
|
|
293
|
+
import CustomHeader from "./custom-header.marko";
|
|
294
|
+
export const components = {
|
|
295
|
+
heading: CustomHeader,
|
|
296
|
+
// link, image, codeBlock, blockquote
|
|
297
|
+
};
|
|
298
|
+
```
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as markodown from "./mod.js";
|
|
2
|
+
import * as marko from "@marko/compiler";
|
|
3
|
+
import type * as esbuild from "esbuild";
|
|
4
|
+
export type EsbuildPluginOptions = Omit<markodown.TransformOptions, "source" | "format"> & {
|
|
5
|
+
marko?: typeof marko;
|
|
6
|
+
markoOptions?: marko.Config;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* esbuild or Bun bundling plugin. Because Bun markets itself as compatible with
|
|
10
|
+
* plugins made for esbuild, this plugin is designed to work around differences
|
|
11
|
+
* in Bun's implementation to allow it to work. Bugs reported for subtle behavior
|
|
12
|
+
* mistakes that are not present when using `esbuild` will not be fixed.
|
|
13
|
+
*/ export default function esbuildPlugin(options?: EsbuildPluginOptions): esbuild.Plugin;
|
|
14
|
+
//# sourceMappingURL=esbuild.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"esbuild.d.ts","sources":["../esbuild.ts"],"names":[],"mappings":"AAAA,YAAY,0BAA0B;AACtC,YAAY,6BAAoC;AAChD,iBAAiB,uBAA+B;AAIhD,YAAY,uBACR,KAAK,UAAU,kBAAkB,WAAW;EAE5C,eAAe;EACf,eAAe,MAAM;;AAGzB;;;;;CAKC,GACD,eAAe,SAAS,cACtB,UAAS,oBAAyB,GACjC,QAAQ"}
|
package/_dist/mod.d.ts
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/** The result of a Markodown transform */ export type Transformed = Success | Failure;
|
|
2
|
+
/** Convert Markodown (`.mdo`) source code into Marko source code (`.marko`) */ export declare function transform(options: TransformOptions): Transformed;
|
|
3
|
+
/**
|
|
4
|
+
* Converts a flat document outline into a nested tree. You can consume this
|
|
5
|
+
* tree with a recursive Marko component:
|
|
6
|
+
|
|
7
|
+
* ```marko
|
|
8
|
+
* <define/Recurse|input: HeadingTree|>
|
|
9
|
+
* <a href=`#${input.id}`><${input.content} /></a>
|
|
10
|
+
|
|
11
|
+
* <if=input.children.length>
|
|
12
|
+
* <ul><for|item| of=input.children>
|
|
13
|
+
* <li><Recurse ...item /></li>
|
|
14
|
+
* </></ul>
|
|
15
|
+
* </>
|
|
16
|
+
* </>
|
|
17
|
+
*
|
|
18
|
+
* <div#toc>
|
|
19
|
+
* <h2>Contents:</h2>
|
|
20
|
+
* <for|item| of=groups>
|
|
21
|
+
* <li><Recurse ...item /></li>
|
|
22
|
+
* </>
|
|
23
|
+
* </div>
|
|
24
|
+
* ```
|
|
25
|
+
*/ export declare function outlineToTree(outline: Heading[]): HeadingTree[];
|
|
26
|
+
/** Options for {@linkcode transform}. */ export interface TransformOptions {
|
|
27
|
+
/** The Markodown source code to be transformed */ source: string;
|
|
28
|
+
/**
|
|
29
|
+
* Specify the allowed output formats. For simplicity, pass `marko`. By
|
|
30
|
+
* including `html`, you can opt into a faster codepath where plain HTML is
|
|
31
|
+
* returned to you as such, when no Marko features are used.
|
|
32
|
+
* @default ["marko"]
|
|
33
|
+
*/ format?: Array<"marko" | "html">;
|
|
34
|
+
/** Wraps the component in another component. Enables Table of Contents generation */ layoutImport?: string;
|
|
35
|
+
/** Import path for the module itself, passed to the layout as `module` */ selfImport?: string;
|
|
36
|
+
/** Replace built-in elements with custom components */ componentImports?: ComponentImports;
|
|
37
|
+
/**
|
|
38
|
+
* When true, disables all Marko extensions, turning this into a pure
|
|
39
|
+
* Markdown parser. Marko tags, template expressions, statements, and
|
|
40
|
+
* comments will be treated as plain text. Defaults to HTML output.
|
|
41
|
+
* @default false
|
|
42
|
+
*/ markdownOnly?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* These extensions are special-cased so that Clover can re-use this on
|
|
45
|
+
* her website without maintaining a second markdown parser. I promise
|
|
46
|
+
* we are not wasting your bundle size on my features.
|
|
47
|
+
*/ cloverExtensions?: CloverQuestionExtensions;
|
|
48
|
+
}
|
|
49
|
+
/** Replace Built In Elements */ export interface ComponentImports {
|
|
50
|
+
/** Replace (h1-h6) with this import. Receives attribute `level: number`. */ heading?: string;
|
|
51
|
+
/** Replace `pre > code` with this import. */ codeBlock?: string;
|
|
52
|
+
/** Replace links with this import. */ link?: string;
|
|
53
|
+
/** Replace images with this import. */ image?: string;
|
|
54
|
+
/** Replace blockquotes with this import. */ blockquote?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Clover's question extensions are syntax features used on the years of backlog
|
|
58
|
+
* from https://paperclover.net/q+a. It was easier to re-implement these than
|
|
59
|
+
* convert everything into Marko. Besides, there are some extra things that
|
|
60
|
+
* make it so these must emit HTML and not Marko, so these components all
|
|
61
|
+
* emit custom HTML elements instead of imported components.
|
|
62
|
+
*
|
|
63
|
+
* Also includes `@html <raw>` block syntax for raw HTML passthrough.
|
|
64
|
+
*
|
|
65
|
+
* @internal
|
|
66
|
+
*/ export interface CloverQuestionExtensions {
|
|
67
|
+
/**
|
|
68
|
+
* Element name for question blocks. Not an import path.
|
|
69
|
+
* `q: ...inline...` -> `<question>...</question>`
|
|
70
|
+
*
|
|
71
|
+
* `q: ...inline...\nq: ...inline...`
|
|
72
|
+
* ^ this inserts a `<br />` between them since theyre stuck together.
|
|
73
|
+
*/ question: string;
|
|
74
|
+
/**
|
|
75
|
+
* Element name for artifact ref. Not an import path.
|
|
76
|
+
* `@its-snowing` -> `<artifactRef>its-snowing</artifactRef>`
|
|
77
|
+
*/ artifactRef: string;
|
|
78
|
+
/**
|
|
79
|
+
* Element name for question ref. Not an import path.
|
|
80
|
+
* `#2602142011` -> `<questionRef>2602142011</questionRef>`
|
|
81
|
+
*
|
|
82
|
+
* Question refs are 10 or 12 numbers in a row.
|
|
83
|
+
*/ questionRef: string;
|
|
84
|
+
/**
|
|
85
|
+
* Element name for Labelled redactions.
|
|
86
|
+
* `#name#` -> `<labelledRedaction>name</labelledRedaction>`
|
|
87
|
+
*/ labelledRedaction: string;
|
|
88
|
+
}
|
|
89
|
+
/** The transformer currently supports two output formats. */ export type OutputFormat = "marko" | "html";
|
|
90
|
+
/** The transform is a success when `success: true` or there are no errors. */ export interface Success {
|
|
91
|
+
/** Easy boolean to discriminate {@linkcode TransformResult} */ success: true;
|
|
92
|
+
/** The transformed text. Format is determined by `format` */ text: string;
|
|
93
|
+
/** The resolved output format of `text` */ format: OutputFormat;
|
|
94
|
+
/** List of errors, if any */ errors: [];
|
|
95
|
+
}
|
|
96
|
+
/** The transform is a success when `success: false` or there is at least one error. */ export interface Failure {
|
|
97
|
+
/** Easy boolean to discriminate {@linkcode TransformResult} */ success: false;
|
|
98
|
+
/** The transformed text. Format is determined by `format` */ text: null;
|
|
99
|
+
/** The resolved output format of `text` */ format: null;
|
|
100
|
+
/** List of errors, if any */ errors: [TransformError, ...TransformError[]];
|
|
101
|
+
}
|
|
102
|
+
/** This is passed to Markodown layouts */ export interface LayoutInput {
|
|
103
|
+
/**
|
|
104
|
+
* Scanned from heading tags, the document outline is provided flat here. You
|
|
105
|
+
* can convert it into a nested tree with {@linkcode outlineToTree}
|
|
106
|
+
*/ outline: Heading[];
|
|
107
|
+
/**
|
|
108
|
+
* A copy of the Module Namespace object of the page. Use this to reflect
|
|
109
|
+
* frontmatter or other customizable exports. Don't render `module.default` as
|
|
110
|
+
* a component, since that will recursively call this layout.
|
|
111
|
+
*/ module: Record<string, unknown>;
|
|
112
|
+
/** The rendered document */ // @ts-ignore fails if marko types not chilling
|
|
113
|
+
content: Marko.Body;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Scanned from heading tags, this represents one heading in the document. You
|
|
117
|
+
* can convert it into a nested tree with {@linkcode outlineToTree}
|
|
118
|
+
*/ export interface Heading {
|
|
119
|
+
/** Which header element this corresponds to. */ level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
120
|
+
/** The link ID. Derived from the `id` attribute of the heading, or generated for you otherwise. */ id: string;
|
|
121
|
+
/** The rendered heading name */ // @ts-ignore fails if marko types not chilling
|
|
122
|
+
content: Marko.Body;
|
|
123
|
+
}
|
|
124
|
+
/** Generated by {@linkcode outlineToTree} */ export interface HeadingTree extends Heading {
|
|
125
|
+
/** Sub-headings */ children: HeadingTree[];
|
|
126
|
+
}
|
|
127
|
+
export interface TransformError {
|
|
128
|
+
/** What went wrong? */ message: string;
|
|
129
|
+
/** Additional notes for the failure */ notes: TransformNote[];
|
|
130
|
+
/** One-based line */ line: number;
|
|
131
|
+
/** One-based column, byte offset */ column: number;
|
|
132
|
+
}
|
|
133
|
+
export interface TransformNote {
|
|
134
|
+
/** What this span is communicating */ message?: string | null;
|
|
135
|
+
/** One-based line */ line: number;
|
|
136
|
+
/** One-based column, byte offset */ column: number;
|
|
137
|
+
/** Byte length */ width: number;
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sources":["../mod.ts"],"names":[],"mappings":"AAKA,wCAAwC,GACxC,YAAY,cAAc,UAAU;AAEpC,6EAA6E,GAC7E,OAAO,iBAAS,UAAU,SAAS,gBAAgB,GAAG;AAsBtD;;;;;;;;;;;;;;;;;;;;;;CAsBC,GACD,OAAO,iBAAS,cAAc,SAAS,SAAS,GAAG;AA2BnD,uCAAuC,GACvC,iBAAiB;EACf,gDAAgD,GAChD,QAAQ,MAAM;EACd;;;;;GAKC,GACD,SAAS,MAAM,UAAU;EACzB,mFAAmF,GACnF,eAAe,MAAM;EACrB,wEAAwE,GACxE,aAAa,MAAM;EACnB,qDAAqD,GACrD,mBAAmB;EACnB;;;;;GAKC,GACD,eAAe,OAAO;EACtB;;;;GAIC,GACD,mBAAmB;;AAGrB,8BAA8B,GAC9B,iBAAiB;EACf,0EAA0E,GAC1E,UAAU,MAAM;EAChB,2CAA2C,GAC3C,YAAY,MAAM;EAClB,oCAAoC,GACpC,OAAO,MAAM;EACb,qCAAqC,GACrC,QAAQ,MAAM;EACd,0CAA0C,GAC1C,aAAa,MAAM;;AAGrB;;;;;;;;;;CAUC,GACD,iBAAiB;EACf;;;;;;GAMC,GACD,UAAU,MAAM;EAChB;;;GAGC,GACD,aAAa,MAAM;EACnB;;;;;GAKC,GACD,aAAa,MAAM;EACnB;;;GAGC,GACD,mBAAmB,MAAM;;AAG3B,2DAA2D,GAC3D,YAAY,eAAe,UAAU;AAErC,4EAA4E,GAC5E,iBAAiB;EACf,6DAA6D,GAC7D,SAAS,IAAI;EACb,2DAA2D,GAC3D,MAAM,MAAM;EACZ,yCAAyC,GACzC,QAAQ;EACR,2BAA2B,GAC3B;;AAGF,qFAAqF,GACrF,iBAAiB;EACf,6DAA6D,GAC7D,SAAS,KAAK;EACd,2DAA2D,GAC3D,MAAM,IAAI;EACV,yCAAyC,GACzC,QAAQ,IAAI;EACZ,2BAA2B,GAC3B,SAAS,mBAAmB;;AAG9B,wCAAwC,GACxC,iBAAiB;EACf;;;GAGC,GACD,SAAS;EACT;;;;GAIC,GACD,QAAQ,OAAO,MAAM,EAAE,OAAO;EAC9B,0BAA0B,GAC1B,+CAA+C;EAC/C,SAAS,MAAM;;AAGjB;;;CAGC,GACD,iBAAiB;EACf,8CAA8C,GAC9C,OAAO,IAAI,IAAI,IAAI,IAAI,IAAI;EAC3B,iGAAiG,GACjG,IAAI,MAAM;EACV,8BAA8B,GAC9B,+CAA+C;EAC/C,SAAS,MAAM;;AAGjB,2CAA2C,GAC3C,iBAAiB,oBAAoB;EACnC,iBAAiB,GACjB,UAAU;;AAGZ,iBAAiB;EACf,qBAAqB,GACrB,SAAS,MAAM;EACf,qCAAqC,GACrC,OAAO;EACP,mBAAmB,GACnB,MAAM,MAAM;EACZ,kCAAkC,GAClC,QAAQ,MAAM;;AAGhB,iBAAiB;EACf,oCAAoC,GACpC,UAAU,MAAM,GAAG,IAAI;EACvB,mBAAmB,GACnB,MAAM,MAAM;EACZ,kCAAkC,GAClC,QAAQ,MAAM;EACd,gBAAgB,GAChB,OAAO,MAAM"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as markodown from "./mod.js";
|
|
2
|
+
import * as marko from "@marko/compiler";
|
|
3
|
+
import type * as rollup from "rollup";
|
|
4
|
+
export type RollupPluginOptions = Omit<markodown.TransformOptions, "source" | "format"> & {
|
|
5
|
+
marko?: typeof marko;
|
|
6
|
+
markoOptions?: marko.Config;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Rollup bundling plugin for markodown files.
|
|
10
|
+
*/ export default function rollupPlugin(options?: RollupPluginOptions): rollup.Plugin;
|
|
11
|
+
//# sourceMappingURL=rollup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rollup.d.ts","sources":["../rollup.ts"],"names":[],"mappings":"AAAA,YAAY,0BAA0B;AACtC,YAAY,6BAAoC;AAChD,iBAAiB,qBAA4B;AAG7C,YAAY,sBACR,KAAK,UAAU,kBAAkB,WAAW;EAE5C,eAAe;EACf,eAAe,MAAM;;AAGzB;;CAEC,GACD,eAAe,SAAS,aACtB,UAAS,mBAAwB,GAChC,OAAO"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export enum OutputFormat {
|
|
5
|
+
Html = 0,
|
|
6
|
+
Marko = 1,
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function transform(src: string, force_format: OutputFormat | null | undefined, layout_import: string | null | undefined, component_imports: any, self_path: string | null | undefined, markdown_only: boolean | null | undefined, clover_extensions: any): any;
|
|
10
|
+
|
|
11
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
12
|
+
|
|
13
|
+
export interface InitOutput {
|
|
14
|
+
readonly memory: WebAssembly.Memory;
|
|
15
|
+
readonly transform: (a: number, b: number, c: number, d: number, e: number, f: any, g: number, h: number, i: number, j: any) => any;
|
|
16
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
17
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
18
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
19
|
+
readonly __wbindgen_start: () => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
26
|
+
* a precompiled `WebAssembly.Module`.
|
|
27
|
+
*
|
|
28
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
29
|
+
*
|
|
30
|
+
* @returns {InitOutput}
|
|
31
|
+
*/
|
|
32
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
36
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
37
|
+
*
|
|
38
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
39
|
+
*
|
|
40
|
+
* @returns {Promise<InitOutput>}
|
|
41
|
+
*/
|
|
42
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|