we rich
1.0.0
แยก HTML ลงในโหนดข้อความ Rich-Text ของ Weapp
HTML转小程序 rich-text 控件节点
npm install we-rich
const weRich = require('we-rich');
var nodes = weRich.parse(html);
< div class =' post post-featured ' >
< p > hello </ p >
< section > world </ section >
< img src =" test.png " style =" max-width:100% " />
</ div >
[
{
"type" : "node" ,
"name" : "div" ,
"attrs" : { "class" : "post post-featured" } ,
"children" : [
{
"type" : "node" ,
"name" : "p" ,
"attrs" : { } ,
"children" : [ { "type" : "text" , "text" : "hello" } ]
} ,
{
"type" : "node" ,
"name" : "div" ,
"attrs" : { } ,
"children" : [ { "type" : "text" , "text" : "world" }
]
} ,
{
"type" : "node" ,
"name" : "img" ,
"attrs" : { "src" : "test.png" , "style" : "max-width:100%" } ,
"children" : [ ]
}
]
}
]
HTML เป็น 微信微信序rich-text使用的nodes
npm install we-rich --save
const weRich = require ( 'we-rich' ) ;
var nodes = weRich . parse ( html ) ;