module MarkdownProcessor module Fixer # Services here in the Fixer module should inherit from this base class. # #call is implemented here so other services only need to define a # METHODS constant that is an Array of symbols referencing other methods # found here. # # For example # METHODS = %i[add_quotes_to_tile add_quotes_to_description] class Base FRONT_MATTER_DETECTOR = /-{3}.*?-{3}/m # Match @_username_ that is not preceded by backtick USERNAME_WITH_UNDERSCORE_REGEXP = /(?.*?)(\r\n|\n)/m) do |target| # `content` is the captured group (.*?) captured_text = Regexp.last_match("content") # The query below checks if the whole text is wrapped in # either single or double quotes. match = captured_text.scan(/(^".*"$|^'.*'$)/) if match.empty? # Double quotes that aren't already escaped will get escaped. # Then the whole text get warped in double quotes. parsed_text = captured_text.gsub(/(?