美文网首页
Learning to use Markdown

Learning to use Markdown

作者: sudhengshi | 来源:发表于2018-01-10 11:03 被阅读8次
MarkDown.png

And now, let's start learning to use markdown.

INTRODUCTION

Markdown is a text-to-HTML conversion tool for web writers.Markdown allows you to write using an easy-to-read,easy-to-write plain text format,then convert it to structurally valid XHTML(or HTML).

Thus,"Markdown" is two things:(1) a plain text formatting syntax; and(2) a software tool, written inPerl, that converts the plain text formatting to HTML. See the Syntax page for detail pertaining to Markdown's formatting syntax. You can try it out, right now, using the online Dingus.

The overriding design goal for Markdown's formatting syntax is to make it as readable as possible. The idea is that a Markdown-formatted document should be publishable as-is, as plain text,without looking like it's been marked up with tags or formatting instructions. While Markdown's syntax has been influenced by several existing text-to-HTML filters, the single biggest source of inspiration for Markdown's syntax is the format of plain text email.

The best way to get a feel for Markdown's formatting syntax is simply to look at a Markdown-formatted document. For example, you can view the Markdown source for the article text on this page here:
http://daringfireball.net/projects/markdown/index.text

Markdown is free software,available under a BSD-style open source license.

INSTALLATION AND REQUIREMENTS

Markdown requires Perl 5.6.0 or later. Welcome to the 21st Century.
Markdown also requires the standard Perl library module Digest::MD5,which is probably installed on your server.

PARAGRAPHS,HEADERS,BLOCKQUOTES

A paragraph is simply one or more consecutive line of text,separated by one or more blank lines.(A blank line is any line that looks like a blank line - a line containing nothing but spaces or tabs is considered blank.)Normal paragraphs should not be indented with spaces or tabs.

Markdown offers two styles of headers: Setext and atx. Setext-style headers for <h1>and <h2> are created by "underlining" with equal signs (=) and hyphens(-), respectively . To create an atx-style header, you put 1-6 hash marks(#) at the beginning of the line - the number of hashes equals the resulting HTML header level.

Blockquotes are indicated using email-style '>' angle brackets.

Markdown:


A First Level Header

A Second Level Header

Now is the time for all good men to come to
the aid of their country. This is just a
regular paragraph.

The quick brown fox jumped over the lazy
dog's back.

Header 3

This is a blockquote.

This is the second paragraph in the blockquote.

This is an H2 in a blockquote


Output:


<h1>A First Level Header</h1>

<h2>A Second Level Header</h2>

<p>Now is the time for all good men to come to the aid of their country. This is just a regular paragraph.</p>

<p>The quick brown fox jumped over the lazy dog's back.</p>

<blockquote>
<p>This is a blockquote.</p>
<p>This is the second paragraph in the blockquote.</p>
<h2>This is an H2 in a block quote</h2>
</blockquote>


PHRASE EMPHASIS

Markdown uses asterisks and underscores to indicate spans of emphasis.

Markdown:


Some of these words are emphasized.
Some of these words are emphasized also.

Use two asterisks for strong emphasis.
or, if you prefer, use two underscores instead.


Output:


<p>Some of these words <em>are emphasized</em>.
some of these words <em>are emphasized also</em>.</p>

<p>Use two asterisks for <strong>strong emphasis</strong>.
Or, if you prefer, <strong>use two underscores instead</strong>.</p>


LISTS

Unordered (bulleted) lists use asterisks, pluses, and hyphens(*,+,and -) as list markers.These three markers are interchangeable; this:


  • Candy.
  • Gum.
  • Booze.

this:


  • Candy.
  • Gum.
  • Booze.

and this:


  • Candy.
  • Gum.
  • Booze.

all produce the same output:


<ul>
<li>Candy.</li>
<li>Gum.</li>
<li>Booze</li>
</ul>


Ordered (numbered) lists use regular numbers, followed by periods, as list markers:


  1. Red
  2. Green
  3. Blue

Output:


<ol>
<li>Red</li>
<li>Green</li>
<li>Blue</li>
</ol>


If you put blank lines between items, you'll get <p> tags for the list item text. You can create multi-paragraph list items by indenting the paragraphs by 4 spaces or 1 tab:


  • A list item.
    With multiple paragraphs.
  • Another item in the list.

Output:


<ul>
<li><p>A list item.</p>
<p>With multiple paragraphs.</p></li>
<li><p>Another item in the list</p></li>
</ul>


LINKS

Markdown supports two styles for creating links: inline and reference. With both styles, you use square brackets to delimit the text you want to turn into a link.

Inline-style links use parentheses immediately after the link text. For example:


This is an example link.

Output:


<p>This is an <a href="http://example.com/">example link</a>.</p>


Optionally, you may include a title attribute in the parentheses:


This is an example link.

Output:


<p>This is an <a href="http://example.com/" title ="With a Title">example link</a>.</p>


Reference-style links allow you to refer to your links by names, which you define elsewhere in your document:


I get 10 times more traffic from Google than from Yahoo or MSN.


Output:


<p>I get 10 times more traffic from <a href= "http://google.com/" title ="Google">Google</a> than from<a href="http://search.yahoo.com/" title="Yahoo Search">Yahoo</a> or <a href ="http://search.msn.com/" title="MSN Search">MSN</a>.</p>


The title attribute is optional. Link names may contain letters, numbers and spaces, but are not case sensitive:


I start my morning with a cup of coffee and The New York Times.


Output:


<p>I start my morning with a cup of coffee and <a href="http://www.nytimes.com/">The New York Times</a>.</p>


IMAGES

Image syntax is very much like link syntax.
Inline(titles are optional):


[图片上传失败...(image-14cf7b-1515553382534)]

Reference-style:


![alt text][id]
[id]: /path/to/img.jpg "Title"


Both of the above examples produce the same output:


<img src="/path/to/img.jpg" alt="alt text" title="Title"/>


CODE

In a regular paragraph , you can create code span by wrapping text in backtick quotes. Any ampersands (&)and angle brackets(<or>) will automatically be translated into HTML entities. This makes it easy to use Markdown to write about HTML example code:


I strongly recommend against using any <blink> tags.

I wish SmartPants used named entities like &mdash;
instead of decimal-encoded entites like &#8212;.


Output:


<p>I strongly recommend against using any<code><blink></code>tags.</p>

<p>I wish SmartyPants used named entities like <code>&mdash;</code> instead of decimal-encoded entites like <code>&#8212;</code>.</p>


To specify an entire block of pre-formatted code, indent every line of the block by 4 spaces or 1 tab. Just like with code spans,&,<,and> characters will be escaped automatically.

Markdown:


If you want your page to validate under XHTML 1.0 Strict,
you've got to put paragraph tags in your block quotes:
<blockquotes>
<p>For example.</p>
</blockquotes>


Output:


<p>If you want your page to validate under XHTML 1.0 Strict, you've got to put paragraph tags in your blockquotes:</p>
<pre><code ><blockquote>
<p>For example.</p>
</blockquote>
</code></pre>


相关文章

网友评论

      本文标题:Learning to use Markdown

      本文链接:https://www.haomeiwen.com/subject/ghbvnxtx.html