org-parser
org-parser copied to clipboard
read-str parses contents of source blocks
Describe the bug
The output of read-str
parses the content between #+BEGIN_SRC
and #+END_SRC
as org syntax.
It appears that you can prevent this by passing :start :block
to the parse
function (as demonstrated in the noparse-blocks
tests), but this doesn't seem to be enabled by default.
To Reproduce
Examples of this not working as expected:
(org-parser.core/read-str "#+BEGIN_src\nfoo * content\nsecond_line\n#+END_src")
;; => {:preamble
;; {:section
;; {:ast
;; [[:block-begin-line [:block-name "src"]]
;; [:text [:text-normal "foo * content"]]
;; [:text
;; [:text-normal "second"]
;; [:text-sub [:text-subsup-word "line"]]]
;; [:block-end-line [:block-name "src"]]],
;; :raw ["#+BEGIN_src" "foo * content" "second_line" "#+END_src"]}}}
(parser/parse "#+BEGIN_src\nfoo * content\nsecond_line\n#+END_src")
;; => [:S
;; [:block-begin-line [:block-name "src"]]
;; [:content-line
;; [:text [:text-normal "foo "] [:text-normal "* content"]]]
;; [:content-line
;; [:text
;; [:text-normal "second"]
;; [:text-sub [:text-subsup-word "line"]]]]
;; [:block-end-line [:block-name "src"]]]
Expected behavior
However, this gives the desired output
(parser/parse "#+BEGIN_src\nfoo * content\nsecond_line\n#+END_src"
:start :block)
;; => [:block
;; [:noparse-block
;; [:noparse-block-begin-line [:block-name-noparse "src"]]
;; [:noparse-block-content "foo * content\nsecond_line\n"]
;; [:block-end-line [:block-name "src"]]]]
Screenshots N/A
Additional context N/A
Yeah, parsing of blocks is kind of broken... if you specify exactly what you want to parse (:block
), it works but it's apparently not correctly integrated. It's about here in EBNF:
https://github.com/200ok-ch/org-parser/blob/master/resources/org.ebnf#L87