Top Related Projects
Quick Overview
wxParse is a WeChat Mini Program component for rendering rich text content, including HTML and Markdown. It provides a solution for displaying complex formatted text within WeChat Mini Programs, which natively lack support for rich text rendering.
Pros
- Supports both HTML and Markdown parsing
- Easy integration into WeChat Mini Program projects
- Customizable styling options for rendered content
- Active community and ongoing maintenance
Cons
- Performance may degrade with large amounts of complex content
- Limited support for advanced HTML features
- Occasional rendering inconsistencies across different devices
- Requires additional setup compared to native text display
Code Examples
- Basic HTML parsing:
<template>
<view>
<wxparse data="{{htmlContent}}" />
</view>
</template>
<script>
Page({
data: {
htmlContent: '<h1>Hello, World!</h1><p>This is a <strong>bold</strong> text.</p>'
}
})
</script>
- Markdown parsing:
<template>
<view>
<wxparse data="{{markdownContent}}" type="md" />
</view>
</template>
<script>
Page({
data: {
markdownContent: '# Hello, World!\n\nThis is a **bold** text.'
}
})
</script>
- Customizing styles:
<template>
<view>
<wxparse data="{{htmlContent}}" tag-style="{{tagStyle}}" />
</view>
</template>
<script>
Page({
data: {
htmlContent: '<h1>Styled Heading</h1><p>Colored paragraph.</p>',
tagStyle: {
h1: 'color: #ff0000;',
p: 'color: #00ff00;'
}
}
})
</script>
Getting Started
-
Install wxParse in your WeChat Mini Program project:
npm install wxparse
-
Import and register the component in your page:
import wxParse from 'wxparse'; Component({ components: { wxparse: wxParse } })
-
Use the component in your WXML:
<wxparse data="{{content}}" />
-
Set the content in your page's data:
Page({ data: { content: '<h1>Hello, wxParse!</h1>' } })
Competitor Comparisons
微信小程序Markdown渲染库
Pros of wemark
- Lighter weight and more focused on Markdown parsing
- Actively maintained with more recent updates
- Better performance for rendering large documents
Cons of wemark
- Less feature-rich compared to wxParse
- Limited support for complex HTML structures
- Fewer customization options for styling
Code Comparison
wxParse:
var wxParse = require('../../wxParse/wxParse.js');
Page({
onLoad: function () {
var article = '<div>Hello World</div>';
wxParse.wxParse('article', 'html', article, this, 5);
}
})
wemark:
var wemark = require('wemark');
Page({
onLoad: function () {
wemark.parse('# Hello World', this, {
imageWidth: wx.getSystemInfoSync().windowWidth - 40,
name: 'wemark'
});
}
})
Both wxParse and wemark are libraries for rendering rich text in WeChat Mini Programs. wxParse offers more comprehensive HTML parsing capabilities, while wemark focuses specifically on Markdown rendering. wxParse provides more flexibility for complex content but may be overkill for simpler use cases. wemark, on the other hand, is more lightweight and optimized for Markdown, making it a good choice for projects primarily dealing with Markdown content.
微信小程序HTML、Markdown渲染库
Pros of towxml
- More actively maintained with recent updates
- Supports both Markdown and HTML parsing
- Offers a more comprehensive set of features, including LaTeX rendering
Cons of towxml
- Larger file size and potentially higher resource usage
- Steeper learning curve due to more complex configuration options
Code Comparison
wxParse:
var WxParse = require('../../wxParse/wxParse.js');
Page({
onLoad: function () {
var article = '<div>Hello World</div>';
WxParse.wxParse('article', 'html', article, this, 5);
}
})
towxml:
const Towxml = require('/towxml/index');
Page({
onLoad: function () {
let article = '# Hello World';
let result = new Towxml().toJson(article, 'markdown');
this.setData({ article: result });
}
})
Both libraries aim to parse and render rich text content in WeChat Mini Programs. wxParse focuses primarily on HTML parsing, while towxml offers more versatility with support for both Markdown and HTML. towxml provides additional features like LaTeX rendering, making it more suitable for complex content. However, this comes at the cost of a larger file size and potentially more complex setup. wxParse, being simpler, may be easier to implement for basic use cases but lacks some advanced features found in towxml.
Web Components Framework - Web组件框架
Pros of omi
- More comprehensive framework for building user interfaces
- Supports multiple platforms beyond WeChat Mini Programs
- Active development and larger community support
Cons of omi
- Steeper learning curve due to its broader scope
- May be overkill for simple parsing tasks
- Requires more setup and configuration
Code Comparison
wxParse:
var wxParse = require('wxParse/wxParse.js');
Page({
onLoad: function() {
var article = '<div>Hello, wxParse!</div>';
wxParse.wxParse('article', 'html', article, this, 5);
}
});
omi:
import { define, WeElement, render } from 'omi';
define('my-component', class extends WeElement {
render() {
return <div>Hello, omi!</div>
}
});
render(<my-component />, 'body');
Summary
wxParse is a lightweight solution specifically designed for parsing rich text in WeChat Mini Programs. It's easy to use and integrate but has limited functionality beyond parsing.
omi is a more robust framework for building user interfaces across multiple platforms. It offers greater flexibility and features but requires more setup and learning. Choose based on your project's complexity and requirements.
小程序富文本组件,支持渲染和编辑 html,支持在微信、QQ、百度、支付宝、头条和 uni-app 平台使用
Pros of mp-html
- More actively maintained with frequent updates
- Supports a wider range of HTML tags and attributes
- Better performance, especially for complex HTML structures
Cons of mp-html
- Slightly larger package size
- May require more configuration for advanced use cases
Code Comparison
wxParse:
<import src="../../wxParse/wxParse.wxml"/>
<template is="wxParse" data="{{wxParseData:article.nodes}}"/>
mp-html:
<mp-html content="{{html}}" />
Key Differences
- Implementation: mp-html uses a more modern, component-based approach, while wxParse relies on older template-based rendering.
- Flexibility: mp-html offers more customization options and supports a broader range of HTML elements.
- Maintenance: mp-html is actively maintained and updated, whereas wxParse has been relatively stagnant.
- Performance: mp-html generally offers better performance, especially for complex HTML structures.
- Learning Curve: wxParse may be simpler to implement initially, but mp-html provides more powerful features for advanced users.
Both libraries serve the purpose of rendering HTML in WeChat Mini Programs, but mp-html offers more features and better long-term support. The choice between them depends on project requirements and complexity.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
æ±æåä½ï¼æ¬é¡¹ç®å·²ç»åæ¢ç»´æ¤ï¼ä¸ºäºä¸ç»æ¨ä½¿ç¨é æé®é¢ï¼è¯·ä» ååè使ç¨ï¼æè°¢åä½æ¯æ
wxParse-微信å°ç¨åºå¯ææ¬è§£æç»ä»¶
æ¯æHtmlåmarkdown转wxmlå¯è§å
çæ¬å·:0.3
æ¥æº: [微信å°ç¨åºå¼å论å-weappdev](https://weappdev.com)
ä½ç¨: å°Html/Markdown转æ¢ä¸ºå¾®ä¿¡å°ç¨åºçå¯è§åæ¹æ¡
ç¹æ§
æ¯æç¹æ§ | å®éªåè½ | ToDo |
---|---|---|
- [x] HTMLç大é¨åæ ç¾è§£æ | [x] å°è¡¨æ emjio | [x] tableæ ç¾ |
- [x] å èstyle | [x] aæ ç¾è·³è½¬ | |
- [x] æ ç¾Class | [x] å¨ææ·»å | |
- [x] å¾çèªéåºè§å | ||
- [x] å¾çå¤å¾çé¢è§ | ||
- [x] 模çå±çº§å¯æ©å±æ§ | ||
- [x] å¤æ°æ®å¾ªç¯æ¹å¼ | ||
- [x] å èstyle | ||
ç¸å ³æªå¾
æè°¢
@stonewen| @Daissmentii | @wuyanwen | @vcxiaohan |
åºæ¬ä½¿ç¨æ¹æ³
-
- Copyæ件夹
wxParse
- Copyæ件夹
- wxParse/
-wxParse.js(å¿
é¡»åå¨)
-html2json.js(å¿
é¡»åå¨)
-htmlparser.js(å¿
é¡»åå¨)
-showdown.js(å¿
é¡»åå¨)
-wxDiscode.js(å¿
é¡»åå¨)
-wxParse.wxml(å¿
é¡»åå¨)
-wxParse.wxss(å¿
é¡»åå¨)
-emojis(å¯é)
-
- å¼å ¥å¿ è¦æ件
//å¨ä½¿ç¨çViewä¸å¼å
¥WxParse模å
var WxParse = require('../../wxParse/wxParse.js');
//å¨ä½¿ç¨çWxssä¸å¼å
¥WxParse.css,å¯ä»¥å¨app.wxss
@import "/wxParse/wxParse.wxss";
-
- æ°æ®ç»å®
var article = '<div>ææ¯HTML代ç </div>';
/**
* WxParse.wxParse(bindName , type, data, target,imagePadding)
* 1.bindNameç»å®çæ°æ®å(å¿
å¡«)
* 2.typeå¯ä»¥ä¸ºhtmlæè
md(å¿
å¡«)
* 3.dataä¸ºä¼ å
¥çå
·ä½æ°æ®(å¿
å¡«)
* 4.target为Page对象,ä¸è¬ä¸ºthis(å¿
å¡«)
* 5.imagePadding为å½å¾çèªéåºæ¯å·¦å³çåä¸padding(é»è®¤ä¸º0,å¯é)
*/
var that = this;
WxParse.wxParse('article', 'html', article, that, 5);
-
- 模çå¼ç¨
// å¼å
¥æ¨¡æ¿
<import src="ä½ çè·¯å¾/wxParse/wxParse.wxml"/>
//è¿édataä¸article为bindName
<template is="wxParse" data="{{wxParseData:article.nodes}}"/>
é«çº§ç¨æ³
- é ç½®å°è¡¨æ emojis
/**
* WxParse.emojisInit(reg,baseSrc,emojis)
* 1.regï¼å¦æ ¼å¼ä¸º[00]=>èµå¼ reg='[]'
* 2.baseSrc,为åå¨emojisçå¾çæ件夹
* 3.emojis,å®ä¹è¡¨æ
é®å¼å¯¹
*/
WxParse.emojisInit('[]', "/wxParse/emojis/", {
"00": "00.gif",
"01": "01.gif",
"02": "02.gif",
"03": "03.gif",
"04": "04.gif",
"05": "05.gif",
"06": "06.gif",
"07": "07.gif",
"08": "08.gif",
"09": "09.gif",
"09": "09.gif",
"10": "10.gif",
"11": "11.gif",
"12": "12.gif",
"13": "13.gif",
"14": "14.gif",
"15": "15.gif",
"16": "16.gif",
"17": "17.gif",
"18": "18.gif",
"19": "19.gif",
});
- å¤æ°æ®æ ¼å¼
- åè§wikiwxParseå¤æ°æ®å¾ªç¯ä½¿ç¨æ¹æ³
FAQ
- åè§wikiweParse常è§é®é¢FAQ
äºæ¬¡å¼å
- åºç¡æ°æ®æ ¼å¼
parsedata:{
view:{},//æ ·å¼åå¨
nodes:{},//å±ç¤ºéè¦çåå¨èç¹
images:[],//åæ¾å¾ç对象æ°ç»
imageUrls:[],//åæ¾å¾çurlæ°ç»
}
- åè§wikiwxParseäºæ¬¡å¼åææ¡£
ç¸å ³æç«
- wxDiscodeï¼å¾®ä¿¡å°ç¨åºç¹æ®å符转ä¹ç¬¦è½¬åå·¥å ·ç±»
- 微信å°ç¨åºç»ä»¶wxParseä¸ç模çtemplateä½¿ç¨ æ¢ç¶ä¸è½å¾ªç¯é£å°±ä½¿ç¨ç¬¨åæ³
- 微信å°ç¨åºåå¾ççèªéåºè®¡ç®
æç®
- åè§wikiæç®ä½è
æ¥æº
微信å°ç¨åºå¼å论å åç´å¾®ä¿¡å°ç¨åºå¼å交æµç¤¾åº
å¯å¨ç½ç«æ«æäºç»´ç è¿å ¥æ们ç微信å°ç¨åºç¾¤ï¼ä¹å¯ä»¥å¾®ä¿¡æç´¢"weappmsg"è¿å ¥"å°ç æ¶æ¯"å ¬ä¼å· å ¶ä»æ¹å¼:åä½qq群511389428
Top Related Projects
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot