1.2.0 • Published 3 years ago

@suin/esa-markdown-format v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

@suin/esa-markdown-format

esa.ioのMarkdownを自動整形する関数です。

特徴

  • PrettierによるMarkdownの自動整形
  • PrettierによるMarkdown内コードブロックの自動整形
  • esa内部リンクを絶対URLから相対URLにする

どのような整形がなされるかの例は自動整形のデモをご覧ください。

インストール

yarn add @suin/esa-markdown-format
# or
npm install @suin/esa-markdown-format

使い方

format関数にフォーマットしたいMarkdownとチーム名を渡すと、フォーマットされたMarkdownが返ります:

import format from "@suin/esa-markdown-format";

const input = `
ヘッダ
=====

* リスト
* リスト

|カラム1|カラム2|カラム3|
|---|---|---|
|a|b|c|

~~~js
const uglyCode=function(){return 'omg'}
~~~

    const indented = "code";

[絶対URL](https://example.esa.io/posts/1)`;

const output = format(input, { team: "example" });

outputの内容:

# ヘッダ

- リスト
- リスト

| カラム1 | カラム2 | カラム3 |
| ------- | ------- | ------- |
| a       | b       | c       |

```js
const uglyCode = function () {
  return "omg";
};
```

```
const indented = "code";
```

[絶対URL](/posts/1)

API リファレンス

https://suin.github.io/esa-markdown-format/