Skip to content

Commit

Permalink
Merge pull request github#1290 from dometto/fix1289
Browse files Browse the repository at this point in the history
Check whether filename is set when rendering asciidoc. Resolves github#1289
  • Loading branch information
Ashe Connor authored Sep 5, 2019
2 parents f3531a5 + 2710ab9 commit cd01f9e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 6 additions & 3 deletions lib/github/markups.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@
'idprefix' => '',
'idseparator' => '-',
'sectanchors' => nil,
'docname' => File.basename(filename, (extname = File.extname(filename))),
'docfilesuffix' => extname,
'outfilesuffix' => extname,
'env' => 'github',
'env-github' => '',
'source-highlighter' => 'html-pipeline'
}
if filename
attributes['docname'] = File.basename(filename, (extname = File.extname(filename)))
attributes['docfilesuffix'] = attributes['outfilesuffix'] = extname
else
attributes['outfilesuffix'] = '.adoc'
end
Asciidoctor::Compliance.unique_id_start_index = 1
Asciidoctor.convert(content, :safe => :secure, :attributes => attributes)
end
Expand Down
5 changes: 4 additions & 1 deletion test/markup_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ def test_each_render_has_a_name
end

def test_rendering_by_symbol
assert_equal '<p><code>test</code></p>', GitHub::Markup.render_s(GitHub::Markups::MARKUP_MARKDOWN, '`test`').strip
markup = '`test`'
result = /<p><code>test<\/code><\/p>/
assert_match result, GitHub::Markup.render_s(GitHub::Markups::MARKUP_MARKDOWN, markup).strip
assert_match result, GitHub::Markup.render_s(GitHub::Markups::MARKUP_ASCIIDOC, markup).split.join
end

def test_raises_error_if_command_exits_non_zero
Expand Down

0 comments on commit cd01f9e

Please sign in to comment.