Skip to content

Commit

Permalink
docs: update vfm doc
Browse files Browse the repository at this point in the history
  • Loading branch information
uetchy committed Jun 14, 2020
1 parent ad6a52a commit f9d6298
Showing 1 changed file with 57 additions and 7 deletions.
64 changes: 57 additions & 7 deletions packages/vfm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@ yarn add @vivliostyle/vfm
## Usage

```js
const {stringifyMarkdown} = require('@vivliostyle/vfm');

function vfm2html(vfmString) {
return stringifyMarkdown(vfmString);
}
const {stringify} = require('@vivliostyle/vfm');

console.log(
vfm2html(`
stringify(`
# はじめに
{Vivliostyle|ビブリオスタイル}の世界へようこそ。
Expand All @@ -32,7 +28,6 @@ This snippet will generates:
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="" />
</head>
<body>
<h1>はじめに</h1>
Expand All @@ -43,3 +38,58 @@ This snippet will generates:
</body>
</html>
```

## Options

### `stylesheet` (default: `undefined`)

```js
stringify('# Hello', {stylesheet: 'https://example.com/book.css'});
```

will generates:

```html
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="https://example.com/book.css" />
</head>
<body>
<p><h1>Hello</h1></p>
</body>
</html>
```

### `partial` (default: `false`)

```js
stringify('# Hello', {partial: true});
```

will generates:

```html
<p><h1>Hello</h1></p>
```

## Advanced usage

### Integrate into Unified.js pipeline

```js
import unified from 'unified';
import vfm from '@vivliostyle/vfm/lib/revive-parse';
import html from '@vivliostyle/vfm/lib/revive-rehype';

function main() {
unified()
.use(vfm)
.use(customRemarkPlugin)
.use(html)
.use(customRehypePlugin)
.processSync('# Hello');
}
```

0 comments on commit f9d6298

Please sign in to comment.