Sha256: 2cbf89c6024d593f1a0048920d76284ef3585ec9d554bd824f3cdecc06101b7c
Contents?: true
Size: 1.07 KB
Versions: 35
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true 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}" end end end ReverseAdoc::Converters.register :a, A.new end end end
Version data entries
35 entries across 35 versions & 1 rubygems