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

Require space between hash/content in ATX heading #1140

Merged
merged 1 commit into from
Jul 17, 2024
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
2 changes: 1 addition & 1 deletion lib/rdoc/markdown.kpeg
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ AtxInline = !@Newline !(@Sp /#*/ @Sp @Newline) Inline
AtxStart = < /\#{1,6}/ >
{ text.length }

AtxHeading = AtxStart:s @Sp AtxInline+:a (@Sp /#*/ @Sp)? @Newline
AtxHeading = AtxStart:s @Spacechar+ AtxInline+:a (@Sp /#*/ @Sp)? @Newline
{ RDoc::Markup::Heading.new(s, a.join) }

SetextHeading = SetextHeading1 | SetextHeading2
Expand Down
17 changes: 15 additions & 2 deletions test/rdoc/test_rdoc_markdown.rb
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,23 @@ def test_parse_escape
end

def test_parse_heading_atx
doc = parse "# heading\n"
# CommonMark Example 62
(1..6).each do |level|
doc = parse "#{"#" * level} heading\n"

expected = @RM::Document.new(
@RM::Heading.new(level, "heading"))

assert_equal expected, doc
end

# CommonMark Example 64
doc = parse "#5 bolt\n\n#hashtag\n"

expected = @RM::Document.new(
@RM::Heading.new(1, "heading"))
para("#5 bolt"),
para("#hashtag"),
)

assert_equal expected, doc
end
Expand Down