improve ansi character removal

pull/314/head
Shuhei Kadowaki 2020-06-14 04:06:25 +09:00
parent f077609798
commit 5a585f845a
2 changed files with 4 additions and 3 deletions

View File

@ -260,7 +260,7 @@ using [`nbconvert`](https://nbconvert.readthedocs.io/en/latest/).
!!! warning
The code is _**not**_ executed by Weave, but by [`nbconvert`](https://nbconvert.readthedocs.io/en/latest/).
This means that the output doesn't necessarily always work properly; see [#116](https://github.com/mpastell/Weave.jl/issues/116).
This means that the output doesn't necessarily always work properly; see [#116](https://github.com/JunoLab/Weave.jl/issues/116).
!!! note
In order to _just_ convert Weave document to Jupyter Notebook,

View File

@ -239,7 +239,7 @@ function capture_output(code, mod, path, error, report)
end
end
return ChunkOutput(code, remove_ansi_code(out), report.rich_output, report.figures)
return ChunkOutput(code, remove_ansi_control_chars(out), report.rich_output, report.figures)
end
function reset_report!(report)
@ -250,7 +250,8 @@ end
unwrap_load_err(err) = return err
unwrap_load_err(err::LoadError) = return err.error
remove_ansi_code(s) = replace(s, r"\u001b\[.*?m" => "")
# https://stackoverflow.com/a/33925425/12113178
remove_ansi_control_chars(s) = replace(s, r"(\x9B|\x1B\[)[0-?]*[ -\/]*[@-~]" => "")
function eval_chunk(doc::WeaveDoc, chunk::CodeChunk, report::Report, mod::Module)
if !chunk.options[:eval]