[linux] 使用markdown写文档

github上很多项目都使用*.md来做说明文档 github上会自动将.md文件内容转成html进行呈现

 

想用go来写个相关的解析器,顺便练手!!~

 

# markdown地址
http://daringfireball.net/projects/markdown/

# 下载安装
wget http://daringfireball.net/projects/downloads/Markdown_1.0.1.zip
unzip Markdown_1.0.1.zip
cd Markdown_1.0.1/

# 编译tags文件&查看
$./Markdown.pl --html4tags foo.md > foo.html
$firefox foo.html &

# 语法

foo.md

This is an H1
=============

this is an h2
---------------

# This is an H1
## This is an H2
### This is an H3
#### This is an H4
##### This is an H5
###### This is an H6

# This is an H1 #
## This is an H2 #
### This is an H3 #
#### This is an H4 #
##### This is an H5 #
###### This is an H6 #

## HTML ##
This is a regular paragraph.

<table>
    <tr>
        <td>Foo</td>
    </tr>
</table>

This is another regular paragraph.

## BLOCK ##
###### block.eg1 #
> This is the first level of quoting.
>
> > This is nested blockquote.
>
> Back to the first level.

###### block.eg2 #
> ## This is a header.
> 
> 1.   This is the first list item.
> 2.   This is the second list item.
> 
> Here's some example code:
> 
>     return shell_exec("echo $input | $markdown_script");

###### block.code.eg1 #
Here is an example of AppleScript:

    tell application "Foo"
        beep
    end tell

###### block.code.eg2 #
``There is a literal backtick (`) here.``

## LIST ##

###### list.eg1 #
*  red
*  green
*  blue

###### list.eg2 #
+  red
+  green
+  blue

###### list.eg3 #
-  red
-  green
-  blue

###### list.eg4 #
1. red
2. green
3. blue

## HORIZONTAL RULES #

* * *
***
******
- - -
---------------------------------

## LINK #
This is [an example](http://example.com/ "Title") inline link.

[This link](http://example.net/) has no title attribute.

## EMPHASIS #

*single asterisks*

_single underscores_

**double asterisks**

__double underscores__

## IMAGE #
![Alt text](/path/to/img.jpg)

![Alt text](/path/to/img.jpg "Optional title")

![Alt text](http://www.google.com.hk/images/srpr/logo3w.png "Optional title")

## MISC #
###### AUTOMATIC LINKS  #
<http://www.163.com>

<address@example.com>

posted on 2012-08-23 15:31  bluefrog  阅读(3502)  评论(0编辑  收藏  举报