Skip to content

Commit a089991

Browse files
authored
Merge pull request #64 from fidian/master
Demo page - live preview
2 parents ad6c7f9 + 05e5309 commit a089991

File tree

3 files changed

+502
-0
lines changed

3 files changed

+502
-0
lines changed

www/demo.css

+153
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
html, body {
2+
margin: 0;
3+
padding: 0;
4+
font-family: Helvetica, Arial, Verdana, sans-serif;
5+
background-color: #DDF;
6+
height: 100%;
7+
}
8+
9+
textarea {
10+
font-family: monospace;
11+
}
12+
13+
#header {
14+
margin: 0;
15+
padding: 0.4em 0 0 0;
16+
text-align: center;
17+
color: #002;
18+
}
19+
20+
#header h1 {
21+
font-size: 2em;
22+
}
23+
24+
#header * {
25+
margin: 0;
26+
padding: 0;
27+
line-height: 1em;
28+
font-weight: 100;
29+
}
30+
31+
#header a {
32+
color: #005;
33+
position: relative;
34+
z-index: 20;
35+
}
36+
37+
#bothContainers {
38+
position: absolute;
39+
top: 0;
40+
bottom: 0;
41+
margin-top: 2.4em;
42+
width: 100%;
43+
}
44+
45+
#leftContainer, #rightContainer {
46+
margin: 0;
47+
padding: 0;
48+
position: absolute;
49+
width: 48.5%;
50+
top: 0;
51+
bottom: 0;
52+
}
53+
54+
#leftContainer {
55+
float: left;
56+
left: 1%;
57+
}
58+
59+
#rightContainer {
60+
float: right;
61+
right: 1%;
62+
}
63+
64+
#rightContainer > * {
65+
float: right;
66+
}
67+
68+
.label {
69+
margin: 0;
70+
padding: 0;
71+
position: relative;
72+
width: 100%;
73+
display: block;
74+
}
75+
76+
.label * {
77+
position: relative;
78+
font-weight: 900;
79+
}
80+
81+
.label span {
82+
color: #444;
83+
}
84+
85+
#outputType {
86+
display: block;
87+
margin-left: auto;
88+
font-weight: 900;
89+
font-family: Arial, Verdana, sans-serif;
90+
background-color: #dacccc;
91+
color: #444;
92+
border: 1px solid #999;
93+
}
94+
95+
.pane {
96+
margin: 1.6em 0em 0.2em;
97+
padding: 0.6em;
98+
background-color: #eee;
99+
display: block;
100+
border: 1px solid #000;
101+
top: 0;
102+
bottom: 0;
103+
left: 0;
104+
right: 0;
105+
position: absolute;
106+
overflow: auto;
107+
}
108+
109+
#previewPane {
110+
background-color: #f3eeee;
111+
}
112+
113+
#outputPane {
114+
background-color: #6c6666;
115+
color: #fff;
116+
display: none;
117+
}
118+
119+
#syntaxPane {
120+
background-color: #e6dede;
121+
background-color: #f7ecec;
122+
display: none;
123+
}
124+
125+
#inputPane {
126+
background-color: #fff;
127+
}
128+
129+
#previewPane {
130+
padding: 0;
131+
}
132+
133+
#previewPane > * {
134+
margin-left: 4px;
135+
margin-right: 4px;
136+
}
137+
138+
#previewPane > blockquote {
139+
margin-left: 3em;
140+
}
141+
142+
#previewPane > :first-child {
143+
margin-top: 4px; /* pane padding */
144+
}
145+
146+
#previewPane * {
147+
line-height: 1.4em;
148+
}
149+
150+
#previewPane code {
151+
font-size: 1.3em;
152+
}
153+

www/demo.html

+244
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
1+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
2+
<head>
3+
<title>Marked Demo Page</title>
4+
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
5+
<script type="text/javascript" src="../lib/marked.js"></script>
6+
<script type="text/javascript" src="demo.js"></script>
7+
<link rel="stylesheet" href="demo.css" type="text/css" />
8+
</head>
9+
<body>
10+
<div id="header">
11+
<h1>Demo Page for <a href="https://github.com/chjj/marked/">Marked</a></h1>
12+
</div>
13+
14+
<div id="bothContainers">
15+
<div id="leftContainer">
16+
<div class="label">
17+
<span>Input</span>
18+
</div>
19+
<textarea id="input" cols="80" rows="20" class="pane">Marked - Markdown Parser
20+
========================
21+
22+
[Marked] lets you convert [Markdown] into HTML. Markdown is a simple text format whose goal is to be very easy to read and write, even when not converted to HTML. This demo page will let you type anything you like and see how it gets converted. Live. No more waiting around.
23+
24+
How To Use The Demo
25+
-------------------
26+
27+
1. Type in stuff on the left.
28+
2. See the live updates on the right.
29+
30+
That's it. Pretty simple. There's also a drop-down option in the upper right to switch between various views:
31+
32+
- **Preview:** A live display of the generated HTML as it would render in a browser.
33+
- **HTML Source:** The generated HTML before your browser makes it pretty.
34+
- **Lexer Data:** What [marked] uses internally, in case you like gory stuff like this.
35+
- **Quick Reference:** A brief run-down of how to format things using markdown.
36+
37+
Why Markdown?
38+
-------------
39+
40+
It's easy. It's not overly bloated, unlike HTML. Also, as the creator of [markdown] says,
41+
42+
> The overriding design goal for Markdown's
43+
> formatting syntax is to make it as readable
44+
> as possible. The idea is that a
45+
> Markdown-formatted document should be
46+
> publishable as-is, as plain text, without
47+
> looking like it's been marked up with tags
48+
> or formatting instructions.
49+
50+
Ready to start writing? Either start changing stuff on the left or
51+
[clear everything](?blank=1) with a simple click.
52+
53+
[Marked]: https://github.com/chjj/marked/
54+
[Markdown]: http://daringfireball.net/projects/markdown/
55+
</textarea>
56+
</div>
57+
58+
<div id="rightContainer">
59+
<div class="label">
60+
<select id="outputType">
61+
<option value="preview">Preview</option>
62+
<option value="html">HTML Source</option>
63+
<option value="lexer">Lexer Data</option>
64+
<option value="quickref">Quick Reference</option>
65+
</select>
66+
</div>
67+
68+
<div id="preview" class="pane"><noscript><h2>You'll need to enable Javascript to use this tool.</h2></noscript></div>
69+
70+
<textarea id="html" class="pane" cols="80" rows="20" readonly="readonly"></textarea>
71+
72+
<textarea id="lexer" class="pane" cols="80" rows="20" readonly="readonly"></textarea>
73+
74+
<textarea id="quickref" class="pane" cols="80" rows="20" readonly="readonly">Markdown Quick Reference
75+
========================
76+
77+
This guide is a very brief overview, with examples, of the syntax that [Markdown] supports. It is itself written in Markdown and you can copy the samples over to the left-hand pane for experimentation. It's shown as *text* and not *rendered HTML*.
78+
79+
[Markdown]: http://daringfireball.net/projects/markdown/
80+
81+
82+
Simple Text Formatting
83+
======================
84+
85+
First thing is first. You can use *stars* or _underscores_ for italics. **Double stars** and __double underscores__ do bold. ***Three together*** do ___both___.
86+
87+
Paragraphs are pretty easy too. Just have a blank line between chunks of text.
88+
89+
> This chunk of text is in a block quote. Its multiple lines will all be
90+
> indended a bit from the rest of the text.
91+
>
92+
> > Multiple levels of block quotes also work.
93+
94+
Sometimes you want to include some code, such as when you are explaining how `<h1>` HTML tags work, or maybe you are a programmer and you are discussing `someMethod()`.
95+
96+
If you want to include some code and have
97+
newlines preserved, indent the line with a tab
98+
or at least four spaces.
99+
Extra spaces work here too.
100+
This is also called preformatted text and it is useful for showing examples.
101+
The text will stay as text, so any *markdown* or <u>HTML</u> you add will
102+
not show up formatted. This way you can show markdown examples in a
103+
markdown document.
104+
105+
> You can also use preformatted text with your blockquotes
106+
> as long as you add at least five spaces.
107+
108+
109+
Headings
110+
========
111+
112+
There are a couple of ways to make headings. Using three or more equals signs on a line under a heading makes it into an "h1" style. Three or more hyphens under a line makes it "h2" (slightly smaller). You can also use multiple pound symbols before and after a heading. Pounds after the title are ignored. Here's some examples:
113+
114+
This is H1
115+
==========
116+
117+
This is H2
118+
----------
119+
120+
# This is H1
121+
## This is H2
122+
### This is H3 with some extra pounds ###
123+
#### You get the idea ####
124+
##### I don't need extra pounds at the end
125+
###### H6 is the max
126+
127+
128+
Links
129+
=====
130+
131+
Let's link to a few sites. First, let's use the bare URL, like <http://www.github.com>. Great for text, but ugly for HTML.
132+
Next is an inline link to [Google](http://www.google.com). A little nicer.
133+
This is a reference-style link to [Wikipedia] [1].
134+
Lastly, here's a pretty link to [Yahoo]. The reference-style and pretty links both automatically use the links defined below, but they could be defined *anywhere* in the markdown and are removed from the HTML. The names are also case insensitive, so you can use [YaHoO] and have it link properly.
135+
136+
[1]: http://www.wikipedia.org/
137+
[Yahoo]: http://www.yahoo.com/
138+
139+
Title attributes may be added to links by adding text after a link.
140+
This is the [inline link](http://www.bing.com "Bing") with a "Bing" title.
141+
You can also go to [W3C] [2] and maybe visit a [friend].
142+
143+
[2]: http://w3c.org (The W3C puts out specs for web-based things)
144+
[Friend]: http://facebook.com/ "Facebook!"
145+
146+
Email addresses in plain text are not linked: [email protected].
147+
Email addresses wrapped in angle brackets are linked: <test@example.com>.
148+
They are also obfuscated so that email harvesting spam robots hopefully won't get them.
149+
150+
151+
Lists
152+
=====
153+
154+
* This is a bulleted list
155+
* Great for shopping lists
156+
- You can also use hyphens
157+
+ Or plus symbols
158+
159+
The above is an "unordered" list. Now, on for a bit of order.
160+
161+
1. Numbered lists are also easy
162+
2. Just start with a number
163+
3738762. However, the actual number doesn't matter when converted to HTML.
164+
1. This will still show up as 4.
165+
166+
You might want a few advanced lists:
167+
168+
- This top-level list is wrapped in paragraph tags
169+
- This generates an extra space between each top-level item.
170+
171+
- You do it by adding a blank line
172+
173+
- This nested list also has blank lines between the list items.
174+
175+
- How to create nested lists
176+
1. Start your regular list
177+
2. Indent nested lists with four spaces
178+
3. Further nesting means you should indent with four more spaces
179+
* This line is indented with eight spaces.
180+
181+
- List items can be quite lengthy. You can keep typing and either continue
182+
them on the next line with no indentation.
183+
184+
- Alternately, if that looks ugly, you can also
185+
indent the next line a bit for a prettier look.
186+
187+
- You can put large blocks of text in your list by just indenting with four spaces.
188+
189+
This is formatted the same as code, but you can inspect the HTML
190+
and find that it's just wrapped in a `<p>` tag and *won't* be shown
191+
as preformatted text.
192+
193+
You can keep adding more and more paragraphs to a single
194+
list item by adding the traditional blank line and then keep
195+
on indenting the paragraphs with four spaces. You really need
196+
to only indent the first line, but that looks ugly.
197+
198+
- Lists support blockquotes
199+
200+
> Just like this example here. By the way, you can
201+
> nest lists inside blockquotes!
202+
> - Fantastic!
203+
204+
- Lists support preformatted text
205+
206+
You just need to indent eight spaces.
207+
208+
209+
Even More
210+
=========
211+
212+
Horizontal Rule
213+
---------------
214+
215+
If you need a horizontal rule you just need to put at least three hyphens, asterisks, or underscores on a line by themselves. You can also even put spaces between the characters.
216+
217+
---
218+
****************************
219+
_ _ _ _ _ _ _
220+
221+
Those three all produced horizontal lines. Keep in mind that three hyphens under any text turns that text into a heading, so add a blank like if you use hyphens.
222+
223+
Images
224+
------
225+
226+
Images work exactly like links, but they have exclamation points in front. They work with references and titles too.
227+
228+
![Google Logo](http://www.google.com/images/errors/logo_sm.gif) and ![Happy].
229+
230+
[Happy]: http://www.wpclipart.com/smiley/simple_smiley/smiley_face_simple_green_small.png ("Smiley face")
231+
232+
233+
Inline HTML
234+
-----------
235+
236+
If markdown is too limiting, you can just insert your own <strike>crazy</strike> HTML. Span-level HTML <u>can *still* use markdown</u>. Block level elements must be separated from text by a blank line and must not have any spaces before the opening and closing HTML.
237+
238+
<div style='font-family: "Comic Sans", sans-serif;'>
239+
It is a pity, but markdown does **not** work in here for most markdown parsers. [Marked] handles it pretty well.
240+
</div>
241+
</textarea></div>
242+
</div>
243+
</body>
244+
</html>

0 commit comments

Comments
 (0)