Skip to content

Commit

Permalink
Fixes: #203
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertDober committed Nov 14, 2018
1 parent 535a554 commit f387477
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 63 deletions.
14 changes: 12 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@

# 1.2.7
# 1.3

* Fix for issues
- [#208 Inline code made Commonmark compatible]( https:/pragdave/earmark/issues/208 )
- [#203 escript does not report filename in error messages]( https:/pragdave/earmark/issues/203 )
- [#90 Parsing "...' or '..." as link titles removed]( https:/pragdave/earmark/issues/90 )

## Dev dependencies updated

* credo -> 0.10

# 1.2.7 Not released Milestone merged into 1.3

Special KUDOS for [pareehonos](https:/pareeohnos) for a huge PR concerning the major Feature Request [#145](https:/pragdave/earmark/issues/145)

Expand Down
12 changes: 11 additions & 1 deletion lib/earmark/cli.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ defmodule Earmark.CLI do
parse = OptionParser.parse(argv, switches: switches, aliases: aliases)
case parse do
{ [ {switch, true } ], _, _ } -> switch
{ options, [ filename ], _ } -> {open_file(filename), options}
{ options, [ filename ], _ } -> {open_file(filename), filename, options}
{ options, [ ], _ } -> {:stdio, options}
_ -> :help
end
Expand All @@ -59,7 +59,17 @@ defmodule Earmark.CLI do
Earmark.as_html!(content, options)
|> IO.puts
end
defp process({io_device, filename, options}) do
options = struct(Earmark.Options,
booleanify(options) |> numberize_options([:timeout]) |> add_filename(filename))

content = IO.stream(io_device, :line) |> Enum.to_list
Earmark.as_html!(content, options)
|> IO.puts
end

defp add_filename(options, filename),
do: [{:file, filename} | options]


defp booleanify( keywords ), do: Enum.map(keywords, &booleanify_option/1)
Expand Down
69 changes: 36 additions & 33 deletions lib/earmark/options.ex
Original file line number Diff line number Diff line change
@@ -1,43 +1,47 @@
defmodule Earmark.Options do

@type t :: %__MODULE__{}

# What we use to render
defstruct renderer: Earmark.HtmlRenderer,
# Inline style options
gfm: true, breaks: false, pedantic: false,
smartypants: true, sanitize: false,
footnotes: false, footnote_offset: 1,

# additional prefies for class of code blocks
code_class_prefix: nil,

# Add possibility to specify a timeout for Task.await
timeout: nil,

# Internal—only override if you're brave
do_smartypants: nil, do_sanitize: nil,

# Very internal—the callback used to perform
# parallel rendering. Set to &Enum.map/2
# to keep processing in process and
# serial
mapper: &Earmark.pmap/2,
mapper_with_timeout: &Earmark.pmap/3,

render_code: &Earmark.HtmlRenderer.render_code/1,

# Filename and initial line number of the markdown block passed in
# for meaningfull error messages
file: "<no file>",
line: 1,
messages: [], # [{:error|:warning, lnb, text},...]
plugins: %{}
defstruct renderer: Earmark.HtmlRenderer,
# Inline style options
gfm: true,
breaks: false,
pedantic: false,
smartypants: true,
sanitize: false,
footnotes: false,
footnote_offset: 1,

# additional prefies for class of code blocks
code_class_prefix: nil,

# Add possibility to specify a timeout for Task.await
timeout: nil,

# Internal—only override if you're brave
do_smartypants: nil,
do_sanitize: nil,

# Very internal—the callback used to perform
# parallel rendering. Set to &Enum.map/2
# to keep processing in process and
# serial
mapper: &Earmark.pmap/2,
mapper_with_timeout: &Earmark.pmap/3,
render_code: &Earmark.HtmlRenderer.render_code/1,

# Filename and initial line number of the markdown block passed in
# for meaningfull error messages
file: "<no file>",
line: 1,
# [{:error|:warning, lnb, text},...]
messages: [],
plugins: %{}

# Only here we are aware of which mapper function to use!
def get_mapper(options) do
if options.timeout do
&(options.mapper_with_timeout.(&1, &2, options.timeout))
&options.mapper_with_timeout.(&1, &2, options.timeout)
else
options.mapper
end
Expand All @@ -46,7 +50,6 @@ defmodule Earmark.Options do
def plugin_for_prefix(options, plugin_name) do
Map.get(options.plugins, plugin_name, false)
end

end

# SPDX-License-Identifier: Apache-2.0
57 changes: 31 additions & 26 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
defmodule Earmark.Mixfile do
use Mix.Project

@version "1.2.7"
@version "1.3.0"

@deps [
{ :credo, "~> 0.8", only: [ :dev, :test ] },
{ :dialyxir, "~> 0.5", only: [ :dev, :test ] },
@deps [
{:credo, "~> 0.10", only: [:dev, :test]},
{:dialyxir, "~> 0.5", only: [:dev, :test]}
]

@description """
Earmark is a pure-Elixir Markdown converter.
Earmark is a pure-Elixir Markdown converter.
It is intended to be used as a library (just call Earmark.as_html),
but can also be used as a command-line tool (run mix escript.build
first).
It is intended to be used as a library (just call Earmark.as_html),
but can also be used as a command-line tool (run mix escript.build
first).
Output generation is pluggable.
"""
Output generation is pluggable.
"""

############################################################

def project do
[
app: :earmark,
version: @version,
elixir: "~> 1.4",
elixirc_paths: elixirc_paths(Mix.env),
escript: escript_config(),
deps: @deps,
description: @description,
package: package(),
aliases: [docs: &docs/1, readme: &readme/1]
app: :earmark,
version: @version,
elixir: "~> 1.4",
elixirc_paths: elixirc_paths(Mix.env()),
escript: escript_config(),
deps: @deps,
description: @description,
package: package(),
aliases: [docs: &docs/1, readme: &readme/1]
]
end

Expand All @@ -43,7 +43,12 @@ defmodule Earmark.Mixfile do
defp package do
[
files: [
"lib", "src/*.xrl", "src/*.yrl", "tasks", "mix.exs", "README.md"
"lib",
"src/*.xrl",
"src/*.yrl",
"tasks",
"mix.exs",
"README.md"
],
maintainers: [
"Robert Dober <[email protected]>",
Expand All @@ -53,25 +58,25 @@ defmodule Earmark.Mixfile do
"Apache 2 (see the file LICENSE for details)"
],
links: %{
"GitHub" => "https:/pragdave/earmark",
"GitHub" => "https:/pragdave/earmark"
}
]
end

defp escript_config do
[ main_module: Earmark.CLI ]
[main_module: Earmark.CLI]
end

defp elixirc_paths(:test), do: [ "lib", "test/support" ]
defp elixirc_paths(_), do: [ "lib" ]
defp elixirc_paths(:test), do: ["lib", "test/support"]
defp elixirc_paths(_), do: ["lib"]

defp docs(args) do
Code.load_file "tasks/docs.exs"
Code.load_file("tasks/docs.exs")
Mix.Tasks.Docs.run(args)
end

defp readme(args) do
Code.load_file "tasks/readme.exs"
Code.load_file("tasks/readme.exs")
Mix.Tasks.Readme.run(args)
end
end
Expand Down
3 changes: 2 additions & 1 deletion mix.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
%{
"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], []},
"credo": {:hex, :credo, "0.8.10", "261862bb7363247762e1063713bb85df2bbd84af8d8610d1272cd9c1943bba63", [:mix], [{:bunt, "~> 0.2.0", [repo: "hexpm", hex: :bunt, optional: false]}], "hexpm"},
"credo": {:hex, :credo, "0.10.2", "03ad3a1eff79a16664ed42fc2975b5e5d0ce243d69318060c626c34720a49512", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"},
"dialyxir": {:hex, :dialyxir, "0.5.0", "5bc543f9c28ecd51b99cc1a685a3c2a1a93216990347f259406a910cf048d1d7", [:mix], [], "hexpm"},
"floki": {:hex, :floki, "0.14.0", "91a6be57349e10a63cf52d7890479a19012cef9185fa93c305d4fe42e6a50dee", [:mix], [{:mochiweb, "~> 2.15", [hex: :mochiweb, optional: false]}]},
"jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"},
"meck": {:hex, :meck, "0.8.4", "59ca1cd971372aa223138efcf9b29475bde299e1953046a0c727184790ab1520", [:make, :rebar], []},
"mochiweb": {:hex, :mochiweb, "2.15.0", "e1daac474df07651e5d17cc1e642c4069c7850dc4508d3db7263a0651330aacc", [:rebar3], []},
"mock": {:hex, :mock, "0.2.1", "bfdba786903e77f9c18772dee472d020ceb8ef000783e737725a4c8f54ad28ec", [:mix], [{:meck, "~> 0.8.2", [hex: :meck, optional: false]}]},
Expand Down

0 comments on commit f387477

Please sign in to comment.