Created
August 20, 2014 17:29
-
-
Save aslakknutsen/07e90afa8fcd8c7aac01 to your computer and use it in GitHub Desktop.
Asciidoctor 1.5.0 regression?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "asciidoctor" | |
require 'asciidoctor/extensions' | |
Asciidoctor::Extensions.register do | |
inline_macro do | |
named :javaapi | |
match /((?:java|javax)\.\w[\.\w]+\.[A-Z]\w+)/ | |
process do |parent, target| | |
doc_uri_pattern = 'https://javaee-spec.java.net/nonav/javadocs/%s.html' | |
doc_uri = doc_uri_pattern % target.gsub(/\./, '/') | |
link_name = target | |
link_name = $1 if target =~ /([A-Z]\w*$)/ | |
(create_anchor parent, link_name, type: :link, target: doc_uri, attributes: {'title' => target}).render | |
end | |
end | |
end | |
def render content | |
Asciidoctor.render(content) | |
end | |
def verify content | |
expect(content).to match /<a/ | |
end | |
describe "Asciidoctor inline macro" do | |
it "Inline macro on pure text" do | |
verify render "javax.test.Api" | |
end | |
it "Inline macro on code text" do | |
verify render "+javax.test.Api+" | |
end | |
end |
Aha! That's because you need to refer to the migration guide :)
http://asciidoctor.org/docs/migration/#migration-cheatsheet
+
now means passthrough, not monospaced. You need to either switch it to backtick:
`javax.test.Api`
Add the compat role:
[x-]+javax.test.Api+
Or switch on compat mode globally:
:compat-mode:
Aha! :)
def render content
Asciidoctor.render(content, :attributes => {'compat-mode' => true})
end
Back to normal..
Oh, right! That works too. I should have suggested that.
Btw, you can just set a value of empty string to mean true...though that's one of the things we need to cleanup in Asciidoctor because that's a legacy hold-over from AsciiDoc Python. Why true and false aren't true and false is beyond me :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In Asciidoctor 1.5.0 +javax.test.Api+ never trigger the maco. Nor does it output code tags for that matter.