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 f72e7de
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion lib/github/markups.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,18 @@
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))),
'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 f72e7de

Please sign in to comment.