Re: Allowed characters/formatting in Org text blocks

2022-06-26 Thread Fabio Natali
On 2022-06-26 19:39:25 +0800, Ihor Radchenko  wrote:
[...]
> So, headlines always have higher priority over other elements because
> they always serve as separators of the document or parent heading
> contents.
> 
> The high priority of headline elements has prons and cons.

Hey Ihor,

I see, it all makes sense. That was a very useful recap.

Thanks for your help with this! All the best, Fabio.



Re: Allowed characters/formatting in Org text blocks

2022-06-26 Thread Ihor Radchenko
Fabio Natali  writes:

> Incidentally and FWIW, this is a bit counter-intuitive to me. I'd have
> expected everything withing a comment or literal block to be treated as
> content until the ending statement, =#+end_comment= or =#+end_src=
> respectively. I suppose that this makes sense in the larger scheme of
> Org things though?

Each Org document consists of an optional first chapter followed by a
sequence of headlines. Each headline is a sequence of optional section
followed by sequence of child headlines. Each section is a sequence of
ordinary syntax elements. No syntax element ever intersect other
element.

So, headlines always have higher priority over other elements because
they always serve as separators of the document or parent heading
contents.

The high priority of headline elements has prons and cons.
Consider the following markdown markup:

 test 1
==

```
(message "Hello world!")

... 100 headings not shown ...

 test 2
==

(message "Hello world!")

```

Should "test 2" be considered a heading?
The answer is not so important in short documents, but long documents
with large number of headings may become very sensitive to incomplete or
broken markup like the above.
In Org, you just need to care about getting the headings right. Issues
with all other markup elements should never go beyond the containing
headline section, which is especially useful when Org document is used
as todo-list with large number of headings.

Best,
Ihor



Re: Allowed characters/formatting in Org text blocks

2022-06-26 Thread Fabio Natali
On 2022-06-26 08:29:02 +0800, Ihor Radchenko  wrote:
[...]
> You need to escape "*" and "#+" at the beginning of line inside code
> blocks using comma: ",*", ",#+".

Hi Ihor,

Thanks for getting back to me!

I see, and yes, the documentation is pretty clear in that regard, you're
right. Escaping leading =*= and =#+= is perfectly possible in my case
and this completely solves my issue.

By the way, I've just tried with comment blocks, and I see that this
works the same way there too.

Incidentally and FWIW, this is a bit counter-intuitive to me. I'd have
expected everything withing a comment or literal block to be treated as
content until the ending statement, =#+end_comment= or =#+end_src=
respectively. I suppose that this makes sense in the larger scheme of
Org things though?

Thanks again, best wishes,

Fabio.



Re: Allowed characters/formatting in Org text blocks

2022-06-25 Thread Ihor Radchenko
Fabio Natali  writes:

> Now consider a slight variation where "Hello world" is formatted as a
> Org heading. The 'org-babel-goto-named-src-block' function is no longer
> able to identify the text block. Executing the Emacs Lisp block results
> in the error message below.
>
> #+name: bar
> #+begin_src text
> * Hello world
> #+end_src
> ...
> Is this expected? Am I misunderstanding what text blocks are for and
> what characters/formatting they're allowed to use?

Headline markup has the highest priority. Your block is interpreted as


#+name: bar
#+begin_sec text

* Hello world

#+end_src

See https://orgmode.org/manual/Literal-Examples.html
You need to escape "*" and "#+" at the beginning of line inside code
blocks using comma: ",*", ",#+".
Org will do it for you automatically if you use C-c ' interface to edit
source blocks.

Best,
Ihor