From b77055c6bd81f3e10695c6eff0187cbbedb8cb90 Mon Sep 17 00:00:00 2001 From: Brad Hanks Date: Fri, 16 Feb 2024 21:14:24 -0700 Subject: [PATCH 1/5] look_for_alignments/1 Consolidated two Enum.map together; other changes are incidental whitespace formatting --- lib/earmark_parser/parser.ex | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/lib/earmark_parser/parser.ex b/lib/earmark_parser/parser.ex index 727f873..a9957c1 100644 --- a/lib/earmark_parser/parser.ex +++ b/lib/earmark_parser/parser.ex @@ -1,5 +1,4 @@ defmodule EarmarkParser.Parser do - @moduledoc false alias EarmarkParser.{Block, Line, LineScanner, Options} @@ -41,7 +40,7 @@ defmodule EarmarkParser.Parser do end def parse_markdown(lines, _) do - raise ArgumentError, "#{inspect lines} not a binary, nor a list of binaries" + raise ArgumentError, "#{inspect(lines)} not a binary, nor a list of binaries" end def parse(text_lines, options = %Options{}, recursive) do @@ -59,7 +58,6 @@ defmodule EarmarkParser.Parser do {blocks, footnotes, options} = lines |> remove_trailing_blank_lines() |> lines_to_blocks(options, recursive) - links = links_from_blocks(blocks) {blocks, links, footnotes, options} end @@ -268,7 +266,13 @@ defmodule EarmarkParser.Parser do {code_lines, rest} = Enum.split_while(list, &indent_or_blank?/1) code_lines = remove_trailing_blank_lines(code_lines) code = for line <- code_lines, do: properly_indent(line, 1) - _parse([%Line.Blank{}|rest], [%Block.Code{lines: code, lnb: lnb} | result], options, recursive) + + _parse( + [%Line.Blank{} | rest], + [%Block.Code{lines: code, lnb: lnb} | result], + options, + recursive + ) end ############### @@ -447,7 +451,6 @@ defmodule EarmarkParser.Parser do ) end - ####################################################### # Assign attributes that follow a block to that block # ####################################################### @@ -463,10 +466,16 @@ defmodule EarmarkParser.Parser do end defp _check_closing_fence(rest, lnb, delimiter, options) + defp _check_closing_fence([], lnb, delimiter, options) do - {[], add_message(options, {:error, lnb, "Fenced Code Block opened with #{delimiter} not closed at end of input"})} + {[], + add_message( + options, + {:error, lnb, "Fenced Code Block opened with #{delimiter} not closed at end of input"} + )} end - defp _check_closing_fence([_|rest], _lnb, _delimiter, options) do + + defp _check_closing_fence([_ | rest], _lnb, _delimiter, options) do {rest, options} end @@ -523,8 +532,9 @@ defmodule EarmarkParser.Parser do defp look_for_alignments([_first, second | _rest]) do if Enum.all?(second, fn row -> row =~ ~r{^:?-+:?$} end) do second - |> Enum.map(fn row -> Regex.replace(~r/-+/, row, "-") end) |> Enum.map(fn row -> + row = Regex.replace(~r/-+/, row, "-") + case row do ":-:" -> :center ":-" -> :left From d1d337a7d3f6dbcc950f76046448e056a3aee852 Mon Sep 17 00:00:00 2001 From: Brad Hanks Date: Fri, 16 Feb 2024 21:18:49 -0700 Subject: [PATCH 2/5] _split_table_columns/1: combined two Enum.map function calls --- lib/earmark_parser/line_scanner.ex | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/earmark_parser/line_scanner.ex b/lib/earmark_parser/line_scanner.ex index 2e85b5a..87e9ce0 100644 --- a/lib/earmark_parser/line_scanner.ex +++ b/lib/earmark_parser/line_scanner.ex @@ -51,13 +51,14 @@ defmodule EarmarkParser.LineScanner do when is_boolean(recursive), do: type_of(line, %Options{}, recursive) - def type_of({line, lnb}, options = %Options{annotations: annotations}, recursive) when is_binary(line) do + def type_of({line, lnb}, options = %Options{annotations: annotations}, recursive) + when is_binary(line) do {line1, annotation} = line |> Helpers.expand_tabs() |> Helpers.remove_line_ending(annotations) %{_type_of(line1, options, recursive) | annotation: annotation, lnb: lnb} end def type_of({line, lnb}, _, _) do - raise ArgumentError, "line number #{lnb} #{inspect line} is not a binary" + raise ArgumentError, "line number #{lnb} #{inspect(line)} is not a binary" end defp _type_of(line, options = %Options{}, recursive) do @@ -184,7 +185,9 @@ defmodule EarmarkParser.LineScanner do line: line } - line |> String.replace(~r/\[\[ .*? \]\]/x, "") |> String.match?(~r/\A (\s*) .* \s \| \s /x) -> + line + |> String.replace(~r/\[\[ .*? \]\]/x, "") + |> String.match?(~r/\A (\s*) .* \s \| \s /x) -> columns = _split_table_columns(line) %Line.TableLine{ @@ -195,7 +198,8 @@ defmodule EarmarkParser.LineScanner do line: line } - options.gfm_tables && line |> String.replace(~r/\[\[ .*? \]\]/x, "") |> String.match?(~r/\A (\s*) .* \| /x) -> + options.gfm_tables && + line |> String.replace(~r/\[\[ .*? \]\]/x, "") |> String.match?(~r/\A (\s*) .* \| /x) -> columns = _split_table_columns(line) %Line.TableLine{ @@ -303,8 +307,10 @@ defmodule EarmarkParser.LineScanner do defp _split_table_columns(line) do line |> String.split(~r{(? Enum.map(&String.trim/1) - |> Enum.map(fn col -> Regex.replace(~r{\\\|}, col, "|") end) + |> Enum.map(fn col -> + col = String.trim(col) + Regex.replace(~r{\\\|}, col, "|") + end) end end From 47250203e15920335887bebdf3b26315522d4f5e Mon Sep 17 00:00:00 2001 From: Brad Hanks Date: Fri, 16 Feb 2024 21:40:59 -0700 Subject: [PATCH 3/5] refactored some conditionals to pattern matching --- lib/earmark_parser/ast_renderer.ex | 61 ++++++++++++++---------------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/lib/earmark_parser/ast_renderer.ex b/lib/earmark_parser/ast_renderer.ex index 8857676..4ab70d3 100644 --- a/lib/earmark_parser/ast_renderer.ex +++ b/lib/earmark_parser/ast_renderer.ex @@ -87,7 +87,8 @@ defmodule EarmarkParser.AstRenderer do emit( "h#{level}", context1.value |> Enum.reverse(), - attrs) + attrs + ) ] end ) @@ -107,32 +108,26 @@ defmodule EarmarkParser.AstRenderer do ######### # Table # ######### + defp render_block( - %Block.Table{lnb: lnb, header: header, rows: rows, alignments: aligns, attrs: attrs}, + %Block.Table{lnb: lnb, header: nil, rows: rows, alignments: aligns, attrs: attrs}, context, _loose? ) do - header_offset = - if header do - 2 # 1 line for header text, 1 line for header separator - else - 0 - end - - {rows_ast, context1} = render_rows(rows, lnb + header_offset, aligns, context) - - {rows_ast1, context2} = - if header do - {header_ast, context3} = render_header(header, lnb, aligns, context1) - {[header_ast | rows_ast], context3} - else - {rows_ast, context1} - end + {rows_ast, context} = render_rows(rows, lnb, aligns, context) + prepend(clear_value(context), emit("table", rows_ast, attrs)) + end - prepend( - clear_value(context2), - emit("table", rows_ast1, attrs) - ) + defp render_block( + %Block.Table{lnb: lnb, header: header, rows: rows, alignments: aligns, attrs: attrs}, + context, + _loose? + ) do + header_offset = 2 + {rows_ast, context} = render_rows(rows, lnb + header_offset, aligns, context) + {header_ast, context} = render_header(header, lnb, aligns, context) + {rows_ast, context} = {[header_ast | rows_ast], context} + prepend(clear_value(context), emit("table", rows_ast, attrs)) end ######## @@ -188,6 +183,7 @@ defmodule EarmarkParser.AstRenderer do _loose? ) do context1 = render(blocks, clear_value(context), loose?) + prepend( context, emit("li", context1.value, attrs), @@ -199,15 +195,16 @@ defmodule EarmarkParser.AstRenderer do # Text # ######## - defp render_block(%Block.Text{line: line, lnb: lnb}, context, loose?) do - context1 = convert(line, lnb, clear_value(context)) - ast = context1.value |> Enum.reverse() + defp render_block(%Block.Text{line: line, lnb: lnb}, context, true = _loose?) do + context = convert(line, lnb, clear_value(context)) + ast = context.value |> Enum.reverse() + modify_value(context, fn _ -> [emit("p", ast)] end) + end - if loose? do - modify_value(context1, fn _ -> [emit("p", ast)] end) - else - modify_value(context1, fn _ -> ast end) - end + defp render_block(%Block.Text{line: line, lnb: lnb}, context, false = _loose?) do + context = convert(line, lnb, clear_value(context)) + ast = context.value |> Enum.reverse() + modify_value(context, fn _ -> ast end) end ################## @@ -215,13 +212,14 @@ defmodule EarmarkParser.AstRenderer do ################## @empty_set MapSet.new([]) - defp render_block(%Block.FnList{}=fn_list, context, _loose?) do + defp render_block(%Block.FnList{} = fn_list, context, _loose?) do if MapSet.equal?(context.referenced_footnote_ids, @empty_set) do context else render_defined_fns(fn_list, context) end end + ####################################### # Isolated IALs are rendered as paras # ####################################### @@ -261,7 +259,6 @@ defmodule EarmarkParser.AstRenderer do start1 -> start1 end end - end # SPDX-License-Identifier: Apache-2.0 From 9f3ef38de38a389ee3e1d3815a3aa3508922f949 Mon Sep 17 00:00:00 2001 From: Brad Hanks Date: Sat, 17 Feb 2024 18:24:43 -0700 Subject: [PATCH 4/5] undo Enum.map refactor --- lib/earmark_parser/line_scanner.ex | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/earmark_parser/line_scanner.ex b/lib/earmark_parser/line_scanner.ex index 87e9ce0..3bcb41b 100644 --- a/lib/earmark_parser/line_scanner.ex +++ b/lib/earmark_parser/line_scanner.ex @@ -307,10 +307,8 @@ defmodule EarmarkParser.LineScanner do defp _split_table_columns(line) do line |> String.split(~r{(? Enum.map(fn col -> - col = String.trim(col) - Regex.replace(~r{\\\|}, col, "|") - end) + |> Enum.map(&String.trim/1) + |> Enum.map(fn col -> Regex.replace(~r{\\\|}, col, "|") end) end end From e9ae60f827144fa0e931623d5d1a9ba9b0610aca Mon Sep 17 00:00:00 2001 From: Brad Hanks Date: Mon, 17 Mar 2025 15:47:30 -0600 Subject: [PATCH 5/5] consolidated block modules into a single file, add types for Line and Block modules. --- lib/earmark_parser/block.ex | 126 +++++++++++++++++++++++ lib/earmark_parser/block/block_quote.ex | 6 -- lib/earmark_parser/block/code.ex | 6 -- lib/earmark_parser/block/fn_def.ex | 6 -- lib/earmark_parser/block/fn_list.ex | 6 -- lib/earmark_parser/block/heading.ex | 6 -- lib/earmark_parser/block/html.ex | 6 -- lib/earmark_parser/block/html_comment.ex | 6 -- lib/earmark_parser/block/html_oneline.ex | 6 -- lib/earmark_parser/block/ial.ex | 6 -- lib/earmark_parser/block/id_def.ex | 6 -- lib/earmark_parser/block/list.ex | 18 ---- lib/earmark_parser/block/list_item.ex | 13 --- lib/earmark_parser/block/para.ex | 6 -- lib/earmark_parser/block/ruler.ex | 6 -- lib/earmark_parser/block/table.ex | 10 -- lib/earmark_parser/block/text.ex | 6 -- lib/earmark_parser/line.ex | 19 ++++ 18 files changed, 145 insertions(+), 119 deletions(-) create mode 100644 lib/earmark_parser/block.ex delete mode 100644 lib/earmark_parser/block/block_quote.ex delete mode 100644 lib/earmark_parser/block/code.ex delete mode 100644 lib/earmark_parser/block/fn_def.ex delete mode 100644 lib/earmark_parser/block/fn_list.ex delete mode 100644 lib/earmark_parser/block/heading.ex delete mode 100644 lib/earmark_parser/block/html.ex delete mode 100644 lib/earmark_parser/block/html_comment.ex delete mode 100644 lib/earmark_parser/block/html_oneline.ex delete mode 100644 lib/earmark_parser/block/ial.ex delete mode 100644 lib/earmark_parser/block/id_def.ex delete mode 100644 lib/earmark_parser/block/list.ex delete mode 100644 lib/earmark_parser/block/list_item.ex delete mode 100644 lib/earmark_parser/block/para.ex delete mode 100644 lib/earmark_parser/block/ruler.ex delete mode 100644 lib/earmark_parser/block/table.ex delete mode 100644 lib/earmark_parser/block/text.ex diff --git a/lib/earmark_parser/block.ex b/lib/earmark_parser/block.ex new file mode 100644 index 0000000..adec157 --- /dev/null +++ b/lib/earmark_parser/block.ex @@ -0,0 +1,126 @@ +defmodule EarmarkParser.Block do + @moduledoc false + + @type t :: + %__MODULE__.BlockQuote{} + | %__MODULE__.Code{} + | %__MODULE__.FnDef{} + | %__MODULE__.FnList{} + | %__MODULE__.Heading{} + | %__MODULE__.Html{} + | %__MODULE__.HtmlComment{} + | %__MODULE__.HtmlOneline{} + | %__MODULE__.Ial{} + | %__MODULE__.IdDef{} + | %__MODULE__.ListItem{} + | %__MODULE__.List{} + | %__MODULE__.Para{} + | %__MODULE__.Ruler{} + | %__MODULE__.Table{} + | %__MODULE__.Text{} + + defmodule BlockQuote do + @moduledoc false + defstruct lnb: 0, annotation: nil, attrs: nil, blocks: [] + end + + defmodule Code do + @moduledoc false + defstruct lnb: 0, annotation: nil, attrs: nil, lines: [], language: nil + end + + defmodule FnDef do + @moduledoc false + defstruct lnb: 0, annotation: nil, attrs: nil, id: nil, number: nil, blocks: [] + end + + defmodule FnList do + @moduledoc false + defstruct lnb: 0, annotation: nil, attrs: ".footnotes", blocks: [] + end + + defmodule Heading do + @moduledoc false + defstruct lnb: 0, annotation: nil, attrs: nil, content: nil, level: nil + end + + defmodule HtmlComment do + @moduledoc false + defstruct lnb: 0, annotation: nil, attrs: nil, lines: [] + end + + defmodule HtmlOneline do + @moduledoc false + defstruct lnb: 0, annotation: nil, attrs: nil, html: "" + end + + defmodule Html do + @moduledoc false + defstruct lnb: 0, annotation: nil, attrs: nil, html: [], tag: nil + end + + defmodule Ial do + @moduledoc false + defstruct lnb: 0, annotation: nil, attrs: nil, content: nil, verbatim: "" + end + + defmodule IdDef do + @moduledoc false + defstruct lnb: 0, annotation: nil, attrs: nil, id: nil, url: nil, title: nil + end + + defmodule ListItem do + @moduledoc false + defstruct attrs: nil, + blocks: [], + bullet: "", + lnb: 0, + annotation: nil, + loose?: false, + spaced?: true, + type: :ul + end + + defmodule List do + @moduledoc false + + defstruct annotation: nil, + attrs: nil, + blocks: [], + lines: [], + bullet: "-", + indent: 0, + lnb: 0, + loose?: false, + pending: {nil, 0}, + spaced?: false, + start: "", + type: :ul + end + + defmodule Para do + @moduledoc false + defstruct lnb: 0, annotation: nil, attrs: nil, lines: [] + end + + defmodule Ruler do + @moduledoc false + defstruct lnb: 0, annotation: nil, attrs: nil, type: nil + end + + defmodule Table do + @moduledoc false + defstruct lnb: 0, annotation: nil, attrs: nil, rows: [], header: nil, alignments: [] + + def new_for_columns(n) do + %__MODULE__{alignments: Elixir.List.duplicate(:left, n)} + end + end + + defmodule Text do + @moduledoc false + defstruct attrs: nil, lnb: 0, annotation: nil, line: "" + end +end + +# SPDX-License-Identifier: Apache-2.0 diff --git a/lib/earmark_parser/block/block_quote.ex b/lib/earmark_parser/block/block_quote.ex deleted file mode 100644 index 6cb001e..0000000 --- a/lib/earmark_parser/block/block_quote.ex +++ /dev/null @@ -1,6 +0,0 @@ -defmodule EarmarkParser.Block.BlockQuote do - @moduledoc false - defstruct lnb: 0, annotation: nil, attrs: nil, blocks: [] -end - -# SPDX-License-Identifier: Apache-2.0 diff --git a/lib/earmark_parser/block/code.ex b/lib/earmark_parser/block/code.ex deleted file mode 100644 index 820dc36..0000000 --- a/lib/earmark_parser/block/code.ex +++ /dev/null @@ -1,6 +0,0 @@ -defmodule EarmarkParser.Block.Code do - @moduledoc false - defstruct lnb: 0, annotation: nil, attrs: nil, lines: [], language: nil -end - -# SPDX-License-Identifier: Apache-2.0 diff --git a/lib/earmark_parser/block/fn_def.ex b/lib/earmark_parser/block/fn_def.ex deleted file mode 100644 index 5d26767..0000000 --- a/lib/earmark_parser/block/fn_def.ex +++ /dev/null @@ -1,6 +0,0 @@ -defmodule EarmarkParser.Block.FnDef do - @moduledoc false - defstruct lnb: 0, annotation: nil, attrs: nil, id: nil, number: nil, blocks: [] -end - -# SPDX-License-Identifier: Apache-2.0 diff --git a/lib/earmark_parser/block/fn_list.ex b/lib/earmark_parser/block/fn_list.ex deleted file mode 100644 index 173a0d2..0000000 --- a/lib/earmark_parser/block/fn_list.ex +++ /dev/null @@ -1,6 +0,0 @@ -defmodule EarmarkParser.Block.FnList do - @moduledoc false - defstruct lnb: 0, annotation: nil, attrs: ".footnotes", blocks: [] -end - -# SPDX-License-Identifier: Apache-2.0 diff --git a/lib/earmark_parser/block/heading.ex b/lib/earmark_parser/block/heading.ex deleted file mode 100644 index 2ef0405..0000000 --- a/lib/earmark_parser/block/heading.ex +++ /dev/null @@ -1,6 +0,0 @@ -defmodule EarmarkParser.Block.Heading do - @moduledoc false - defstruct lnb: 0, annotation: nil, attrs: nil, content: nil, level: nil -end - -# SPDX-License-Identifier: Apache-2.0 diff --git a/lib/earmark_parser/block/html.ex b/lib/earmark_parser/block/html.ex deleted file mode 100644 index ba01b0d..0000000 --- a/lib/earmark_parser/block/html.ex +++ /dev/null @@ -1,6 +0,0 @@ -defmodule EarmarkParser.Block.Html do - @moduledoc false - defstruct lnb: 0, annotation: nil, attrs: nil, html: [], tag: nil -end - -# SPDX-License-Identifier: Apache-2.0 diff --git a/lib/earmark_parser/block/html_comment.ex b/lib/earmark_parser/block/html_comment.ex deleted file mode 100644 index 63dfd90..0000000 --- a/lib/earmark_parser/block/html_comment.ex +++ /dev/null @@ -1,6 +0,0 @@ -defmodule EarmarkParser.Block.HtmlComment do - @moduledoc false - defstruct lnb: 0, annotation: nil, attrs: nil, lines: [] -end - -# SPDX-License-Identifier: Apache-2.0 diff --git a/lib/earmark_parser/block/html_oneline.ex b/lib/earmark_parser/block/html_oneline.ex deleted file mode 100644 index ef6a429..0000000 --- a/lib/earmark_parser/block/html_oneline.ex +++ /dev/null @@ -1,6 +0,0 @@ -defmodule EarmarkParser.Block.HtmlOneline do - @moduledoc false - defstruct lnb: 0, annotation: nil, attrs: nil, html: "" -end - -# SPDX-License-Identifier: Apache-2.0 diff --git a/lib/earmark_parser/block/ial.ex b/lib/earmark_parser/block/ial.ex deleted file mode 100644 index 5a397b0..0000000 --- a/lib/earmark_parser/block/ial.ex +++ /dev/null @@ -1,6 +0,0 @@ -defmodule EarmarkParser.Block.Ial do - @moduledoc false - defstruct lnb: 0, annotation: nil, attrs: nil, content: nil, verbatim: "" -end - -# SPDX-License-Identifier: Apache-2.0 diff --git a/lib/earmark_parser/block/id_def.ex b/lib/earmark_parser/block/id_def.ex deleted file mode 100644 index 9e860cb..0000000 --- a/lib/earmark_parser/block/id_def.ex +++ /dev/null @@ -1,6 +0,0 @@ -defmodule EarmarkParser.Block.IdDef do - @moduledoc false - defstruct lnb: 0, annotation: nil, attrs: nil, id: nil, url: nil, title: nil -end - -# SPDX-License-Identifier: Apache-2.0 diff --git a/lib/earmark_parser/block/list.ex b/lib/earmark_parser/block/list.ex deleted file mode 100644 index e7e4f9a..0000000 --- a/lib/earmark_parser/block/list.ex +++ /dev/null @@ -1,18 +0,0 @@ -defmodule EarmarkParser.Block.List do - @moduledoc false - - defstruct annotation: nil, - attrs: nil, - blocks: [], - lines: [], - bullet: "-", - indent: 0, - lnb: 0, - loose?: false, - pending: {nil, 0}, - spaced?: false, - start: "", - type: :ul -end - -# SPDX-License-Identifier: Apache-2.0 diff --git a/lib/earmark_parser/block/list_item.ex b/lib/earmark_parser/block/list_item.ex deleted file mode 100644 index de9d682..0000000 --- a/lib/earmark_parser/block/list_item.ex +++ /dev/null @@ -1,13 +0,0 @@ -defmodule EarmarkParser.Block.ListItem do - @moduledoc false - defstruct attrs: nil, - blocks: [], - bullet: "", - lnb: 0, - annotation: nil, - loose?: false, - spaced?: true, - type: :ul -end - -# SPDX-License-Identifier: Apache-2.0 diff --git a/lib/earmark_parser/block/para.ex b/lib/earmark_parser/block/para.ex deleted file mode 100644 index 4e35d7d..0000000 --- a/lib/earmark_parser/block/para.ex +++ /dev/null @@ -1,6 +0,0 @@ -defmodule EarmarkParser.Block.Para do - @moduledoc false - defstruct lnb: 0, annotation: nil, attrs: nil, lines: [] -end - -# SPDX-License-Identifier: Apache-2.0 diff --git a/lib/earmark_parser/block/ruler.ex b/lib/earmark_parser/block/ruler.ex deleted file mode 100644 index 17c8a30..0000000 --- a/lib/earmark_parser/block/ruler.ex +++ /dev/null @@ -1,6 +0,0 @@ -defmodule EarmarkParser.Block.Ruler do - @moduledoc false - defstruct lnb: 0, annotation: nil, attrs: nil, type: nil -end - -# SPDX-License-Identifier: Apache-2.0 diff --git a/lib/earmark_parser/block/table.ex b/lib/earmark_parser/block/table.ex deleted file mode 100644 index fb9b90b..0000000 --- a/lib/earmark_parser/block/table.ex +++ /dev/null @@ -1,10 +0,0 @@ -defmodule EarmarkParser.Block.Table do - @moduledoc false - defstruct lnb: 0, annotation: nil, attrs: nil, rows: [], header: nil, alignments: [] - - def new_for_columns(n) do - %__MODULE__{alignments: Elixir.List.duplicate(:left, n)} - end -end - -# SPDX-License-Identifier: Apache-2.0 diff --git a/lib/earmark_parser/block/text.ex b/lib/earmark_parser/block/text.ex deleted file mode 100644 index a0a2d8d..0000000 --- a/lib/earmark_parser/block/text.ex +++ /dev/null @@ -1,6 +0,0 @@ -defmodule EarmarkParser.Block.Text do - @moduledoc false - defstruct attrs: nil, lnb: 0, annotation: nil, line: "" -end - -# SPDX-License-Identifier: Apache-2.0 diff --git a/lib/earmark_parser/line.ex b/lib/earmark_parser/line.ex index df4d142..cecc888 100644 --- a/lib/earmark_parser/line.ex +++ b/lib/earmark_parser/line.ex @@ -1,6 +1,25 @@ defmodule EarmarkParser.Line do @moduledoc false + @type t :: + %__MODULE__.Blank{} + | %__MODULE__.Ruler{} + | %__MODULE__.Heading{} + | %__MODULE__.BlockQuote{} + | %__MODULE__.Indent{} + | %__MODULE__.Fence{} + | %__MODULE__.HtmlOpenTag{} + | %__MODULE__.HtmlCloseTag{} + | %__MODULE__.HtmlComment{} + | %__MODULE__.HtmlOneLine{} + | %__MODULE__.IdDef{} + | %__MODULE__.FnDef{} + | %__MODULE__.ListItem{} + | %__MODULE__.SetextUnderlineHeading{} + | %__MODULE__.TableLine{} + | %__MODULE__.Ial{} + | %__MODULE__.Text{} + defmodule Blank do @moduledoc false defstruct(annotation: nil, lnb: 0, line: "", indent: -1, content: "")