2020-05-09 17:01:49 +02:00
|
|
|
# TODO: concreate typing
|
2015-01-04 14:18:17 +01:00
|
|
|
|
2017-12-31 13:02:28 +01:00
|
|
|
abstract type WeaveChunk end
|
2020-05-24 11:17:58 +02:00
|
|
|
abstract type Inline end
|
2020-05-31 09:49:20 +02:00
|
|
|
abstract type WeaveFormat end
|
2016-12-26 19:06:03 +01:00
|
|
|
|
2017-12-31 13:02:28 +01:00
|
|
|
mutable struct WeaveDoc
|
2016-04-11 17:40:18 +02:00
|
|
|
source::AbstractString
|
|
|
|
basename::AbstractString
|
|
|
|
path::AbstractString
|
2020-05-09 17:01:49 +02:00
|
|
|
chunks::Vector{WeaveChunk}
|
2016-04-11 17:40:18 +02:00
|
|
|
cwd::AbstractString
|
2020-05-08 16:39:17 +02:00
|
|
|
format::Any
|
2020-05-15 18:49:30 +02:00
|
|
|
doctype::String
|
2016-11-02 22:45:32 +01:00
|
|
|
header_script::String
|
2016-12-14 23:07:56 +01:00
|
|
|
header::Dict
|
2019-03-05 18:36:27 +01:00
|
|
|
chunk_defaults::Dict{Symbol,Any}
|
2015-01-06 23:01:25 +01:00
|
|
|
end
|
|
|
|
|
2017-12-31 13:02:28 +01:00
|
|
|
struct ChunkOutput
|
2020-06-13 14:59:09 +02:00
|
|
|
code::String
|
|
|
|
stdout::String
|
|
|
|
rich_output::String
|
|
|
|
figures::Vector{String}
|
2015-01-11 22:38:58 +01:00
|
|
|
end
|
2015-01-06 23:01:25 +01:00
|
|
|
|
2017-12-31 13:02:28 +01:00
|
|
|
mutable struct CodeChunk <: WeaveChunk
|
2020-05-24 17:29:02 +02:00
|
|
|
content::String
|
2015-01-04 14:18:17 +01:00
|
|
|
number::Int
|
|
|
|
start_line::Int
|
2020-05-24 17:29:02 +02:00
|
|
|
optionstring::String
|
2020-05-08 16:39:17 +02:00
|
|
|
options::Dict{Symbol,Any}
|
2016-04-11 17:40:18 +02:00
|
|
|
output::AbstractString
|
2016-04-27 16:14:42 +02:00
|
|
|
rich_output::AbstractString
|
2020-05-24 17:29:02 +02:00
|
|
|
figures::Vector{String}
|
2020-05-09 17:01:49 +02:00
|
|
|
result::Vector{ChunkOutput}
|
2020-05-24 17:29:02 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function CodeChunk(content, number, start_line, optionstring, options)
|
|
|
|
return CodeChunk(
|
|
|
|
string(rstrip(content), '\n'), # normalize end of chunk)
|
|
|
|
number,
|
|
|
|
start_line,
|
|
|
|
optionstring,
|
|
|
|
options,
|
|
|
|
"",
|
|
|
|
"",
|
2020-05-24 17:49:12 +02:00
|
|
|
AbstractString[],
|
2020-05-24 17:29:02 +02:00
|
|
|
ChunkOutput[]
|
|
|
|
)
|
2015-01-04 14:18:17 +01:00
|
|
|
end
|
|
|
|
|
2017-12-31 13:02:28 +01:00
|
|
|
mutable struct DocChunk <: WeaveChunk
|
2020-05-09 12:25:47 +02:00
|
|
|
content::Vector{Inline}
|
2015-01-04 14:18:17 +01:00
|
|
|
number::Int
|
|
|
|
start_line::Int
|
2016-12-26 19:06:03 +01:00
|
|
|
end
|
|
|
|
|
2020-05-24 11:17:58 +02:00
|
|
|
struct InlineText <: Inline
|
|
|
|
content::String
|
2016-12-27 20:43:13 +01:00
|
|
|
number::Int
|
2015-01-04 14:18:17 +01:00
|
|
|
end
|
2015-01-11 22:38:58 +01:00
|
|
|
|
2017-12-31 13:02:28 +01:00
|
|
|
mutable struct InlineCode <: Inline
|
2020-05-24 11:17:58 +02:00
|
|
|
content::String
|
2016-12-27 20:43:13 +01:00
|
|
|
number::Int
|
2019-03-06 21:27:47 +01:00
|
|
|
ctype::Symbol
|
2020-05-24 11:17:58 +02:00
|
|
|
output::String
|
|
|
|
rich_output::String
|
|
|
|
figures::Vector{String}
|
2016-12-26 19:06:03 +01:00
|
|
|
end
|
2020-05-24 11:17:58 +02:00
|
|
|
InlineCode(content, number, ctype) = InlineCode(content, number, ctype, "", "", String[])
|