Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

render a latex environment input as a paragraph #1401

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/Writers/LaTeXWriter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,15 @@ function _print_code_escapes_inline(io, s::AbstractString)
end

function latex(io::IO, md::Markdown.Paragraph)
for md in md.content
latexinline(io, md)
if occursin(r"^\h*?\\begin{\p{Xan}*?}", first(md.content))
Copy link
Member

@mortenpi mortenpi Aug 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Elements of md.content are not guaranteed to be strings, so this implementation may throw an error: https://travis-ci.org/github/JuliaDocs/Documenter.jl/jobs/717872752#L320-L329

for md in md.content
md = Base.replace(md, r"\\$" => "\\\\")
Base.print(io.io, md)
end
else
for md in md.content
latexinline(io, md)
end
end
_println(io, "\n")
end
Expand Down
23 changes: 23 additions & 0 deletions test/examples/src.latex_simple/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,26 @@ julia> 127 % Int8
```julia-repl sayhello2
julia> function foo end;
```

## Issue 1401

1. The output is a latex tabular environment

```@example
using DataFrames
DataFrame(i=1:3, y='A':'C')
```
mortenpi marked this conversation as resolved.
Show resolved Hide resolved

2. The paragraph itself is a latex tabular environment

\begin{tabular}{r|ccc}
& i & y & z\\
\hline
& Int64 & Char & Int64\\
\hline
1 & 1 & 'A' & 5 \\
2 & 2 & 'B' & 6 \\
3 & 3 & 'C' & 7 \\
4 & 4 & 'D' & 8 \\
\end{tabular}
mortenpi marked this conversation as resolved.
Show resolved Hide resolved