Sha256: 95c2b5ad631c9891f9b858aafad6cf3552955e2aff771c2808465fcc62498a6f
Contents?: true
Size: 492 Bytes
Versions: 10
Compression:
Stored size: 492 Bytes
Contents
# frozen_string_literal: true module Tocer module Transformers # Finds appropriate header transformer for matching pattern. class Finder TRANSFORMERS = { /\[.+\]\(.+\)/ => Transformers::Link, /.*/ => Transformers::Text }.freeze def self.call markdown TRANSFORMERS.find { |pattern, transformer| break transformer if pattern.match? markdown } .then { |transformer| transformer.new markdown } end end end end
Version data entries
10 entries across 10 versions & 1 rubygems