Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed CodeFence without blank lines #794

Merged
merged 1 commit into from
Feb 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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