Sha256: d56923858598709d55be70e4ecaa687aef9bc7bd69f06d4a0590d717975896d7
Contents?: true
Size: 1.12 KB
Versions: 3
Compression:
Stored size: 1.12 KB
Contents
# frozen_string_literal: true require "uri" module Stepmod module Utils module Converters class A < ReverseAdoc::Converters::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&.match?(URI::DEFAULT_PARSER.make_regexp) link = "#{href}[#{name}]" # link.prepend(' ') " #{link}" end end end ReverseAdoc::Converters.register :a, A.new end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
stepmod-utils-0.3.9 | lib/stepmod/utils/converters/a.rb |
stepmod-utils-0.3.8 | lib/stepmod/utils/converters/a.rb |
stepmod-utils-0.3.7 | lib/stepmod/utils/converters/a.rb |