Still hate switches.

This commit is contained in:
Zixaphir 2014-01-19 21:38:46 -07:00
parent f37484cd33
commit 11e5f348f0
3 changed files with 39 additions and 77 deletions

View File

@ -3408,32 +3408,19 @@
return Get.insert(post, root, context); return Get.insert(post, root, context);
}, },
parseMarkup: function(text) { parseMarkup: function(text) {
switch (text) { return {
case '\n': '\n': '<br>',
return '<br>'; '[b]': '<b>',
case '[b]': '[/b]': '</b>',
return '<b>'; '[spoiler]': '<s>',
case '[/b]': '[/spoiler]': '</s>',
return '</b>'; '[code]': '<pre class=prettyprint>',
case '[spoiler]': '[/code]': '</pre>',
return '<s>'; '[moot]': '<div style="padding:5px;margin-left:.5em;border-color:#faa;border:2px dashed rgba(255,0,0,.1);border-radius:2px">',
case '[/spoiler]': '[/moot]': '</div>',
return '</s>'; '[banned]': '<strong style="color: red;">',
case '[code]': '[/banned]': '</strong>'
return '<pre class=prettyprint>'; }[text] || text.replace(':lit', '');
case '[/code]':
return '</pre>';
case '[moot]':
return '<div style="padding:5px;margin-left:.5em;border-color:#faa;border:2px dashed rgba(255,0,0,.1);border-radius:2px">';
case '[/moot]':
return '</div>';
case '[banned]':
return '<strong style="color: red;">';
case '[/banned]':
return '</strong>';
default:
return text.replace(':lit', '');
}
} }
}; };

View File

@ -3418,32 +3418,19 @@
return Get.insert(post, root, context); return Get.insert(post, root, context);
}, },
parseMarkup: function(text) { parseMarkup: function(text) {
switch (text) { return {
case '\n': '\n': '<br>',
return '<br>'; '[b]': '<b>',
case '[b]': '[/b]': '</b>',
return '<b>'; '[spoiler]': '<s>',
case '[/b]': '[/spoiler]': '</s>',
return '</b>'; '[code]': '<pre class=prettyprint>',
case '[spoiler]': '[/code]': '</pre>',
return '<s>'; '[moot]': '<div style="padding:5px;margin-left:.5em;border-color:#faa;border:2px dashed rgba(255,0,0,.1);border-radius:2px">',
case '[/spoiler]': '[/moot]': '</div>',
return '</s>'; '[banned]': '<strong style="color: red;">',
case '[code]': '[/banned]': '</strong>'
return '<pre class=prettyprint>'; }[text] || text.replace(':lit', '');
case '[/code]':
return '</pre>';
case '[moot]':
return '<div style="padding:5px;margin-left:.5em;border-color:#faa;border:2px dashed rgba(255,0,0,.1);border-radius:2px">';
case '[/moot]':
return '</div>';
case '[banned]':
return '<strong style="color: red;">';
case '[/banned]':
return '</strong>';
default:
return text.replace(':lit', '');
}
} }
}; };

View File

@ -215,28 +215,16 @@ Get =
Main.callbackNodes Post, [post] Main.callbackNodes Post, [post]
Get.insert post, root, context Get.insert post, root, context
parseMarkup: (text) -> parseMarkup: (text) ->
switch text {
when '\n' '\n': '<br>'
'<br>' '[b]': '<b>'
when '[b]' '[/b]': '</b>'
'<b>' '[spoiler]': '<s>'
when '[/b]' '[/spoiler]': '</s>'
'</b>' '[code]': '<pre class=prettyprint>'
when '[spoiler]' '[/code]': '</pre>'
'<s>' '[moot]': '<div style="padding:5px;margin-left:.5em;border-color:#faa;border:2px dashed rgba(255,0,0,.1);border-radius:2px">'
when '[/spoiler]' '[/moot]': '</div>'
'</s>' '[banned]': '<strong style="color: red;">'
when '[code]' '[/banned]': '</strong>'
'<pre class=prettyprint>' }[text] or text.replace ':lit', ''
when '[/code]'
'</pre>'
when '[moot]'
'<div style="padding:5px;margin-left:.5em;border-color:#faa;border:2px dashed rgba(255,0,0,.1);border-radius:2px">'
when '[/moot]'
'</div>'
when '[banned]'
'<strong style="color: red;">'
when '[/banned]'
'</strong>'
else
text.replace ':lit', ''