Skip to content

Modify pagedown to support tables, strikethroughs, code blocks, etc.

Notifications You must be signed in to change notification settings

forzys/custom-markdown

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Custom-Markdown

Modify pagedown to support tables, strikethroughs, code blocks, etc.
修改 pagedown 添加table支持 添加删除线 以及代码块。

特性:极简(10k) gzip(5k) 支持度较好 高度自定义


Usage

import Markdown from './Markdown';

const converter = new Markdown.Converter()

let md = '_this_ is **easy** to `use`.';

let html = converter.makeHtml(md)

console.log(html);
//<p><em>this</em> is <strong>easy</strong> to <code>use</code>.</p>


// Hooks 

converter.hooks.chain("preConversion", function (text) {
    // This is the string before conversion
    return text.replace(/\b(a\w*)/gi, "**$1**");
});

converter.hooks.chain("plainLinkText", function (url) {
    // This is the matching URL link
    return "This is a link to " + url.replace(/^https?:\/\//, "");
});

converter.hooks.chain("postConversion", function (html) {
    // This is the converted HTML string
    return html
});
 

/**
 * Other Hook :
 * 添加代码高亮支持
 * postCodeGamut
 * 
 * postNormalization
 * preBlockGamut
 * postBlockGamut
 * preSpanGamut
 * postSpanGamut 
 * /

Build

方式1 

    1. 安装  
        yarn add rollup --dev
        npm install uglify-js -g
     
    2. 使用  
        yarn rollup Markdown.js --format cjs --file dist/Markdown_cjs.js
    
    3. 压缩  
        uglifyjs dist/Markdown_cjs.js -m -o dist/Markdown.min.js

方式2

    1. 安装    
        npm install uglify-js -g  // 全局安装 uglify
        yarn // 安装依赖

    2. build  
        yarn build
 

支持情况


标题

文本与分割线

引用

图片

列表

代码

高亮

表格

About

Modify pagedown to support tables, strikethroughs, code blocks, etc.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published