8000 Merge pull request #1290 from dometto/fix1289 · github/markup@cd01f9e · GitHub
[go: up one dir, main page]

Skip to content

Commit cd01f9e

Browse files
author
Ashe Connor
authored
Merge pull request #1290 from dometto/fix1289
Check whether filename is set when rendering asciidoc. Resolves #1289
2 parents f3531a5 + 2710ab9 commit cd01f9e

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lib/github/markups.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,16 @@
3333
'idprefix' => '',
3434
'idseparator' => '-',
3535
'sectanchors' => nil,
36-
'docname' => File.basename(filename, (extname = File.extname(filename))),
37-
'docfilesuffix' => extname,
38-
'outfilesuffix' => extname,
3936
'env' => 'github',
4037
'env-github' => '',
4138
'source-highlighter' => 'html-pipeline'
4239
}
40+
if filename
41+
attributes['docname'] = File.basename(filename, (extname = File.extname(filename)))
42+
attributes['docfilesuffix'] = attributes['outfilesuffix'] = extname
43+
else
44+
attributes['outfilesuffix'] = '.adoc'
45+
end
4346
Asciidoctor::Compliance.unique_id_start_index = 1
4447
Asciidoctor.convert(content, :safe => :secure, :attributes => attributes)
4548
end

test/markup_test.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ def test_each_render_has_a_name
9494
end
9595

9696
def test_rendering_by_symbol
97-
assert_equal '<p><code>test</code></p>', GitHub::Markup.render_s(GitHub::Markups::MARKUP_MARKDOWN, '`test`').strip
97+
markup = '`test`'
98+
result = /<p><code>test<\/code><\/p>/
99+
assert_match result, GitHub::Markup.render_s(GitHub::Markups::MARKUP_MARKDOWN, markup).strip
100+
assert_match result, GitHub::Markup.render_s(GitHub::Markups::MARKUP_ASCIIDOC, markup).split.join
98101
end
99102

100103
def test_raises_error_if_command_exits_non_zero

0 commit comments

Comments
 (0)
0