Commit 0093554ad6055a0843b0537557e8ca44d6ff2429
1 parent
3cc26654
Exists in
master
and in
4 other branches
Add test and docs for markdown tables
Showing
2 changed files
with
31 additions
and
1 deletions
Show diff stats
doc/markdown/markdown.md
| ... | ... | @@ -27,8 +27,9 @@ Table of Contents |
| 27 | 27 | [Inline HTML](#toc_25) |
| 28 | 28 | [Horizontal Rule](#toc_26) |
| 29 | 29 | [Line Breaks](#toc_27) |
| 30 | +[Tables](#toc_28) | |
| 30 | 31 | |
| 31 | -[References](#toc_28) | |
| 32 | +[References](#toc_29) | |
| 32 | 33 | --------------------- |
| 33 | 34 | |
| 34 | 35 | ---------------------------------------------- |
| ... | ... | @@ -440,6 +441,26 @@ This line is separated from the one above by two newlines, so it will be a *sepa |
| 440 | 441 | This line is also begins a separate paragraph, but... |
| 441 | 442 | This line is only separated by a single newline, so it's a separate line in the *same paragraph*. |
| 442 | 443 | |
| 444 | + | |
| 445 | +## Tables | |
| 446 | + | |
| 447 | +Tables aren't part of the core Markdown spec, but they are part of GFM and Markdown Here supports them. | |
| 448 | + | |
| 449 | +``` | |
| 450 | +| header 1 | header 2 | | |
| 451 | +| -------- | -------- | | |
| 452 | +| cell 1 | cell 2 | | |
| 453 | +| cell 3 | cell 4 | | |
| 454 | +``` | |
| 455 | + | |
| 456 | +Code above produces next output: | |
| 457 | + | |
| 458 | +| header 1 | header 2 | | |
| 459 | +| -------- | -------- | | |
| 460 | +| cell 1 | cell 2 | | |
| 461 | +| cell 3 | cell 4 | | |
| 462 | + | |
| 463 | + | |
| 443 | 464 | ------------ |
| 444 | 465 | |
| 445 | 466 | <a name="references"/> | ... | ... |
spec/helpers/gitlab_markdown_helper_spec.rb
| ... | ... | @@ -366,6 +366,15 @@ describe GitlabMarkdownHelper do |
| 366 | 366 | markdown(actual).should match(%r{Apply <em><a.+>!#{merge_request.iid}</a></em>}) |
| 367 | 367 | end |
| 368 | 368 | |
| 369 | + it "should handle tables" do | |
| 370 | + actual = %Q{| header 1 | header 2 | | |
| 371 | +| -------- | -------- | | |
| 372 | +| cell 1 | cell 2 | | |
| 373 | +| cell 3 | cell 4 |} | |
| 374 | + | |
| 375 | + markdown(actual).should match(/\A<table/) | |
| 376 | + end | |
| 377 | + | |
| 369 | 378 | it "should leave code blocks untouched" do |
| 370 | 379 | helper.stub(:user_color_scheme_class).and_return(:white) |
| 371 | 380 | ... | ... |