Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/egoist/vmark

Convert markdown to Vue component.
https://github.com/egoist/vmark

Last synced: 14 days ago
JSON representation

Convert markdown to Vue component.

Awesome Lists containing this project

README

        

> __๐Ÿ’– Using webpack? You may want vmark-loader โžก๏ธ__

# vmark

[![NPM version](https://img.shields.io/npm/v/vmark.svg?style=flat)](https://npmjs.com/package/vmark) [![NPM downloads](https://img.shields.io/npm/dm/vmark.svg?style=flat)](https://npmjs.com/package/vmark) [![CircleCI](https://circleci.com/gh/egoist/vmark/tree/master.svg?style=shield)](https://circleci.com/gh/egoist/vmark/tree/master) [![donate](https://img.shields.io/badge/$-donate-ff69b4.svg?maxAge=2592000&style=flat)](https://github.com/egoist/donate) [![chat](https://img.shields.io/badge/chat-on%20discord-7289DA.svg?style=flat)](https://chat.egoist.moe)

## Install

```bash
yarn add vmark
```

## Usage

Basically you can write Markdown code alongside `` and `<style>` tags, and these tags work just like how it is in a normal `.vue` file.

In:

```markdown
# Show off some counter

<counter :start="0" />

<script>
import counter from './counter.vue'
export default {
components: {
counter
}
}

```

Out:

```vue


Show off some counter



import counter from './counter.vue'
export default {
components: {
counter
}
}

```

Code:

```js
const component = vmark(input)
// Get the component in SFC format
```

### Insert code block

Automatically transform:

````markdown
```vue {insert: 'below'}
Button
```
````

Into:

````markdown
```vue
Button
```

Button
````

`insert` can also be `above`.

## API

### vmark(input, [options])

#### input

Type: `string`

Required: `true`

Input markdown string.

#### options

##### options.markdown

Options for [markdown-it](https://markdown-it.github.io/markdown-it/).

##### options.extend

- Type: `(md: MarkdownIt) => void`

A function whose first argument is the MarkdownIt instance.

##### options.wrapHTML

- Type: `(html: string) => string`
- Default: html => `<div class="vmark">${html}</div>`

Wrap the HTML in an element, because the `` block in Vue SFC doesn't allow multiple root elements. You can use this option to wrap HTML inside a Vue component:

```js
const wrapHTML = html => `${html}`
```

Then inside the `` component, you can access the `html` like this:

```vue




```

## Contributing

1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D

## Author

**vmark** ยฉ [egoist](https://github.com/egoist), Released under the [MIT](./LICENSE) License.

Authored and maintained by egoist with help from contributors ([list](https://github.com/egoist/vmark/contributors)).

> [github.com/egoist](https://github.com/egoist) ยท GitHub [@egoist](https://github.com/egoist) ยท Twitter [@_egoistlily](https://twitter.com/_egoistlily)