Sha256: a780062a34879a4b3c228af0f72938e36261f217c64c970d6c09c24dc1788b0b
Contents?: true
Size: 994 Bytes
Versions: 4
Compression:
Stored size: 994 Bytes
Contents
require "uri" module ReverseAsciidoctor module Converters class A < Base def convert(node, state = {}) name = treat_children(node, state) href = node['href'] title = extract_title(node) id = node['id'] || node['name'] id = id&.gsub(/\s/, "")&.gsub(/__+/, "_") if /^_Toc\d+$|^_GoBack$/.match id "" elsif !id.nil? && !id.empty? "[[#{id}]]" elsif href.to_s.start_with?('#') href = href.sub(/^#/, "").gsub(/\s/, "").gsub(/__+/, "_") if name.empty? "<<#{href}>>" else "<<#{href},#{name}>>" end elsif href.to_s.empty? name else name = title if name.empty? href = "link:#{href}" unless href.to_s =~ URI::DEFAULT_PARSER.make_regexp link = "#{href}[#{name}]" link.prepend(' ') link end end private end register :a, A.new end end
Version data entries
4 entries across 4 versions & 1 rubygems