17 Star 77 Fork 12

腾石科技 / bdParse

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

bdParse

项目介绍

百度小程序富文本解析工具bdParse,改造自wxparse,支持html转换成百度小程序富文本节点。

安装教程

拷贝的方式使用

  1. 下载整个全部文件,放到你的小程序根目录下
  2. 在小程序页面的js种直接引入代码:var bdParse = require('../../bdParse/bdParse.js'); 对应css中引入@import "../../bdParse/bdParse.css";
  3. 在需要的字段使用baparse,代码:(注意:article和content不要重复) that.setData({ content:bdParse.bdParse('article', 'html', content, that, 5), })
  4. swan页面引入模板,<import src="../../bdParse/bdParse.swan" /> 然后在需要显示富文本的地方调用:<template is="bdParse" data="{{ {bdParseData:article.nodes} }}" /> (注意:data调用改为和wxParse一致写法,注意是三个大括号,原先的直接写{{article}}不再支持,请注意修改)

NPM与自定义组件的方式使用 查看:参考文档

使用说明

  1. swan调用模板的data="{{ {bdParseData:article.nodes} }}"和setData中的article保持一致。
  2. 调用bdparse组件的时候,组件已经把富文本内容赋值(即setData)给了article;{{ {bdParseData:article.nodes} }} 这种写法的意思是:把article.nodes的内容赋值给bdParseData,bdParse.swan中调用的是bdParseData。

其他说明

  1. bdParse是在wxParse的基础上改造的,只是把wxParse替换换成了bdParse,包含js,swan, css
  2. wxml修改后缀改成swan,并且修改了全部模板传值的调用方式,符合百度小程序的使用。
  3. 修复了其他百度小程序的专有组件,比如s-for,s-if,s-elif,s-for-index等等
  4. 修复其他问题,比如去掉<template name="wxParseImg">重复的mode以及去掉data-from,给所有的s-for-index添加idx(好像不能为空)。
  5. 其他修改,不再赘述
  6. 因为直接批量替换内容,基本文章可以满足使用,其他没有做过多测试,欢迎大家反馈bug

参与贡献

码农不易,多多支持

如果你觉得bdParse帮你解决了问题,请不要忘了打赏,你的支持是我们最大的动力。

输入图片说明

The MIT License (MIT) Copyright (c) 2018 石头建站 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

百度小程序富文本解析工具bdParse,改造自wxparse,支持html转换成百度小程序富文本节点。 展开 收起
JavaScript 等 2 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/sootou/bdparse.git
git@gitee.com:sootou/bdparse.git
sootou
bdparse
bdParse
master

搜索帮助

14c37bed 8189591 565d56ea 8189591