yyxx9988 / html-wxml-converter
A PHP library that can convert html into wxml and back.
Installs: 26
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 1
Forks: 2
Open Issues: 1
pkg:composer/yyxx9988/html-wxml-converter
Requires (Dev)
- phpunit/phpunit: ^5.7
This package is not auto-updated.
Last update: 2025-10-30 02:23:17 UTC
README
A PHP library that can convert html into wxml and back.
Requirement
- PHP >= 5.4
Installation
$ composer require "yyxx9988/html-wxml-converter"
Usage
use \yyxx9988\mlconverter\Converter; $converter = new Converter(); $converter->setHtml(' <div> <a>...</a> <p><img src="..."></p> </div> '); echo $converter->convert(); // result <view data-htmltag="div"> <view data-htmltag="a">...</view> <view data-htmltag="p"><image src="..."></image></view> </view>
Customize
- Default supported tags
[
'p' => 'view',
'h1' => 'view',
'h2' => 'view',
'h3' => 'view',
'h4' => 'view',
'h5' => 'view',
'h6' => 'view',
'ul' => 'view',
'ol' => 'view',
'li' => 'view',
'div' => 'view',
'nav' => 'view',
'pre' => 'view',
'code' => 'view',
'menu' => 'view',
'aside' => 'view',
'header' => 'view',
'footer' => 'view',
'legend' => 'view',
'section' => 'view',
'article' => 'view',
'caption' => 'view',
'details' => 'view',
'summary' => 'view',
'menuitem' => 'view',
'blockquote' => 'view',
'i' => 'text',
'b' => 'text',
's' => 'text',
'u' => 'text',
'big' => 'text',
'del' => 'text',
'sub' => 'text',
'sup' => 'text',
'ins' => 'text',
'font' => 'text',
'mark' => 'text',
'time' => 'text',
'span' => 'text',
'center' => 'text',
'strong' => 'text',
'strike' => 'text',
];
- Customize special tags
$converter = new Converter(); // add a tag $converter->addHtmlTags('xxx', 'view'); // change a tag $converter->setHtmlTags('li', 'text'); // remove a tag $converter->removeHtmlTags('article'); echo $converter->convert();
License
MIT