1.0.3 • Published 3 years ago

@ryan-liu/html-to-markdown v1.0.3

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

description

wechat url to markdown

输入微信公众号地址可以转化为 markdown 格式

返回格式

返回属性说明类型
title标题string
author作者string
contentmarkdown 内容string

Basic Usage

CommonJs

const { transformHtml2Markdown } = require('@ryan-liu/html-to-markdown')

setTimeout(async () => {
    const { title, author, content } = await transformHtml2Markdown('https://mp.weixin.qq.com/s/9d5DWg7YdMHPvVl-2KLH2w')
    console.log('标题', title)
    console.log('作者', author)
    console.log('内容', content)
}, 0)

vue3

index.ts

import { transformHtml2Markdown } from '@ryan-liu/html-to-markdown'

setup() {
    const getData = async () => {
        const { title, author, content } = await transformHtml2Markdown(
            '/api/s/9d5DWg7YdMHPvVl-2KLH2w'
        )
        console.log('标题', title)
        console.log('作者', author)
        console.log('内容', content)
    }

    getData()

    return {}
},

vite.config.ts

...
server: {
    proxy: {
        '/api': {
            target: 'https://mp.weixin.qq.com',
            changeOrigin: true,
            rewrite: (path) => path.replace(/^\/api/, ''),
        },
    },
},
...

Packages

axios (著名的请求库)

cheerio (可以用 JQuery 方式操作 html 源码)

turndown (html to markdown)

turndown-plugin-gfm (turndown 解析部分 html 元素插件)

Reference

html2md (一个非常完善的 url to markdown 项目)

1.0.2

3 years ago

1.0.3

3 years ago

1.0.0

3 years ago