Skip to content

Commit d6744da

Browse files
committed
Prepare v0.0.11
1 parent d91eaa5 commit d6744da

File tree

4 files changed

+60
-48
lines changed

4 files changed

+60
-48
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,6 @@
5252
+ Support `specify time` in a blockquote
5353
+ Support color to vary the blockquoutes
5454
+ Support render CSV as table
55-
+ Support PlantUML
55+
+ Support PlantUML
56+
+ `v0.0.11`
57+
+ Support fretboard

README.md

Lines changed: 53 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,23 @@
22

33
[![NPM version](https://img.shields.io/npm/v/hackmd-to-html-cli.svg?logo=npm&style=flat-square)](https://www.npmjs.org/package/hackmd-to-html-cli) ![](https://img.shields.io/github/license/ksw2000/hackmd-to-html-cli?color=yellow&style=flat-square) ![](https://img.shields.io/github/actions/workflow/status/ksw2000/hackmd-to-html-cli/gitpage.yml?branch=main&style=flat-square) ![](https://img.shields.io/npm/dt/hackmd-to-html-cli?color=blue&style=flat-square)
44

5-
Convert [HackMD](https://hackmd.io/) markdown to HTML.
5+
Not only is this a CLI tool, but it is also an importable package for converting standard Markdown and even [HackMD](https://hackmd.io/)-supported Markdown into HTML.
6+
7+
+ See the example of input markdown: [./example/index.md](https://raw.githubusercontent.com/ksw2000/hackmd-to-html-cli/main/example/index.md)
8+
9+
+ See the example of output html: [https://ksw2000.github.io/hackmd-to-html-cli/](https://ksw2000.github.io/hackmd-to-html-cli/)
610

711
## Install
812

913
```sh
14+
# CLI
1015
npm install -g hackmd-to-html-cli
11-
```
1216

13-
Input: [./example/index.md](https://raw.githubusercontent.com/ksw2000/hackmd-to-html-cli/main/example/index.md)
14-
15-
Output: [https://ksw2000.github.io/hackmd-to-html-cli/](https://ksw2000.github.io/hackmd-to-html-cli/)
17+
# Package
18+
npm install hackmd-to-html-cli
19+
```
1620

17-
## Usage
21+
## CLI
1822

1923
```sh
2024
$ hmd2html --help
@@ -30,7 +34,7 @@ Options:
3034
-h, --help display help for command
3135
```
3236

33-
### Convert
37+
**Convert**
3438

3539
```sh
3640
# files
@@ -41,51 +45,56 @@ $ hmd2html -s ./dir1 ./dir2
4145

4246
# files or directories
4347
$ hmd2html -s file1.md ./dir1
44-
```
4548

46-
### Set output folder
47-
48-
```sh
49+
# Set output folder
4950
$ hmd2html -s file1.md -d ./out
51+
52+
# Use custom layout
53+
$ hmd2html -s hello.md -l ./myLayout.html
5054
```
5155

52-
### Use custom layout
56+
## Package (beta)
5357

54-
```sh
55-
$ hmd2html -s hello.md -l ./myLayout.html
58+
```js
59+
const {Convert} = require('hackmd-to-html-cli')
60+
61+
md = `
62+
# title
63+
hello world
64+
`
65+
const hardBreak = true
66+
const converter = new Convert("{{main}}", hardBreak)
67+
console.log(converter.convert(md))
5668
```
5769

58-
+ /
59-
+ output/ *generated*
60-
+ hello.html
61-
+ hello.md
62-
+ myLayout.html
63-
64-
**./myLayout.html**
65-
```html
66-
<html>
67-
<head></head>
68-
<body>
69-
{{main}}
70-
</body>
71-
</html>
70+
**output**
71+
7272
```
73+
<h1 id="title" tabindex="-1">title</h1>
74+
<p>hello world</p>
75+
```
76+
77+
If you want to get default layout
7378

74-
**./hello.md**
75-
```markdown
76-
# hello
79+
```js
80+
convert.defaultLayout()
7781
```
7882

79-
**./output/hello.html**
80-
```html
81-
<html>
82-
<head></head>
83-
<body>
84-
<h1>hello</h1>
85-
</body>
86-
</html>
83+
If you want to get metadata after converting
84+
85+
```js
86+
converter.getMetadata()
8787
```
8888

89+
## Layout
90+
91+
See default layout here: https://github.com/ksw2000/hackmd-to-html-cli/blob/main/layout.html
92+
93+
+ `{{main}}` renders main content of markdown.
94+
+ `{{lang}}` renders lang property if there are yaml metadata about `lang` in markdown file. e.g. `lang="zh-TW"`
95+
+ `{{dir}}` renders dir property if there are yaml metadata about `dir` in markdown file. e.g. `dir="ltr"`
96+
+ `{{meta}}` renders meta tag if there are yaml metadata about `title`, `description`, `robots` or`image`. e.g. `<meta name="robots" content="noindex">`
97+
8998
## Develop
9099

91100
1. `npm run lint` to check the format of source code.
@@ -97,6 +106,8 @@ $ hmd2html -s hello.md -l ./myLayout.html
97106

98107
`HackMD Default Converter`: The default markdown to html converter provided by HackMD, i.e., download HTML file on HackMD.
99108

109+
HackMD fully supports syntax: [features](https://hackmd.io/features-tw?both)
110+
100111
| Features | hmd2html | HackMD Default Converter | |
101112
|---------------|:---------:|:--:|:--:|
102113
| ToC ||||
@@ -119,7 +130,7 @@ $ hmd2html -s hello.md -l ./myLayout.html
119130
| Abc |||v0.0.7⬆|
120131
| PlantUML |||v0.0.10⬆|
121132
| Vega-Lite |||v0.0.7⬆|
122-
| Fretboard | |||
133+
| Fretboard | ||v0.0.11⬆|
123134
| Alert Area ||||
124135
| Detail ||||
125136
| Spoiler container |||v0.0.7⬆|
@@ -172,9 +183,8 @@ $ hmd2html -s hello.md -l ./myLayout.html
172183
| image || `<meta property="og:image">`<br>`<meta name="twitter:image:src">` |
173184
| others || Hide the metadata by html comment |
174185

175-
HackMD sets the `lang` tag and `dir` tag at the beginning of `<body>`. hmd2html sets the the `lang` tag and `dir` tag at `<html>`.
186+
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.
176187

177188
## TODO
178189

179-
+ Provide more templates & styles
180-
+ Support more HackMD [syntax](https://hackmd.io/features-tw?both)
190+
+ Provide more templates & styles

lib/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import commander from 'commander'
33
import fs from 'fs'
44
import { Convert } from './converter'
55

6-
commander.program.version('0.0.10', '-v, --version', 'output the current version')
6+
commander.program.version('0.0.11', '-v, --version', 'output the current version')
77
commander.program
88
.requiredOption('-s, --source <files_or_dirs...>', 'specify the input markdown files or directories')
99
.addOption(new commander.Option('-d, --destination <path>', 'specify the output directory').default('./output', './output'))

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hackmd-to-html-cli",
3-
"version": "0.0.10",
3+
"version": "0.0.11",
44
"description": "A node.js CLI tool for converting HackMD markdown to HTML.",
55
"keywords": [
66
"hackmd",
@@ -17,7 +17,7 @@
1717
"bin": {
1818
"hmd2html": "dist/index.js"
1919
},
20-
"main":"dist/converter.js",
20+
"main": "dist/converter.js",
2121
"types": "types/converter.d.ts",
2222
"scripts": {
2323
"build": "tsc",
@@ -54,4 +54,4 @@
5454
"eslint": "^8.34.0",
5555
"typescript": "^4.9.5"
5656
}
57-
}
57+
}

0 commit comments

Comments
 (0)