This demonstrates turndown – an HTML to Markdown converter in JavaScript.
-
-
Usage
-
-
var turndownService = new TurndownService()
-console.log(
- turndownService.turndown('<h1>Hello world</h1>')
-)
-
-
-
-
It aims to be CommonMark
- compliant, and includes options to style the output. These options include:
-
-
-
headingStyle (setext or atx)
-
horizontalRule (*, -, or _)
-
bullet (*, -, or +)
-
codeBlockStyle (indented or fenced)
-
fence
-
emDelimiter (_ or *)
-
strongDelimiter (** or __)
-
linkStyle (inlined or referenced)
-
linkReferenceStyle (full, collapsed, or shortcut)
-
- `,
- },
- {
- name: "keep tag",
- html: `
Content
`,
- },
- {
- name: "remove tag",
- html: `
Content
`,
- },
- {
- /*
- When a header (eg.
) contains any new lines in its body, it will split the header contents
- over multiple lines, breaking the header in Markdown (because in Markdown, a header just
- starts with #'s and anything on the next line is not part of the header). Since in HTML
- and Markdown all white space is treated the same, I chose to replace line endings with spaces.
- -> https://github.com/lunny/html2md/pull/6
- */
- name: "strip newlines from header",
- html: `
-
-
-
- Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Vestibulum id ligula porta felis euismod semper.
- More
-
-
-`,
- },
- {
- name: "pre tag without code tag",
- html: `
-
// Fprint formats using the default formats for its operands and writes to w.
-// Spaces are added between operands when neither is a string.
-// It returns the number of bytes written and any write error encountered.
-func Fprint(w io.Writer, a ...interface{}) (n int, err error) {
-`,
- },
- {
- name: "escape pipe characters because of the use in tables",
- html: `
With | Character
`,
- },
- {
- name: "br adds new line break",
- html: `
1. xxx 2. xxxx 3. xxx
4. golang a. xx b. xx
`,
- },
- {
- name: "br does not add new line inside header",
- html: `
Heading
One
`,
- },
- {
- name: "dont escape too much",
- html: `jmap –histo[:live]`,
- },
- {
- name: "html in noscript",
- html: `
-
- `,
- },
- {
- name: "remove iframe",
- html: ` `,
- },
- /*
- { // TODO: not working yet
- name: "p tag with lots of whitespace",
- html: `
-
- Sometimes a struct field, function, type, or even a whole package becomes
-
-
- redundant or unnecessary, but must be kept for compatibility with existing
+func TestConvertReader(t *testing.T) {
+ input := `Bold`
+ expected := `**Bold**`
+ converter := NewConverter("", true, nil)
+ res, err := converter.ConvertReader(strings.NewReader(input))
+ if err != nil {
+ t.Error(err)
+ }
- programs.
+ if !bytes.Equal(res.Bytes(), []byte(expected)) {
+ t.Error("the result is different that expected")
+ }
+}
+func TestConvertBytes(t *testing.T) {
+ input := `Bold`
+ expected := `**Bold**`
- To signal that an identifier should not be used, add a paragraph to its doc
+ converter := NewConverter("", true, nil)
+ res, err := converter.ConvertBytes([]byte(input))
+ if err != nil {
+ t.Error(err)
+ }
+ if !bytes.Equal(res, []byte(expected)) {
+ t.Error("the result is different that expected")
+ }
+}
- comment that begins with "Deprecated:" followed by some information about the
+func TestConvertResponse(t *testing.T) {
+ input := `Bold`
+ expected := `**Bold**`
+ converter := NewConverter("", true, nil)
+ res, err := converter.ConvertResponse(&http.Response{
+ StatusCode: 200,
+ Body: ioutil.NopCloser(bytes.NewBufferString(input)),
+ Request: &http.Request{},
+ })
+ if err != nil {
+ t.Error(err)
+ }
- deprecation.
+ if res != expected {
+ t.Error("the result is different that expected")
+ }
+}
+func TestConvertString(t *testing.T) {
+ input := `Bold`
+ expected := `**Bold**`
- There are a few examples in the standard library.
-
- `,
- },
- */
+ converter := NewConverter("", true, nil)
+ res, err := converter.ConvertString(input)
+ if err != nil {
+ t.Error(err)
}
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- converter := NewConverter(test.domain, true, test.options)
- converter.Keep("keep-tag").Remove("remove-tag")
-
- markdown, err := converter.ConvertString(test.html)
- if err != nil {
- t.Error(err)
- }
- data := []byte(markdown)
- name := strings.Replace(test.name, " ", "_", -1)
- if url.QueryEscape(name) != name {
- fmt.Printf("'%s' is not a safe path", name)
- }
- name = url.QueryEscape(name) // for safety
- name = filepath.Join("TestFromString", name)
+ if res != expected {
+ t.Error("the result is different that expected")
+ }
+}
- gp := filepath.Join("testdata", name+".golden")
- if *update {
- t.Log("update golden file")
- if err := ioutil.WriteFile(gp, data, 0644); err != nil {
- t.Fatalf("failed to update golden file: %s", err)
- }
- }
+func TestConvertSelection(t *testing.T) {
+ input := `Bold`
+ expected := `**Bold**`
- g, err := ioutil.ReadFile(gp)
- if err != nil {
- t.Logf("Result:\n'%s'\n", markdown)
- t.Fatalf("failed reading .golden: %s", err)
- }
+ doc, err := goquery.NewDocumentFromReader(strings.NewReader(input))
+ if err != nil {
+ t.Error(err)
+ }
- if !bytes.Equal([]byte(markdown), g) {
- dmp := diffmatchpatch.New()
+ converter := NewConverter("", true, nil)
+ res := converter.Convert(doc.Selection)
- diffs := dmp.DiffMain(string(g), markdown, false)
- diffs = dmp.DiffCleanupSemantic(diffs)
+ if res != expected {
+ t.Error("the result is different that expected")
+ }
+}
- fmt.Println(dmp.DiffToDelta(diffs))
+func TestConvertURL(t *testing.T) {
+ input := `Bold`
+ expected := `**Bold**`
+
+ // Start a local HTTP server
+ server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
+ rw.Write([]byte(input))
+ }))
+ // Close the server when test finishes
+ defer server.Close()
+ // override the client used in `ConvertURL`
+ netClient = server.Client()
+
+ converter := NewConverter(server.URL, true, nil)
+ res, err := converter.ConvertURL(server.URL)
+ if err != nil {
+ t.Error(err)
+ }
- t.Errorf("written json does not match .golden file: %+v \n", dmp.DiffPrettyText(diffs))
- }
- })
+ if res != expected {
+ t.Error("the result is different that expected")
}
}
+// - - - - - - - - - - - - //
+
func BenchmarkFromString(b *testing.B) {
converter := NewConverter("www.google.com", true, nil)
@@ -977,64 +244,3 @@ func TestAddRules_Fallback(t *testing.T) {
t.Error("second rule was not called")
}
}
-func TestWholeSite(t *testing.T) {
- var tests = []struct {
- name string
- domain string
-
- file string
- }{
- {
- name: "golang.org",
-
- domain: "golang.org",
- },
- {
- name: "bonnerruderverein.de",
- domain: "bonnerruderverein.de",
- },
- {
- name: "blog.golang.org",
- domain: "blog.golang.org",
- },
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- converter := NewConverter(test.domain, true, nil)
-
- htmlData, err := ioutil.ReadFile(
- filepath.Join("testdata", t.Name()+".html"),
- )
- if err != nil {
- t.Error(err)
- }
-
- markdownData, err := converter.ConvertBytes(htmlData)
- if err != nil {
- t.Error(err)
- }
-
- // output := blackfriday.Run(data)
- // fmt.Println(string(output))
-
- gp := filepath.Join("testdata", t.Name()+".md")
- if *update {
- t.Log("update golden file")
- if err := ioutil.WriteFile(gp, markdownData, 0644); err != nil {
- t.Fatalf("failed to update golden file: %s", err)
- }
- }
-
- g, err := ioutil.ReadFile(gp)
- if err != nil {
- t.Logf("Result:\n'%s'\n", string(markdownData))
- t.Fatalf("failed reading .golden: %s", err)
- }
-
- if !bytes.Equal(markdownData, g) {
- t.Errorf("written json does not match .golden file \nexpected:\n'%s'\nbut got:\n'%s'", string(g), string(markdownData))
- }
- })
- }
-}
diff --git a/testdata/TestCommonmark/blockquote/goldmark.golden b/testdata/TestCommonmark/blockquote/goldmark.golden
new file mode 100644
index 0000000..c630b98
--- /dev/null
+++ b/testdata/TestCommonmark/blockquote/goldmark.golden
@@ -0,0 +1,8 @@
+
+
Some Quote
+Next Line
+
+
+
Allowing an unimportant mistake to pass without comment is a wonderful social grace.
+
Ideological differences are no excuse for rudeness.
+
diff --git a/testdata/TestCommonmark/blockquote/input.html b/testdata/TestCommonmark/blockquote/input.html
new file mode 100644
index 0000000..a2d219f
--- /dev/null
+++ b/testdata/TestCommonmark/blockquote/input.html
@@ -0,0 +1,16 @@
+
+
+Some Quote
+Next Line
+
+
+
+
+
+
+
+
+
Allowing an unimportant mistake to pass without comment is a wonderful social grace.
+
Ideological differences are no excuse for rudeness.
+
+
\ No newline at end of file
diff --git a/testdata/TestFromString/large_blockquote.golden b/testdata/TestCommonmark/blockquote/output.default.golden
similarity index 84%
rename from testdata/TestFromString/large_blockquote.golden
rename to testdata/TestCommonmark/blockquote/output.default.golden
index 7b709ea..261bab9 100644
--- a/testdata/TestFromString/large_blockquote.golden
+++ b/testdata/TestCommonmark/blockquote/output.default.golden
@@ -1,3 +1,6 @@
+> Some Quote
+> Next Line
+
> Allowing an unimportant mistake to pass without comment is a wonderful social grace.
>
> Ideological differences are no excuse for rudeness.
\ No newline at end of file
diff --git a/testdata/TestCommonmark/bold/goldmark.golden b/testdata/TestCommonmark/bold/goldmark.golden
new file mode 100644
index 0000000..f8999b3
--- /dev/null
+++ b/testdata/TestCommonmark/bold/goldmark.golden
@@ -0,0 +1,12 @@
+
Some Text
+
Some Text
+
Text
+
Some Text
+
Some Text.
+
Some Text Content
+
Some Text.
+
Some Text
+
首付 19,8万 / 月供 6339元X24
+
**Not Strong**
+**Still Not
+Strong**
diff --git a/testdata/TestCommonmark/bold/input.html b/testdata/TestCommonmark/bold/input.html
new file mode 100644
index 0000000..92a78bd
--- /dev/null
+++ b/testdata/TestCommonmark/bold/input.html
@@ -0,0 +1,36 @@
+
+
Some Text
+
+
+
+
Some Text
+
+
+
+
Text
+
+
+
+
SomeText
+
+
+
+
Some Text.
+
+
SomeTextContent
+
+
SomeText.
+
+
+
Some Text
+
+
+
+
首付19,8万 /
+ 月供6339元X24
+
+
+
+
**Not Strong**
+ **Still Not
+ Strong**
\ No newline at end of file
diff --git a/testdata/TestCommonmark/bold/output.asterisks.golden b/testdata/TestCommonmark/bold/output.asterisks.golden
new file mode 100644
index 0000000..a546d29
--- /dev/null
+++ b/testdata/TestCommonmark/bold/output.asterisks.golden
@@ -0,0 +1,21 @@
+Some **Text**
+
+Some **Text**
+
+**Text**
+
+Some **Text**
+
+Some **Text.**
+
+Some **Text** Content
+
+Some **Text.**
+
+Some **Text**
+
+#### 首付 _19,8万_ / 月供 _6339元X24_
+
+\*\*Not Strong\*\*
+\*\*Still Not
+Strong\*\*
\ No newline at end of file
diff --git a/testdata/TestCommonmark/bold/output.default.golden b/testdata/TestCommonmark/bold/output.default.golden
new file mode 100644
index 0000000..8f8727f
--- /dev/null
+++ b/testdata/TestCommonmark/bold/output.default.golden
@@ -0,0 +1,17 @@
+Some **Text**
+
+Some **Text**
+
+**Text**
+
+Some **Text**
+
+Some **Text.**
+
+Some **Text** Content
+
+Some **Text.**
+
+Some **Text**
+
+#### 首付 _19,8万_ / 月供 _6339元X24_
\ No newline at end of file
diff --git a/testdata/TestCommonmark/bold/output.underscores.golden b/testdata/TestCommonmark/bold/output.underscores.golden
new file mode 100644
index 0000000..c3957cd
--- /dev/null
+++ b/testdata/TestCommonmark/bold/output.underscores.golden
@@ -0,0 +1,21 @@
+Some __Text__
+
+Some __Text__
+
+__Text__
+
+Some __Text__
+
+Some __Text.__
+
+Some __Text__ Content
+
+Some __Text.__
+
+Some __Text__
+
+#### 首付 _19,8万_ / 月供 _6339元X24_
+
+\*\*Not Strong\*\*
+\*\*Still Not
+Strong\*\*
\ No newline at end of file
diff --git a/testdata/TestCommonmark/br_element/goldmark.golden b/testdata/TestCommonmark/br_element/goldmark.golden
new file mode 100644
index 0000000..aab43ac
--- /dev/null
+++ b/testdata/TestCommonmark/br_element/goldmark.golden
@@ -0,0 +1,7 @@
+
diff --git a/testdata/TestCommonmark/h3/output.atx.golden b/testdata/TestCommonmark/h3/output.atx.golden
deleted file mode 100644
index e7127a3..0000000
--- a/testdata/TestCommonmark/h3/output.atx.golden
+++ /dev/null
@@ -1 +0,0 @@
-### The Title
\ No newline at end of file
diff --git a/testdata/TestCommonmark/h3/output.setext.golden b/testdata/TestCommonmark/h3/output.setext.golden
deleted file mode 100644
index e7127a3..0000000
--- a/testdata/TestCommonmark/h3/output.setext.golden
+++ /dev/null
@@ -1 +0,0 @@
-### The Title
\ No newline at end of file
diff --git a/testdata/TestCommonmark/heading/goldmark.golden b/testdata/TestCommonmark/heading/goldmark.golden
new file mode 100644
index 0000000..b4a4733
--- /dev/null
+++ b/testdata/TestCommonmark/heading/goldmark.golden
@@ -0,0 +1,21 @@
+
diff --git a/testdata/TestCommonmark/italic/input.html b/testdata/TestCommonmark/italic/input.html
new file mode 100644
index 0000000..480d0f9
--- /dev/null
+++ b/testdata/TestCommonmark/italic/input.html
@@ -0,0 +1,24 @@
+
+
Some Text
+
+
+
+
Some Text
+
+
+
+
Some Text
+
+
+
+
DoubleItalic
+
+
Some 19,80€ Text
+
+
+
+
Content and no space afterward.
+
+
+
+
_Not Italic_
\ No newline at end of file
diff --git a/testdata/TestCommonmark/italic/output.asterisks.golden b/testdata/TestCommonmark/italic/output.asterisks.golden
new file mode 100644
index 0000000..bfd5672
--- /dev/null
+++ b/testdata/TestCommonmark/italic/output.asterisks.golden
@@ -0,0 +1,13 @@
+Some *Text*
+
+Some *Text*
+
+Some *Text*
+
+*DoubleItalic*
+
+Some *19,80€* Text
+
+*Content* and no space afterward.
+
+\_Not Italic\_
\ No newline at end of file
diff --git a/testdata/TestCommonmark/italic/output.default.golden b/testdata/TestCommonmark/italic/output.default.golden
new file mode 100644
index 0000000..0910317
--- /dev/null
+++ b/testdata/TestCommonmark/italic/output.default.golden
@@ -0,0 +1,11 @@
+Some _Text_
+
+Some _Text_
+
+Some _Text_
+
+_DoubleItalic_
+
+Some _19,80€_ Text
+
+_Content_ and no space afterward.
\ No newline at end of file
diff --git a/testdata/TestCommonmark/italic/output.underscores.golden b/testdata/TestCommonmark/italic/output.underscores.golden
new file mode 100644
index 0000000..2fbdb34
--- /dev/null
+++ b/testdata/TestCommonmark/italic/output.underscores.golden
@@ -0,0 +1,13 @@
+Some _Text_
+
+Some _Text_
+
+Some _Text_
+
+_DoubleItalic_
+
+Some _19,80€_ Text
+
+_Content_ and no space afterward.
+
+\_Not Italic\_
\ No newline at end of file
diff --git a/testdata/TestCommonmark/keep_remove_tag/goldmark.golden b/testdata/TestCommonmark/keep_remove_tag/goldmark.golden
new file mode 100644
index 0000000..4285b55
--- /dev/null
+++ b/testdata/TestCommonmark/keep_remove_tag/goldmark.golden
@@ -0,0 +1 @@
+
diff --git a/testdata/TestCommonmark/list/output.asterisks.golden b/testdata/TestCommonmark/list/output.asterisks.golden
new file mode 100644
index 0000000..e728005
--- /dev/null
+++ b/testdata/TestCommonmark/list/output.asterisks.golden
@@ -0,0 +1,44 @@
+* Some Thing
+* Another Thing
+
+1. First Thing
+2. Second Thing
+
+1. 1
+2. 2
+3. 3
+4. 4
+5. 5
+6. 6
+7. 7
+8. 8
+9. 9
+10. 10
+11. 11
+12. 12
+13. 13
+14. 14
+15. 15
+
+1. First Thing
+ * Some Thing
+ * Another Thing
+2. Second Thing
+
+* foo
+* bar
+
+* List items
+* Ending with
+* A space
+
+* Indent First Thing
+
+ Second Thing
+
+* Third Thing
+
+\- Not List
+
+1\. Not List 1. Not List
+1\. Not List
\ No newline at end of file
diff --git a/testdata/TestCommonmark/list/output.dash.golden b/testdata/TestCommonmark/list/output.dash.golden
new file mode 100644
index 0000000..d256abc
--- /dev/null
+++ b/testdata/TestCommonmark/list/output.dash.golden
@@ -0,0 +1,44 @@
+- Some Thing
+- Another Thing
+
+1. First Thing
+2. Second Thing
+
+1. 1
+2. 2
+3. 3
+4. 4
+5. 5
+6. 6
+7. 7
+8. 8
+9. 9
+10. 10
+11. 11
+12. 12
+13. 13
+14. 14
+15. 15
+
+1. First Thing
+ - Some Thing
+ - Another Thing
+2. Second Thing
+
+- foo
+- bar
+
+- List items
+- Ending with
+- A space
+
+- Indent First Thing
+
+ Second Thing
+
+- Third Thing
+
+\- Not List
+
+1\. Not List 1. Not List
+1\. Not List
\ No newline at end of file
diff --git a/testdata/TestCommonmark/list/output.plus.golden b/testdata/TestCommonmark/list/output.plus.golden
new file mode 100644
index 0000000..f884f3f
--- /dev/null
+++ b/testdata/TestCommonmark/list/output.plus.golden
@@ -0,0 +1,44 @@
++ Some Thing
++ Another Thing
+
+1. First Thing
+2. Second Thing
+
+1. 1
+2. 2
+3. 3
+4. 4
+5. 5
+6. 6
+7. 7
+8. 8
+9. 9
+10. 10
+11. 11
+12. 12
+13. 13
+14. 14
+15. 15
+
+1. First Thing
+ + Some Thing
+ + Another Thing
+2. Second Thing
+
++ foo
++ bar
+
++ List items
++ Ending with
++ A space
+
++ Indent First Thing
+
+ Second Thing
+
++ Third Thing
+
+\- Not List
+
+1\. Not List 1. Not List
+1\. Not List
\ No newline at end of file
diff --git a/testdata/TestCommonmark/list_nested/goldmark.golden b/testdata/TestCommonmark/list_nested/goldmark.golden
new file mode 100644
index 0000000..560ad9f
--- /dev/null
+++ b/testdata/TestCommonmark/list_nested/goldmark.golden
@@ -0,0 +1,42 @@
+
+
+
foo
+
+
bar
+
+
baz
+
+
boo
+
+
+
+
+
+
+
+
Coffee
+
+
+
Tea
+
+
Black tea
+
Green tea
+
+
+
+
Milk
+
+
+
header1
+
+
Bullet list
+
+
Nested bullet
+
+
Sub-nested bullet etc
+
+
+
+
+
Bullet list item 2
+
diff --git a/testdata/TestCommonmark/list_nested/input.html b/testdata/TestCommonmark/list_nested/input.html
new file mode 100644
index 0000000..ebe7a96
--- /dev/null
+++ b/testdata/TestCommonmark/list_nested/input.html
@@ -0,0 +1,44 @@
+
+
+
foo
+
+
bar
+
+
baz
+
+
boo
+
+
+
+
+
+
+
+
+
+
+
+
Coffee
+
Tea
+
Black tea
+
Green tea
+
+
+
Milk
+
header1
+
+
+
+
Bullet list
+
+
Nested bullet
+
+
Sub-nested bullet etc
+
+
+
+
+
Bullet list item 2
+
+
+
diff --git a/testdata/TestCommonmark/list_nested/output.asterisks.golden b/testdata/TestCommonmark/list_nested/output.asterisks.golden
new file mode 100644
index 0000000..759afe1
--- /dev/null
+++ b/testdata/TestCommonmark/list_nested/output.asterisks.golden
@@ -0,0 +1,17 @@
+* foo
+ * bar
+ * baz
+ * boo
+
+* Coffee
+* Tea
+ * Black tea
+ * Green tea
+* Milk
+
+# header1
+
+* Bullet list
+ * Nested bullet
+ * Sub-nested bullet etc
+* Bullet list item 2
\ No newline at end of file
diff --git a/testdata/TestFromString/nested_lists_without_space.golden b/testdata/TestCommonmark/list_nested/output.dash.golden
similarity index 74%
rename from testdata/TestFromString/nested_lists_without_space.golden
rename to testdata/TestCommonmark/list_nested/output.dash.golden
index 12c0f6a..b30f305 100644
--- a/testdata/TestFromString/nested_lists_without_space.golden
+++ b/testdata/TestCommonmark/list_nested/output.dash.golden
@@ -1,3 +1,8 @@
+- foo
+ - bar
+ - baz
+ - boo
+
- Coffee
- Tea
- Black tea
diff --git a/testdata/TestCommonmark/list_nested/output.plus.golden b/testdata/TestCommonmark/list_nested/output.plus.golden
new file mode 100644
index 0000000..9ac4888
--- /dev/null
+++ b/testdata/TestCommonmark/list_nested/output.plus.golden
@@ -0,0 +1,17 @@
++ foo
+ + bar
+ + baz
+ + boo
+
++ Coffee
++ Tea
+ + Black tea
+ + Green tea
++ Milk
+
+# header1
+
++ Bullet list
+ + Nested bullet
+ + Sub-nested bullet etc
++ Bullet list item 2
\ No newline at end of file
diff --git a/testdata/TestCommonmark/p_inside_div/goldmark.golden b/testdata/TestCommonmark/p_inside_div/goldmark.golden
deleted file mode 100644
index fd0cf7b..0000000
--- a/testdata/TestCommonmark/p_inside_div/goldmark.golden
+++ /dev/null
@@ -1,2 +0,0 @@
-
+ Sometimes a struct field, function, type, or even a whole package becomes
+
+
+ redundant or unnecessary, but must be kept for compatibility with existing
+
+
+ programs.
+
+
+ To signal that an identifier should not be used, add a paragraph to its doc
+
+
+ comment that begins with "Deprecated:" followed by some information about the
+
+
+ deprecation.
+
+
+ There are a few examples in the standard library.
+
\ No newline at end of file
diff --git a/testdata/TestCommonmark/p_tag/output.default.golden b/testdata/TestCommonmark/p_tag/output.default.golden
new file mode 100644
index 0000000..e5dadd6
--- /dev/null
+++ b/testdata/TestCommonmark/p_tag/output.default.golden
@@ -0,0 +1,23 @@
+Some Content
+
+Text
+
+Some Text
+
+Some Content
+
+jmap –histo[:live]
+
+Sometimes a struct field, function, type, or even a whole package becomes
+
+redundant or unnecessary, but must be kept for compatibility with existing
+
+programs.
+
+To signal that an identifier should not be used, add a paragraph to its doc
+
+comment that begins with "Deprecated:" followed by some information about the
+
+deprecation.
+
+There are a few examples [in the standard library](https://golang.org/search?q=Deprecated:).
\ No newline at end of file
diff --git a/testdata/TestCommonmark/p_with_b/goldmark.golden b/testdata/TestCommonmark/p_with_b/goldmark.golden
deleted file mode 100644
index fa306a7..0000000
--- a/testdata/TestCommonmark/p_with_b/goldmark.golden
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/testdata/TestCommonmark/p_with_strong/output.default.golden b/testdata/TestCommonmark/p_with_strong/output.default.golden
deleted file mode 100644
index 5b9916d..0000000
--- a/testdata/TestCommonmark/p_with_strong/output.default.golden
+++ /dev/null
@@ -1 +0,0 @@
-Some **Content**
\ No newline at end of file
diff --git a/testdata/TestCommonmark/p_with_strong/output.underscore.golden b/testdata/TestCommonmark/p_with_strong/output.underscore.golden
deleted file mode 100644
index c083fe1..0000000
--- a/testdata/TestCommonmark/p_with_strong/output.underscore.golden
+++ /dev/null
@@ -1 +0,0 @@
-Some __Content__
\ No newline at end of file
diff --git a/testdata/TestCommonmark/pre_code/goldmark.golden b/testdata/TestCommonmark/pre_code/goldmark.golden
new file mode 100644
index 0000000..3344886
--- /dev/null
+++ b/testdata/TestCommonmark/pre_code/goldmark.golden
@@ -0,0 +1,22 @@
+
last_30_days
+
Who ate the most donuts this week?
+
Jeff 15
+Sam 11
+Robin 6
+
+
// Fprint formats using the default formats for its operands and writes to w.
+// Spaces are added between operands when neither is a string.
+// It returns the number of bytes written and any write error encountered.
+func Fprint(w io.Writer, a ...interface{}) (n int, err error) {
+
// Fprint formats using the default formats for its operands and writes to w.
+// Spaces are added between operands when neither is a string.
+// It returns the number of bytes written and any write error encountered.
+func Fprint(w io.Writer, a ...interface{}) (n int, err error) {
+
+
+
+
When x = 3, that means x + 2 = 5
+
+
+
+
```
+
+
~~~
+
+
+Some ~~~
+totally ~~~~~~ normal
+~ code
+
\ No newline at end of file
diff --git a/testdata/TestFromString/pre_tag_without_code_tag.golden b/testdata/TestCommonmark/pre_code/output.fenced_backtick.golden
similarity index 57%
rename from testdata/TestFromString/pre_tag_without_code_tag.golden
rename to testdata/TestCommonmark/pre_code/output.fenced_backtick.golden
index b472408..6ce763e 100644
--- a/testdata/TestFromString/pre_tag_without_code_tag.golden
+++ b/testdata/TestCommonmark/pre_code/output.fenced_backtick.golden
@@ -1,6 +1,34 @@
+`last_30_days`
+
+Who ate the most donuts this week?
+
+```foo+bar
+Jeff 15
+Sam 11
+Robin 6
+```
+
```
// Fprint formats using the default formats for its operands and writes to w.
// Spaces are added between operands when neither is a string.
// It returns the number of bytes written and any write error encountered.
func Fprint(w io.Writer, a ...interface{}) (n int, err error) {
+```
+
+When `x = 3`, that means `x + 2 = 5`
+
+````
+```
+````
+
+```
+~~~
+```
+
+```
+
+Some ~~~
+totally ~~~~~~ normal
+~ code
+
```
\ No newline at end of file
diff --git a/testdata/TestCommonmark/pre_code/output.fenced_tilde.golden b/testdata/TestCommonmark/pre_code/output.fenced_tilde.golden
new file mode 100644
index 0000000..4f269f8
--- /dev/null
+++ b/testdata/TestCommonmark/pre_code/output.fenced_tilde.golden
@@ -0,0 +1,34 @@
+`last_30_days`
+
+Who ate the most donuts this week?
+
+~~~foo+bar
+Jeff 15
+Sam 11
+Robin 6
+~~~
+
+~~~
+// Fprint formats using the default formats for its operands and writes to w.
+// Spaces are added between operands when neither is a string.
+// It returns the number of bytes written and any write error encountered.
+func Fprint(w io.Writer, a ...interface{}) (n int, err error) {
+~~~
+
+When `x = 3`, that means `x + 2 = 5`
+
+~~~
+```
+~~~
+
+~~~~
+~~~
+~~~~
+
+~~~~~~~
+
+Some ~~~
+totally ~~~~~~ normal
+~ code
+
+~~~~~~~
\ No newline at end of file
diff --git a/testdata/TestCommonmark/pre_code/output.indented.golden b/testdata/TestCommonmark/pre_code/output.indented.golden
new file mode 100644
index 0000000..6ce763e
--- /dev/null
+++ b/testdata/TestCommonmark/pre_code/output.indented.golden
@@ -0,0 +1,34 @@
+`last_30_days`
+
+Who ate the most donuts this week?
+
+```foo+bar
+Jeff 15
+Sam 11
+Robin 6
+```
+
+```
+// Fprint formats using the default formats for its operands and writes to w.
+// Spaces are added between operands when neither is a string.
+// It returns the number of bytes written and any write error encountered.
+func Fprint(w io.Writer, a ...interface{}) (n int, err error) {
+```
+
+When `x = 3`, that means `x + 2 = 5`
+
+````
+```
+````
+
+```
+~~~
+```
+
+```
+
+Some ~~~
+totally ~~~~~~ normal
+~ code
+
+```
\ No newline at end of file
diff --git a/testdata/TestCommonmark/sup_element/goldmark.golden b/testdata/TestCommonmark/sup_element/goldmark.golden
new file mode 100644
index 0000000..44f39b2
--- /dev/null
+++ b/testdata/TestCommonmark/sup_element/goldmark.golden
@@ -0,0 +1,7 @@
+
One of the most common equations in all of physics is
+E=mc2.
+
The ordinal number "fifth" can be abbreviated in various languages as follows:
The Go project takes documentation seriously. Documentation is a huge part of making software accessible and maintainable.
+Of course it must be well-written and accurate, but it also must be easy to write and to maintain. Ideally, it
+should be coupled to the code itself so the documentation evolves along with the code. The easier it is for programmers
+to produce good documentation, the better for everyone.
+
To that end, we have developed the
+godoc documentation tool. This article describes godoc's approach to documentation, and explains how
+you can use our conventions and tools to write good documentation for your own projects.
+
Godoc parses Go source code - including comments - and produces documentation as HTML or plain text. The end result is documentation
+tightly coupled with the code it documents. For example, through godoc's web interface you can navigate from
+a function's
+documentation to its
+implementation with one click.
+
Godoc is conceptually related to Python's
+Docstring and Java's
+Javadoc, but its design is simpler. The comments read by godoc are not language constructs (as with Docstring)
+nor must they have their own machine-readable syntax (as with Javadoc). Godoc comments are just good comments,
+the sort you would want to read even if godoc didn't exist.
+
The convention is simple: to document a type, variable, constant, function, or even a package, write a regular comment directly
+preceding its declaration, with no intervening blank line. Godoc will then present that comment as text alongside
+the item it documents. For example, this is the documentation for the
+fmt package's
+Fprint function:
+
// Fprint formats using the default formats for its operands and writes to w.
+// Spaces are added between operands when neither is a string.
+// It returns the number of bytes written and any write error encountered.
+func Fprint(w io.Writer, a ...interface{}) (n int, err error) {
+
+
Notice this comment is a complete sentence that begins with the name of the element it describes. This important convention
+allows us to generate documentation in a variety of formats, from plain text to HTML to UNIX man pages, and makes
+it read better when tools truncate it for brevity, such as when they extract the first line or sentence.
+
Comments on package declarations should provide general package documentation. These comments can be short, like the
+sort package's brief description:
+
// Package sort provides primitives for sorting slices and user-defined
+// collections.
+package sort
+
+
They can also be detailed like the
+gob package's overview. That package uses another convention for packages that need large amounts of
+introductory documentation: the package comment is placed in its own file,
+doc.go, which contains only those comments and a package clause.
+
When writing package comments of any size, keep in mind that their first sentence will appear in godoc's
+package list.
+
Comments that are not adjacent to a top-level declaration are omitted from godoc's output, with one notable exception.
+Top-level comments that begin with the word
+"BUG(who)” are recognized as known bugs, and included in the "Bugs” section of the package documentation. The "who”
+part should be the user name of someone who could provide more information. For example, this is a known issue
+from the
+bytes package:
+
// BUG(r): The rule Title uses for word boundaries does not handle Unicode punctuation properly.
+
+
Sometimes a struct field, function, type, or even a whole package becomes redundant or unnecessary, but must be kept for
+compatibility with existing programs. To signal that an identifier should not be used, add a paragraph to its
+doc comment that begins with "Deprecated:" followed by some information about the deprecation. There
+are a few examples
+in the standard library.
+
There are a few formatting rules that Godoc uses when converting comments to HTML:
+
+
+
Subsequent lines of text are considered part of the same paragraph; you must leave a blank line to separate paragraphs.
+
+
+
Pre-formatted text must be indented relative to the surrounding comment text (see gob's
+doc.go for an example).
+
+
+
URLs will be converted to HTML links; no special markup is necessary.
+
+
+
Note that none of these rules requires you to do anything out of the ordinary.
+
In fact, the best thing about godoc's minimal approach is how easy it is to use. As a result, a lot of Go code, including
+all of the standard library, already follows the conventions.
+
Your own code can present good documentation just by having comments as described above. Any Go packages installed inside
+$GOROOT/src/pkg and any
+GOPATH work spaces will already be accessible via godoc's command-line and HTTP interfaces, and you can specify
+additional paths for indexing via the
+-path flag or just by running
+"godoc ." in the source directory. See the
+godoc documentation for more details.
diff --git a/testdata/TestWholeSite/blog.golang.org.html b/testdata/TestRealWorld/blog.golang.org/input.html
similarity index 100%
rename from testdata/TestWholeSite/blog.golang.org.html
rename to testdata/TestRealWorld/blog.golang.org/input.html
diff --git a/testdata/TestWholeSite/blog.golang.org.md b/testdata/TestRealWorld/blog.golang.org/output.emphasis_asterisks.golden
similarity index 100%
rename from testdata/TestWholeSite/blog.golang.org.md
rename to testdata/TestRealWorld/blog.golang.org/output.emphasis_asterisks.golden
diff --git a/testdata/TestRealWorld/blog.golang.org/output.emphasis_underscores.golden b/testdata/TestRealWorld/blog.golang.org/output.emphasis_underscores.golden
new file mode 100644
index 0000000..3bf3be8
--- /dev/null
+++ b/testdata/TestRealWorld/blog.golang.org/output.emphasis_underscores.golden
@@ -0,0 +1,187 @@
+Godoc: documenting Go code - The Go Blog
+
+[The Go Programming Language](//golang.org/)
+
+[Go](//golang.org/)
+
+▽
+
+[Documents](//golang.org/doc/) [Packages](//golang.org/pkg/) [The Project](//golang.org/project/) [Help](//golang.org/help/) [Blog](/)submit search
+
+#### Next article
+
+[Introducing Gofix](/introducing-gofix)
+
+#### Previous article
+
+[Gobs of data](/gobs-of-data)
+
+#### Links
+
+- [golang.org](//golang.org/)
+- [Install Go](//golang.org/doc/install.html)
+- [A Tour of Go](//tour.golang.org/)
+- [Go Documentation](//golang.org/doc/)
+- [Go Mailing List](//groups.google.com/group/golang-nuts)
+- [Go on Google+](//plus.google.com/101406623878176903605)
+- [Go+ Community](//plus.google.com/communities/114112804251407510571)
+- [Go on Twitter](//twitter.com/golang)
+
+[Blog index](/index)
+
+# [The Go Blog](/)
+
+### [Godoc: documenting Go code](/godoc-documenting-go-code)
+
+31 March 2011
+
+The Go project takes documentation seriously. Documentation is a huge part of making software accessible and maintainable.
+Of course it must be well-written and accurate, but it also must be easy to write and to maintain. Ideally, it
+should be coupled to the code itself so the documentation evolves along with the code. The easier it is for programmers
+to produce good documentation, the better for everyone.
+
+
+To that end, we have developed the
+[godoc](https://golang.org/cmd/godoc/) documentation tool. This article describes godoc's approach to documentation, and explains how
+you can use our conventions and tools to write good documentation for your own projects.
+
+
+Godoc parses Go source code - including comments - and produces documentation as HTML or plain text. The end result is documentation
+tightly coupled with the code it documents. For example, through godoc's web interface you can navigate from
+a function's
+[documentation](https://golang.org/pkg/strings/#HasPrefix) to its
+[implementation](https://golang.org/src/pkg/strings/strings.go#L493) with one click.
+
+
+Godoc is conceptually related to Python's
+[Docstring](http://www.python.org/dev/peps/pep-0257/) and Java's
+[Javadoc](http://www.oracle.com/technetwork/java/javase/documentation/index-jsp-135444.html), but its design is simpler. The comments read by godoc are not language constructs (as with Docstring)
+nor must they have their own machine-readable syntax (as with Javadoc). Godoc comments are just good comments,
+the sort you would want to read even if godoc didn't exist.
+
+
+The convention is simple: to document a type, variable, constant, function, or even a package, write a regular comment directly
+preceding its declaration, with no intervening blank line. Godoc will then present that comment as text alongside
+the item it documents. For example, this is the documentation for the
+`fmt` package's
+[`Fprint`](https://golang.org/pkg/fmt/#Fprint) function:
+
+
+```
+// Fprint formats using the default formats for its operands and writes to w.
+// Spaces are added between operands when neither is a string.
+// It returns the number of bytes written and any write error encountered.
+func Fprint(w io.Writer, a ...interface{}) (n int, err error) {
+```
+
+Notice this comment is a complete sentence that begins with the name of the element it describes. This important convention
+allows us to generate documentation in a variety of formats, from plain text to HTML to UNIX man pages, and makes
+it read better when tools truncate it for brevity, such as when they extract the first line or sentence.
+
+
+Comments on package declarations should provide general package documentation. These comments can be short, like the
+[`sort`](https://golang.org/pkg/sort/) package's brief description:
+
+
+```
+// Package sort provides primitives for sorting slices and user-defined
+// collections.
+package sort
+```
+
+They can also be detailed like the
+[gob package](https://golang.org/pkg/encoding/gob/)'s overview. That package uses another convention for packages that need large amounts of
+introductory documentation: the package comment is placed in its own file,
+[doc.go](https://golang.org/src/pkg/encoding/gob/doc.go), which contains only those comments and a package clause.
+
+
+When writing package comments of any size, keep in mind that their first sentence will appear in godoc's
+[package list](https://golang.org/pkg/).
+
+
+Comments that are not adjacent to a top-level declaration are omitted from godoc's output, with one notable exception.
+Top-level comments that begin with the word
+`"BUG(who)”` are recognized as known bugs, and included in the "Bugs” section of the package documentation. The "who”
+part should be the user name of someone who could provide more information. For example, this is a known issue
+from the
+[bytes package](https://golang.org/pkg/bytes/#pkg-note-BUG):
+
+
+```
+// BUG(r): The rule Title uses for word boundaries does not handle Unicode punctuation properly.
+```
+
+Sometimes a struct field, function, type, or even a whole package becomes redundant or unnecessary, but must be kept for
+compatibility with existing programs. To signal that an identifier should not be used, add a paragraph to its
+doc comment that begins with "Deprecated:" followed by some information about the deprecation. There
+are a few examples
+[in the standard library](https://golang.org/search?q=Deprecated:).
+
+
+There are a few formatting rules that Godoc uses when converting comments to HTML:
+
+
+- Subsequent lines of text are considered part of the same paragraph; you must leave a blank line to separate paragraphs.
+
+- Pre-formatted text must be indented relative to the surrounding comment text (see gob's
+ [doc.go](https://golang.org/src/pkg/encoding/gob/doc.go) for an example).
+
+- URLs will be converted to HTML links; no special markup is necessary.
+
+Note that none of these rules requires you to do anything out of the ordinary.
+
+
+In fact, the best thing about godoc's minimal approach is how easy it is to use. As a result, a lot of Go code, including
+all of the standard library, already follows the conventions.
+
+
+Your own code can present good documentation just by having comments as described above. Any Go packages installed inside
+`$GOROOT/src/pkg` and any
+`GOPATH` work spaces will already be accessible via godoc's command-line and HTTP interfaces, and you can specify
+additional paths for indexing via the
+`-path` flag or just by running
+`"godoc ."` in the source directory. See the
+[godoc documentation](https://golang.org/cmd/godoc/) for more details.
+
+
+By Andrew Gerrand
+
+## Related articles
+
+- [HTTP/2 Server Push](/h2push)
+- [Introducing HTTP Tracing](/http-tracing)
+- [Testable Examples in Go](/examples)
+- [Generating code](/generate)
+- [Introducing the Go Race Detector](/race-detector)
+- [Go maps in action](/go-maps-in-action)
+- [go fmt your code](/go-fmt-your-code)
+- [Organizing Go code](/organizing-go-code)
+- [Debugging Go programs with the GNU Debugger](/debugging-go-programs-with-gnu-debugger)
+- [The Go image/draw package](/go-imagedraw-package)
+- [The Go image package](/go-image-package)
+- [The Laws of Reflection](/laws-of-reflection)
+- [Error handling and Go](/error-handling-and-go)
+- ["First Class Functions in Go"](/first-class-functions-in-go-and-new-go)
+- [Profiling Go Programs](/profiling-go-programs)
+- [A GIF decoder: an exercise in Go interfaces](/gif-decoder-exercise-in-go-interfaces)
+- [Introducing Gofix](/introducing-gofix)
+- [Gobs of data](/gobs-of-data)
+- [C? Go? Cgo!](/c-go-cgo)
+- [JSON and Go](/json-and-go)
+- [Go Slices: usage and internals](/go-slices-usage-and-internals)
+- [Go Concurrency Patterns: Timing out, moving on](/go-concurrency-patterns-timing-out-and)
+- [Defer, Panic, and Recover](/defer-panic-and-recover)
+- [Share Memory By Communicating](/share-memory-by-communicating)
+- [JSON-RPC: a tale of interfaces](/json-rpc-tale-of-interfaces)
+
+Except as
+[noted](https://developers.google.com/site-policies#restrictions), the content of this page is licensed under the Creative Commons Attribution 3.0 License,
+
+
+and code is licensed under a
+[BSD license](//golang.org/LICENSE).
+
+
+[Terms of Service](//golang.org/doc/tos.html) \|
+[Privacy Policy](//www.google.com/intl/en/policies/privacy/) \|
+[View the source code](https://go.googlesource.com/blog/)
\ No newline at end of file
diff --git a/testdata/TestRealWorld/blog.golang.org/output.inlined.golden b/testdata/TestRealWorld/blog.golang.org/output.inlined.golden
new file mode 100644
index 0000000..3bf3be8
--- /dev/null
+++ b/testdata/TestRealWorld/blog.golang.org/output.inlined.golden
@@ -0,0 +1,187 @@
+Godoc: documenting Go code - The Go Blog
+
+[The Go Programming Language](//golang.org/)
+
+[Go](//golang.org/)
+
+▽
+
+[Documents](//golang.org/doc/) [Packages](//golang.org/pkg/) [The Project](//golang.org/project/) [Help](//golang.org/help/) [Blog](/)submit search
+
+#### Next article
+
+[Introducing Gofix](/introducing-gofix)
+
+#### Previous article
+
+[Gobs of data](/gobs-of-data)
+
+#### Links
+
+- [golang.org](//golang.org/)
+- [Install Go](//golang.org/doc/install.html)
+- [A Tour of Go](//tour.golang.org/)
+- [Go Documentation](//golang.org/doc/)
+- [Go Mailing List](//groups.google.com/group/golang-nuts)
+- [Go on Google+](//plus.google.com/101406623878176903605)
+- [Go+ Community](//plus.google.com/communities/114112804251407510571)
+- [Go on Twitter](//twitter.com/golang)
+
+[Blog index](/index)
+
+# [The Go Blog](/)
+
+### [Godoc: documenting Go code](/godoc-documenting-go-code)
+
+31 March 2011
+
+The Go project takes documentation seriously. Documentation is a huge part of making software accessible and maintainable.
+Of course it must be well-written and accurate, but it also must be easy to write and to maintain. Ideally, it
+should be coupled to the code itself so the documentation evolves along with the code. The easier it is for programmers
+to produce good documentation, the better for everyone.
+
+
+To that end, we have developed the
+[godoc](https://golang.org/cmd/godoc/) documentation tool. This article describes godoc's approach to documentation, and explains how
+you can use our conventions and tools to write good documentation for your own projects.
+
+
+Godoc parses Go source code - including comments - and produces documentation as HTML or plain text. The end result is documentation
+tightly coupled with the code it documents. For example, through godoc's web interface you can navigate from
+a function's
+[documentation](https://golang.org/pkg/strings/#HasPrefix) to its
+[implementation](https://golang.org/src/pkg/strings/strings.go#L493) with one click.
+
+
+Godoc is conceptually related to Python's
+[Docstring](http://www.python.org/dev/peps/pep-0257/) and Java's
+[Javadoc](http://www.oracle.com/technetwork/java/javase/documentation/index-jsp-135444.html), but its design is simpler. The comments read by godoc are not language constructs (as with Docstring)
+nor must they have their own machine-readable syntax (as with Javadoc). Godoc comments are just good comments,
+the sort you would want to read even if godoc didn't exist.
+
+
+The convention is simple: to document a type, variable, constant, function, or even a package, write a regular comment directly
+preceding its declaration, with no intervening blank line. Godoc will then present that comment as text alongside
+the item it documents. For example, this is the documentation for the
+`fmt` package's
+[`Fprint`](https://golang.org/pkg/fmt/#Fprint) function:
+
+
+```
+// Fprint formats using the default formats for its operands and writes to w.
+// Spaces are added between operands when neither is a string.
+// It returns the number of bytes written and any write error encountered.
+func Fprint(w io.Writer, a ...interface{}) (n int, err error) {
+```
+
+Notice this comment is a complete sentence that begins with the name of the element it describes. This important convention
+allows us to generate documentation in a variety of formats, from plain text to HTML to UNIX man pages, and makes
+it read better when tools truncate it for brevity, such as when they extract the first line or sentence.
+
+
+Comments on package declarations should provide general package documentation. These comments can be short, like the
+[`sort`](https://golang.org/pkg/sort/) package's brief description:
+
+
+```
+// Package sort provides primitives for sorting slices and user-defined
+// collections.
+package sort
+```
+
+They can also be detailed like the
+[gob package](https://golang.org/pkg/encoding/gob/)'s overview. That package uses another convention for packages that need large amounts of
+introductory documentation: the package comment is placed in its own file,
+[doc.go](https://golang.org/src/pkg/encoding/gob/doc.go), which contains only those comments and a package clause.
+
+
+When writing package comments of any size, keep in mind that their first sentence will appear in godoc's
+[package list](https://golang.org/pkg/).
+
+
+Comments that are not adjacent to a top-level declaration are omitted from godoc's output, with one notable exception.
+Top-level comments that begin with the word
+`"BUG(who)”` are recognized as known bugs, and included in the "Bugs” section of the package documentation. The "who”
+part should be the user name of someone who could provide more information. For example, this is a known issue
+from the
+[bytes package](https://golang.org/pkg/bytes/#pkg-note-BUG):
+
+
+```
+// BUG(r): The rule Title uses for word boundaries does not handle Unicode punctuation properly.
+```
+
+Sometimes a struct field, function, type, or even a whole package becomes redundant or unnecessary, but must be kept for
+compatibility with existing programs. To signal that an identifier should not be used, add a paragraph to its
+doc comment that begins with "Deprecated:" followed by some information about the deprecation. There
+are a few examples
+[in the standard library](https://golang.org/search?q=Deprecated:).
+
+
+There are a few formatting rules that Godoc uses when converting comments to HTML:
+
+
+- Subsequent lines of text are considered part of the same paragraph; you must leave a blank line to separate paragraphs.
+
+- Pre-formatted text must be indented relative to the surrounding comment text (see gob's
+ [doc.go](https://golang.org/src/pkg/encoding/gob/doc.go) for an example).
+
+- URLs will be converted to HTML links; no special markup is necessary.
+
+Note that none of these rules requires you to do anything out of the ordinary.
+
+
+In fact, the best thing about godoc's minimal approach is how easy it is to use. As a result, a lot of Go code, including
+all of the standard library, already follows the conventions.
+
+
+Your own code can present good documentation just by having comments as described above. Any Go packages installed inside
+`$GOROOT/src/pkg` and any
+`GOPATH` work spaces will already be accessible via godoc's command-line and HTTP interfaces, and you can specify
+additional paths for indexing via the
+`-path` flag or just by running
+`"godoc ."` in the source directory. See the
+[godoc documentation](https://golang.org/cmd/godoc/) for more details.
+
+
+By Andrew Gerrand
+
+## Related articles
+
+- [HTTP/2 Server Push](/h2push)
+- [Introducing HTTP Tracing](/http-tracing)
+- [Testable Examples in Go](/examples)
+- [Generating code](/generate)
+- [Introducing the Go Race Detector](/race-detector)
+- [Go maps in action](/go-maps-in-action)
+- [go fmt your code](/go-fmt-your-code)
+- [Organizing Go code](/organizing-go-code)
+- [Debugging Go programs with the GNU Debugger](/debugging-go-programs-with-gnu-debugger)
+- [The Go image/draw package](/go-imagedraw-package)
+- [The Go image package](/go-image-package)
+- [The Laws of Reflection](/laws-of-reflection)
+- [Error handling and Go](/error-handling-and-go)
+- ["First Class Functions in Go"](/first-class-functions-in-go-and-new-go)
+- [Profiling Go Programs](/profiling-go-programs)
+- [A GIF decoder: an exercise in Go interfaces](/gif-decoder-exercise-in-go-interfaces)
+- [Introducing Gofix](/introducing-gofix)
+- [Gobs of data](/gobs-of-data)
+- [C? Go? Cgo!](/c-go-cgo)
+- [JSON and Go](/json-and-go)
+- [Go Slices: usage and internals](/go-slices-usage-and-internals)
+- [Go Concurrency Patterns: Timing out, moving on](/go-concurrency-patterns-timing-out-and)
+- [Defer, Panic, and Recover](/defer-panic-and-recover)
+- [Share Memory By Communicating](/share-memory-by-communicating)
+- [JSON-RPC: a tale of interfaces](/json-rpc-tale-of-interfaces)
+
+Except as
+[noted](https://developers.google.com/site-policies#restrictions), the content of this page is licensed under the Creative Commons Attribution 3.0 License,
+
+
+and code is licensed under a
+[BSD license](//golang.org/LICENSE).
+
+
+[Terms of Service](//golang.org/doc/tos.html) \|
+[Privacy Policy](//www.google.com/intl/en/policies/privacy/) \|
+[View the source code](https://go.googlesource.com/blog/)
\ No newline at end of file
diff --git a/testdata/TestRealWorld/blog.golang.org/output.referenced_collapsed.golden b/testdata/TestRealWorld/blog.golang.org/output.referenced_collapsed.golden
new file mode 100644
index 0000000..78d750e
--- /dev/null
+++ b/testdata/TestRealWorld/blog.golang.org/output.referenced_collapsed.golden
@@ -0,0 +1,252 @@
+Godoc: documenting Go code - The Go Blog
+
+[The Go Programming Language][]
+
+[Go][]
+
+▽
+
+[Documents][] [Packages][] [The Project][] [Help][] [Blog][]submit search
+
+#### Next article
+
+[Introducing Gofix][]
+
+#### Previous article
+
+[Gobs of data][]
+
+#### Links
+
+- [golang.org][]
+- [Install Go][]
+- [A Tour of Go][]
+- [Go Documentation][]
+- [Go Mailing List][]
+- [Go on Google+][]
+- [Go+ Community][]
+- [Go on Twitter][]
+
+[Blog index][]
+
+# [The Go Blog][]
+
+### [Godoc: documenting Go code][]
+
+31 March 2011
+
+The Go project takes documentation seriously. Documentation is a huge part of making software accessible and maintainable.
+Of course it must be well-written and accurate, but it also must be easy to write and to maintain. Ideally, it
+should be coupled to the code itself so the documentation evolves along with the code. The easier it is for programmers
+to produce good documentation, the better for everyone.
+
+
+To that end, we have developed the
+[godoc][] documentation tool. This article describes godoc's approach to documentation, and explains how
+you can use our conventions and tools to write good documentation for your own projects.
+
+
+Godoc parses Go source code - including comments - and produces documentation as HTML or plain text. The end result is documentation
+tightly coupled with the code it documents. For example, through godoc's web interface you can navigate from
+a function's
+[documentation][] to its
+[implementation][] with one click.
+
+
+Godoc is conceptually related to Python's
+[Docstring][] and Java's
+[Javadoc][], but its design is simpler. The comments read by godoc are not language constructs (as with Docstring)
+nor must they have their own machine-readable syntax (as with Javadoc). Godoc comments are just good comments,
+the sort you would want to read even if godoc didn't exist.
+
+
+The convention is simple: to document a type, variable, constant, function, or even a package, write a regular comment directly
+preceding its declaration, with no intervening blank line. Godoc will then present that comment as text alongside
+the item it documents. For example, this is the documentation for the
+`fmt` package's
+[`Fprint`][] function:
+
+
+```
+// Fprint formats using the default formats for its operands and writes to w.
+// Spaces are added between operands when neither is a string.
+// It returns the number of bytes written and any write error encountered.
+func Fprint(w io.Writer, a ...interface{}) (n int, err error) {
+```
+
+Notice this comment is a complete sentence that begins with the name of the element it describes. This important convention
+allows us to generate documentation in a variety of formats, from plain text to HTML to UNIX man pages, and makes
+it read better when tools truncate it for brevity, such as when they extract the first line or sentence.
+
+
+Comments on package declarations should provide general package documentation. These comments can be short, like the
+[`sort`][] package's brief description:
+
+
+```
+// Package sort provides primitives for sorting slices and user-defined
+// collections.
+package sort
+```
+
+They can also be detailed like the
+[gob package][]'s overview. That package uses another convention for packages that need large amounts of
+introductory documentation: the package comment is placed in its own file,
+[doc.go][], which contains only those comments and a package clause.
+
+
+When writing package comments of any size, keep in mind that their first sentence will appear in godoc's
+[package list][].
+
+
+Comments that are not adjacent to a top-level declaration are omitted from godoc's output, with one notable exception.
+Top-level comments that begin with the word
+`"BUG(who)”` are recognized as known bugs, and included in the "Bugs” section of the package documentation. The "who”
+part should be the user name of someone who could provide more information. For example, this is a known issue
+from the
+[bytes package][]:
+
+
+```
+// BUG(r): The rule Title uses for word boundaries does not handle Unicode punctuation properly.
+```
+
+Sometimes a struct field, function, type, or even a whole package becomes redundant or unnecessary, but must be kept for
+compatibility with existing programs. To signal that an identifier should not be used, add a paragraph to its
+doc comment that begins with "Deprecated:" followed by some information about the deprecation. There
+are a few examples
+[in the standard library][].
+
+
+There are a few formatting rules that Godoc uses when converting comments to HTML:
+
+
+- Subsequent lines of text are considered part of the same paragraph; you must leave a blank line to separate paragraphs.
+
+- Pre-formatted text must be indented relative to the surrounding comment text (see gob's
+ [doc.go][] for an example).
+
+- URLs will be converted to HTML links; no special markup is necessary.
+
+Note that none of these rules requires you to do anything out of the ordinary.
+
+
+In fact, the best thing about godoc's minimal approach is how easy it is to use. As a result, a lot of Go code, including
+all of the standard library, already follows the conventions.
+
+
+Your own code can present good documentation just by having comments as described above. Any Go packages installed inside
+`$GOROOT/src/pkg` and any
+`GOPATH` work spaces will already be accessible via godoc's command-line and HTTP interfaces, and you can specify
+additional paths for indexing via the
+`-path` flag or just by running
+`"godoc ."` in the source directory. See the
+[godoc documentation][] for more details.
+
+
+By Andrew Gerrand
+
+## Related articles
+
+- [HTTP/2 Server Push][]
+- [Introducing HTTP Tracing][]
+- [Testable Examples in Go][]
+- [Generating code][]
+- [Introducing the Go Race Detector][]
+- [Go maps in action][]
+- [go fmt your code][]
+- [Organizing Go code][]
+- [Debugging Go programs with the GNU Debugger][]
+- [The Go image/draw package][]
+- [The Go image package][]
+- [The Laws of Reflection][]
+- [Error handling and Go][]
+- ["First Class Functions in Go"][]
+- [Profiling Go Programs][]
+- [A GIF decoder: an exercise in Go interfaces][]
+- [Introducing Gofix][]
+- [Gobs of data][]
+- [C? Go? Cgo!][]
+- [JSON and Go][]
+- [Go Slices: usage and internals][]
+- [Go Concurrency Patterns: Timing out, moving on][]
+- [Defer, Panic, and Recover][]
+- [Share Memory By Communicating][]
+- [JSON-RPC: a tale of interfaces][]
+
+Except as
+[noted][], the content of this page is licensed under the Creative Commons Attribution 3.0 License,
+
+
+and code is licensed under a
+[BSD license][].
+
+
+[Terms of Service][] \|
+[Privacy Policy][] \|
+[View the source code][]
+
+[The Go Programming Language]: //golang.org/
+[Go]: //golang.org/
+[Documents]: //golang.org/doc/
+[Packages]: //golang.org/pkg/
+[The Project]: //golang.org/project/
+[Help]: //golang.org/help/
+[Blog]: /
+[Introducing Gofix]: /introducing-gofix
+[Gobs of data]: /gobs-of-data
+[golang.org]: //golang.org/
+[Install Go]: //golang.org/doc/install.html
+[A Tour of Go]: //tour.golang.org/
+[Go Documentation]: //golang.org/doc/
+[Go Mailing List]: //groups.google.com/group/golang-nuts
+[Go on Google+]: //plus.google.com/101406623878176903605
+[Go+ Community]: //plus.google.com/communities/114112804251407510571
+[Go on Twitter]: //twitter.com/golang
+[Blog index]: /index
+[The Go Blog]: /
+[Godoc: documenting Go code]: /godoc-documenting-go-code
+[godoc]: https://golang.org/cmd/godoc/
+[documentation]: https://golang.org/pkg/strings/#HasPrefix
+[implementation]: https://golang.org/src/pkg/strings/strings.go#L493
+[Docstring]: http://www.python.org/dev/peps/pep-0257/
+[Javadoc]: http://www.oracle.com/technetwork/java/javase/documentation/index-jsp-135444.html
+[`Fprint`]: https://golang.org/pkg/fmt/#Fprint
+[`sort`]: https://golang.org/pkg/sort/
+[gob package]: https://golang.org/pkg/encoding/gob/
+[doc.go]: https://golang.org/src/pkg/encoding/gob/doc.go
+[package list]: https://golang.org/pkg/
+[bytes package]: https://golang.org/pkg/bytes/#pkg-note-BUG
+[in the standard library]: https://golang.org/search?q=Deprecated:
+[doc.go]: https://golang.org/src/pkg/encoding/gob/doc.go
+[godoc documentation]: https://golang.org/cmd/godoc/
+[HTTP/2 Server Push]: /h2push
+[Introducing HTTP Tracing]: /http-tracing
+[Testable Examples in Go]: /examples
+[Generating code]: /generate
+[Introducing the Go Race Detector]: /race-detector
+[Go maps in action]: /go-maps-in-action
+[go fmt your code]: /go-fmt-your-code
+[Organizing Go code]: /organizing-go-code
+[Debugging Go programs with the GNU Debugger]: /debugging-go-programs-with-gnu-debugger
+[The Go image/draw package]: /go-imagedraw-package
+[The Go image package]: /go-image-package
+[The Laws of Reflection]: /laws-of-reflection
+[Error handling and Go]: /error-handling-and-go
+["First Class Functions in Go"]: /first-class-functions-in-go-and-new-go
+[Profiling Go Programs]: /profiling-go-programs
+[A GIF decoder: an exercise in Go interfaces]: /gif-decoder-exercise-in-go-interfaces
+[Introducing Gofix]: /introducing-gofix
+[Gobs of data]: /gobs-of-data
+[C? Go? Cgo!]: /c-go-cgo
+[JSON and Go]: /json-and-go
+[Go Slices: usage and internals]: /go-slices-usage-and-internals
+[Go Concurrency Patterns: Timing out, moving on]: /go-concurrency-patterns-timing-out-and
+[Defer, Panic, and Recover]: /defer-panic-and-recover
+[Share Memory By Communicating]: /share-memory-by-communicating
+[JSON-RPC: a tale of interfaces]: /json-rpc-tale-of-interfaces
+[noted]: https://developers.google.com/site-policies#restrictions
+[BSD license]: //golang.org/LICENSE
+[Terms of Service]: //golang.org/doc/tos.html
+[Privacy Policy]: //www.google.com/intl/en/policies/privacy/
+[View the source code]: https://go.googlesource.com/blog/
\ No newline at end of file
diff --git a/testdata/TestRealWorld/blog.golang.org/output.referenced_full.golden b/testdata/TestRealWorld/blog.golang.org/output.referenced_full.golden
new file mode 100644
index 0000000..98c99a2
--- /dev/null
+++ b/testdata/TestRealWorld/blog.golang.org/output.referenced_full.golden
@@ -0,0 +1,252 @@
+Godoc: documenting Go code - The Go Blog
+
+[The Go Programming Language][1]
+
+[Go][2]
+
+▽
+
+[Documents][4] [Packages][5] [The Project][6] [Help][7] [Blog][8]submit search
+
+#### Next article
+
+[Introducing Gofix][9]
+
+#### Previous article
+
+[Gobs of data][10]
+
+#### Links
+
+- [golang.org][11]
+- [Install Go][12]
+- [A Tour of Go][13]
+- [Go Documentation][14]
+- [Go Mailing List][15]
+- [Go on Google+][16]
+- [Go+ Community][17]
+- [Go on Twitter][18]
+
+[Blog index][19]
+
+# [The Go Blog][20]
+
+### [Godoc: documenting Go code][21]
+
+31 March 2011
+
+The Go project takes documentation seriously. Documentation is a huge part of making software accessible and maintainable.
+Of course it must be well-written and accurate, but it also must be easy to write and to maintain. Ideally, it
+should be coupled to the code itself so the documentation evolves along with the code. The easier it is for programmers
+to produce good documentation, the better for everyone.
+
+
+To that end, we have developed the
+[godoc][22] documentation tool. This article describes godoc's approach to documentation, and explains how
+you can use our conventions and tools to write good documentation for your own projects.
+
+
+Godoc parses Go source code - including comments - and produces documentation as HTML or plain text. The end result is documentation
+tightly coupled with the code it documents. For example, through godoc's web interface you can navigate from
+a function's
+[documentation][23] to its
+[implementation][24] with one click.
+
+
+Godoc is conceptually related to Python's
+[Docstring][25] and Java's
+[Javadoc][26], but its design is simpler. The comments read by godoc are not language constructs (as with Docstring)
+nor must they have their own machine-readable syntax (as with Javadoc). Godoc comments are just good comments,
+the sort you would want to read even if godoc didn't exist.
+
+
+The convention is simple: to document a type, variable, constant, function, or even a package, write a regular comment directly
+preceding its declaration, with no intervening blank line. Godoc will then present that comment as text alongside
+the item it documents. For example, this is the documentation for the
+`fmt` package's
+[`Fprint`][27] function:
+
+
+```
+// Fprint formats using the default formats for its operands and writes to w.
+// Spaces are added between operands when neither is a string.
+// It returns the number of bytes written and any write error encountered.
+func Fprint(w io.Writer, a ...interface{}) (n int, err error) {
+```
+
+Notice this comment is a complete sentence that begins with the name of the element it describes. This important convention
+allows us to generate documentation in a variety of formats, from plain text to HTML to UNIX man pages, and makes
+it read better when tools truncate it for brevity, such as when they extract the first line or sentence.
+
+
+Comments on package declarations should provide general package documentation. These comments can be short, like the
+[`sort`][28] package's brief description:
+
+
+```
+// Package sort provides primitives for sorting slices and user-defined
+// collections.
+package sort
+```
+
+They can also be detailed like the
+[gob package][29]'s overview. That package uses another convention for packages that need large amounts of
+introductory documentation: the package comment is placed in its own file,
+[doc.go][30], which contains only those comments and a package clause.
+
+
+When writing package comments of any size, keep in mind that their first sentence will appear in godoc's
+[package list][31].
+
+
+Comments that are not adjacent to a top-level declaration are omitted from godoc's output, with one notable exception.
+Top-level comments that begin with the word
+`"BUG(who)”` are recognized as known bugs, and included in the "Bugs” section of the package documentation. The "who”
+part should be the user name of someone who could provide more information. For example, this is a known issue
+from the
+[bytes package][32]:
+
+
+```
+// BUG(r): The rule Title uses for word boundaries does not handle Unicode punctuation properly.
+```
+
+Sometimes a struct field, function, type, or even a whole package becomes redundant or unnecessary, but must be kept for
+compatibility with existing programs. To signal that an identifier should not be used, add a paragraph to its
+doc comment that begins with "Deprecated:" followed by some information about the deprecation. There
+are a few examples
+[in the standard library][33].
+
+
+There are a few formatting rules that Godoc uses when converting comments to HTML:
+
+
+- Subsequent lines of text are considered part of the same paragraph; you must leave a blank line to separate paragraphs.
+
+- Pre-formatted text must be indented relative to the surrounding comment text (see gob's
+ [doc.go][34] for an example).
+
+- URLs will be converted to HTML links; no special markup is necessary.
+
+Note that none of these rules requires you to do anything out of the ordinary.
+
+
+In fact, the best thing about godoc's minimal approach is how easy it is to use. As a result, a lot of Go code, including
+all of the standard library, already follows the conventions.
+
+
+Your own code can present good documentation just by having comments as described above. Any Go packages installed inside
+`$GOROOT/src/pkg` and any
+`GOPATH` work spaces will already be accessible via godoc's command-line and HTTP interfaces, and you can specify
+additional paths for indexing via the
+`-path` flag or just by running
+`"godoc ."` in the source directory. See the
+[godoc documentation][35] for more details.
+
+
+By Andrew Gerrand
+
+## Related articles
+
+- [HTTP/2 Server Push][36]
+- [Introducing HTTP Tracing][37]
+- [Testable Examples in Go][38]
+- [Generating code][39]
+- [Introducing the Go Race Detector][40]
+- [Go maps in action][41]
+- [go fmt your code][42]
+- [Organizing Go code][43]
+- [Debugging Go programs with the GNU Debugger][44]
+- [The Go image/draw package][45]
+- [The Go image package][46]
+- [The Laws of Reflection][47]
+- [Error handling and Go][48]
+- ["First Class Functions in Go"][49]
+- [Profiling Go Programs][50]
+- [A GIF decoder: an exercise in Go interfaces][51]
+- [Introducing Gofix][52]
+- [Gobs of data][53]
+- [C? Go? Cgo!][54]
+- [JSON and Go][55]
+- [Go Slices: usage and internals][56]
+- [Go Concurrency Patterns: Timing out, moving on][57]
+- [Defer, Panic, and Recover][58]
+- [Share Memory By Communicating][59]
+- [JSON-RPC: a tale of interfaces][60]
+
+Except as
+[noted][61], the content of this page is licensed under the Creative Commons Attribution 3.0 License,
+
+
+and code is licensed under a
+[BSD license][62].
+
+
+[Terms of Service][63] \|
+[Privacy Policy][64] \|
+[View the source code][65]
+
+[1]: //golang.org/
+[2]: //golang.org/
+[4]: //golang.org/doc/
+[5]: //golang.org/pkg/
+[6]: //golang.org/project/
+[7]: //golang.org/help/
+[8]: /
+[9]: /introducing-gofix
+[10]: /gobs-of-data
+[11]: //golang.org/
+[12]: //golang.org/doc/install.html
+[13]: //tour.golang.org/
+[14]: //golang.org/doc/
+[15]: //groups.google.com/group/golang-nuts
+[16]: //plus.google.com/101406623878176903605
+[17]: //plus.google.com/communities/114112804251407510571
+[18]: //twitter.com/golang
+[19]: /index
+[20]: /
+[21]: /godoc-documenting-go-code
+[22]: https://golang.org/cmd/godoc/
+[23]: https://golang.org/pkg/strings/#HasPrefix
+[24]: https://golang.org/src/pkg/strings/strings.go#L493
+[25]: http://www.python.org/dev/peps/pep-0257/
+[26]: http://www.oracle.com/technetwork/java/javase/documentation/index-jsp-135444.html
+[27]: https://golang.org/pkg/fmt/#Fprint
+[28]: https://golang.org/pkg/sort/
+[29]: https://golang.org/pkg/encoding/gob/
+[30]: https://golang.org/src/pkg/encoding/gob/doc.go
+[31]: https://golang.org/pkg/
+[32]: https://golang.org/pkg/bytes/#pkg-note-BUG
+[33]: https://golang.org/search?q=Deprecated:
+[34]: https://golang.org/src/pkg/encoding/gob/doc.go
+[35]: https://golang.org/cmd/godoc/
+[36]: /h2push
+[37]: /http-tracing
+[38]: /examples
+[39]: /generate
+[40]: /race-detector
+[41]: /go-maps-in-action
+[42]: /go-fmt-your-code
+[43]: /organizing-go-code
+[44]: /debugging-go-programs-with-gnu-debugger
+[45]: /go-imagedraw-package
+[46]: /go-image-package
+[47]: /laws-of-reflection
+[48]: /error-handling-and-go
+[49]: /first-class-functions-in-go-and-new-go
+[50]: /profiling-go-programs
+[51]: /gif-decoder-exercise-in-go-interfaces
+[52]: /introducing-gofix
+[53]: /gobs-of-data
+[54]: /c-go-cgo
+[55]: /json-and-go
+[56]: /go-slices-usage-and-internals
+[57]: /go-concurrency-patterns-timing-out-and
+[58]: /defer-panic-and-recover
+[59]: /share-memory-by-communicating
+[60]: /json-rpc-tale-of-interfaces
+[61]: https://developers.google.com/site-policies#restrictions
+[62]: //golang.org/LICENSE
+[63]: //golang.org/doc/tos.html
+[64]: //www.google.com/intl/en/policies/privacy/
+[65]: https://go.googlesource.com/blog/
\ No newline at end of file
diff --git a/testdata/TestRealWorld/blog.golang.org/output.referenced_shortcut.golden b/testdata/TestRealWorld/blog.golang.org/output.referenced_shortcut.golden
new file mode 100644
index 0000000..7757ffd
--- /dev/null
+++ b/testdata/TestRealWorld/blog.golang.org/output.referenced_shortcut.golden
@@ -0,0 +1,252 @@
+Godoc: documenting Go code - The Go Blog
+
+[The Go Programming Language]
+
+[Go]
+
+▽
+
+[Documents] [Packages] [The Project] [Help] [Blog]submit search
+
+#### Next article
+
+[Introducing Gofix]
+
+#### Previous article
+
+[Gobs of data]
+
+#### Links
+
+- [golang.org]
+- [Install Go]
+- [A Tour of Go]
+- [Go Documentation]
+- [Go Mailing List]
+- [Go on Google+]
+- [Go+ Community]
+- [Go on Twitter]
+
+[Blog index]
+
+# [The Go Blog]
+
+### [Godoc: documenting Go code]
+
+31 March 2011
+
+The Go project takes documentation seriously. Documentation is a huge part of making software accessible and maintainable.
+Of course it must be well-written and accurate, but it also must be easy to write and to maintain. Ideally, it
+should be coupled to the code itself so the documentation evolves along with the code. The easier it is for programmers
+to produce good documentation, the better for everyone.
+
+
+To that end, we have developed the
+[godoc] documentation tool. This article describes godoc's approach to documentation, and explains how
+you can use our conventions and tools to write good documentation for your own projects.
+
+
+Godoc parses Go source code - including comments - and produces documentation as HTML or plain text. The end result is documentation
+tightly coupled with the code it documents. For example, through godoc's web interface you can navigate from
+a function's
+[documentation] to its
+[implementation] with one click.
+
+
+Godoc is conceptually related to Python's
+[Docstring] and Java's
+[Javadoc], but its design is simpler. The comments read by godoc are not language constructs (as with Docstring)
+nor must they have their own machine-readable syntax (as with Javadoc). Godoc comments are just good comments,
+the sort you would want to read even if godoc didn't exist.
+
+
+The convention is simple: to document a type, variable, constant, function, or even a package, write a regular comment directly
+preceding its declaration, with no intervening blank line. Godoc will then present that comment as text alongside
+the item it documents. For example, this is the documentation for the
+`fmt` package's
+[`Fprint`] function:
+
+
+```
+// Fprint formats using the default formats for its operands and writes to w.
+// Spaces are added between operands when neither is a string.
+// It returns the number of bytes written and any write error encountered.
+func Fprint(w io.Writer, a ...interface{}) (n int, err error) {
+```
+
+Notice this comment is a complete sentence that begins with the name of the element it describes. This important convention
+allows us to generate documentation in a variety of formats, from plain text to HTML to UNIX man pages, and makes
+it read better when tools truncate it for brevity, such as when they extract the first line or sentence.
+
+
+Comments on package declarations should provide general package documentation. These comments can be short, like the
+[`sort`] package's brief description:
+
+
+```
+// Package sort provides primitives for sorting slices and user-defined
+// collections.
+package sort
+```
+
+They can also be detailed like the
+[gob package]'s overview. That package uses another convention for packages that need large amounts of
+introductory documentation: the package comment is placed in its own file,
+[doc.go], which contains only those comments and a package clause.
+
+
+When writing package comments of any size, keep in mind that their first sentence will appear in godoc's
+[package list].
+
+
+Comments that are not adjacent to a top-level declaration are omitted from godoc's output, with one notable exception.
+Top-level comments that begin with the word
+`"BUG(who)”` are recognized as known bugs, and included in the "Bugs” section of the package documentation. The "who”
+part should be the user name of someone who could provide more information. For example, this is a known issue
+from the
+[bytes package]:
+
+
+```
+// BUG(r): The rule Title uses for word boundaries does not handle Unicode punctuation properly.
+```
+
+Sometimes a struct field, function, type, or even a whole package becomes redundant or unnecessary, but must be kept for
+compatibility with existing programs. To signal that an identifier should not be used, add a paragraph to its
+doc comment that begins with "Deprecated:" followed by some information about the deprecation. There
+are a few examples
+[in the standard library].
+
+
+There are a few formatting rules that Godoc uses when converting comments to HTML:
+
+
+- Subsequent lines of text are considered part of the same paragraph; you must leave a blank line to separate paragraphs.
+
+- Pre-formatted text must be indented relative to the surrounding comment text (see gob's
+ [doc.go] for an example).
+
+- URLs will be converted to HTML links; no special markup is necessary.
+
+Note that none of these rules requires you to do anything out of the ordinary.
+
+
+In fact, the best thing about godoc's minimal approach is how easy it is to use. As a result, a lot of Go code, including
+all of the standard library, already follows the conventions.
+
+
+Your own code can present good documentation just by having comments as described above. Any Go packages installed inside
+`$GOROOT/src/pkg` and any
+`GOPATH` work spaces will already be accessible via godoc's command-line and HTTP interfaces, and you can specify
+additional paths for indexing via the
+`-path` flag or just by running
+`"godoc ."` in the source directory. See the
+[godoc documentation] for more details.
+
+
+By Andrew Gerrand
+
+## Related articles
+
+- [HTTP/2 Server Push]
+- [Introducing HTTP Tracing]
+- [Testable Examples in Go]
+- [Generating code]
+- [Introducing the Go Race Detector]
+- [Go maps in action]
+- [go fmt your code]
+- [Organizing Go code]
+- [Debugging Go programs with the GNU Debugger]
+- [The Go image/draw package]
+- [The Go image package]
+- [The Laws of Reflection]
+- [Error handling and Go]
+- ["First Class Functions in Go"]
+- [Profiling Go Programs]
+- [A GIF decoder: an exercise in Go interfaces]
+- [Introducing Gofix]
+- [Gobs of data]
+- [C? Go? Cgo!]
+- [JSON and Go]
+- [Go Slices: usage and internals]
+- [Go Concurrency Patterns: Timing out, moving on]
+- [Defer, Panic, and Recover]
+- [Share Memory By Communicating]
+- [JSON-RPC: a tale of interfaces]
+
+Except as
+[noted], the content of this page is licensed under the Creative Commons Attribution 3.0 License,
+
+
+and code is licensed under a
+[BSD license].
+
+
+[Terms of Service] \|
+[Privacy Policy] \|
+[View the source code]
+
+[The Go Programming Language]: //golang.org/
+[Go]: //golang.org/
+[Documents]: //golang.org/doc/
+[Packages]: //golang.org/pkg/
+[The Project]: //golang.org/project/
+[Help]: //golang.org/help/
+[Blog]: /
+[Introducing Gofix]: /introducing-gofix
+[Gobs of data]: /gobs-of-data
+[golang.org]: //golang.org/
+[Install Go]: //golang.org/doc/install.html
+[A Tour of Go]: //tour.golang.org/
+[Go Documentation]: //golang.org/doc/
+[Go Mailing List]: //groups.google.com/group/golang-nuts
+[Go on Google+]: //plus.google.com/101406623878176903605
+[Go+ Community]: //plus.google.com/communities/114112804251407510571
+[Go on Twitter]: //twitter.com/golang
+[Blog index]: /index
+[The Go Blog]: /
+[Godoc: documenting Go code]: /godoc-documenting-go-code
+[godoc]: https://golang.org/cmd/godoc/
+[documentation]: https://golang.org/pkg/strings/#HasPrefix
+[implementation]: https://golang.org/src/pkg/strings/strings.go#L493
+[Docstring]: http://www.python.org/dev/peps/pep-0257/
+[Javadoc]: http://www.oracle.com/technetwork/java/javase/documentation/index-jsp-135444.html
+[`Fprint`]: https://golang.org/pkg/fmt/#Fprint
+[`sort`]: https://golang.org/pkg/sort/
+[gob package]: https://golang.org/pkg/encoding/gob/
+[doc.go]: https://golang.org/src/pkg/encoding/gob/doc.go
+[package list]: https://golang.org/pkg/
+[bytes package]: https://golang.org/pkg/bytes/#pkg-note-BUG
+[in the standard library]: https://golang.org/search?q=Deprecated:
+[doc.go]: https://golang.org/src/pkg/encoding/gob/doc.go
+[godoc documentation]: https://golang.org/cmd/godoc/
+[HTTP/2 Server Push]: /h2push
+[Introducing HTTP Tracing]: /http-tracing
+[Testable Examples in Go]: /examples
+[Generating code]: /generate
+[Introducing the Go Race Detector]: /race-detector
+[Go maps in action]: /go-maps-in-action
+[go fmt your code]: /go-fmt-your-code
+[Organizing Go code]: /organizing-go-code
+[Debugging Go programs with the GNU Debugger]: /debugging-go-programs-with-gnu-debugger
+[The Go image/draw package]: /go-imagedraw-package
+[The Go image package]: /go-image-package
+[The Laws of Reflection]: /laws-of-reflection
+[Error handling and Go]: /error-handling-and-go
+["First Class Functions in Go"]: /first-class-functions-in-go-and-new-go
+[Profiling Go Programs]: /profiling-go-programs
+[A GIF decoder: an exercise in Go interfaces]: /gif-decoder-exercise-in-go-interfaces
+[Introducing Gofix]: /introducing-gofix
+[Gobs of data]: /gobs-of-data
+[C? Go? Cgo!]: /c-go-cgo
+[JSON and Go]: /json-and-go
+[Go Slices: usage and internals]: /go-slices-usage-and-internals
+[Go Concurrency Patterns: Timing out, moving on]: /go-concurrency-patterns-timing-out-and
+[Defer, Panic, and Recover]: /defer-panic-and-recover
+[Share Memory By Communicating]: /share-memory-by-communicating
+[JSON-RPC: a tale of interfaces]: /json-rpc-tale-of-interfaces
+[noted]: https://developers.google.com/site-policies#restrictions
+[BSD license]: //golang.org/LICENSE
+[Terms of Service]: //golang.org/doc/tos.html
+[Privacy Policy]: //www.google.com/intl/en/policies/privacy/
+[View the source code]: https://go.googlesource.com/blog/
\ No newline at end of file
diff --git a/testdata/TestRealWorld/bonnerruderverein.de/goldmark.golden b/testdata/TestRealWorld/bonnerruderverein.de/goldmark.golden
new file mode 100644
index 0000000..1bf3da2
--- /dev/null
+++ b/testdata/TestRealWorld/bonnerruderverein.de/goldmark.golden
@@ -0,0 +1,136 @@
+
ein unvergleichlich abwechslungsreiches Ruderrevier, ein Bootshaus in einer traumhaften Lage, eine liebevoll geführte Vereinsgastronomie, ein Top-Bootspark und – das Wichtigste – eine bunte Mischung aus interessanten, interessierten und engagierten Mitgliedern.
+
Im Mittelpunkt der Aktivitäten steht der Breitensport mit nahezu täglichen Ruderangeboten sowie regelmäßigen Wanderfahrten auf den unterschiedlichsten Flüssen Deutschlands und Europas. Rudern im BRV heißt, Ausgleichssport mit netten Leuten, ein, zwei Stunden Bewegung an der frischen Luft, und zum Abschluss ein Getränk in netter Runde. Wir trainieren nicht für Kurzstrecken-Rennen oder Meisterschaften. Wer jedoch Wanderfahrten liebt, also mehrtägige Ruder-Reisen mit Tages-Etappen von 30 bis 40 Kilometern, ist beim BRV gut aufgehoben.
+
\ No newline at end of file
diff --git a/testdata/TestFromString/heading_in_link.golden b/testdata/TestRealWorld/snippets/code_design_heading_in_link/output.default.golden
similarity index 100%
rename from testdata/TestFromString/heading_in_link.golden
rename to testdata/TestRealWorld/snippets/code_design_heading_in_link/output.default.golden
diff --git a/testdata/TestRealWorld/snippets/nav_nested_list/goldmark.golden b/testdata/TestRealWorld/snippets/nav_nested_list/goldmark.golden
new file mode 100644
index 0000000..aa11104
--- /dev/null
+++ b/testdata/TestRealWorld/snippets/nav_nested_list/goldmark.golden
@@ -0,0 +1,27 @@
+
+
+
\ No newline at end of file
diff --git a/testdata/TestFromString/nested_list_real_world.golden b/testdata/TestRealWorld/snippets/nav_nested_list/output.default.golden
similarity index 100%
rename from testdata/TestFromString/nested_list_real_world.golden
rename to testdata/TestRealWorld/snippets/nav_nested_list/output.default.golden
diff --git a/testdata/TestRealWorld/snippets/price_em_in_a_p/goldmark.golden b/testdata/TestRealWorld/snippets/price_em_in_a_p/goldmark.golden
new file mode 100644
index 0000000..ba8565d
--- /dev/null
+++ b/testdata/TestRealWorld/snippets/price_em_in_a_p/goldmark.golden
@@ -0,0 +1 @@
+
首付 19,8万 月供
diff --git a/testdata/TestRealWorld/snippets/price_em_in_a_p/input.html b/testdata/TestRealWorld/snippets/price_em_in_a_p/input.html
new file mode 100644
index 0000000..fc5135f
--- /dev/null
+++ b/testdata/TestRealWorld/snippets/price_em_in_a_p/input.html
@@ -0,0 +1 @@
+
首付19,8万 月供
\ No newline at end of file
diff --git a/testdata/TestFromString/em_in_a_p.golden b/testdata/TestRealWorld/snippets/price_em_in_a_p/output.default.golden
similarity index 100%
rename from testdata/TestFromString/em_in_a_p.golden
rename to testdata/TestRealWorld/snippets/price_em_in_a_p/output.default.golden
diff --git a/testdata/TestRealWorld/snippets/text_with_whitespace/goldmark.golden b/testdata/TestRealWorld/snippets/text_with_whitespace/goldmark.golden
new file mode 100644
index 0000000..6d643c3
--- /dev/null
+++ b/testdata/TestRealWorld/snippets/text_with_whitespace/goldmark.golden
@@ -0,0 +1,12 @@
+
Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Vestibulum id ligula porta felis euismod semper.
+More
diff --git a/testdata/TestRealWorld/snippets/text_with_whitespace/input.html b/testdata/TestRealWorld/snippets/text_with_whitespace/input.html
new file mode 100644
index 0000000..1d563b6
--- /dev/null
+++ b/testdata/TestRealWorld/snippets/text_with_whitespace/input.html
@@ -0,0 +1,28 @@
+
+
+
+
+ Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Vestibulum id ligula porta felis euismod semper.
+ More
+
+
diff --git a/testdata/TestFromString/text_with_whitespace.golden b/testdata/TestRealWorld/snippets/text_with_whitespace/output.default.golden
similarity index 100%
rename from testdata/TestFromString/text_with_whitespace.golden
rename to testdata/TestRealWorld/snippets/text_with_whitespace/output.default.golden
diff --git a/testdata/TestRealWorld/snippets/turndown_demo/goldmark.golden b/testdata/TestRealWorld/snippets/turndown_demo/goldmark.golden
new file mode 100644
index 0000000..6d609db
--- /dev/null
+++ b/testdata/TestRealWorld/snippets/turndown_demo/goldmark.golden
@@ -0,0 +1,22 @@
+
Turndown Demo
+
This demonstrates turndown – an HTML to Markdown converter in JavaScript.
+
Usage
+
var turndownService = new TurndownService()
+console.log(
+ turndownService.turndown('<h1>Hello world</h1>')
+)
+
+
+
It aims to be CommonMark
+compliant, and includes options to style the output. These options include:
+
+
headingStyle (setext or atx)
+
horizontalRule (*, -, or _)
+
bullet (*, -, or +)
+
codeBlockStyle (indented or fenced)
+
fence
+
emDelimiter (_ or *)
+
strongDelimiter (** or __)
+
linkStyle (inlined or referenced)
+
linkReferenceStyle (full, collapsed, or shortcut)
+
diff --git a/testdata/TestRealWorld/snippets/turndown_demo/input.html b/testdata/TestRealWorld/snippets/turndown_demo/input.html
new file mode 100644
index 0000000..309cf24
--- /dev/null
+++ b/testdata/TestRealWorld/snippets/turndown_demo/input.html
@@ -0,0 +1,29 @@
+
+
Turndown Demo
+
+
This demonstrates turndown – an HTML to Markdown converter in JavaScript.
+
+
Usage
+
+
var turndownService = new TurndownService()
+console.log(
+ turndownService.turndown('<h1>Hello world</h1>')
+)
+
+
+
+
It aims to be CommonMark
+ compliant, and includes options to style the output. These options include:
+
+
+
headingStyle (setext or atx)
+
horizontalRule (*, -, or _)
+
bullet (*, -, or +)
+
codeBlockStyle (indented or fenced)
+
fence
+
emDelimiter (_ or *)
+
strongDelimiter (** or __)
+
linkStyle (inlined or referenced)
+
linkReferenceStyle (full, collapsed, or shortcut)
+
+
\ No newline at end of file
diff --git a/testdata/TestFromString/turndown_demo.golden b/testdata/TestRealWorld/snippets/turndown_demo/output.default.golden
similarity index 100%
rename from testdata/TestFromString/turndown_demo.golden
rename to testdata/TestRealWorld/snippets/turndown_demo/output.default.golden
diff --git a/testdata/TestRealWorld/snippets/tweet/goldmark.golden b/testdata/TestRealWorld/snippets/tweet/goldmark.golden
new file mode 100644
index 0000000..b219de4
--- /dev/null
+++ b/testdata/TestRealWorld/snippets/tweet/goldmark.golden
@@ -0,0 +1,11 @@
+
+
\ No newline at end of file
diff --git a/testdata/TestFromString/tweet.golden b/testdata/TestRealWorld/snippets/tweet/output.default.golden
similarity index 100%
rename from testdata/TestFromString/tweet.golden
rename to testdata/TestRealWorld/snippets/tweet/output.default.golden