Re: Finally, a draft of the Asciidoctor extension API has landed!
Posted by
mojavelinux on
Aug 16, 2013; 9:24am
URL: https://discuss.asciidoctor.org/Finally-a-draft-of-the-Asciidoctor-extension-API-has-landed-tp455p459.html
I just sent a new pull request for issue #100, which is the custom include macro processor. Here's an example of how it can be used.
```ruby
require 'uri-open'
# Sample content:
#
# include::
https://raw.github.com/asciidoctor/asciidoctor/master/Gemfile[]
#
class RemoteIncludeProcessor < Asciidoctor::Extensions::IncludeProcessor
def handles? target
target.start_with?('
http://') or target.start_with?('
https://')
end
def process target, attributes
open(target).readlines
end
end
Asciidoctor::Extensions.register do |document|
include_processor RemoteIncludeProcessor
end
Asciidoctor.render_file('sample-with-include.ad', :safe => :safe, :in_place => true)
```
-Dan