Skip to content

read-str parses contents of source blocks #70

@lilactown

Description

@lilactown

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions