Org.jl
Org.jl copied to clipboard
LoadError on indented & improperly closed blocks
Description
When a block element is indented, immediately after an item and not closed off with its respective #+end_NAME, the parser errors. The error does not occur if the elements are not in a list like so:
julia> org"
post
#+begin_src python
good?
#+end_example
prev
"
Not-indented
Parses fine, and outputs warnings
julia> org"
- one
#+begin_src python
good?
#+end_example
- two
"
┌ Warning: The following line is being coerced to a paragraph:
│
│ #+begin_src python
│ (line 3, column 1, char 8)
│
│ This is unusual, and likely caused by a malformed Org document.
└ @ Org ~/.julia/packages/Org/MBnbC/src/parse/consumers.jl:333
┌ Warning: The following line is being coerced to a paragraph:
│
│ #+end_example
│ (line 5, column 1, char 49)
│
│ This is unusual, and likely caused by a malformed Org document.
└ @ Org ~/.julia/packages/Org/MBnbC/src/parse/consumers.jl:333
Indented in a list
julia> org"
- one
#+begin_src python
good?
#+end_example
- two
"
ERROR: LoadError: MethodError: Cannot `convert` an object of type Nothing to an object of type Org.Component
Closest candidates are:
convert(::Type{Org.Component}, ::Markdown.Header{level}) where level
@ Org ~/.julia/packages/Org/MBnbC/src/parse/markdown.jl:36
convert(::Type{Org.Component}, ::Markdown.Italic)
@ Org ~/.julia/packages/Org/MBnbC/src/parse/markdown.jl:54
convert(::Type{Org.Component}, ::Markdown.Admonition)
@ Org ~/.julia/packages/Org/MBnbC/src/parse/markdown.jl:101
...
Stacktrace:
[1] push!(a::Vector{Org.Component}, item::Nothing)
@ Base ./array.jl:1060
[2] consume(#unused#::Type{Org.Item}, text::SubString{String})
@ Org ~/.julia/packages/Org/MBnbC/src/parse/consumers.jl:218
[3] consume(#unused#::Type{Org.List}, text::SubString{String})
@ Org ~/.julia/packages/Org/MBnbC/src/parse/consumers.jl:244
[4] parseorg(content::SubString{String}, typematchers::Dict{Char, Vector{<:Type}}, typefallbacks::Vector{DataType}; debug::Bool, partial::Bool, maxobj::Int64)
@ Org ~/.julia/packages/Org/MBnbC/src/parse/parser.jl:49
[5] parseorg
@ ~/.julia/packages/Org/MBnbC/src/parse/parser.jl:22 [inlined]
[6] Org.Section(components::Vector{Union{Nothing, SubString{String}}})
@ Org ~/.julia/packages/Org/MBnbC/src/parse/interpret.jl:102
[7] consume(component::Type{Org.Section}, text::SubString{String})
@ Org ~/.julia/packages/Org/MBnbC/src/parse/consumers.jl:10
[8] parseorg(content::SubString{String}, typematchers::Dict{Char, Vector{DataType}}, typefallbacks::Vector{DataType}; debug::Bool, partial::Bool, maxobj::Int64)
@ Org ~/.julia/packages/Org/MBnbC/src/parse/parser.jl:59
[9] parseorg
@ ~/.julia/packages/Org/MBnbC/src/parse/parser.jl:22 [inlined]
[10] #parseorg#38
@ ~/.julia/packages/Org/MBnbC/src/parse/parser.jl:106 [inlined]
[11] parseorg
@ ~/.julia/packages/Org/MBnbC/src/parse/parser.jl:104 [inlined]
[12] parse(#unused#::Type{OrgDoc}, content::String)
@ Org ~/.julia/packages/Org/MBnbC/src/parse/interpret.jl:66
[13] var"@org_str"(__source__::LineNumberNode, __module__::Module, content::String, type::String)
@ Org ~/.julia/packages/Org/MBnbC/src/Org.jl:32
[14] var"@org_str"(__source__::LineNumberNode, __module__::Module, content::String)
@ Org ~/.julia/packages/Org/MBnbC/src/Org.jl:25
in expression starting at REPL[17]:1
Indented in a list, but not immediately after
This parses fine:
julia> org"
- one
#+begin_src python
good?
#+end_example
- two
"
Thanks for the report. I actually plan on rewriting the parser in the future (this was my first attempt ever writing one), and I think I'll address this then.
This will take a while to get to (about a year and a bit I'll guess), short of getting a cloning machine, full-time-work-level donations, or losing the need to sleep.