Skip to content

Commit 68ff902

Browse files
Create index.html
1 parent aa0bcd4 commit 68ff902

File tree

1 file changed

+227
-0
lines changed

1 file changed

+227
-0
lines changed

index.html

Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Wiki Markup Editor</title>
7+
<style>
8+
body {
9+
font-family: sans-serif;
10+
display: flex;
11+
flex-direction: column;
12+
gap: 1rem;
13+
background: #f5f5f5;
14+
margin: 2rem auto;
15+
max-width: 960px;
16+
padding: 1rem;
17+
}
18+
textarea {
19+
width: 100%;
20+
height: 300px;
21+
font-family: monospace;
22+
}
23+
.preview {
24+
border: 1px solid #ccc;
25+
padding: 1rem;
26+
background: #f9f9f9;
27+
overflow: hidden;
28+
}
29+
code {
30+
background: #eee;
31+
padding: 0.1em 0.3em;
32+
border-radius: 4px;
33+
font-family: monospace;
34+
}
35+
h1, h2, h3 {
36+
margin: 0.5rem 0;
37+
}
38+
h1 + hr, h2 + hr {
39+
border: none;
40+
height: 1px;
41+
background-color: #ddd;
42+
margin: 0.5rem 0 1rem;
43+
}
44+
.image-float-left, .image-float-right {
45+
max-width: 220px;
46+
background: #f2f2f2;
47+
border: 1px solid #ccc;
48+
padding: 4px;
49+
margin-bottom: 1rem;
50+
}
51+
.image-float-left {
52+
float: left;
53+
margin-right: 1rem;
54+
}
55+
.image-float-right {
56+
float: right;
57+
margin-left: 1rem;
58+
}
59+
.image-caption {
60+
text-align: center;
61+
font-size: 0.85rem;
62+
color: #555;
63+
margin-top: 4px;
64+
}
65+
.clearfix::after {
66+
content: "";
67+
display: table;
68+
clear: both;
69+
}
70+
button.download-btn {
71+
align-self: flex-start;
72+
padding: 0.5rem 1rem;
73+
font-size: 1rem;
74+
border: 1px solid #ccc;
75+
background: white;
76+
cursor: pointer;
77+
}
78+
a{
79+
color:rgb(34, 165, 236);
80+
text-decoration: none;
81+
}
82+
a:hover{
83+
text-decoration: underline;
84+
}
85+
.missing-link{
86+
color:rgb(220, 64, 64);
87+
}
88+
.grun{
89+
color:rgb(33, 190, 67);
90+
}
91+
</style>
92+
</head>
93+
<body>
94+
<input type="text" id="title" placeholder="Put Your Title Here!"/>
95+
<textarea id="editor">
96+
=Wiki Markup=
97+
98+
[[https://upload.wikimedia.org/wikipedia/commons/thumb/e/ea/S._Hripsime_Church_Southwest.jpg/2560px-S._Hripsime_Church_Southwest.jpg|St. Hripsime Church|right]]
99+
100+
'''Wiki Markup''' is a [[#|markup language]] designed specifically for creating [[#|wikipedia articles]]. It offers several a more simple syntax for creating [[#|HTML]] webpages. It features no direct similarities with the [[#|Markdown]] syntax.
101+
102+
===The Syntax===
103+
104+
Wiki Markup offers several different markers for bold, italic, links, images, etc.
105+
106+
`=​Header=​`
107+
`​=​=H2=​=`
108+
`​=​=​=H3=​=​=​`
109+
`'​'​'bold'​'​'`
110+
`'​'italic'​'`
111+
`[​[File://Image.png|Caption|Float]​]`
112+
`[​[Https://www.w3.org|Link text]​]​`
113+
`# For an OL`
114+
`* For an UL`
115+
116+
===Custom Syntax===
117+
118+
This is an extended version of the $$Wiki Markup$$ language including:
119+
120+
`$​$green$​​$`
121+
`!​!red!​!`
122+
123+
124+
</textarea>
125+
<button class="download-btn" onclick="downloadHTML()">Download HTML</button>
126+
<div class="preview" id="preview"></div>
127+
128+
<script>
129+
function parseWikiMarkup(markup) {
130+
const lines = markup.split(/\r?\n/);
131+
let html = '<div class="clearfix">';
132+
let inUL = false;
133+
let inOL = false;
134+
135+
for (let line of lines) {
136+
if (/^===(.*?)===/.test(line)) {
137+
html += `<h3>${line.match(/^===(.*?)===/)[1]}</h3>`;
138+
} else if (/^==(.*?)==/.test(line)) {
139+
html += `<h2>${line.match(/^==(.*?)==/)[1]}</h2><hr>`;
140+
} else if (/^=(.*?)=/.test(line)) {
141+
html += `<h1>${line.match(/^=(.*?)=/)[1]}</h1><hr>`;
142+
} else if (/^\*\s?(.*)/.test(line)) {
143+
if (!inUL) {
144+
html += '<ul>';
145+
inUL = true;
146+
}
147+
html += `<li>${line.match(/^\*\s?(.*)/)[1]}</li>`;
148+
} else if (/^#\s?(.*)/.test(line)) {
149+
if (!inOL) {
150+
html += '<ol>';
151+
inOL = true;
152+
}
153+
html += `<li>${line.match(/^#\s?(.*)/)[1]}</li>`;
154+
} else {
155+
if (inUL) {
156+
html += '</ul>';
157+
inUL = false;
158+
}
159+
if (inOL) {
160+
html += '</ol>';
161+
inOL = false;
162+
}
163+
164+
const imageMatch = line.match(/^\[\[(.*?)\|(.*?)\|(.*?)\]\]$/);
165+
if (imageMatch) {
166+
const [_, src, caption, float] = imageMatch;
167+
const floatClass = float.toLowerCase() === 'left' ? 'image-float-left' : float.toLowerCase() === 'right' ? 'image-float-right' : '';
168+
html += `
169+
<div class="${floatClass}">
170+
<img src="${src}" alt="${caption}" style="max-width: 100%; display: block;">
171+
<div class="image-caption">${caption}</div>
172+
</div>
173+
`;
174+
continue;
175+
}
176+
177+
html += `<p>${line
178+
.replace(/'''(.*?)'''/g, '<strong>$1</strong>')
179+
.replace(/''(.*?)''/g, '<em>$1</em>')
180+
.replace(/!!(.*?)!!/g, '<span class="missing-link">$1</span>')
181+
.replace(/\$\$(.*?)\$\$/g, '<span class="grun">$1</span>')
182+
.replace(/`(.*?)`/g, '<code>$1</code>')
183+
.replace(/\[\[(.*?)\|(.*?)\]\]/g, '<a href="$1">$2</a>')}</p>`;
184+
}
185+
}
186+
187+
if (inUL) html += '</ul>';
188+
if (inOL) html += '</ol>';
189+
190+
html += '</div>'; // close clearfix
191+
return html;
192+
}
193+
194+
const editor = document.getElementById('editor');
195+
const preview = document.getElementById('preview');
196+
197+
function updatePreview() {
198+
preview.innerHTML = parseWikiMarkup(editor.value);
199+
}
200+
201+
window.downloadHTML = function () {
202+
let name = document.getElementById("title").value;
203+
const htmlContent = `<!DOCTYPE html>
204+
<html lang="en">
205+
<head>
206+
<meta charset="UTF-8">
207+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
208+
<title>${name}</title>
209+
<style>${document.querySelector('style').innerHTML}</style>
210+
</head>
211+
<body>
212+
<div class="preview">${parseWikiMarkup(editor.value)}</div>
213+
</body>
214+
</html>`;
215+
216+
const blob = new Blob([htmlContent], { type: 'text/html' });
217+
const a = document.createElement('a');
218+
a.href = URL.createObjectURL(blob);
219+
a.download = `${name}.html`;
220+
a.click();
221+
};
222+
223+
editor.addEventListener('input', updatePreview);
224+
updatePreview();
225+
</script>
226+
</body>
227+
</html>

0 commit comments

Comments
 (0)