Autolinker plugin
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
diff --git a/code.js b/code.js
index 4f9c39e..2f4cc2f 100644
--- a/code.js
+++ b/code.js
@@ -165,7 +165,8 @@ var components = {
hasCSS: true
},
'line-highlight': 'Line Highlight',
- 'show-invisibles': 'Show Invisibles'
+ 'show-invisibles': 'Show Invisibles',
+ 'autolinker': 'Autolinker'
}
};
diff --git a/download.html b/download.html
index 4088790..d82fd58 100644
--- a/download.html
+++ b/download.html
@@ -101,7 +101,7 @@ section.download {
<p>
Total filesize: <strong id="filesize"></strong> (<strong id="percent-js"></strong> JavaScript + <strong id="percent-css"></strong> CSS)
</p>
- <p><strong>Note:</strong> The filesizes displayed refer to non-gizipped files and include any CSS code required.</p>
+ <p><strong>Note:</strong> The filesizes displayed refer to non-gizipped files and include any CSS code required. The CSS code is not minified.</p>
<section id="download">
<section id="download-js" class="download">
diff --git a/plugins/autolinker/index.html b/plugins/autolinker/index.html
new file mode 100644
index 0000000..430b0aa
--- /dev/null
+++ b/plugins/autolinker/index.html
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<html lang="en" class="simple">
+<head>
+
+<meta charset="utf-8" />
+<title>Show Invisibles ▲ Prism plugins</title>
+<base href="../.." />
+<link rel="stylesheet" href="style.css" />
+<link rel="stylesheet" href="prism.css" data-noprefix />
+<link rel="stylesheet" href="plugins/autolinker/prism-autolinker.css" data-noprefix />
+<script src="../prefixfree/prefixfree.min.js"></script>
+
+</head>
+<body>
+
+<header>
+ <div class="intro" data-src="templates/header-plugins.html" data-type="text/html"></div>
+
+ <h2>Autolinker</h2>
+ <p>Converts URLs and emails in code to clickable links</p>
+</header>
+
+<section>
+ <h1>Examples</h1>
+
+ <pre><code class="language-javascript">/**
+ * Prism: Lightweight, robust, elegant syntax highlighting
+ * MIT license http://www.opensource.org/licenses/mit-license.php/
+ * @author Lea Verou http://lea.verou.me
+ * Reach Lea at fake@email.com (no, not really)
+ */
+var foo = 5;
+// And a single line comment http://google.com</code></pre>
+
+ <pre><code class="language-css">@font-face {
+ src: url(http://lea.verou.me/logo.otf);
+ font-family: 'LeaVerou';
+}</code></pre>
+</section>
+
+<footer data-src="templates/footer.html" data-type="text/html"></footer>
+
+<script src="prism.js"></script>
+<script src="plugins/autolinker/prism-autolinker.js"></script>
+<script src="utopia.js"></script>
+<script src="code.js"></script>
+
+
+</body>
+</html>
\ No newline at end of file
diff --git a/plugins/autolinker/prism-autolinker.css b/plugins/autolinker/prism-autolinker.css
new file mode 100644
index 0000000..b5f7630
--- /dev/null
+++ b/plugins/autolinker/prism-autolinker.css
@@ -0,0 +1,3 @@
+.token a {
+ color: inherit;
+}
\ No newline at end of file
diff --git a/plugins/autolinker/prism-autolinker.js b/plugins/autolinker/prism-autolinker.js
new file mode 100644
index 0000000..71f23eb
--- /dev/null
+++ b/plugins/autolinker/prism-autolinker.js
@@ -0,0 +1,19 @@
+(function(){
+
+if (!window.Prism) {
+ return;
+}
+
+var url = /\b([a-z]{3,7}:\/\/|tel:)\S+/g,
+ email = /\b\S+@[\w.]+[a-z]{2}/g,
+ candidates = ['comment', 'line-comment', 'url'];
+
+Prism.hooks.add('wrap', function(env) {
+ if (candidates.indexOf(env.type) > -1) {
+ env.content = env.content
+ .replace(url, '<a href="$&">$&</a>')
+ .replace(email, '<a href="mailto:$&">$&</a>')
+ }
+});
+
+})();
\ No newline at end of file
diff --git a/plugins/autolinker/prism-autolinker.min.js b/plugins/autolinker/prism-autolinker.min.js
new file mode 100644
index 0000000..5e43fd3
--- /dev/null
+++ b/plugins/autolinker/prism-autolinker.min.js
@@ -0,0 +1 @@
+(function(){if(!window.Prism)return;var e=/\b([a-z]{3,7}:\/\/|tel:)\S+/g,t=/\b\S+@[\w.]+[a-z]{2}/g,n=["comment","line-comment","url"];Prism.hooks.add("wrap",function(r){n.indexOf(r.type)>-1&&(r.content=r.content.replace(e,'<a href="$&">$&</a>').replace(t,'<a href="mailto:$&">$&</a>'))})})();
\ No newline at end of file
diff --git a/prism-funky.css b/prism-funky.css
index 4120132..693d663 100644
--- a/prism-funky.css
+++ b/prism-funky.css
@@ -30,7 +30,6 @@ pre[class*="language-"] {
overflow: auto;
background: url('data:image/svg+xml;charset=utf-8,<svg%20version%3D"1.1"%20xmlns%3D"http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg"%20width%3D"100"%20height%3D"100"%20fill%3D"rgba(0%2C0%2C0%2C.2)">%0D%0A<polygon%20points%3D"0%2C50%2050%2C0%200%2C0"%20%2F>%0D%0A<polygon%20points%3D"0%2C100%2050%2C100%20100%2C50%20100%2C0"%20%2F>%0D%0A<%2Fsvg>');
background-size: 1em 1em;
- line-height: 1.4;
}
code[class*="language-"] {