Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor README.md toc links #293

Merged
merged 2 commits into from
Sep 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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