Skip to content

Commit

Permalink
set outfilesuffix to match extension of input filename
Browse files Browse the repository at this point in the history
- set outfilesuffix to match extension of input filename
- update test for inter-document xref
- set docname attribute
- add test for docname attribute value
- pass attributes as a hash to ensure docname value is properly escaped
  • Loading branch information
mojavelinux committed Apr 3, 2017
1 parent 9fe0536 commit 36b3680
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
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>
</div>
</div>
</div>
Expand Down

0 comments on commit 36b3680

Please sign in to comment.