You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
const converter = new Converter(template, hardBreak)
74
-
const md = `
75
-
# title
76
-
hello world
77
-
`
78
-
console.log(converter.convert(md))
79
-
```
67
+
We provide the two default layouts. Please see layouts here: [https://github.com/ksw2000/hackmd-to-html-cli/blob/main/layouts/](./layouts/)
68
+
69
+
+ `{{main}}` renders main content of markdown.
70
+
+ `{{lang}}` renders lang property if there are yaml metadata about `lang`in markdown file. e.g. `lang="zh-TW"`
71
+
+ `{{dir}}` renders dir property if there are yaml metadata about `dir`in markdown file. e.g. `dir="ltr"`
72
+
+ `{{meta}}` renders meta tag if there are yaml metadata about `title`, `description`, `robots` or`image`. e.g. `<meta name="robots" content="noindex">`
See default layout here: https://github.com/ksw2000/hackmd-to-html-cli/blob/main/layout.html
107
+
```ts
108
+
import { Converter } from "hackmd-to-html-cli"
102
109
103
-
+ `{{main}}` renders main content of markdown.
104
-
+ `{{lang}}` renders lang property if there are yaml metadata about `lang`in markdown file. e.g. `lang="zh-TW"`
105
-
+ `{{dir}}` renders dir property if there are yaml metadata about `dir`in markdown file. e.g. `dir="ltr"`
106
-
+ `{{meta}}` renders meta tag if there are yaml metadata about `title`, `description`, `robots` or`image`. e.g. `<meta name="robots" content="noindex">`
110
+
const converter = new Converter();
111
+
const res = converter.render("# hello");
107
112
108
-
## Develop
113
+
console.log(res.main);
114
+
```
109
115
110
-
1. `npm run lint` to check the format of source code.
111
-
2. `npm run example` runs example forthis package, which generates result from `./example` and places themin`./output`.
112
-
3. `npm test` runs unit test files whose filenames end with `.test.ts`
116
+
### Web
117
+
118
+
```js
119
+
const converter = new window.hmd2html.Converter();
| others | ✅ | Hide the metadata by html comment |
196
206
197
207
HackMD sets the `lang` tag and `dir` tag at the beginning of `<body>`. hmd2html sets the the `lang` tag and `dir` tag at `<html>` when using default layout.
208
+
209
+
## Development
210
+
211
+
1. `npm run lint` to check the format of source code.
212
+
2. `npm run example` runs example forthis package, which generates result from `./example` and places themin`./output`.
213
+
3. `npm test` runs unit test files whose filenames end with `.spec.ts`
214
+
215
+
## Contributing
216
+
217
+
Contributions to **hackmd-to-html-cli** are welcome and highly appreciated. Please run lint `npm run lint` and test`npm run test` before pull requesting.
0 commit comments