[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: nested blocks in org
From: |
Ihor Radchenko |
Subject: |
Re: nested blocks in org |
Date: |
Sat, 17 Feb 2024 19:44:16 +0000 |
[ Adding Org list back to CC; please use Reply All or wide reply to keep
the discussion public ]
mahmood sheikh <mahmod.m2015@gmail.com> writes:
> consider the following block
> ```
> #+begin_solution
> #+begin_src sql
> SELECT
> CONCAT(c.first_name, ' ', c.family_name) AS name, c.customer_id,
> ...
> #+end_solution
> ```
> the src block isnt fontified by org because it is inside another block
... which is just a bug in the Org fontification code.
If you try M-: (org-element-at-point) <RET>, you will see that Org does
recognize the code block.
So ...
> can you point me in the right direction of getting org mode to recognize
> nested blocks,
Org already recognizes nested blocks using Org element parser. See
https://orgmode.org/worg/dev/org-element-api.html
> ... like code highlighting for src blocks that are within
> another special block?
See https://list.orgmode.org/87ee7c9quk.fsf@localhost/
This is something we are working in.
To get parser-aware fontification locally, you can use a function
MATCHER (as in font-lock-keywords docstring) and invoke
`org-element-at-point' there to check context.
> ... and getting org-element-map to iterate through both
> a parent and its child blocks all the same?
May you elaborate? `org-element-map' iterates through everything,
including nested parent and child blocks. What did you try?
> could modifying `org-block-regexp` to be a recursive regex be of help?
Sorry, but it is hard to see how this is related to `org-element-map'.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>