markdown2typst 0.1.1 → 0.1.3
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/README.md +51 -10
- package/dist/markdown2typst.js +2 -0
- package/dist/markdown2typst.js.map +2 -2
- package/dist/markdown2typst.min.js +6 -6
- package/package.json +1 -1
- package/src/markdown2typst.ts +3 -0
package/README.md
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
A JavaScript library for converting Markdown to [Typst](https://typst.app/) code.
|
|
4
4
|
|
|
5
|
-
## Try it online
|
|
6
|
-
See an example use case
|
|
5
|
+
## Demo - Try it online
|
|
6
|
+
See as an example use case the [demo](./demo/) of this repository published as a static website: [https://Mapaor.github.io/markdown2typst](https://Mapaor.github.io/markdown2typst).
|
|
7
7
|
|
|
8
8
|
## Supported Markdown features
|
|
9
9
|
### GitHub Flavored Markdown (GFM)
|
|
@@ -100,7 +100,7 @@ Note: any non-standard key is simply ignored, all keys are optional. The front-m
|
|
|
100
100
|
### NPM package (for Node.js projects)
|
|
101
101
|
Package link:
|
|
102
102
|
|
|
103
|
-
[](https://www.npmjs.com/package/markdown2typst)
|
|
103
|
+
[https://www.npmjs.com/package/markdown2typst](https://www.npmjs.com/package/markdown2typst)
|
|
104
104
|
|
|
105
105
|
Install it:
|
|
106
106
|
|
|
@@ -141,26 +141,46 @@ A javascript bundle will appear in the `dist` folder. Make the desired changes t
|
|
|
141
141
|
npm run test
|
|
142
142
|
```
|
|
143
143
|
|
|
144
|
+
## Simple Usage
|
|
144
145
|
|
|
145
|
-
|
|
146
|
+
#### Using the package
|
|
146
147
|
|
|
147
|
-
|
|
148
|
+
##### Simplest example
|
|
149
|
+
```javascript
|
|
150
|
+
import { markdown2typst } from 'markdown2typst';
|
|
148
151
|
|
|
149
|
-
|
|
152
|
+
const markdown = '# Hello Typst\n\nThis is a **test**.';
|
|
153
|
+
const typst = markdown2typst(markdown);
|
|
154
|
+
console.log(typst);
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
##### Converting a Markdown file
|
|
158
|
+
```js
|
|
159
|
+
import { markdown2typst } from 'markdown2typst';
|
|
160
|
+
import { readFileSync } from 'fs';
|
|
150
161
|
|
|
151
|
-
|
|
162
|
+
const markdown = readFileSync('./example-file.md', 'utf-8');
|
|
163
|
+
const typst = markdown2typst(markdown);
|
|
164
|
+
console.log(typst);
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
#### Using the bundle - Locally
|
|
168
|
+
|
|
169
|
+
Suppose you've downloaded the JS bundle and saved it in a `assets` folder, now for using it in your website you would simply do:
|
|
170
|
+
|
|
171
|
+
##### In Node.js (ESM)
|
|
152
172
|
```javascript
|
|
153
|
-
import { markdown2typst } from './
|
|
173
|
+
import { markdown2typst } from './assets/markdown2typst.min.js';
|
|
154
174
|
|
|
155
175
|
const markdown = '# Hello Typst\n\nThis is a **test**.';
|
|
156
176
|
const typst = markdown2typst(markdown);
|
|
157
177
|
console.log(typst);
|
|
158
178
|
```
|
|
159
179
|
|
|
160
|
-
##### In the browser
|
|
180
|
+
##### In the browser
|
|
161
181
|
```html
|
|
162
182
|
<script type="module">
|
|
163
|
-
import { markdown2typst } from './
|
|
183
|
+
import { markdown2typst } from './assets/markdown2typst.min.js';
|
|
164
184
|
|
|
165
185
|
const markdown = '# Hello Typst';
|
|
166
186
|
const typst = markdown2typst(markdown);
|
|
@@ -168,6 +188,27 @@ console.log(typst);
|
|
|
168
188
|
</script>
|
|
169
189
|
```
|
|
170
190
|
|
|
191
|
+
#### Using the bundle - Via CDN
|
|
192
|
+
|
|
193
|
+
```html
|
|
194
|
+
<script src="https://cdn.jsdelivr.net/npm/markdown2typst@latest/dist/markdown2typst.min.js"></script>
|
|
195
|
+
<script>
|
|
196
|
+
const markdown = '# Hello Typst\n\nThis is a **test**.';
|
|
197
|
+
const typst = markdown2typst(markdown);
|
|
198
|
+
console.log(typst);
|
|
199
|
+
</script>
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
#### Or in a javascript file
|
|
203
|
+
```js
|
|
204
|
+
import markdown2typst from 'https://cdn.jsdelivr.net/npm/markdown2typst@latest/dist/markdown2typst.min.js';
|
|
205
|
+
|
|
206
|
+
const markdown = '# Hello Typst\n\nThis is a **test**.';
|
|
207
|
+
const typst = markdown2typst(markdown);
|
|
208
|
+
console.log(typst);
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Which is what the [demo](./demo/) uses.
|
|
171
212
|
## Examples
|
|
172
213
|
|
|
173
214
|
See the [Examples](/examples/README.md) page for basic and advanced examples on how to use the library and all the features it supports.
|
package/dist/markdown2typst.js
CHANGED
|
@@ -20455,8 +20455,10 @@ function markdown2typst(markdown, options = {}) {
|
|
|
20455
20455
|
throw error;
|
|
20456
20456
|
}
|
|
20457
20457
|
}
|
|
20458
|
+
var markdown2typst_default = markdown2typst;
|
|
20458
20459
|
export {
|
|
20459
20460
|
ErrorSeverity,
|
|
20461
|
+
markdown2typst_default as default,
|
|
20460
20462
|
markdown2typst
|
|
20461
20463
|
};
|
|
20462
20464
|
/**
|