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 ) """ defp id_re do ~r''' ^\[([^^].*?)\]: # [someid]: \s+ (?| < (\S+) > # url in <>s | (\S+) # or without ) (?: \s+ # optional title #{@id_title_part} )? \s* $ '''x end defp indent_re do ~r''' \A ( (?: \s{4})+ ) (\s*) # 4 or more leading spaces (.*) # the rest '''x end @void_tags ~w{area br hr img wbr} # Converted rgx_map to a function defp rgx_map(:block_quote), do: ~r/\A>\s?(.*)/ defp rgx_map(:column_rgx), do: ~r{\A[\s|:-]+\z} defp rgx_map(:comment_rest), do: ~r/()(.*)/ defp rgx_map(:fence), do: ~r/\A(\s*)(`{3,}|~{3,})\s*([^`\s]*)\s*\z/u defp rgx_map(:footnote_definition), do: ~r/\A\[\^([^\s\]]+)\]:\s+(.*)/ defp rgx_map(:heading), do: ~r/^(\#{1,6})\s+(?|(.*?)\s*#*\s*$|(.*))/u defp rgx_map(:html_close_tag), do: ~r/\A<\/([-\w]+?)>/ defp rgx_map(:html_comment_complete), do: ~r/\A \z/x defp rgx_map(:html_comment_start), do: ~r/\A