diff --git a/shared/lib/CrossDocumentReferencesMacro/extension.rb b/shared/lib/CrossDocumentReferencesMacro/extension.rb index e85efe67f3..f1af69e522 100644 --- a/shared/lib/CrossDocumentReferencesMacro/extension.rb +++ b/shared/lib/CrossDocumentReferencesMacro/extension.rb @@ -1,34 +1,34 @@ require 'asciidoctor/extensions' unless RUBY_ENGINE == 'opal' include ::Asciidoctor class CrossDocumentReferencesMacro < Asciidoctor::Extensions::InlineMacroProcessor use_dsl # Macro to handle cross references to a different book. named :extref name_positional_attributes 'attributes' def process parent, target, attrs destination = target text = attrs[1] anchor = "" unless attrs[2].nil? anchor = "#" + attrs[2] end doc = parent.document if doc.attributes['isonline'] == "1" - (create_anchor parent, text, type: :link, target: %(#{destination}#{anchor})).render + create_anchor parent, text, type: :link, target: %(#{destination}#{anchor}) else if doc.attributes['doctype'] == "book" - (create_anchor parent, text, type: :link, target: %(../#{destination}/index.html#{anchor})).render + create_anchor parent, text, type: :link, target: %(../#{destination}/index.html#{anchor}) else - (create_anchor parent, text, type: :link, target: %(#{destination}/index.html#{anchor})).render + create_anchor parent, text, type: :link, target: %(#{destination}/index.html#{anchor}) end end end end diff --git a/shared/lib/GitReferencesMacro/extension.rb b/shared/lib/GitReferencesMacro/extension.rb index 40dcbed1fd..089bdced78 100644 --- a/shared/lib/GitReferencesMacro/extension.rb +++ b/shared/lib/GitReferencesMacro/extension.rb @@ -1,25 +1,28 @@ require 'asciidoctor/extensions' unless RUBY_ENGINE == 'opal' include ::Asciidoctor class GitReferencesMacro < Asciidoctor::Extensions::InlineMacroProcessor use_dsl named :gitref def process parent, target, attrs hash = target repository = if (repository = attrs['repository']) "#{repository}" else "src" end length = if (length = attrs['length']) length.to_i else 12 end url = %(https://cgit.freebsd.org/#{repository}/commit/?id=#{hash}) - %(#{hash[0, length]}) + + short_sha = hash[0...length] + create_anchor parent, short_sha, type: :link, target: url + end end diff --git a/shared/lib/InterDocumentReferencesMacro/extension.rb b/shared/lib/InterDocumentReferencesMacro/extension.rb index 7d74ede1bb..010c858bbe 100644 --- a/shared/lib/InterDocumentReferencesMacro/extension.rb +++ b/shared/lib/InterDocumentReferencesMacro/extension.rb @@ -1,44 +1,44 @@ require 'asciidoctor/extensions' unless RUBY_ENGINE == 'opal' include ::Asciidoctor class InterDocumentReferencesMacro < Asciidoctor::Extensions::InlineMacroProcessor use_dsl # Macro to handle cross references to different files in the same book. named :crossref def process parent, target, attrs anchor = attrs[1] text = attrs[2] if text.nil? || text.empty? warn "Crossref '#{anchor}' needs a description." end doc = parent.document if doc.backend == 'html5' if doc.attributes['book'] == "true" if doc.attributes['isonline'] == "1" - (create_anchor parent, text, type: :link, target: %(./##{anchor})).render + create_anchor parent, text, type: :link, target: %(./##{anchor}) else - (create_anchor parent, text, type: :link, target: %(./index.html##{anchor})).render + create_anchor parent, text, type: :link, target: %(./index.html##{anchor}) end else if doc.attributes['isonline'] == "1" - (create_anchor parent, text, type: :link, target: %(../#{target}/##{anchor})).render + create_anchor parent, text, type: :link, target: %(../#{target}/##{anchor}) else - (create_anchor parent, text, type: :link, target: %(../#{target}/index.html##{anchor})).render + create_anchor parent, text, type: :link, target: %(../#{target}/index.html##{anchor}) end end else xref_attrs = { 'refid' => anchor } xref_node = create_anchor parent, text, type: :xref, target: target, attributes: xref_attrs # Return the node xref_node end end # process end # class diff --git a/shared/lib/ManPageMacro/extension.rb b/shared/lib/ManPageMacro/extension.rb index 7f930bbd21..f544bff6c7 100644 --- a/shared/lib/ManPageMacro/extension.rb +++ b/shared/lib/ManPageMacro/extension.rb @@ -1,21 +1,22 @@ require 'asciidoctor/extensions' unless RUBY_ENGINE == 'opal' include ::Asciidoctor class ManPageMacro < Asciidoctor::Extensions::InlineMacroProcessor use_dsl named :man name_positional_attributes 'section' def process parent, target, attrs manname = target section = if (section = attrs['section']) "#{section}" else "" end url = %(https://man.freebsd.org/cgi/man.cgi?query=#{manname}&sektion=#{section}&format=html) - %(#{manname}(#{section})) + link_text = section.empty? ? manname : "#{manname}(#{section})" + create_anchor parent, link_text, type: :link, target: url end end diff --git a/shared/lib/PackagesMacro/extension.rb b/shared/lib/PackagesMacro/extension.rb index 5476995c49..7d84349101 100644 --- a/shared/lib/PackagesMacro/extension.rb +++ b/shared/lib/PackagesMacro/extension.rb @@ -1,28 +1,29 @@ require 'asciidoctor/extensions' unless RUBY_ENGINE == 'opal' include ::Asciidoctor class PackagesMacro < Asciidoctor::Extensions::InlineMacroProcessor use_dsl named :package name_positional_attributes 'pkgname' def process parent, target, attrs pkgorigin = target if pkgorigin.include?("@") pkgorigin = pkgorigin[0..pkgorigin.index("@")-1] end pkgname = if (pkgname = attrs['pkgname']) "#{pkgname}" else "#{target}" end url = %(https://cgit.freebsd.org/ports/tree/#{pkgorigin}/) - %(#{pkgname}) + create_anchor parent, target, type: :link, target: url + end end