MCPcopy Create free account
hub / github.com/cnodejs/nodeclub / writeImageTag

Function writeImageTag

public/libs/showdown.js:718–763  ·  view source on GitHub ↗
(wholeMatch,m1,m2,m3,m4,m5,m6,m7)

Source from the content-addressed store, hash-verified

716}
717
718var writeImageTag = function(wholeMatch,m1,m2,m3,m4,m5,m6,m7) {
719 var whole_match = m1;
720 var alt_text = m2;
721 var link_id = m3.toLowerCase();
722 var url = m4;
723 var title = m7;
724
725 if (!title) title = "";
726
727 if (url == "") {
728 if (link_id == "") {
729 // lower-case and turn embedded newlines into spaces
730 link_id = alt_text.toLowerCase().replace(/ ?\n/g," ");
731 }
732 url = "#"+link_id;
733
734 if (g_urls[link_id] != undefined) {
735 url = g_urls[link_id];
736 if (g_titles[link_id] != undefined) {
737 title = g_titles[link_id];
738 }
739 }
740 else {
741 return whole_match;
742 }
743 }
744
745 alt_text = alt_text.replace(/"/g,""");
746 url = isUrl(url) ? url : HOST + url;
747
748 url = escapeCharacters(url,"*_");
749 var result = "<img src=\"" + url + "\" alt=\"" + alt_text + "\"";
750
751 // attacklab: Markdown.pl adds empty title attributes to images.
752 // Replicate this bug.
753
754 //if (title != "") {
755 title = title.replace(/"/g,"&quot;");
756 title = escapeCharacters(title,"*_");
757 result += " title=\"" + title + "\"";
758 //}
759
760 result += " />";
761
762 return result;
763}
764
765
766var _DoHeaders = function(text) {

Callers

nothing calls this directly

Calls 2

isUrlFunction · 0.85
escapeCharactersFunction · 0.70

Tested by

no test coverage detected