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

set outfilesuffix to match extension of input filename #1041

Merged
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
13 changes: 12 additions & 1 deletion lib/github/markups.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,19 @@
end

markup(::GitHub::Markups::MARKUP_ASCIIDOC, :asciidoctor, /adoc|asc(iidoc)?/, ["AsciiDoc"]) do |filename, content|
attributes = {
'showtitle' => '@',
'idprefix' => '',
'idseparator' => '-',
'docname' => File.basename(filename, (extname = File.extname(filename))),
'docfilesuffix' => extname,
'outfilesuffix' => extname,
'env' => 'github',
'env-github' => '',
'source-highlighter' => 'html-pipeline'
}
Asciidoctor::Compliance.unique_id_start_index = 1
Asciidoctor.convert(content, :safe => :secure, :attributes => %w(showtitle=@ idprefix idseparator=- outfilesuffix=.adoc env=github env-github source-highlighter=html-pipeline))
Asciidoctor.convert(content, :safe => :secure, :attributes => attributes)
end

command(
Expand Down
2 changes: 1 addition & 1 deletion test/markups/README.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

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

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

== Another Section

Expand Down
2 changes: 1 addition & 1 deletion test/markups/README.asciidoc.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h2>First Section</h2>
<p>Refer to <a href="#another-section">Another Section</a> or <a href="#another-section-1">Another Section</a>.</p>
</div>
<div>
<p>Navigate to <a href="another-document.adoc">another document</a>.</p>
<p>Navigate from README.asciidoc to <a href="another-document.asciidoc">another document</a>.</p>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kivikakk notice that the extension of referenced file now matches the extension of the file being converted.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

</div>
</div>
</div>
Expand Down