Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read-str parses contents of source blocks #70

Open
lilactown opened this issue Sep 5, 2023 · 1 comment
Open

read-str parses contents of source blocks #70

lilactown opened this issue Sep 5, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@lilactown
Copy link
Contributor

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

@lilactown lilactown added the bug Something isn't working label Sep 5, 2023
@schoettl
Copy link
Collaborator

schoettl commented Sep 6, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants