Module: Awestruct::AsciiDocable
- Included in:
- AsciiDocFile, Haml::Filters::AsciiDoc
- Defined in:
- lib/awestruct/asciidocable.rb
Instance Method Summary collapse
- #_render(content, relative_source_path, site) ⇒ Object
- #content ⇒ Object
- #execute(command, target) ⇒ Object
- #render(context) ⇒ Object
Instance Method Details
#_render(content, relative_source_path, site) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/awestruct/asciidocable.rb', line 13 def _render(content, relative_source_path, site) # TODO replace with site.engine.config.images_dir once available imagesdir = Pathname.new('/images').relative_path_from(Pathname.new(File.dirname(relative_source_path))) iconsdir = File.join(imagesdir, 'icons') conffile = File.join(site.engine.config.config_dir, 'asciidoc.conf') confopt = File.exist?(conffile) ? '-f ' + conffile : '' execute("asciidoc -s -b html5 -a pygments -a icons -a iconsdir='#{iconsdir}' -a imagesdir='#{imagesdir}' #{confopt} -o - -", content) end |
#content ⇒ Object
8 9 10 11 |
# File 'lib/awestruct/asciidocable.rb', line 8 def content context = site.engine.create_context( self ) render( context ) end |
#execute(command, target) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/awestruct/asciidocable.rb', line 22 def execute(command, target) out = '' Open3.popen3(command) do |stdin, stdout, _| stdin.puts target stdin.close out = stdout.read end out.gsub("\r", '') rescue Errno::EPIPE "" end |
#render(context) ⇒ Object
4 5 6 |
# File 'lib/awestruct/asciidocable.rb', line 4 def render(context) _render(context.interpolate_string(raw_page_content), context.page.relative_source_path, site) end |