You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unfortunately, can't use the double-quote " mark as it's stripped before the args is populated. Propose using the back-tick ` mark instead. See my solution to this problem:
'use strict';// {% link title, url %}// {% link `title`, url, img %}hexo.extend.tag.register('link',function(args){lettext='';leturl='';letimg='';letresult='';//args are defaulted to space ` ` delimited...args=args.join(' ');// console.info("{% link {{args}} %}: ", args);//check for encapsulating back-tick (`) marks, if exist pull out titleif(args.indexOf("`",1)>1){//extract title from argstext=args.split('`')[1];// console.log(" {% link {{text}} %}: ", text);// grab URL (& img)args=args.split('`')[2].split(",");}else{// console.info(" text not back-ticked encapsulated...");args=args.split(',');text=args[0].trim();}//check for URLif(args.length>=2){url=args[1].trim();// console.log(" {% link {{url}} %}: ", url);}//check for imgif(args.length==3){img=args[2].trim();// console.log(" {% link {{img}} %}: ", img);}if(url!==''){// 发现如果不套一层 div 在其它可渲染 md 的容器中容易被分解result+='<div class="tagLink"><a class="link-card" title="'+text+'" href="'+url+'">';// leftresult+='<div class="left">';result+='<img src="'+(img||hexo.theme.config.tag_plugins.linkImg)+'"/>';result+='</div>';// rightresult+='<div class="right"><p class="text">'+text+'</p><p class="url">'+url+'</p></div>';result+='</a></div>';}returnresult;});hexo.extend.tag.register('linkgroup',function(args,content){letret='';ret+='<div class="link-group">';ret+=content;ret+='</div>';returnret;},{ends: true});
The comma is often used in languages with the alphabet and is required in certain cases. Please consider updating this function. My version is backwards compatible with existing link tags that don't use a back-tick to denote a title.
The text was updated successfully, but these errors were encountered:
lorezyra
changed the title
{% link %} tag doesn't handle ENGLISH titles with a comma (,){% link %} tag doesn't handle ENGLISH titles with a comma (,)
Aug 31, 2022
This code is not only WET, but does not handle text with a comma
,
...hexo-theme-bamboo/scripts/tag/link.js
Lines 5 to 33 in 6b383a8
Unfortunately, can't use the double-quote
"
mark as it's stripped before the args is populated. Propose using the back-tick`
mark instead. See my solution to this problem:The comma is often used in languages with the alphabet and is required in certain cases. Please consider updating this function. My version is backwards compatible with existing link tags that don't use a back-tick to denote a title.
The text was updated successfully, but these errors were encountered: