├── LICENSE ├── README.md ├── copy.min.js ├── index.css ├── index.html └── index.js /LICENSE: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2 | Version 2, December 2004 3 | 4 | Copyright (C) 2004 Sam Hocevar 5 | 6 | Everyone is permitted to copy and distribute verbatim or modified 7 | copies of this license document, and changing it is allowed as long 8 | as the name is changed. 9 | 10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12 | 13 | 0. You just DO WHAT THE FUCK YOU WANT TO. 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BBCode To Markdown Converter 2 | 3 | Live version here: http://jondum.github.com/BBCode-To-Markdown-Converter/ 4 | -------------------------------------------------------------------------------- /copy.min.js: -------------------------------------------------------------------------------- 1 | function copyToClipboard(t){var e,n,o="INPUT"===t.tagName||"TEXTAREA"===t.tagName;o&&(target=t,e=t.selectionStart,n=t.selectionEnd);var c,a=document.activeElement;target.focus(),target.setSelectionRange(0,target.value.length);try{c=document.execCommand("copy")}catch(t){c=!1}return a&&"function"==typeof a.focus&&a.focus(),o?t.setSelectionRange(e,n):target.textContent="",c}document.getElementById("copybtn").addEventListener("click",function(){copyToClipboard(document.getElementById("left_ta"))}); -------------------------------------------------------------------------------- /index.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | margin: 0; 3 | padding: 0; 4 | height: 100%; 5 | background: #bdbdbd; 6 | overflow: hidden; 7 | } 8 | 9 | textarea { 10 | font-family: 'Marck Script',cursive; 11 | height: 100%; 12 | width: 100%; 13 | resize: none; 14 | } 15 | 16 | h1 { 17 | font-size: 2em; 18 | color: #454545; 19 | text-shadow: 0 1px #fff; 20 | display: inline; 21 | } 22 | 23 | span { 24 | margin-left: 50px; 25 | } 26 | 27 | @-moz-document url-prefix() { 28 | .ta_container { 29 | padding: 105px 20px 20px 20px; 30 | } 31 | } 32 | 33 | #fork { 34 | z-index:99999; 35 | background: #007bff; 36 | width: 215px; 37 | height: 24px; 38 | position: absolute; 39 | transform: rotate(40deg); 40 | right: -35px; 41 | top: 45px; 42 | } 43 | #fork a { 44 | color: whitesmoke; 45 | font-weight: bold; 46 | } 47 | 48 | #copybtn { 49 | height: 8% !important; 50 | } 51 | 52 | #boxing { 53 | height: 70%; 54 | } 55 | 56 | #boxing * { 57 | height: 100%; 58 | } -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | BBCode -> Markdown (Reddit) 7 | 8 | 9 | 10 | 11 | 12 |
13 | Fork me on Github 14 |
15 |
16 |
17 |
18 |

BBCode to Markdown (Reddit) Converter

19 |

Paste your BBCode into the left, Markdown appears on the right.

20 |

Please keep in mind that not all BBCode constructs are implemented yet.


21 |
22 |
23 |
24 |
25 |
26 |
27 | 28 |
29 |
30 | > 31 |
32 |
33 | 34 | 35 |
36 |
37 |
38 | 39 | 40 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 2 | function convert() { 3 | var left = document.getElementById('left_ta'); 4 | var right = document.getElementById('right_ta'); 5 | 6 | var left_value = left.value; 7 | 8 | //preprocessing for tf2toolbox BBCode 9 | if(left_value.search(/TF2Toolbox/gmi) != -1) { 10 | left_value = left_value 11 | .replace(/(\(List generated at .+?\[\/URL\]\))((?:.|\n)+)/gmi, '$2\n\n\n$1') //Move TF2Toolbox link to bottom 12 | .replace('(List generated at', '(List generated from') 13 | .replace(/[^\S\n]+\(List/gmi,'(List') 14 | .replace(/\[b\]\[u\](.+?)\[\/u\]\[\/b\]/gmi,'[b]$1[/b]\n') //Fix double emphasized titles 15 | .replace(/(\n)\[\*\]\[b\](.+?)\[\/b\]/gmi, '$1\[\*\] $2'); 16 | } 17 | 18 | //general BBcode conversion 19 | left_value = left_value 20 | .replace(/\[b\]((?:.|\n)+?)\[\/b\]/gmi, '**$1**') //bold; replace [b] $1 [/b] with ** $1 ** 21 | .replace(/\[\i\]((?:.|\n)+?)\[\/\i\]/gmi, '*$1*') //italics; replace [i] $1 [/u] with * $1 * 22 | .replace(/\[\u\]((?:.|\n)+?)\[\/\u\]/gmi, '$1') //remove underline; 23 | .replace(/\[s\]((?:.|\n)+?)\[\/s\]/gmi, '~~ $1~~') //strikethrough; replace [s] $1 [/s] with ~~ $1 ~~ 24 | .replace(/\[center\]((?:.|\n)+?)\[\/center\]/gmi, '$1') //remove center; 25 | .replace(/\[quote\=.+?\]((?:.|\n)+?)\[\/quote\]/gmi, '$1') //remove [quote=] tags 26 | .replace(/\[size\=.+?\]((?:.|\n)+?)\[\/size\]/gmi, '## $1') //Size [size=] tags 27 | .replace(/\[color\=.+?\]((?:.|\n)+?)\[\/color\]/gmi, '$1') //remove [color] tags 28 | .replace(/\[list\=1\]((?:.|\n)+?)\[\/list\]/gmi, function (match, p1, offset, string) {return p1.replace(/\[\*\]/gmi, '1. ');}) 29 | .replace(/(\n)\[\*\]/gmi, '$1* ') //lists; replcae lists with + unordered lists. 30 | .replace(/\[\/*list\]/gmi, '') 31 | .replace(/\[img\]((?:.|\n)+?)\[\/img\]/gmi,'![$1]($1)') 32 | .replace(/\[url=(.+?)\]((?:.|\n)+?)\[\/url\]/gmi,'[$2]($1)') 33 | .replace(/\[code\](.*?)\[\/code\]/gmi, '`$1`') 34 | .replace(/\[code\]((?:.|\n)+?)\[\/code\]/gmi, function (match, p1, offset, string) {return p1.replace(/^/gmi, ' ');}) 35 | .replace(/\[php\](.*?)\[\/php\]/gmi, '`$1`') 36 | .replace(/\[php\]((?:.|\n)+?)\[\/php\]/gmi, function (match, p1, offset, string) {return p1.replace(/^/gmi, ' ');}) 37 | .replace(/\[pawn\](.*?)\[\/pawn\]/gmi, '`$1`') 38 | .replace(/\[pawn\]((?:.|\n)+?)\[\/pawn\]/gmi, function (match, p1, offset, string) {return p1.replace(/^/gmi, ' ');}); 39 | 40 | //post processing for tf2toolbox BBCode 41 | if(left_value.search(/TF2Toolbox/gmi) != -1) { 42 | left_value = left_value 43 | .replace('/bbcode_lookup.php))', '/bbcode_lookup.php) and converted to /r/tf2trade ready Markdown by Dum\'s [converter](http://jondum.github.com/BBCode-To-Markdown-Converter/)).') //add a linkback 44 | .replace(/\*\*.+?\*\*[\s]+?None[\s]{2}/gmi, ''); //remove empty sections 45 | 46 | } 47 | 48 | right.value = left_value; 49 | 50 | } 51 | --------------------------------------------------------------------------------