MCPcopy
hub / github.com/markedjs/marked / url

Method url

src/Tokenizer.ts:913–948  ·  view source on GitHub ↗
(src: string)

Source from the content-addressed store, hash-verified

911 }
912
913 url(src: string): Tokens.Link | undefined {
914 let cap;
915 if (cap = this.rules.inline.url.exec(src)) {
916 let text, href;
917 if (cap[2] === '@') {
918 text = cap[0];
919 href = 'mailto:' + text;
920 } else {
921 // do extended autolink path validation
922 let prevCapZero;
923 do {
924 prevCapZero = cap[0];
925 cap[0] = this.rules.inline._backpedal.exec(cap[0])?.[0] ?? '';
926 } while (prevCapZero !== cap[0]);
927 text = cap[0];
928 if (cap[1] === 'www.') {
929 href = 'http://' + cap[0];
930 } else {
931 href = cap[0];
932 }
933 }
934 return {
935 type: 'link',
936 raw: cap[0],
937 text,
938 href,
939 tokens: [
940 {
941 type: 'text',
942 raw: text,
943 text,
944 },
945 ],
946 };
947 }
948 }
949
950 inlineText(src: string): Tokens.Text | undefined {
951 const cap = this.rules.inline.text.exec(src);

Callers 1

inlineTokensMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected