Repository: tlienart/Franklin.jl
Pull request #386 (2020-02-27 11:38:20)

Coverage

codecov[bot]: # [Codecov](https://codecov.io/gh/tlienart/Franklin.jl/pull/386?src=pr&el=h1) Report
> Merging [#386](https://codecov.io/gh/tlienart/Franklin.jl/pull/386?src=pr&el=desc) into [master](https://codecov.io/gh/tlienart/Franklin.jl/commit/9d984e823649cdf793a39031ce5af44ac78e02a2?src=pr&el=desc) will **increase** coverage by `0.59%`.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/tlienart/Franklin.jl/pull/386/graphs/tree.svg?width=650&token=6aP21CmJcY&height=150&src=pr)](https://codecov.io/gh/tlienart/Franklin.jl/pull/386?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master     #386      +/-   ##
==========================================
+ Coverage   87.64%   88.23%   +0.59%     
==========================================
  Files          39       39              
  Lines        2015     2023       +8     
==========================================
+ Hits         1766     1785      +19     
+ Misses        249      238      -11
```


| [Impacted Files](https://codecov.io/gh/tlienart/Franklin.jl/pull/386?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/parser/markdown/validate.jl](https://codecov.io/gh/tlienart/Franklin.jl/pull/386/diff?src=pr&el=tree#diff-c3JjL3BhcnNlci9tYXJrZG93bi92YWxpZGF0ZS5qbA==) | `100% <ø> (+1.66%)` | :arrow_up: |
| [src/parser/markdown/indent.jl](https://codecov.io/gh/tlienart/Franklin.jl/pull/386/diff?src=pr&el=tree#diff-c3JjL3BhcnNlci9tYXJrZG93bi9pbmRlbnQuamw=) | `100% <0%> (+1.13%)` | :arrow_up: |
| [src/parser/ocblocks.jl](https://codecov.io/gh/tlienart/Franklin.jl/pull/386/diff?src=pr&el=tree#diff-c3JjL3BhcnNlci9vY2Jsb2Nrcy5qbA==) | `100% <0%> (+1.72%)` | :arrow_up: |
| [src/utils/misc.jl](https://codecov.io/gh/tlienart/Franklin.jl/pull/386/diff?src=pr&el=tree#diff-c3JjL3V0aWxzL21pc2Muamw=) | `100% <0%> (+7.69%)` | :arrow_up: |
| [src/utils/errors.jl](https://codecov.io/gh/tlienart/Franklin.jl/pull/386/diff?src=pr&el=tree#diff-c3JjL3V0aWxzL2Vycm9ycy5qbA==) | `100% <0%> (+25%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/tlienart/Franklin.jl/pull/386?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/tlienart/Franklin.jl/pull/386?src=pr&el=footer). Last update [9d984e8...1ac0b6d](https://codecov.io/gh/tlienart/Franklin.jl/pull/386?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/src/parser/latex/blocks.jl b/src/parser/latex/blocks.jl
index d8590c49..22b416ed 100644
--- a/src/parser/latex/blocks.jl
+++ b/src/parser/latex/blocks.jl
@@ -44,10 +44,19 @@ function find_lxdefs(tokens::Vector{Token}, blocks::Vector{OCBlock})
         # check if it looks like [.d.] where d is a number and . are
         # optional spaces (specification of the number of arguments)
         if !isempty(rge)
-            lxnarg = match(LX_NARG_PAT, subs(str(braces[k]), rge))
-            if isnothing(lxnarg)
-                throw(LxDefError("Ill formed newcommand (where I expected " *
-                                 "the specification of the number of " * "arguments)."))
+            inter  = subs(str(braces[k]), rge)
+            lxnarg = match(LX_NARG_PAT, inter)
+            # see test/utils/errors for examples
+            if isnothing(lxnarg.captures[1])
+                sinner = strip(inter)
+                if !isempty(sinner)
+                    # corner case: {...}[ ]{...} (empty)
+                    if isnothing(match(r"\[\s*\]", sinner))
+                        throw(LxDefError(
+                            "Ill formed newcommand (where I expected the " *
+                            "specification of the number of arguments)."))
+                    end
+                end
             end
             matched = lxnarg.captures[2]
             lxnarg  = isnothing(matched) ? 0 : parse(Int, matched)
diff --git a/src/parser/markdown/validate.jl b/src/parser/markdown/validate.jl
index 20a2c7ff..45de70b6 100644
--- a/src/parser/markdown/validate.jl
+++ b/src/parser/markdown/validate.jl
@@ -60,7 +60,6 @@ function validate_headers!(tokens::Vector{Token})::Nothing
     return
 end
 
-postprocess_link(s::String) = replace(r"")
 
 """
 $(SIGNATURES)


Test patch:
diff --git a/test/coverage/paths.jl b/test/coverage/paths.jl
new file mode 100644
index 00000000..d1f7db43
--- /dev/null
+++ b/test/coverage/paths.jl
@@ -0,0 +1,21 @@
+@testset "filecmp" begin
+    gotd()
+
+    p1 = joinpath(td, "hello.md")
+    p2 = joinpath(td, "bye.md")
+    p3 = joinpath(td, "cp1.md")
+
+    write(p1, "foo")
+    write(p2, "foo")
+
+    cp(p1, p3)
+
+    @test F.filecmp(p1, p1)
+    @test F.filecmp(p1, p2)
+    @test F.filecmp(p1, p3)
+
+    write(p2, "baz")
+    @test !F.filecmp(p1, p2)
+
+    @test !F.filecmp(p1, "foo/bar")
+end
diff --git a/test/parser/2-blocks.jl b/test/parser/2-blocks.jl
index e2372804..714907ae 100644
--- a/test/parser/2-blocks.jl
+++ b/test/parser/2-blocks.jl
@@ -122,6 +122,11 @@ end
     @test b[1].name == :DIV
 end
 
+@testset "More ind" begin
+    b = "A\n\n\tB1\n\tB2\n\n\tB3\nC" |> blk3
+    @test isblk(b[1], :CODE_BLOCK_IND, "\n\tB1\n\tB2\n\n\tB3\n")
+end
+
 @testset "P:2:blk-{}" begin
     b = "{ABC}" |> blk3
     @test F.content(b[1]) == "ABC"
diff --git a/test/runtests.jl b/test/runtests.jl
index ca9b513d..6c045a65 100644
--- a/test/runtests.jl
+++ b/test/runtests.jl
@@ -104,6 +104,7 @@ cd(joinpath(dirname(dirname(pathof(Franklin)))))
 
 println("COVERAGE")
 include("coverage/extras1.jl")
+include("coverage/paths.jl")
 
 println("😅 😅 😅 😅")
 
diff --git a/test/utils/errors.jl b/test/utils/errors.jl
index 8814d874..62c83178 100644
--- a/test/utils/errors.jl
+++ b/test/utils/errors.jl
@@ -26,3 +26,82 @@ Corn amaranth salsify bunya nuts nori azuki bean chickweed potato bell pepper ar
     # println(mess)
     @test mess == "Context:\n\t... potato bell pepper artichoke. (near line 5)\n	                        ^---\n"
 end
+
+@testset "show" begin
+    ocbe = F.OCBlockError("foo", "bar")
+    io = IOBuffer()
+    Base.showerror(io, ocbe)
+    r = String(take!(io))
+    @test r == "foo\nbar"
+
+    mcbe = F.MathBlockError("foo")
+    @test mcbe.m == "foo"
+end
+
+@testset "ocbe" begin
+    s = raw"""
+        Foo $$ end.
+        """
+    @test_throws F.OCBlockError s |> fd2html_td
+end
+
+@testset "lxbe" begin
+    s = raw"""
+        Foo
+        \newcommand{\hello}
+        End
+        """
+    @test_throws F.LxDefError s |> fd2html_td
+
+    s = raw"""
+        Foo
+        \newcommand{\hello} {goodbye}
+        \hello
+        End
+        """ |> fd2html_td
+    @test isapproxstr(s, "<p>Foo</p> goodbye End</p>")
+
+    s2 = raw"""
+        Foo
+        \newcommand{\hello}[ ]{goodbye}
+        \hello
+        End
+        """ |> fd2html_td
+    @test isapproxstr(s, s2)
+
+    # should  fail XXX
+
+    s2 = raw"""
+        Foo
+        \newcommand{\hello}b{goodbye}
+        \hello
+        End
+        """
+    @test_throws F.LxDefError s2 |> fd2html_td
+
+    s2 = raw"""
+        Foo
+        \newcommand{\hello}b{goodbye #1}
+        \hello{ccc}
+        End
+        """
+    @test_throws F.LxDefError s2 |> fd2html_td
+
+    s2 = raw"""
+        Foo
+        \newcommand{\hello}[bb]{goodbye #1}
+        \hello{ccc}
+        End
+        """
+    @test_throws F.LxDefError s2 |> fd2html_td
+
+    # tolerated
+
+    s2 = raw"""
+        Foo
+        \newcommand{\hello}  {goodbye}
+        \hello
+        End
+        """ |> fd2html_td
+    @test isapproxstr(s, s2)
+end