aboutsummaryrefslogtreecommitdiffstats
path: root/haiku.js
diff options
context:
space:
mode:
authordrry2008-09-23 15:48:18 +0000
committerdrry2008-09-23 15:48:18 +0000
commita819abe04af7dd7efe6c8f029a51d48c2a2a19a7 (patch)
tree3cd0f0f96bef03f00330c495978a5533cde333d7 /haiku.js
parenta8d952d3be690c4325e19d8b555ef79429adea51 (diff)
downloadvimperator-plugins-a819abe04af7dd7efe6c8f029a51d48c2a2a19a7.tar.bz2
* 正規表現を修正しました。
* ほか。 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@19785 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'haiku.js')
-rw-r--r--haiku.js24
1 files changed, 12 insertions, 12 deletions
diff --git a/haiku.js b/haiku.js
index f3e71fb..f0f6a65 100644
--- a/haiku.js
+++ b/haiku.js
@@ -80,7 +80,7 @@
var html = <style type="text/css"><![CDATA[
span.haiku.entry-title { text-decoration: underline; }
- span.haiku.entry-content { white-space:normal; }
+ span.haiku.entry-content { white-space: normal; }
span.haiku.entry-content a { text-decoration: none; }
img.haiku.photo { border; 0px; width: 16px; height: 16px; vertical-align: baseline; }
]]></style>.toSource()
@@ -107,27 +107,27 @@
liberator.echo(html, true);
}
function convert(str){
- function createHTML(url,userid){
+ function createHTML(all){
var str = '';
- if (userid){
- str = '<a href="http://h.hatena.ne.jp/id/'+userid+'">id:'+userid+'</a>'
- } else if (/\.(?:jpe?g|gif|png|bmp)$/.test(url)){
- str = '<img src="'+url+'"/>';
- } else if (/^http:\/\/www\.youtube\.com\/(?:watch\?v=|v\/)([-\w]+)$/.test(url)){
+ if (all.indexOf("id:") == 0){
+ str = '<a href="http://h.hatena.ne.jp/id/' + all.substring(3) + '">' + all + '</a>'
+ } else if (/\.(?:jpe?g|gif|png|bmp)$/.test(all)){
+ str = '<img src="' + all + '"/>';
+ } else if (/^http:\/\/www\.youtube\.com\/(?:watch\?v=|v\/)([-\w]+)$/.test(all)){
var url = "http://www.youtube.com/v/" + RegExp.$1;
str = '<a href="#" class="hl-URL">' + url + '</a>\n' +
'<div><object height="250" width="300" data="' + url + '" type="application/x-shockwave-flash">' +
'<param name="wmode" value="transparent"/>' +
'</object></div>';
} else {
- if (url.charAt(0) == "<")
- str = url.replace(/(href|src)="\//g,'$1="http://h.hatena.ne.jp/');
- else
- str = '<a href="#" class="hl-URL">'+url+'</a>';
+ if (all.charAt(0) == "<")
+ str = all.replace(/(?:href|src)="(?=\/)/g,'$&http://h.hatena.ne.jp');
+ else
+ str = '<a href="#" class="hl-URL">' + all + '</a>';
}
return str;
}
- return str.replace(/<[^>]+>|https?:\/\/[-\w!#$%&'()*+,.\/:;=?@~]+|id:([-\w]+)/g, createHTML)
+ return str.replace(/<[^>]+>|https?:\/\/[-\w!#$%&'()*+,.\/:;=?@~]+|id:[a-zA-Z][-\w]{1,30}[a-zA-Z\d]/g, createHTML)
.replace("\n","<br/>","g");
}
liberator.commands.addUserCommand(["haiku"], "Change Haiku status",