From 2710ab922c6d976137f8c1e8585ba5f41dbce90e Mon Sep 17 00:00:00 2001 From: Dawa Ometto Date: Wed, 4 Sep 2019 13:43:49 +0200 Subject: [PATCH] Check whether filename is set when rendering asciidoc --- lib/github/markups.rb | 9 ++++++--- test/markup_test.rb | 5 ++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/github/markups.rb b/lib/github/markups.rb index ea816c75..0ed55df0 100644 --- a/lib/github/markups.rb +++ b/lib/github/markups.rb @@ -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 diff --git a/test/markup_test.rb b/test/markup_test.rb index 4c3cc7af..24e78000 100644 --- a/test/markup_test.rb +++ b/test/markup_test.rb @@ -94,7 +94,10 @@ def test_each_render_has_a_name end def test_rendering_by_symbol - assert_equal '

test

', GitHub::Markup.render_s(GitHub::Markups::MARKUP_MARKDOWN, '`test`').strip + markup = '`test`' + result = /

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