• 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*([ 	]*([^"']*)(?:[ 	]+(["'])(.*?)2)?[ 	]*)/ );
            //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
  • 相关阅读:
    不在折腾---hbase-0.96.2-hadoop2
    不在折腾---hive-0.13.1-bin
    不在折腾---storm-0.9.2-incubating分布式安装
    zookeeper的zoo.cfg的配置
    Linux常用命令
    不在折腾----zookeeper-3.4.5
    VMware克隆后,网卡若干问题
    防火墙基础技术-02
    JavaScript email格式校验
    js透明按钮图片滑动切换焦点图
  • 原文地址:https://www.cnblogs.com/aliblogs/p/5941080.html
Copyright © 2020-2023  润新知