Skip to content

Commit

Permalink
Merge pull request #794 from nobu/code-fence
Browse files Browse the repository at this point in the history
Fixed CodeFence without blank lines
  • Loading branch information
aycabta authored Feb 25, 2021
2 parents b4130e6 + 0e1776c commit 4c2c140
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
3 changes: 2 additions & 1 deletion lib/rdoc/markdown.kpeg
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,8 @@ StyleBlock = < InStyleTags >
end }

Inlines = ( !@Endline Inline:i { i }
| @Endline:c &Inline { c } )+:chunks @Endline?
| @Endline:c !( &{ github? } Ticks3 /[^`\n]*$/ )
&Inline { c } )+:chunks @Endline?
{ chunks }

Inline = Str
Expand Down
36 changes: 32 additions & 4 deletions test/rdoc/test_rdoc_markdown.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def test_parse_code
end

def test_parse_code_github
doc = parse <<-MD
doc = <<-MD
Example:
```
Expand All @@ -156,11 +156,25 @@ def test_parse_code_github
para("Example:"),
verb("code goes here\n"))

assert_equal expected, doc
assert_equal expected, parse(doc)
assert_equal expected, parse(doc.sub(/^\n/, ''))

@parser.github = false

expected =
doc(para("Example:"),
para("<code>\n""code goes here\n</code>"))

assert_equal expected, parse(doc)

expected =
doc(para("Example:\n<code>\n""code goes here\n</code>"))

assert_equal expected, parse(doc.sub(/^\n/, ''))
end

def test_parse_code_github_format
doc = parse <<-MD
doc = <<-MD
Example:
``` ruby
Expand All @@ -176,7 +190,21 @@ def test_parse_code_github_format
para("Example:"),
code)

assert_equal expected, doc
assert_equal expected, parse(doc)
assert_equal expected, parse(doc.sub(/^\n/, ''))

@parser.github = false

expected =
doc(para("Example:"),
para("<code>ruby\n""code goes here\n</code>"))

assert_equal expected, parse(doc)

expected =
doc(para("Example:\n<code>ruby\n""code goes here\n</code>"))

assert_equal expected, parse(doc.sub(/^\n/, ''))
end

def test_parse_definition_list
Expand Down

0 comments on commit 4c2c140

Please sign in to comment.