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 ...
随机推荐
- PHP:执行模型和内存模型
PHP:执行模型和内存模型 背景 对于任何一种语言,了解其执行模型和内存模型都是有意义的,本文中的内容不见得正确,请多批评. 执行模型 每个请求都是一个独立的PHP进程,两个请求之间会完全隔离,会话和 ...
- Machine Learning/Random Projection
这次突然打算写点dimension reduction的东西, 虽然可以从PCA, manifold learning之类的东西开始, 但很难用那些东西说出好玩的东西. 这次选择的是一个不太出名但很有 ...
- MySQL 的 phpmyadmin上传大小限制(转)以及 MySQL server has gone away 的解决办法
phpmyadmin上传大小限制 原帖地址:http://www.hmidc.com/home/news/?13914.html 时间:2011-6-21 11:17:57 作者:红帽之家 来源: ...
- Operation not permitted引发的惊魂72小时
0.问题及描述 在测试产品的时候,莫名其妙发现了我们的主进程VPNd会出现以下的报错: 2013-07-18 13:05:13 www.1.com/192.168.200.220:65527 wri ...
- Python学习入门基础教程(learning Python)--6 Python下的list数据类型
1. List是数组么? 答案是: 不是!Python 里面有一个非常强大的数据类型list.他什么都能装下!list里面既可以支持 int类型,也可以支持str类型. >>> li ...
- ASP.NET Zero--5.配置权限
修改角色的时候,会有一份权限列表,可以给这个角色分配哪些权限,那如何添加一个新权限呢? 这里以添加一个“测试”的权限为例 1.打开AppPermissions.cs [..\MyCompanyNa ...
- 【未来畅想】未来的电信通讯行业,账号密码将取代sim卡
今天看到一条新闻,是关于LG模块化的手机,LG将手机电池模块化了,很多人一片叫好,但是我认为模块化手机无法成为未来的趋势,原因如下:模块化必然要增加手机的卡口.插口增,意味着体积也大大增加,手机正因为 ...
- Nodejs应用安全备忘录
本人新博客www.wjs.photo,基于360的firekylin,感兴趣的可以看看哈 本文翻译自 www.risingstack.com ,并非逐字逐句的翻译,有错误的地方请指出,谢谢啦 应用程序 ...
- ClickOnce部署疑难杂症:更新时部署与应用程序标识不一致问题。要安装此应用程序,请修改此文件的清单版本或卸载之前存在的应用程序。
使用ClickOnce部署winform应用程序.无论是安装或者自动更新都极为方便,但有时候一些疑难杂症也令人头疼 1.注意每次部署完成之后 setup.exe无需覆盖,只需要在Application ...
- ASP.NET Zero--7.控制器加权限
上次已经实现了菜单权限的配置,达到了不同角色的用户显示不同的菜单.但这里还有BUG,如果你直接访问http://localhost:8019/Mpa/Test这个控制器时,并使用"Defau ...