Skip to content

Commit

Permalink
Start preparing initial release of the library
Browse files Browse the repository at this point in the history
We updated `mix.exs` by adding some extra options, as well as moved our
initial documentation from the source code file to README (however, we
still load the module docs in the original file with a nice trick).
  • Loading branch information
cr0t committed Jul 1, 2024
1 parent 1f62267 commit 5219f60
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 42 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# CHANGELOG

## v0.1.0 (2024-07-01)

* Genesis!
42 changes: 31 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,39 @@
# Tuftemark

Markdown transformer tailored for Edward Tufte's handout format and ready to be
used with [Tufte CSS](https://github.com/edwardtufte/tufte-css).
[Online Documentation](https://hexdocs.pm/tuftemark).

## Installation
<!-- MDOC !-->

Tuftemark converts Markdown content into format that is suitable to be used with
[Tufte CSS](https://github.com/edwardtufte/tufte-css) tool.

Tufte CSS layout requires a few things to be applied to the HTML, for example:

- the whole post must be wrapped in `<article>` tag
- content must be split into `<section>`s around every H2 tag
- footnotes must be converted into margin notes (compatible with the CSS)

The `as_html!/2` method is trying to apply all the given transformation to the
originally parsed AST, so we get applicable HTML output in the end.

## Extra Modifications

Some of layout decisions cannot be made automatically, but we can use some super
powers provided us by default Earmark's Parser.

**TO BE UPDATED**
For example:

If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `tuftemark` to your list of dependencies in `mix.exs`:
- if we want a paragraph written in sans-serif, we can use Kramdown syntax for
attributes: (`{:.sans}`);
- if we want to provide a citation (as a blockquote), we can use set an attr:
`{:cite="https://example.com"}`;

See all such examples in the TuftemarkTest suite.

## Installation

The package can be installed by adding `tuftemark` to your list of dependencies
in `mix.exs`:

```elixir
def deps do
Expand All @@ -17,8 +42,3 @@ def deps do
]
end
```

Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
be found at <https://hexdocs.pm/tuftemark>.

28 changes: 3 additions & 25 deletions lib/tuftemark.ex
Original file line number Diff line number Diff line change
@@ -1,35 +1,13 @@
defmodule Tuftemark do
@moduledoc """
Tuftemark converts Markdown content into format that is suitable to be used with Tufte CSS set of styles.
Tufte CSS layout requires a few things to be applied to the HTML, for example:
- the whole post must be wrapped in `<article>` tag
- content must be split into `<section>`s around every H2 tag
- footnotes must be converted into margin notes (compatible with the CSS)
The `as_html!/2` method is trying to apply all the given transformation to the originally parsed AST,
so we get applicable HTML output in the end.
## Extra Modifications
Some of layout decisions cannot be made automatically, but we can use some super powers provided us by default
Earmark's Parser.
For example:
- if we want a paragraph written in sans-serif, we can use Kramdown syntax for attributes: (`{:.sans}`);
- if we want to provide a citation (as a blockquote), we can use set an attr: `{:cite="https://example.com"}`;
See all such examples in the TuftemarkTest suite.
"""
@external_resource "README.md"
@moduledoc "README.md" |> File.read!() |> String.split("<!-- MDOC !-->") |> Enum.fetch!(1)

alias Earmark.{Options, Parser, Transform}
alias Tuftemark.{Blockquotes, Figures, Sections, Sidenotes, Utils}

@doc """
Expects a [GitHub Flavored Markdown](https://github.github.com/gfm/) as first argument and list of options
applicable to [`Earmark.as_html!/2](https://hexdocs.pm/earmark/Earmark.html#as_html!/2) to pass into other
applicable to [`Earmark.as_html!/2`](https://hexdocs.pm/earmark/Earmark.html#as_html!/2) to pass into other
Earmark-related modules.
"""
def as_html!(markdown, opts \\ []) do
Expand Down
34 changes: 28 additions & 6 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -1,27 +1,49 @@
defmodule Tuftemark.MixProject do
use Mix.Project

@version "0.1.0"
@url "https://github.com/stackfusion/tuftemark"

def project do
[
app: :tuftemark,
version: "0.1.0",
deps: deps(),
description:
"Markdown converter tailored for Edward Tufte's handout format and ready to be used with Tufte CSS",
docs: docs(),
elixir: "~> 1.16",
start_permanent: Mix.env() == :prod,
deps: deps()
name: "Tuftemark",
package: package(),
version: @version
]
end

# Run "mix help compile.app" to learn about applications.
def application do
[
extra_applications: [:logger]
]
end

# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:earmark, "~> 1.4.46"}
{:earmark, "~> 1.4"},
{:ex_doc, "~> 0.34", only: :dev, runtime: false}
]
end

defp docs do
[
main: "Tuftemark",
source_ref: "v#{@version}",
source_url: @url
]
end

defp package do
%{
licenses: ["MIT"],
maintainers: ["Sergey Kuznetsov"],
links: %{"GitHub" => @url}
}
end
end
6 changes: 6 additions & 0 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
%{
"earmark": {:hex, :earmark, "1.4.46", "8c7287bd3137e99d26ae4643e5b7ef2129a260e3dcf41f251750cb4563c8fb81", [:mix], [], "hexpm", "798d86db3d79964e759ddc0c077d5eb254968ed426399fbf5a62de2b5ff8910a"},
"earmark_parser": {:hex, :earmark_parser, "1.4.39", "424642f8335b05bb9eb611aa1564c148a8ee35c9c8a8bba6e129d51a3e3c6769", [:mix], [], "hexpm", "06553a88d1f1846da9ef066b87b57c6f605552cfbe40d20bd8d59cc6bde41944"},
"ex_doc": {:hex, :ex_doc, "0.34.1", "9751a0419bc15bc7580c73fde506b17b07f6402a1e5243be9e0f05a68c723368", [:mix], [{:earmark_parser, "~> 1.4.39", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "d441f1a86a235f59088978eff870de2e815e290e44a8bd976fe5d64470a4c9d2"},
"makeup": {:hex, :makeup, "1.1.2", "9ba8837913bdf757787e71c1581c21f9d2455f4dd04cfca785c70bbfff1a76a3", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cce1566b81fbcbd21eca8ffe808f33b221f9eee2cbc7a1706fc3da9ff18e6cac"},
"makeup_elixir": {:hex, :makeup_elixir, "0.16.2", "627e84b8e8bf22e60a2579dad15067c755531fea049ae26ef1020cad58fe9578", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "41193978704763f6bbe6cc2758b84909e62984c7752b3784bd3c218bb341706b"},
"makeup_erlang": {:hex, :makeup_erlang, "1.0.0", "6f0eff9c9c489f26b69b61440bf1b238d95badae49adac77973cbacae87e3c2e", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "ea7a9307de9d1548d2a72d299058d1fd2339e3d398560a0e46c27dab4891e4d2"},
"nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"},
}

0 comments on commit 5219f60

Please sign in to comment.