Skip to content

Commit 7e85b37

Browse files
author
Yuki Izumi
authored
Merge pull request #1041 from mojavelinux/match-outfilesuffix-to-input-file
set outfilesuffix to match extension of input filename
2 parents 9fe0536 + 36b3680 commit 7e85b37

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

lib/github/markups.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,19 @@
2828
end
2929

3030
markup(::GitHub::Markups::MARKUP_ASCIIDOC, :asciidoctor, /adoc|asc(iidoc)?/, ["AsciiDoc"]) do |filename, content|
31+
attributes = {
32+
'showtitle' => '@',
33+
'idprefix' => '',
34+
'idseparator' => '-',
35+
'docname' => File.basename(filename, (extname = File.extname(filename))),
36+
'docfilesuffix' => extname,
37+
'outfilesuffix' => extname,
38+
'env' => 'github',
39+
'env-github' => '',
40+
'source-highlighter' => 'html-pipeline'
41+
}
3142
Asciidoctor::Compliance.unique_id_start_index = 1
32-
Asciidoctor.convert(content, :safe => :secure, :attributes => %w(showtitle=@ idprefix idseparator=- outfilesuffix=.adoc env=github env-github source-highlighter=html-pipeline))
43+
Asciidoctor.convert(content, :safe => :secure, :attributes => attributes)
3344
end
3445

3546
command(

test/markups/README.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
Refer to <<another-section>> or <<another-section-1>>.
99

10-
Navigate to <<another-document#,another document>>.
10+
Navigate from {docname}{outfilesuffix} to <<another-document#,another document>>.
1111

1212
== Another Section
1313

test/markups/README.asciidoc.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ <h2>First Section</h2>
1616
<p>Refer to <a href="#another-section">Another Section</a> or <a href="#another-section-1">Another Section</a>.</p>
1717
</div>
1818
<div>
19-
<p>Navigate to <a href="another-document.adoc">another document</a>.</p>
19+
<p>Navigate from README.asciidoc to <a href="another-document.asciidoc">another document</a>.</p>
2020
</div>
2121
</div>
2222
</div>

0 commit comments

Comments
 (0)