-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.html
158 lines (154 loc) · 7.01 KB
/
index.html
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Markdown Github to BBCode Feral converter</title>
<link rel="stylesheet" href="css/foundation.css" />
<script src="js/vendor/modernizr.js"></script>
<style type="text/css" media="screen">
.mycustom1 {
}
.textdivsize {
height: 300px;
padding: 0px;
}
.textareasize {
height: 100%;
}
body {
background-image: url('img/grey.png');
}
@media (max-width: 600px) {
body {
background-image: url('img/[email protected]');
}
}
</style>
<script type="text/javascript">
function convert()
{
var left = document.getElementById("left_ta");
var right = document.getElementById("right_ta");
var left_value = left.value;
//general Markdown conversion
left_value = left_value
//
.replace(/\[(.+?)\]\((.+?)(\s".*")?\)/gmi,'[url=$2]$1[/url]') // url
//
.replace(/^(.+)(\n|\r\n)([=]{3,3}\s*(\n|\r\n)?)$/gmi, "[h1]$1[/h1]") // h1
.replace(/^(.+)(\n|\r\n)([-]{3,3}\s*(\n|\r\n)?)$/gmi, "[h2]$1[/h2]") // h2
//
.replace(/^[#]{6,6}\s*(.*[^\s])\s*[#]{6,6}\n?$/gmi, "[h6]$1[/h6]") // h4
.replace(/^[#]{6,6}\s*(.*)\n?$/gmi, "[h6]$1[/h6]") // h4
//
.replace(/^>(.*)?[^\n]?$/gmi, "$1") // removes quotes
//
.replace(/^[#]{5,5}\s*(.*[^\s])\s*[#]{5,5}\n?$/gmi, "[h5]$1[/h5]") // h4
.replace(/^[#]{5,5}\s*(.*)\n?$/gmi, "[h5]$1[/h5]") // h4
//
.replace(/^[#]{4,4}\s*(.*[^\s])\s*[#]{4,4}\n?$/gmi, "[h4]$1[/h4]") // h4
.replace(/^[#]{4,4}\s*(.*)\n?$/gmi, "[h4]$1[/h4]") // h4
//
.replace(/^[#]{3,3}\s*(.*[^\s])\s*[#]{3,3}\n?$/gmi, "[h3]$1[/h3]") // h3
.replace(/^[#]{3,3}\s?(.*)\n?$/gmi, "[h3]$1[/h3]") // h3
//
//.replace(/^[#]{2,2}\s*(.*[^\s])\s*[#]{2,2}\n?$/gmi, "[h2]$1[/h2]") // h2
//.replace(/^[#]{2,2}\s*(.*)\n?$/gmi, "[h2]$1[/h2]") // h2
//
//.replace(/^[#]{1,1}\s*(.*[^\s])\s*[#]{1,1}\n?$/gmi, "[h1]$1[/h1]") // h1
//.replace(/^(?!\n*[`]{3,3})[#]{1,1}\s*(.*)\n?$/gmi, "[h1]$1[/h1]") // h1
//
//.replace(/^\t|[ ]{4,4}(.*)/gmi, "$1") //code; strips tabs
.replace(/^\`{3,3}(.*)\n((?:.|\n)+?)\n\`{3,3}\n?$/gmi, "[code]$2[/code]") // back ticks
.replace(/^\~{3,3}(.*)\n((?:.|\n)+?)\n\~{3,3}\n?$/gmi, "[code]$2[/code]") // tilde
.replace(/\`([^\`].*?)\`/gmi, "[code single]$1[/code]") // inline code
//
.replace(/\[!\[.*?\]\((.*?)\)\]\((.*?)\)/gmi,'[img]$1[/img]\nClickable image was pointing to [url=$2]here[/url]') //image
.replace(/!\[(.*)\]\((.*)\)/gmi,'[img]$2[/img]') //image
//
.replace(/\*\*\*([^\*].*?)\*\*\*/gmi, "[b][i]$1[/i][/b]") // bold + itlaic
.replace(/\*\*([^\*].*?)\*\*/gmi, "[b]$1[/b]") // bold
.replace(/(\s)\*((?!\/[0-9]|\s|\*).*?)\*(\s)/gmi, "$1[i]$2[/i]$3") // italic
//
right.value = left_value;
console.log('converted');
}
</script>
</head>
<body>
<div class="row">
<div class="large-12 columns">
<h2>Markdown to BBcode</h2>
<a class="small button" href="https://github.com/feralhosting/markdown-to-bbcode">Fork/Contribute to this version</a>
<a class="small button" href="http://feralhosting.github.io/">Return to feralhosting.github.io</a>
<a class="small button" href="http://feralhosting.github.io/b2m/index.html">BBCode to Markdown</a>
<a class="small button" href="https://www.feralhosting.com/faq/">Return to Feral FAQs</a>
<a class="small button" href="http://github.com/JonDum/BBCode-To-Markdown-Converter">Credits</a>
</div>
</div>
<div class="row">
<div class="large-12 columns">
<!-- Grid Example -->
<div class="row">
<div class="large-12 columns">
<div class="panel">
<p>
Paste your Markdown formatted text into the top box and Feral FAQ formatted BBCode appears in the bottom. Indented code will have the space/tabs stripped. You have to manually apply <kbd>[code][/code]</kbd> tags to these. Github style <kbd>```</kbd> code tags or <kbd>~~~</kbd> will be replaced with <kbd>[code]some code[/code]</kbd> tags.
</p>
<p>
For <kbd>H1</kbd> and <kbd>H2</kbd> tags do not use <kbd>#</kbd> and <kbd>##</kbd>. Instead use <kbd>===</kbd> underneath for <kbd>H1</kbd> and <kbd>---</kbd> underneath for <kbd>H2</kbd> or they will not be converted. So for example:
</p>
<div>
<pre><code>Sometitle H1</code></pre>
<pre><code>===</code></pre>
<p>
</p>
<pre><code>Sometitle H2</code></pre>
<pre><code>---</code></pre>
</div>
</div>
</div>
</div>
<div class="row">
<div class="large-12 columns mycustom1">
<div class="panel textdivsize">
<textarea id="left_ta" class="textareasize" onChange="convert()" onKeyUp="convert()" placeholder="Enter your Markdown formatted text here" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Enter your Markdown formatted text here'"></textarea>
</div>
</div>
</div>
<div class="row">
<div class="large-12 columns mycustom1">
<div class="panel textdivsize">
<textarea id="right_ta" class="textareasize" placeholder="Your BBCode formatted text will be automatically shown in this box" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Your BBCode formatted text will be automatically shown in this box'"></textarea>
</div>
</div>
</div>
</div>
</div>
<script src="js/vendor/jquery.js"></script>
<script src="js/foundation.min.js"></script>
<script>
$(document).foundation();
</script>
<script type="text/javascript">
var textBoxl = document.getElementById("left_ta");
var textBoxr = document.getElementById("right_ta");
textBoxl.onfocus = function() {
textBoxl.select();
textBoxl.onmouseup = function() {
textBoxl.onmouseup = null;
return false;
};
};
textBoxr.onfocus = function() {
textBoxr.select();
textBoxr.onmouseup = function() {
textBoxr.onmouseup = null;
return false;
};
};
// http://stackoverflow.com/questions/5797539/jquery-select-all-text-from-a-textarea
</script>
</body>
</html>