defmodule Earmark.Parser.LineScanner do @moduledoc false require Logger alias Earmark.Parser.{Helpers, Line, Options} # This is the re that matches the ridiculous "[id]: url title" syntax @id_title_part ~S""" (?| " (.*) " # in quotes | ' (.*) ' # | \( (.*) \) # in parens ) """ @id_re ~r''' ^\[([^^].*?)\]: # [someid]: \s+ (?| < (\S+) > # url in <>s | (\S+) # or without ) (?: \s+ # optional title #{@id_title_part} )? \s* $ '''x @indent_re ~r''' \A ( (?: \s{4})+ ) (\s*) # 4 or more leading spaces (.*) # the rest '''x @void_tags ~w{area br hr img wbr} @void_tag_rgx ~r''' ^<( #{Enum.join(@void_tags, "|")} ) .*? > '''x @rgx_map %{ block_quote: ~r/\A>\s?(.*)/, column_rgx: ~r{\A[\s|:-]+\z}, comment_rest: ~r/()(.*)/, fence: ~r/\A(\s*)(`{3,}|~{3,})\s*([^`\s]*)\s*\z/u, footnote_definition: ~r/\A\[\^([^\s\]]+)\]:\s+(.*)/, heading: ~r/^(\#{1,6})\s+(?|(.*?)\s*#*\s*$|(.*))/u, html_close_tag: ~r/\A<\/([-\w]+?)>/, html_comment_complete: ~r/\A \z/x, html_comment_start: ~r/\A