From f72e7de6e2d3f3ce4e64dc868dd89ff02e9ae7e7 Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Sun, 2 Apr 2017 20:53:50 -0600 Subject: [PATCH] set outfilesuffix to match extension of input filename - 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 --- lib/github/markups.rb | 12 +++++++++++- test/markups/README.asciidoc | 2 +- test/markups/README.asciidoc.html | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/github/markups.rb b/lib/github/markups.rb index 19b539b1..c1ff0bd1 100644 --- a/lib/github/markups.rb +++ b/lib/github/markups.rb @@ -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( diff --git a/test/markups/README.asciidoc b/test/markups/README.asciidoc index 6b5c49d0..d3c872f7 100644 --- a/test/markups/README.asciidoc +++ b/test/markups/README.asciidoc @@ -7,7 +7,7 @@ Refer to <> or <>. -Navigate to <>. +Navigate from {docname}{outfilesuffix} to <>. == Another Section diff --git a/test/markups/README.asciidoc.html b/test/markups/README.asciidoc.html index cd8fe8c1..6f478cab 100644 --- a/test/markups/README.asciidoc.html +++ b/test/markups/README.asciidoc.html @@ -16,7 +16,7 @@

First Section

Refer to Another Section or Another Section.

-

Navigate to another document.

+

Navigate from README.asciidoc to another document.