From a2b63b8f0724664bb101ea73c6756bc4f826523f Mon Sep 17 00:00:00 2001 From: Matti Pastell Date: Thu, 22 Dec 2016 21:40:07 +0200 Subject: [PATCH] Fix handling of \r #72 --- .gitattributes | 1 + src/readers.jl | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..fcadb2c --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text eol=lf diff --git a/src/readers.jl b/src/readers.jl index 7ef09c7..a7062ff 100644 --- a/src/readers.jl +++ b/src/readers.jl @@ -47,6 +47,7 @@ end function read_doc(source::AbstractString, format=:auto) format == :auto && (format = detect_informat(source)) document = readstring(source) + document = replace(document, "\r\n", "\n") parsed = parse_doc(document, format) header = parse_header(parsed[1]) doc = WeaveDoc(source, parsed, header) @@ -73,6 +74,7 @@ end """Parse documents with Weave.jl markup""" function parse_doc(document::AbstractString, format::MarkupInput) + document = replace(document, "\r\n", "\n") lines = split(document, "\n") codestart = format.codestart @@ -151,6 +153,7 @@ end """Parse .jl scripts with Weave.jl markup""" function parse_doc(document::AbstractString, format::ScriptInput) + document = replace(document, "\r\n", "\n") lines = split(document, "\n") doc_line = format.doc_line @@ -250,6 +253,7 @@ end """Parse IJUlia notebook""" function parse_doc(document::String, format::NotebookInput) + document = replace(document, "\r\n", "\n") nb = JSON.parse(document) parsed = Any[] options = Dict{Symbol,Any}()