|
45 | 45 | }; |
46 | 46 |
|
47 | 47 | Prism.hooks.add('before-tokenize', function (env) { |
48 | | - if (env.language !== 'markdown') { |
49 | | - Prism.plugins.autolinker.processGrammar(env.grammar); |
50 | | - } |
| 48 | + if (env.language !== 'markdown') { |
| 49 | + Prism.plugins.autolinker.processGrammar(env.grammar); |
| 50 | + } |
51 | 51 | }); |
52 | 52 |
|
53 | 53 | Prism.hooks.add('wrap', function (env) { |
54 | | - if (env.language !== 'markdown') { |
55 | | - if (/-link$/.test(env.type)) { |
56 | | - env.tag = 'a'; |
57 | | - |
58 | | - var href = env.content; |
59 | | - |
60 | | - if (env.type == 'email-link' && href.indexOf('mailto:') != 0) { |
61 | | - href = 'mailto:' + href; |
62 | | - } else if (env.type == 'md-link') { |
63 | | - // Markdown |
64 | | - var match = env.content.match(linkMd); |
65 | | - |
66 | | - href = match[2]; |
67 | | - env.content = match[1]; |
68 | | - } |
69 | | - |
70 | | - var isMac = navigator.platform.indexOf('Mac') > -1; |
71 | | - |
72 | | - env.attributes.href = href.replaceAll('\'','').replaceAll('"','').replaceAll('`',''); |
73 | | - env.attributes.onclick = 'if ((event.ctrlKey || event.metaKey) && event.shiftKey) { event.preventDefault(); window.open(this.href, "_blank") }'; |
74 | | - env.attributes.title = isMac ? '⌘ + shift + click to open link' : 'Ctrl + shift + click to open link'; |
75 | | - |
76 | | - // Silently catch any error thrown by decodeURIComponent (#1186) |
77 | | - try { |
78 | | - env.content = decodeURIComponent(env.content); |
79 | | - } catch (e) { /* noop */ } |
80 | | - } |
81 | | - } |
| 54 | + if (env.language !== 'markdown') { |
| 55 | + if (/-link$/.test(env.type)) { |
| 56 | + env.tag = 'a'; |
| 57 | + |
| 58 | + var href = env.content; |
| 59 | + |
| 60 | + if (env.type == 'email-link' && href.indexOf('mailto:') != 0) { |
| 61 | + href = 'mailto:' + href; |
| 62 | + } else if (env.type == 'md-link') { |
| 63 | + // Markdown |
| 64 | + var match = env.content.match(linkMd); |
| 65 | + |
| 66 | + href = match[2]; |
| 67 | + env.content = match[1]; |
| 68 | + } |
| 69 | + |
| 70 | + var isMac = navigator.platform.indexOf('Mac') > -1; |
| 71 | + |
| 72 | + env.attributes.href = href.replaceAll('\'','').replaceAll('"','').replaceAll('`',''); |
| 73 | + env.attributes.onclick = 'if ((event.ctrlKey || event.metaKey) && event.shiftKey) { event.preventDefault(); window.open(this.href, "_blank") }'; |
| 74 | + env.attributes.title = isMac ? '⌘ + shift + click to open link' : 'Ctrl + shift + click to open link'; |
| 75 | + |
| 76 | + // Silently catch any error thrown by decodeURIComponent (#1186) |
| 77 | + try { |
| 78 | + env.content = decodeURIComponent(env.content); |
| 79 | + } catch (e) { /* noop */ } |
| 80 | + } |
| 81 | + } |
82 | 82 | }); |
83 | 83 |
|
84 | 84 | }()); |
0 commit comments