Skip to content

Commit

Permalink
Use align for ```math blocks (#143)
Browse files Browse the repository at this point in the history
* Use align for ```math blocks
* Fix deprecation from inline parsing
* Update tests
  • Loading branch information
mpastell authored Aug 23, 2018
1 parent 6d0779c commit bf57bf8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Markdown2HTML.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ end

function html(io::IO, tex::LaTeX)
withtag(io, :p, :class => "math") do
write(io, string("\\[", tex.formula, "\\]"))
write(io, string("\\[\n\\begin{align}\n", tex.formula, "\n\\end{align}\n\\]"))
end
end

Expand Down
6 changes: 5 additions & 1 deletion src/format.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ using Compat
using Dates
using Markdown
using REPL.REPLCompletions: latex_symbols
import Markdown.latex

function format(doc::WeaveDoc)
formatted = AbstractString[]
Expand Down Expand Up @@ -301,7 +302,6 @@ function indent(text, nindent)
string(repeat(" ", nindent), x), split(text, "\n")), "\n")
end


function wraplines(text, line_width=75)
result = AbstractString[]
lines = split(text, "\n")
Expand All @@ -324,3 +324,7 @@ result = ""
end
result *= text
end

function latex(io::IO, tex::Markdown.LaTeX)
write(io, string("\n\\begin{align}\n", tex.formula, "\n\\end{align}\n"))
end
1 change: 1 addition & 0 deletions src/pandoc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ function run_latex(doc::WeaveDoc, outname, latex_cmd = "xelatex")
@info("Weaved code to $outname. Running $latex_cmd")
textmp = mktempdir(".")
try
out = read(`$latex_cmd -shell-escape $xname -aux-directory $textmp -include-directory $(doc.cwd)`, String)
out = read(`$latex_cmd -shell-escape $xname -aux-directory $textmp -include-directory $(doc.cwd)`, String)
rm(xname)
rm(textmp, recursive=true)
Expand Down
2 changes: 1 addition & 1 deletion src/readers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ function parse_inline(text::AbstractString, inline_ex::Regex)
doc = InlineText(text[e:(s-1)], e, s-1, textno)
textno += 1
push!(res, doc)
e = s + endof(ic.match)
e = s + lastindex(ic.match)
push!(res, InlineCode(ic.captures[1], s, e, codeno))
codeno += 1
end
Expand Down
10 changes: 7 additions & 3 deletions test/markdown_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Some **text** with different [^note] *formatting* and \$math\$ and text.
2. List two
```julia
x = 3
x = 3
```
!!! note "Something"
Expand All @@ -49,7 +49,11 @@ ref_html = """<h1>H1</h1>
<div class=\"footnote\" id=\"footnote-note\"><p class=\"footnote-title\">note</p><p>test note</p>
</div>
<hr />
<p class=\"math\">\\[more math\\]</p>
<p class=\"math\">\\[
\\begin{align}
more math
\\end{align}
\\]</p>
<ul>
<li><p>List one</p>
</li>
Expand All @@ -62,7 +66,7 @@ ref_html = """<h1>H1</h1>
<li><p>List two</p>
</li>
</ol>
<pre><code class=\"language-julia\">x &#61; 3 </code></pre>
<pre><code class=\"language-julia\">x &#61; 3</code></pre>
<div class=\"admonition note\"><p class=\"admonition-title\">Something</p><p>Test admonition with <img src=\"link/to/image.png\" alt=\"Image\" /></p>
</div>
<blockquote>
Expand Down

0 comments on commit bf57bf8

Please sign in to comment.