Top Related Projects
Quick Overview
Wemark is a WeChat Mini Program markdown rendering library. It allows developers to easily convert markdown text into WeChat Mini Program compatible view elements, making it simple to display rich text content in WeChat Mini Programs.
Pros
- Easy integration with WeChat Mini Programs
- Supports a wide range of markdown syntax
- Customizable styles for rendered elements
- Lightweight and efficient
Cons
- Limited to WeChat Mini Program environment
- May not support some advanced markdown features
- Documentation is primarily in Chinese
- Requires understanding of WeChat Mini Program development
Code Examples
- Basic usage:
Page({
data: {
md: '# Hello\n\nThis is **bold** and this is *italic*.'
},
onLoad: function() {
var wemark = require('wemark');
wemark.parse(this.data.md, this, {
imageWidth: wx.getSystemInfoSync().windowWidth - 40,
name: 'wemark'
})
}
})
- Custom styling:
Page({
data: {
md: '# Custom Styled Heading\n\nThis is a paragraph.'
},
onLoad: function() {
var wemark = require('wemark');
wemark.parse(this.data.md, this, {
name: 'wemark',
theme: {
h1: {
color: '#ff0000',
fontSize: 32
},
paragraph: {
color: '#666666',
fontSize: 16
}
}
})
}
})
- Handling image loading:
Page({
data: {
md: '![An image](https://example.com/image.jpg)'
},
onLoad: function() {
var wemark = require('wemark');
wemark.parse(this.data.md, this, {
name: 'wemark',
imageLoad: (src, success, fail) => {
wx.getImageInfo({
src: src,
success: success,
fail: fail
})
}
})
}
})
Getting Started
-
Install wemark in your WeChat Mini Program project:
npm install wemark
-
In your page's JavaScript file, require wemark and use it to parse markdown:
const wemark = require('wemark'); Page({ data: { md: '# Hello Wemark\n\nThis is a **markdown** example.' }, onLoad: function() { wemark.parse(this.data.md, this, { name: 'wemark' }); } });
-
In your page's WXML file, add the wemark template:
<import src="../../wemark/wemark.wxml"/> <template is="wemark" data="{{wemark}}"/>
-
In your page's WXSS file, import wemark styles:
@import '../../wemark/wemark.wxss';
Competitor Comparisons
wxParse-微信小程序富文本解析自定义组件,支持HTML及markdown解析
Pros of wxParse
- Supports a wider range of HTML tags and attributes
- Offers more customization options for rendering
- Includes support for both Markdown and HTML parsing
Cons of wxParse
- Larger file size and potentially slower performance
- Less actively maintained, with fewer recent updates
- More complex setup and usage compared to wemark
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);
}
})
wemark:
var wemark = require('wemark');
Page({
onLoad: function () {
wemark.parse('# Hello, wemark!', this, {
imageWidth: 690,
name: 'wemark'
})
}
})
Both wxParse and wemark are libraries for rendering rich text in WeChat Mini Programs. wxParse offers more comprehensive HTML support and customization options, while wemark focuses specifically on Markdown rendering with a simpler API. wxParse may be better suited for complex HTML content, whereas wemark is more lightweight and easier to implement for Markdown-specific use cases.
微信小程序HTML、Markdown渲染库
Pros of towxml
- Supports both Markdown and HTML parsing
- Offers more customization options for styling and rendering
- Includes built-in support for LaTeX math expressions
Cons of towxml
- Larger file size and potentially higher resource usage
- More complex setup and configuration process
- May have a steeper learning curve for beginners
Code Comparison
wemark:
var wemark = require('wemark');
wemark.parse(markdown, {
imageWidth: 0,
name: 'wemark'
}, function(err, rendered) {
// rendered is an object containing the parsed result
});
towxml:
const Towxml = require('towxml');
const towxml = new Towxml();
let result = towxml.toJson(markdown, 'markdown');
this.setData({article: result});
Both libraries offer straightforward parsing of Markdown content, but towxml provides additional options for HTML parsing and more advanced rendering features. wemark focuses on simplicity and ease of use, while towxml offers more flexibility and customization at the cost of increased 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
wemark - 微信å°ç¨åºMarkdown渲æåº
å°ç¨åºå·²åçæ¯æHTML渲æï¼åºæ¬å¯æ¿ä»£wemarkï¼æ¨è使ç¨ãæ¬åºå¹´ä¹ 失修ï¼ç®åå¤äºä¸ç»´æ¤ç¶æï¼è¯·è°¨æ 使ç¨ã
èæ¯ååè½
ç¨äºå¨å°ç¨åºä¸æ¸²æMarkdownææ¬ã
å¨å°ç¨åºè¯çä¹åï¼Markdownç渲æä¸è¬éè¦è§£ææHTMLï¼ç¶å渲æ解æåçHTMLãç¶èå°ç¨åºå¹¶æ²¡ææä¾HTML渲æçåè½ï¼å æ¤å¨wemarkè¯çä¹åï¼å ä¹ææçMarkdown渲æåºå ¨é¨æ æ³å¨å°ç¨åºä¸æ£å¸¸å·¥ä½ã
wemarkå¯ä»¥å®ç°å¨å°ç¨åºä¸æ¸²æMarkdownå 容ï¼æ¯æå¾çãè¡¨æ ¼å¨å ç大é¨åMarkdownç¹æ§ã
ç¹æ§
- 以å°ç¨åºèªå®ä¹ç»ä»¶å½¢å¼æä¾ï¼å¯ç´æ¥å¼å ¥ä½¿ç¨
- æ¯æ大é¨åmarkdownæ è®°ç解æã渲æï¼è¯¦ç»æ¯ææ åµè§ä¸æ¹éå½ï¼
- æ¯æ代ç è¡¨æ ¼ã代ç é«äº®ãHTMLè§é¢çç¹æ§
- æ¯æ使ç¨åç
rich-text
è¿è¡æ¸²æ - å ¼å®¹mpvueçå¼åæ¡æ¶
使ç¨æ¹å¼
- ä¸è½½å¹¶æ·è´
wemark
ç®å½å°å°ç¨åºæ ¹ç®å½ - å¨é¡µé¢çé
ç½®æ件ä¸å¼ç¨
wemark
ç»ä»¶{ "usingComponents": { "wemark": "../wemark/wemark" } }
- WXMLä¸ä½¿ç¨ï¼
<wemark md="{{md}}" link highlight type="wemark"></wemark>
详ç»ä»£ç å¯è§
demo
ç®å½ï¼è¯¥ç®å½æ¯ä¸ä¸ªå®æ´çå°ç¨åºâ代ç ç段â项ç®ï¼å¯å¨wemarkæ ¹ç®å½å è¿è¡npm run copy
ï¼ç¶åæ·»å å°å¾®ä¿¡å¼åè å·¥å ·çâ代ç ç段âä¸è¿è¡ä½éªã
åæ°è¯´æï¼
md
ï¼å¿ å¡«ï¼éè¦æ¸²æçMarkdownå符串ï¼link
ï¼æ¯å¦è§£æé¾æ¥ï¼å¦æ解æï¼ä¼ä½¿ç¨å°ç¨åºnavigator
ç»ä»¶å±ç°ï¼å¯å¨å°ç¨åºå 跳转ï¼é»è®¤ä¸ºfalse
ï¼highlight
ï¼æ¯å¦å¯¹ä»£ç è¿è¡é«äº®å¤çï¼é»è®¤ä¸ºfalse
ï¼type
ï¼æ¸²ææ¹å¼ï¼wemark
ä¼ä½¿ç¨wemark
çæ°æ®ç»æå模æ¿è¿è¡æ¸²æï¼rich-text
ä¼ä½¿ç¨å°ç¨åºå ç½®çrich-text
ç»ä»¶è¿è¡æ¸²æï¼ä¸æ¯æé¾æ¥è·³è½¬ãè§é¢ï¼ã
注ï¼ä»£ç é«äº®ä¼ä½¿æ ç¾æ°éå解æåçæ°æ®éå¢å¤§ï¼ä¸æé¤äº§ç渲ææ§è½é®é¢ï¼è¯·æ ¹æ®å®é éè¦é æ 使ç¨ã
å ¶å®æ¡æ¶ä¸ä½¿ç¨
mpvue
mpvueæ¯æå¼å
¥å¾®ä¿¡èªå®ä¹ç»ä»¶ï¼å¯å¨é¡µé¢ç.js
æ件ä¸æ·»å é
ç½®ï¼å¼ç¨wemark
ï¼ç¶åå¨.vue
æ件çtemplate
é¨åç´æ¥ä½¿ç¨wemark
ï¼
export default {
config: {
// è¿å¿æ·»å è¦ç¨çå°ç¨åºç»ä»¶
usingComponents: {
wemark: '../../static/wemark/wemark'
}
}
}
<wemark :md="md" link highlight type="wemark"></wemark>
注ï¼ä¸ºäºè®©mpvueæå æ¶è½æ
wemark
å ä¸å¹¶æå å°dist
ç®å½ï¼å»ºè®®å°wemark
æ¾ç½®å¨æºç static
ç®å½ä¸ã
æ¬é¡¹ç®mpvue
ç®å½ä¸å
å«å®æ´çmpvueå°ç¨åºæ¼ç¤ºé¡¹ç®ï¼å¯å¨wemark
æ ¹ç®å½è¿è¡npm run copy
ï¼ç¶åå¨å¾®ä¿¡å¼åè
å·¥å
·ä¸æå¼ä½¿ç¨ã
taro
å¨å·²æçtaro项ç®ä¸è¿è¡å¦ä¸ä¿®æ¹ï¼
- å°
wemark
æ¾å ¥src
ç®å½ï¼å³src/wemark
ç®å½ - 设置ç¼è¯æ¶å¤å¶
wemark
ç®å½ï¼ä¿®æ¹config/index.js
ï¼å¨copy
设置项ä¸å¢åwemark
ï¼åèå¦ä¸ï¼copy: { patterns: [ { from: 'src/wemark', to: 'dist/wemark', }, ], options: { } },
- 设置taroç¼è¯æ¶å¿½ç¥
remarkable.js
ï¼ç»§ç»ä¿®æ¹config/index.js
ï¼åèå¦ä¸ï¼weapp: { compile: { exclude: [ 'src/wemark/remarkable.js', ] }, ... }
- å¨é¡µé¢ä¸å¼å
¥å使ç¨
wemark
ï¼ä¾å¦src/pages/index/index.js
ï¼config = { navigationBarTitleText: 'é¦é¡µ', usingComponents: { wemark: '../../wemark/wemark' } } state = { md: '# heading\n\nText' } //... render () { return ( <View className='index'> <wemark md={this.state.md} link highlight type='wemark' /> </View> ) }
- å¨
global.d.ts
ä¸æ·»å 以ä¸å 容ï¼ä» typescript 项ç®ï¼declare namespace JSX { interface IntrinsicElements { wemark: any } }
æ¬é¡¹ç®taro
ç®å½ä¸å
å«å®æ´çtaroå°ç¨åºæ¼ç¤ºé¡¹ç®ï¼å¯å¨wemark
æ ¹ç®å½è¿è¡npm run copy
ï¼ç¶åå¨å¾®ä¿¡å¼åè
å·¥å
·ä¸æå¼ä½¿ç¨ã
ç¹å«æè°¢ @Songkeys å ¨ç¨è·è¿taro使ç¨äºå®ï¼è¯¦æ è§ https://github.com/TooBug/wemark/issues/36 ã
éï¼ç¹æ§
- æ é¢
- 段è½
- 代ç 段ï¼å¯é«äº®ï¼
- å¼ç¨
- æ åºå表
- æåºå表
- ç²ä½
- 强è°ï¼æä½ï¼
- å é¤çº¿
- è¡å 代ç
- å¾ç
- è¡¨æ ¼
- HTMLæ è®°
- è§é¢
æµè¯
npm install
npm test
å¼æºåè®®
MIT
ç¨æ·å表
- TooNote
- çè è£èæ©ç¥é
- æçé
- 群éæäº ï¼ç®æµ å°è¯èç³»ä½è 确认ï¼æ²¡æååºï¼
- 麦è½Lite
- å端å°å©æï¼å端æ©æ¥ãå¨åçä¿¡æ¯ï¼
- GitHub Trending Hub (以 Feed æµå½¢å¼æ¥ç GitHub Trending ä»åºéåçå·¥å ·)
å¦æä½ ä¹ä½¿ç¨äº wemarkï¼æ¬¢è¿æ PR å°èªå·±çå°ç¨åºå å ¥å表
çæ¬è®°å½
v2.0.0 2019-02-23
- ä¿®å¤ä»£ç é«äº®å¼å¯æ¶é¨å代ç æ¾ç¤ºé误çé®é¢ #58
v2.0.0-beta2 2018-08-18
- ä¿®å¤HTML代ç é«äº®çbug #39
v2.0.0-beta1 2018-07-12
- éæ代ç ï¼ä½¿ç¨å°ç¨åºèªå®ä¹ç»ä»¶åå¸ï¼å ¼å®¹mpvue #34 #32 #24
- æ¯æ代ç é«äº® #25
- æ¯æé¾æ¥è§£æï¼å¨å°ç¨åºå 跳转 #37
- æ¯æ使ç¨å°ç¨åºå¯ææ¬ç»ä»¶
rich-text
渲æ - æ¯æâåç©ºæ ¼+å车âç软æ¢è¡æ¸²æ #29
v1.2.3 2018-07-05
- æ¯æ缩è¿å½¢å¼ç代ç 段 #31 by kapeter
- ä¿®å¤â##âåä¸å ç©ºæ ¼åæåæ¶æ¸²æåºéçé®é¢ #27
v1.2.2 2018-01-30
- ä¿®å¤å°ç¨åºæ¡æ¶æ´æ°åæ°ç»å¤æ失æ导è´æ¸²æ失败çé®é¢ #17
v1.2.1 2017-07-24
- æ¯æ使ç¨
video[poster]
å±æ§æ·»å è§é¢å°é¢å¾ #15 by @kilik52
v1.2.0 2017-06-30
- ä¸äºæ¸²æç»èæ ·å¼ä¿®æ£ #9 #10
- å¾ç渲æ使ç¨
widthFix
模å¼ï¼ä¸åå¨æ计ç®é«åº¦ #11 #12
v1.1.0 2017-01-22
- æ·»å å é¤çº¿æ¸²æï¼
~~deleted~~
ï¼ - æ·»å HTMLè§é¢è§£æï¼éæ±&åå§å®ç° by @littleduï¼
- 解æåè½è¡¥é½èªå¨æµè¯
v1.0.0 2016-12-12
- åºæ¬åè½
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