Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

miniprogram-posthtml-render

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

miniprogram-posthtml-render

Renders PostHTML Tree to HTML/XML

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

miniprogram-posthtml-render

Fork from posthtml/posthtml-render@1.3.0

posthtml-render做如下变更

  • 默认单标签元素:
[
 'area',
  'base',
  'br',
  'col',
  'command',
  'embed',
  'hr',
  'img',
  'input',
  'keygen',
  'link',
  'menuitem',
  'meta',
  'param',
  'source',
  'track',
  'wbr'
]

替换为适用于小程序的:

[
  'wxs',
  'input',
  'textarea',
  'audio',
  'icon',
  'progress',
  'rich-text',
  'checkbox',
  'radio',
  'slider',
  'switch',
  'live-player',
  'live-pusher',
  'voip-room',
  'canvas',
  'ad',
  'ad-custom',
  'official-account',
  'open-data',
  'web-view',
]
// image, video可以有内容
  • 添加removeSpaceBetweenAttributes选项用于压缩, quoteAllAttributes同时为true生效。
  <input class="phone" type="number" />

->

<input class="phone"type="number"/>
<input class="phone" type="number" disabled />

->

<input class="phone"type="number" disabled/>
  • 将属性值为空字符串的属性只保留key, 以支持<input disabled />写法。posthtml-parser会将disabled解释为{ "disabled": "" }
  • 指定closingSingleTag且内容为空的标签视为单标签:<view></view> => <view />

Usage

$ yarn add miniprogram-posthtml-render -D
const render = require('miniprogram-posthtml-render');

render(true, options);

Keywords

miniprogram

FAQs

Package last updated on 08 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts