markdown2typst 0.1.0 → 0.1.2
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 +57 -50
- package/dist/markdown2typst.js +2 -0
- package/dist/markdown2typst.js.map +2 -2
- package/dist/markdown2typst.min.js +6 -6
- package/package.json +2 -2
- package/src/markdown2typst.ts +3 -0
- package/src/old/oldmarkdown2typst.ts +0 -1092
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
A JavaScript library for converting Markdown to [Typst](https://typst.app/) code.
|
|
4
4
|
|
|
5
|
-
## Try it online
|
|
5
|
+
## Try it online (PENDING!!!)
|
|
6
6
|
See an example use case in this demo website: [https://markdown2typst.vercel.app](https://markdown2typst.vercel.app).
|
|
7
7
|
|
|
8
8
|
## Supported Markdown features
|
|
@@ -98,6 +98,11 @@ Note: any non-standard key is simply ignored, all keys are optional. The front-m
|
|
|
98
98
|
## Installation
|
|
99
99
|
|
|
100
100
|
### NPM package (for Node.js projects)
|
|
101
|
+
Package link:
|
|
102
|
+
|
|
103
|
+
[https://www.npmjs.com/package/markdown2typst](https://www.npmjs.com/package/markdown2typst)
|
|
104
|
+
|
|
105
|
+
Install it:
|
|
101
106
|
|
|
102
107
|
```bash
|
|
103
108
|
npm install tex2typst
|
|
@@ -105,28 +110,16 @@ npm install tex2typst
|
|
|
105
110
|
|
|
106
111
|
### JS Bundle
|
|
107
112
|
|
|
108
|
-
Available both on JSDeliver and Unpkg.
|
|
109
|
-
|
|
110
113
|
#### JSDelivr
|
|
111
114
|
|
|
112
|
-
##### JSDelivr NPM
|
|
113
|
-
|
|
114
|
-
```
|
|
115
|
-
<script src="https://cdn.jsdelivr.net/npm/..."></script>
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
##### JSDelivr GitHub Link
|
|
119
|
-
|
|
120
115
|
```
|
|
121
|
-
<script src="https://cdn.jsdelivr.net/
|
|
116
|
+
<script src="https://cdn.jsdelivr.net/npm/markdown2typst@latest/dist/markdown2typst.min.js"></script>
|
|
122
117
|
```
|
|
123
118
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
#### Unpkg (NPM link)
|
|
119
|
+
#### Unpkg
|
|
127
120
|
|
|
128
121
|
```
|
|
129
|
-
<script src="https://unpkg.com
|
|
122
|
+
<script src="https://unpkg.com/markdown2typst@latest/dist/markdown2typst.min.js"></script>
|
|
130
123
|
```
|
|
131
124
|
|
|
132
125
|
### Build from source
|
|
@@ -138,33 +131,56 @@ cd markdown2typst
|
|
|
138
131
|
|
|
139
132
|
# Install dependencies
|
|
140
133
|
npm install
|
|
141
|
-
|
|
142
|
-
Make the desired changes to the library (`markdown2typst.ts` file) and then build from source
|
|
143
|
-
```bash
|
|
134
|
+
|
|
144
135
|
# Build the bundle
|
|
145
136
|
npm run build
|
|
146
137
|
```
|
|
147
|
-
|
|
138
|
+
A javascript bundle will appear in the `dist` folder. Make the desired changes to the library and then build again if you need. To test your modifications still comply with what's expected from the library run the tests.
|
|
139
|
+
```bash
|
|
140
|
+
# Testing
|
|
141
|
+
npm run test
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Simple Usage
|
|
148
145
|
|
|
149
|
-
|
|
146
|
+
#### Using the package
|
|
150
147
|
|
|
151
|
-
|
|
148
|
+
##### Simplest example
|
|
149
|
+
```javascript
|
|
150
|
+
import { markdown2typst } from 'markdown2typst';
|
|
152
151
|
|
|
153
|
-
|
|
152
|
+
const markdown = '# Hello Typst\n\nThis is a **test**.';
|
|
153
|
+
const typst = markdown2typst(markdown);
|
|
154
|
+
console.log(typst);
|
|
155
|
+
```
|
|
154
156
|
|
|
155
|
-
#####
|
|
157
|
+
##### Converting a Markdown file
|
|
158
|
+
```js
|
|
159
|
+
import { markdown2typst } from 'markdown2typst';
|
|
160
|
+
import { readFileSync } from 'fs';
|
|
161
|
+
|
|
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)
|
|
156
172
|
```javascript
|
|
157
|
-
import { markdown2typst } from './
|
|
173
|
+
import { markdown2typst } from './assets/markdown2typst.min.js';
|
|
158
174
|
|
|
159
175
|
const markdown = '# Hello Typst\n\nThis is a **test**.';
|
|
160
176
|
const typst = markdown2typst(markdown);
|
|
161
177
|
console.log(typst);
|
|
162
178
|
```
|
|
163
179
|
|
|
164
|
-
##### In the browser
|
|
180
|
+
##### In the browser
|
|
165
181
|
```html
|
|
166
182
|
<script type="module">
|
|
167
|
-
import { markdown2typst } from './
|
|
183
|
+
import { markdown2typst } from './assets/markdown2typst.min.js';
|
|
168
184
|
|
|
169
185
|
const markdown = '# Hello Typst';
|
|
170
186
|
const typst = markdown2typst(markdown);
|
|
@@ -172,30 +188,20 @@ console.log(typst);
|
|
|
172
188
|
</script>
|
|
173
189
|
```
|
|
174
190
|
|
|
191
|
+
#### Using the bundle - Via CDN
|
|
175
192
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
This is a paragraph with **bold** and *italic* text.
|
|
185
|
-
|
|
186
|
-
## Features
|
|
187
|
-
|
|
188
|
-
- Item 1
|
|
189
|
-
- Item 2
|
|
190
|
-
`;
|
|
191
|
-
|
|
192
|
-
const typst = markdown2typst(markdown);
|
|
193
|
-
console.log(typst);
|
|
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>
|
|
194
200
|
```
|
|
195
201
|
|
|
196
|
-
|
|
202
|
+
## Examples
|
|
197
203
|
|
|
198
|
-
See the [Examples](/examples/README.md) page for advanced examples on how to use the library.
|
|
204
|
+
See the [Examples](/examples/README.md) page for basic and advanced examples on how to use the library and all the features it supports.
|
|
199
205
|
|
|
200
206
|
## Internal architecture
|
|
201
207
|
Check the [Architecture](./ARCHITECTURE.md) doc for getting a better understanding of how the library works under the hood.
|
|
@@ -218,15 +224,16 @@ Built thanks to the following open-source projects:
|
|
|
218
224
|
- [remark-parse](https://github.com/remarkjs/remark/tree/main)
|
|
219
225
|
- [esbuild](https://esbuild.github.io/) - Fast bundler
|
|
220
226
|
- [tex2typst](https://github.com/qwinsi/tex2typst) - Typst conversion for LaTeX equations
|
|
227
|
+
- [js-yaml](https://github.com/nodeca/js-yaml) - YAML parser
|
|
221
228
|
|
|
222
|
-
This code
|
|
229
|
+
This code was initially based on the code by zhaoyiqun (@cosformula on GitHub), more specifically in his [markdownToTypst.ts](https://github.com/cosformula/mdxport/blob/main/src/lib/pipeline/markdownToTypst.ts) custom conversion library (renderer to Typst code) built for his open source project [MDXport](https://mdxport.com).
|
|
223
230
|
|
|
224
231
|
## Roadmap
|
|
225
232
|
|
|
226
233
|
- [X] Finish an initial working version
|
|
227
234
|
- [X] Add frontmatter support and also allow to pass the keys as custom options of the main function
|
|
228
|
-
- [
|
|
229
|
-
- [
|
|
235
|
+
- [X] Publish to npm
|
|
236
|
+
- [X] Add a comprehensive test suite
|
|
230
237
|
- [ ] Add CLI tool
|
|
231
238
|
- [ ] Support custom templates
|
|
232
239
|
- [ ] Support more Markdown extensions/flavors/specs
|
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
|
/**
|