Skip to content

Commit

Permalink
Merge pull request #293 from raygesualdo/refactor-readme-toc-links
Browse files Browse the repository at this point in the history
Refactor README.md toc links
  • Loading branch information
RobertDober committed Sep 25, 2019
2 parents 8c63366 + c25ff31 commit aa1697a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
* [Dependency](#dependency)
* [Usage](#usage)
* [Details](#details)
* [`Earmark.as_html/2`](#`earmark.as_html/2`)
* [`Earmark.as_ast/2`](#`earmark.as_ast/2`)
* [`Earmark.Transform.transform/2`](#`earmark.transform.transform/2`)
* [`Earmark.as_html/2`](#earmarkas_html2)
* [`Earmark.as_ast/2`](#earmarkas_ast2)
* [`Earmark.Transform.transform/2`](#earmarktransformtransform2)
* [Contributing](#contributing)
* [Author](#author)
<!-- END generated TOC -->
Expand Down Expand Up @@ -447,7 +447,8 @@ Therefore `as_ast` is of the following type
## `Earmark.Transform.transform/2`

<!-- BEGIN inserted functiondoc Earmark.Transform.transform/2 -->
**EXPERIMENTAL**, but well tested, just expect API changes in the 1.4 branch
**EXPERIMENTAL**
But well tested, just expect API changes in the 1.4 branch
Takes an ast, and optional options (I love this pun), which can be
a map or keyword list of which the following keys will be used:

Expand Down
6 changes: 3 additions & 3 deletions tasks/readme.exs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ defmodule Mix.Tasks.Readme do

defp add_doc(line) do
[ "<!-- BEGIN inserted #{line} -->",
line
line
|> String.split()
|> doc_for(),
"<!-- END inserted #{line} -->" ]
Expand Down Expand Up @@ -102,12 +102,12 @@ defmodule Mix.Tasks.Readme do
end
end

defp make_h2_anchor(title), do: title |> String.downcase() |> String.replace(~r{\s+}, "-")
defp make_h2_anchor(title), do: title |> String.downcase() |> String.replace(~r{\s+}, "-") |> String.replace(~r{[^\w-]}, "")

defp make_toc_entry(title), do: "* [#{title}](##{make_h2_anchor(title)})"

defp make_toc_string(tocs),
do:
do:
[ "<!-- BEGIN generated TOC -->",
tocs |> Enum.join("\n"),
"<!-- END generated TOC -->"
Expand Down

0 comments on commit aa1697a

Please sign in to comment.