@aiello/wechat-to-markdown
TypeScript icon, indicating that this package has built-in type declarations

1.2.5 • Public • Published

wechat-to-markdown

Fork from https://github.com/LuckyRyan-web/wechat-to-markdown

add some bug fix

yarn add @aiello/wechat-to-markdown
# or
npm install @aiello/wechat-to-markdown

description

Enter the WeChat public address to convert it to markdown format

English | 简体中文

return options

interface TurnDownResult {
    success: boolean
    code: number
    data?: {
        title?: string
        author?: string
        content?: string
    }
    msg?: string
}

Basic Usage

CommonJs

const transformHtml2Markdown = require('@aiello/wechat-to-markdown').default

setTimeout(async () => {
    const articleData = await transformHtml2Markdown('https://mp.weixin.qq.com/s/9d5DWg7YdMHPvVl-2KLH2w')

    const { title, author, content } = articleData.data

    console.log('title', title)
    console.log('author', author)
    console.log('content', content)
}, 0)

vue3

index.ts

import transformHtml2Markdown from '@aiello/wechat-to-markdown'

setup() {
    const getData = async () => {
        const articleData = await transformHtml2Markdown(
            '/api/s/9d5DWg7YdMHPvVl-2KLH2w'
        )

        const { title, author, content } = articleData.data

        console.log('title', title)
        console.log('author', author)
        console.log('content', 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

turndown (html to markdown)

turndown-plugin-gfm (turndown parsing partial html element plugin)

Reference

html2md (A very well developed url to markdown project)

TODO

  1. The markdown code that supports conversion can replace the image and upload it to the cdn

Package Sidebar

Install

npm i @aiello/wechat-to-markdown

Weekly Downloads

1

Version

1.2.5

License

MIT

Unpacked Size

36.6 kB

Total Files

8

Last publish

Collaborators

  • aiellochan