- 2023-06-19Turndown 源码分析:二、规则`commonmark-ruiles.js` REV1
import{repeat}from'./utilities'varrules={}//段落rules.paragraph={filter:'p',replacement:function(content){//前后加两个换行return'\n\n'+content+'\n\n'}}//换行rules.lineBrea
- 2023-06-19 Turndown 源码分析:四、`turndown.js`
importCOMMONMARK_RULESfrom'./commonmark-rules'importRulesfrom'./rules'import{extend,trimLeadingNewlines,trimTrailingNewlines}from'./utilities'importRootNodefrom'./root-node'importNodefrom'
- 2023-04-25 Turndown 源码解析:二、规则
规则集包含一系列规则,决定各种标签如何反编译。单个规则的格式是:{ filter:String|String[]|function(node), replacement:function(node,content,options),}filter字段用于判断节点是否适用单条规则。如果它是字符串,则判断node.nodeName===filter;如果它是字符串数
- 2023-04-25Turndown 源码解析:一、辅助函数
extend()Object.assign的补丁。functionextend(destination){for(vari=1;i<arguments.length;i++){varsource=arguments[i];for(varkeyinsource){if(source.hasOwnProperty(key))destination[key]=source[key];}}ret