# html2wxml **Repository Path**: qwqoffice/html2wxml ## Basic Information - **Project Name**: html2wxml - **Description**: 用于微信小程序的HTML和Markdown格式的富文本渲染组件,支持代码高亮 - **Primary Language**: PHP - **License**: GPL-2.0 - **Default Branch**: master - **Homepage**: https://www.qwqoffice.com/article.php?mod=view&tid=40 - **GVP Project**: No ## Statistics - **Stars**: 171 - **Forks**: 46 - **Created**: 2018-07-18 - **Last Updated**: 2024-09-25 ## Categories & Tags **Categories**: weixin-lapp **Tags**: None ## README ## 申请使用注意事项 **插件版本解析服务是由 `QwqOffice` 完成,存在不稳定因素,如对稳定性有很高的要求,请自行搭建解析服务,或在自家服务器上直接完成解析。对于有关插件版本不能使用/不能解析的提问,不作任何回答** ![html2wxml](https://www.qwqoffice.com/html2wxml/images/html2wxml.jpg) # html2wxml微信小程序富文本组件 ## 效果 ![html2wxml截图](https://www.qwqoffice.com/html2wxml/images/html2wxml-screenshot.png "html2wxml截图") ## 参考 小程序富文本解析 [https://github.com/icindy/wxParse](https://github.com/icindy/wxParse "https://github.com/icindy/wxParse") PHP移植版highlight.js [https://github.com/scrivo/highlight.php](https://github.com/scrivo/highlight.php "https://github.com/scrivo/highlight.php") PHP编写的Markdown解析器 [https://github.com/erusev/parsedown](https://github.com/erusev/parsedown "https://github.com/erusev/parsedown") ## Java版解决方案 [java版](https://gitee.com/909854136/html2wxml4J) https://gitee.com/909854136/html2wxml4J ## 演示 扫码打开演示小程序 ![html2wxml演示小程序](https://www.qwqoffice.com/html2wxml/images/html2wxml-qrcode.jpg "html2wxml演示小程序") ## 小程序端用法 ### 三种版本演示 三种版本演示所用的小程序源码均在demo目录中 ### 插件版本准备 1. 打开小程序管理后台,转到设置 - 第三方服务,点击添加插件 ![添加小程序插件](https://www.qwqoffice.com/html2wxml/images/plugin-1.png "添加小程序插件") 2. 搜索 `html2wxml` ,选中并添加 ![添加小程序插件](https://www.qwqoffice.com/html2wxml/images/plugin-2.png "添加小程序插件") 3. 添加成功 ![添加小程序插件](https://www.qwqoffice.com/html2wxml/images/plugin-3.png "添加小程序插件") 4. 回到小程序开发环境,编辑 `app.json` ,添加插件声明,最新版为 `1.3.0` "plugins": { "htmltowxml": { "version": "1.3.0", "provider": "wxa51b9c855ae38f3c" } } 5. 在对应页面的 `json` 文件,比如首页 `index.json`,添加使用插件组件的声明 "usingComponents": { "htmltowxml": "plugin://htmltowxml/view" } 6. 参考下面组件使用方法 ### 组件版本准备 1. 复制整个 `html2wxml-component` 文件夹到小程序目录 2. 在对应页面的 `json` 文件,比如首页 `index.json`,添加使用组件的声明,注意路径 "usingComponents": { "htmltowxml": "path/to/html2wxml-component/html2wxml" } 3. 参考下面组件使用方法 ### 模板版本准备 1. 复制整个 `html2wxml-template` 文件夹到小程序目录 2. 在对应页面的 `js` 文件,比如首页 `index.js`,添加引用声明,并使用`html2wxml`方法进行数据绑定,注意路径,参数分别为绑定的数据名、已解析的富文本数据、当前页面对象和容器与屏幕边缘的单边的距离 var html2wxml = require('path/to/html2wxml-template/html2wxml.js'); html2wxml.html2wxml('article', res.data, this, 5); 3. 在对应页面的 `wxml` 文件,比如首页 `index.wxml`,添加引用模板的声明,并使用模板,注意路径和绑定的数据名