markdown 自定义一个锚点
//自定义锚点 s
"m[": function mlink( text ) {
var orig = String(text);
// Inline content is possible inside `link text`
var res = inline_until_char.call( this, text.substr(2), "]" ); // No closing ']' found. Just consume the [
if ( !res )
return [ 1, "m" ]; var consumed = 2 + res[ 0 ],
children = res[ 1 ],
link,
attrs; // At this point the first [...] has been parsed. See what follows to find
// out which kind of link we are (reference or direct url)
text = text.substr( consumed ); // [link text](/path/to/img.jpg "Optional title")
// 1 2 3 <--- captures
// This will capture up to the last paren in the block. We then pull
// back based on if there a matching ones in the url
// ([here](/url/(test))
// The parens have to be balanced
var m = text.match( /^\s*\([ \t]*([^"']*)(?:[ \t]+(["'])(.*?)\2)?[ \t]*\)/ );
//alert(text+"-"+ m)
if ( m ) { var url = m[1];
consumed += m[0].length; if ( url && url[0] === "<" && url[url.length-1] === ">" )
url = url.substring( 1, url.length - 1 ); // If there is a title we don't have to worry about parens in the url
if ( !m[3] ) {
var open_parens = 1; // One open that isn't in the capture
for ( var len = 0; len < url.length; len++ ) {
switch ( url[len] ) {
case "(":
open_parens++;
break;
case ")":
if ( --open_parens === 0) {
consumed -= url.length - len;
url = url.substring(0, len);
}
break;
}
}
} // Process escapes only
url = this.dialect.inline.__call__.call( this, url, /\\/ )[0]; attrs = { };
if ( m[1] !== undefined)
attrs.id = m[1]; link = [ "link", attrs ].concat( children );
return [ consumed, link ];
} // [Alt text][id]
// [Alt text] [id]
m = text.match( /^\s*\[(.*?)\]/ ); if ( m ) { consumed += m[ 0 ].length; // [links][] uses links as its reference
attrs = { ref: ( m[ 1 ] || String(children) ).toLowerCase(), original: orig.substr( 0, consumed ) }; link = [ "link_ref", attrs ].concat( children ); // We can't check if the reference is known here as it likely wont be
// found till after. Check it in md tree->hmtl tree conversion.
// Store the original so that conversion can revert if the ref isn't found.
return [ consumed, link ];
} // [id]
// Only if id is plain (no formatting.)
if ( children.length === 1 && typeof children[0] === "string" ) { attrs = { ref: children[0].toLowerCase(), original: orig.substr( 0, consumed ) };
link = [ "link_ref", attrs, children[0] ];
return [ consumed, link ];
} // Just consume the "["
return [ 1, "[" ];
},
//自定义锚点 e
调用 :
自定义一个id为aaa的锚点
m[](aaa) 空格空格
空格空格
next
markdown 自定义一个锚点的更多相关文章
- markdown中的锚点处理
markdown markdown是一个相对简单的DSL,定义了简单的标签来描述html文档格式. 比如: #一级标题 来生成html <h1>一级标题<h1> ##二级标题 ...
- SpringMVC 自定义一个拦截器
自定义一个拦截器方法,实现HandlerInterceptor方法 public class FirstInterceptor implements HandlerInterceptor{ /** * ...
- 利用git+hugo+markdown 搭建一个静态网站
利用git+hugo+markdown 搭建一个静态网站 一直想要有一个自己的文档管理系统: 可以很方便书写,而且相应的文档很容易被分享 很方便的存储.管理.历史记录 比较方面的浏览和查询 第一点用M ...
- jQuery Validate 表单验证插件----自定义一个验证方法
一.下载依赖包 网盘下载:https://yunpan.cn/cryvgGGAQ3DSW 访问密码 f224 二.引入依赖包 <script src="../../scripts/j ...
- Spring自定义一个拦截器类SomeInterceptor,实现HandlerInterceptor接口及其方法的实例
利用Spring的拦截器可以在处理器Controller方法执行前和后增加逻辑代码,了解拦截器中preHandle.postHandle和afterCompletion方法执行时机. 自定义一个拦截器 ...
- JSTL,自定义一个标签的功能案例
1.自定义一个带有两个属性的标签<max>,用于计算并输出两个数的最大值: 2.自定义一个带有一个属性的标签<lxn:readFile src=“”>,用于输出指定文件的内容 ...
- 自定义View(7)官方教程:自定义View(含onMeasure),自定义一个Layout(混合组件),重写一个现有组件
Custom Components In this document The Basic Approach Fully Customized Components Compound Controls ...
- Volley HTTP库系列教程(5)自定义一个Volley请求
Implementing a Custom Request Previous Next This lesson teaches you to Write a Custom Request parse ...
- 在String()构造器不存在的情况下自定义一个MyString()函数,实现如下内建String()方法和属性:
在String()构造器不存在的情况下自定义一个MyString()函数,实现如下内建String()方法和属性: var s = new MyString("hello"); s ...
随机推荐
- hadoop集群安装
首现非常感谢 虾皮(http://www.cnblogs.com/xia520pi/archive/2012/05/16/2503949.html) 安装过程是参照他的<Hadoop集群(第5期 ...
- vsftp FTP服务器 server settings , and add different users
建议阅读知识:http://linux.vbird.org/linux_basic/0210filepermission.php 这是关于档案权限,用户,组等的问题.介绍的很有意思. 1. Inst ...
- DB2使用存储过程插入数据
要求:插入一张表(TESTMV)中三个字段(ID, GROUPID[组id], USERID[用户id]),为了产生多个组,每个组多个人的数据,进行统计每个组多少人数据用 代码如下: delete t ...
- Hadoop HDFS文件操作
1.创建目录 import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.ha ...
- sharepoint 2013 文档库eventhandle权限控制
记录一下如何在sharepoint server 2013文档库中,使用eventhandle控制文档库document library的条目item权限. ///<summary> // ...
- Js-Html 前端系列--Ajax
最近在做Web项目,用到很多Ajax,也遇到很多问题.下面与大家分享. Ajax传参 Ajax同步与异步 Ajax与谷歌浏览器 Ajax传参 我们一般传参有两种形式: $.ajax({ ... dat ...
- ruby web性能响应时间
可以统计单个web页面加载时间. require 'watir-webdriver' require 'watir-webdriver-performance' b = Watir::Browser. ...
- 在VirtualBox上安装CentOS7
文章的出处:http://jingyan.baidu.com/article/9c69d48f8ec01613c8024e58.html 工具: VirtualBox-5.1.2-108956-Win ...
- select的onchange事件获取不了option的value
一,select的onchange事件获取不了option的value是当你使用JQ($("#xxx").val())方法的获取的值一直提示undefined 二,解决方法: va ...
- LIst去重,重写方法,继承接口。
调用: ]).ToList(); var dic = dataThis.Distinct( new repDic()).ToList();var repList = ""; for ...