Fix qlink(), rearrange mangleRecord(), fix some style
mangleRecord() should now processes bold/italics before lists, so it should
properly distinguish between a * beginning a line and a * beginning a list
(but maybe not).
.quote {
border-left: 2px solid blue;
padding-left: 6px;
+ margin-left: 2px;
}
<h1><a href="/">Blërg!</a></h1>
<h2><span name="section">Welcome</span></h2>
<div id="usercontrols" style="display:none">
- <a href="#" name="user.reflink">[chatter]</a>
+ <a href="#" name="user.reflink" onclick="return qlink()">[chatter]</a>
<a href="#" name="user.subscribelink" onclick="subscribe(); return false" style="display: none">[stalk]</a>
<a href="#" name="user.unsubscribelink" onclick="unsubscribe(); return false" style="display: none">[stop stalking]</a>
</div>
return;
}
+ // Put quoted material into a special paragraph
if (l[0] == '>') {
var pi = out.lastIndexOf('<p>');
if (pi != -1) {
l = l.replace(/^>\s*/, '');
}
}
+
+ // Sanitize HTML input
+ l = l.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
+
+ // Turn HTTP URLs into links
+ l = l.replace(/(\s|^)(https?:\/\/[a-zA-Z0-9.-]*[a-zA-Z0-9](\/([^\s"]*[^.!,;?()\s])?)?)/g, '$1<a href="$2">$2</a>');
+
+ // Turn markdown links into links
+ l = l.replace(/(\s|^)\[([^\]]+)\]\((https?:\/\/[a-zA-Z0-9.-]*[a-zA-Z0-9](\/[^)"]*?)?)\)/g, '$1<a href="$3">$2</a>');
+
+ // Turn *foo* into italics and **foo** into bold
+ l = l.replace(/(\W|^)\*\*([^*]+)\*\*(\W|$)/g, '$1<b>$2</b>$3');
+ l = l.replace(/(\W|^)\*([^*]+)\*(\W|$)/g, '$1<i>$2</i>$3');
+
+ // Turn refs and tags into links
+ l = l.replace(/(\s|^)#([A-Za-z0-9_-]+)/g, '$1<a href="#/tag/$2" class="ref" onclick="return qlink()">#$2</a>');
+ l = l.replace(/(\s|^)@([A-Za-z0-9_-]+)/g, '$1<a href="#$2" class="ref" onclick="return qlink()">@$2</a>');
+
+ // Create lists when lines begin with *
if (l[0] == '*') {
if (!listMode) {
var pi = out.lastIndexOf('<p>');
out.push('<li>');
endpush = '</li>';
}
+
+ // Create headers when lines begin with =
if (l[0] == '=') {
var m = l.match(/^(=+)/);
var depth = m[1].length;
}
}
- // Sanitize HTML input
- l = l.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
-
- // Turn HTTP URLs into links
- l = l.replace(/(\s|^)(https?:\/\/[a-zA-Z0-9.-]*[a-zA-Z0-9](\/([^\s"]*[^.!,;?()\s])?)?)/g, '$1<a href="$2">$2</a>');
-
- // Turn markdown links into links
- l = l.replace(/(\s|^)\[([^\]]+)\]\((https?:\/\/[a-zA-Z0-9.-]*[a-zA-Z0-9](\/[^)"]*?)?)\)/g, '$1<a href="$3">$2</a>');
-
- // Turn *foo* into italics and **foo** into bold
- l = l.replace(/(\s)\*\*([^*]+)\*\*(\s)/g, '$1<b>$2</b>$3');
- l = l.replace(/(\s)\*([^*]+)\*(\s)/g, '$1<i>$2</i>$3');
-
- // Turn refs and tags into links
- l = l.replace(/(\s|^)#([A-Za-z0-9_-]+)/g, '$1<a href="#/tag/$2" class="ref" onclick="return qlink()">#$2</a>');
- l = l.replace(/(\s|^)@([A-Za-z0-9_-]+)/g, '$1<a href="#$2" class="ref" onclick="return qlink()">@$2</a>');
-
out.push(l);
if (endpush) {
out.push(endpush);
});
while (out[out.length - 1] == '<br>' || out[out.length - 1] == '<p>')
out.pop();
+ if (listMode)
+ out.push('</ul>');
record.data = out.join('');
record.date = (new Date(record.timestamp * 1000)).toString();
function qlink(loc) {
if (loc) {
location.hash = loc;
- } else if (this.href) {
- location.hash = this.href;
+ } else if (event && event.target) {
+ location.href = event.target.href;
} else {
// Bogus qlink
return;
setInterval(hashCheck, 250);
document.body.observe('keyup', function(event) {
- if (event.shiftKey && event.keyCode == '32') {
+ if (event.shiftKey && event.keyCode == 32) {
postPopup();
event.stop();
}