changed CHANGELOG.md
 
@@ -1,5 +1,11 @@
1
1
# Changelog
2
2
3
+ ## v1.1.1
4
+
5
+ ### Fixes
6
+
7
+ - Fix compile error when Earmark is not installed
8
+
3
9
## v1.1.0
4
10
5
11
### Enhancements
changed hex_metadata.config
 
@@ -1,6 +1,6 @@
1
1
{<<"links">>,[{<<"GitHub">>,<<"https://github.com/cozy-elixir/fs_build">>}]}.
2
2
{<<"name">>,<<"fs_build">>}.
3
- {<<"version">>,<<"1.1.0">>}.
3
+ {<<"version">>,<<"1.1.1">>}.
4
4
{<<"description">>,
5
5
<<"A filesystem-based build engine which provides a flexible mechanism for parsing and processing files.">>}.
6
6
{<<"elixir">>,<<"~> 1.12">>}.
changed lib/fs_build/adapters/markdown_publisher.ex
 
@@ -1,127 +1,113 @@
1
- defmodule FsBuild.Adapters.MarkdownPublisher do
2
- @moduledoc """
3
- An adapter for building a Markdown publishing system.
1
+ if Code.ensure_loaded?(Earmark) do
2
+ defmodule FsBuild.Adapters.MarkdownPublisher do
3
+ @moduledoc """
4
+ An adapter for building a Markdown publishing system.
4
5
5
- ## Required dependencies
6
+ ## Required dependencies
6
7
7
- * `:earmark`
8
- * `:makeup`
8
+ * `:earmark`
9
+ * `:makeup`
9
10
10
- ## Options
11
+ ## Options
11
12
12
- * `:earmark_options` - an `%Earmark.Options{}` struct
13
- * `:highlighters` - which code highlighters to use. `FsBuild`
14
- uses `Makeup` for syntax highlighting and you will need to add its
15
- `.css` classes. You can generate the CSS classes by calling
16
- `Makeup.stylesheet(:vim_style, "makeup")` inside iex -S mix.
17
- You can replace `:vim_style` by any style of your choice
18
- [defined here](https://elixir-makeup.github.io/makeup_demo/elixir.html).
13
+ * `:earmark_options` - an `%Earmark.Options{}` struct
14
+ * `:highlighters` - which code highlighters to use. `FsBuild`
15
+ uses `Makeup` for syntax highlighting and you will need to add its
16
+ `.css` classes. You can generate the CSS classes by calling
17
+ `Makeup.stylesheet(:vim_style, "makeup")` inside iex -S mix.
18
+ You can replace `:vim_style` by any style of your choice
19
+ [defined here](https://elixir-makeup.github.io/makeup_demo/elixir.html).
19
20
20
- """
21
+ """
21
22
22
- require Logger
23
+ require Logger
23
24
24
- @behaviour FsBuild.Adapter
25
+ @behaviour FsBuild.Adapter
25
26
26
- @impl true
27
- def init(opts) do
28
- check_dep_earmark!()
29
- check_dep_makeup!()
27
+ @impl true
28
+ def init(opts) do
29
+ check_dep_makeup!()
30
30
31
- for highlighter <- Keyword.get(opts, :highlighters, []) do
32
- Application.ensure_all_started(highlighter)
31
+ for highlighter <- Keyword.get(opts, :highlighters, []) do
32
+ Application.ensure_all_started(highlighter)
33
+ end
34
+
35
+ :ok
33
36
end
34
37
35
- :ok
36
- end
38
+ defp check_dep_makeup!() do
39
+ unless Code.ensure_loaded?(Makeup) do
40
+ Logger.error("""
41
+ Could not find required dependency.
37
42
38
- defp check_dep_earmark!() do
39
- unless Code.ensure_loaded?(Earmark) do
40
- Logger.error("""
41
- Could not find required dependency.
43
+ Please add :makeup to your dependencies:
42
44
43
- Please add :earmark to your dependencies:
45
+ {:makeup, "~> 1.0"}
44
46
45
- {:earmark, "~> 1.4"}
47
+ """)
46
48
47
- """)
48
-
49
- raise "missing dependency - :earmark"
49
+ raise "missing dependency - :makeup"
50
+ end
50
51
end
51
- end
52
52
53
- defp check_dep_makeup!() do
54
- unless Code.ensure_loaded?(Makeup) do
55
- Logger.error("""
56
- Could not find required dependency.
53
+ @impl true
54
+ def transform(path, content, opts) do
55
+ {body, attrs} = parse_content!(path, content)
56
+ html_body = as_html(body, opts)
57
57
58
- Please add :makeup to your dependencies:
59
-
60
- {:makeup, "~> 1.0"}
61
-
62
- """)
63
-
64
- raise "missing dependency - :makeup"
58
+ {html_body, attrs}
65
59
end
66
- end
67
60
68
- @impl true
69
- def transform(path, content, opts) do
70
- {body, attrs} = parse_content!(path, content)
71
- html_body = as_html(body, opts)
61
+ defp parse_content!(path, content) do
62
+ case parse_content(path, content) do
63
+ {:ok, body, attrs} ->
64
+ {body, attrs}
72
65
73
- {html_body, attrs}
74
- end
66
+ {:error, message} ->
67
+ raise """
68
+ #{message}
75
69
76
- defp parse_content!(path, content) do
77
- case parse_content(path, content) do
78
- {:ok, body, attrs} ->
79
- {body, attrs}
70
+ Each entry must have a map with attributes, followed by --- and a body. For example:
80
71
81
- {:error, message} ->
82
- raise """
83
- #{message}
72
+ %{
73
+ title: "Hello World"
74
+ }
75
+ ---
76
+ Hello world!
84
77
85
- Each entry must have a map with attributes, followed by --- and a body. For example:
86
-
87
- %{
88
- title: "Hello World"
89
- }
90
- ---
91
- Hello world!
92
-
93
- """
78
+ """
79
+ end
94
80
end
95
- end
96
81
97
- defp parse_content(path, content) do
98
- case :binary.split(content, ["\n---\n", "\r\n---\r\n"]) do
99
- [_] ->
100
- {:error, "could not find separator --- in #{inspect(path)}"}
82
+ defp parse_content(path, content) do
83
+ case :binary.split(content, ["\n---\n", "\r\n---\r\n"]) do
84
+ [_] ->
85
+ {:error, "could not find separator --- in #{inspect(path)}"}
101
86
102
- [code, body] ->
103
- case Code.eval_string(code, []) do
104
- {%{} = attrs, _} ->
105
- {:ok, body, attrs}
87
+ [code, body] ->
88
+ case Code.eval_string(code, []) do
89
+ {%{} = attrs, _} ->
90
+ {:ok, body, attrs}
106
91
107
- {other, _} ->
108
- {:error,
109
- "expected attributes for #{inspect(path)} to return a map, got: #{inspect(other)}"}
110
- end
92
+ {other, _} ->
93
+ {:error,
94
+ "expected attributes for #{inspect(path)} to return a map, got: #{inspect(other)}"}
95
+ end
96
+ end
111
97
end
112
- end
113
98
114
- defp as_html(body, opts) do
115
- earmark_opts = Keyword.get(opts, :earmark_options, %Earmark.Options{})
116
- highlighters = Keyword.get(opts, :highlighters, [])
117
- body |> Earmark.as_html!(earmark_opts) |> highlight(highlighters)
118
- end
99
+ defp as_html(body, opts) do
100
+ earmark_opts = Keyword.get(opts, :earmark_options, Earmark.Options.make_options!())
101
+ highlighters = Keyword.get(opts, :highlighters, [])
102
+ body |> Earmark.as_html!(earmark_opts) |> highlight(highlighters)
103
+ end
119
104
120
- defp highlight(html, []) do
121
- html
122
- end
105
+ defp highlight(html, []) do
106
+ html
107
+ end
123
108
124
- defp highlight(html, _) do
125
- __MODULE__.Highlighter.highlight(html)
109
+ defp highlight(html, _) do
110
+ __MODULE__.Highlighter.highlight(html)
111
+ end
126
112
end
127
113
end
changed mix.exs
 
@@ -1,7 +1,7 @@
1
1
defmodule FsBuild.MixProject do
2
2
use Mix.Project
3
3
4
- @version "1.1.0"
4
+ @version "1.1.1"
5
5
@name "FsBuild"
6
6
@description "A filesystem-based build engine which provides a flexible mechanism for parsing and processing files."
7
7
@source_url "https://github.com/cozy-elixir/fs_build"