emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: mahmood sheikh <mahmod.m2015@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: nested blocks in org
Date: Sat, 17 Feb 2024 19:44:16 +0000	[thread overview]
Message-ID: <87il2mc1v3.fsf@localhost> (raw)
In-Reply-To: <CAOj1L_fau2YcXrkUduEn=m8H0tUh=FPisMXAOTD0Ebn7sYHbrA@mail.gmail.com>

[ 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>


  parent reply	other threads:[~2024-02-17 17:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-15 22:51 nested blocks in org mahmood sheikh
2024-02-17 16:04 ` Ihor Radchenko
     [not found]   ` <CAOj1L_fau2YcXrkUduEn=m8H0tUh=FPisMXAOTD0Ebn7sYHbrA@mail.gmail.com>
2024-02-17 19:44     ` Ihor Radchenko [this message]
2024-03-05 14:27       ` mahmood sheikh
2024-03-06 10:34         ` Ihor Radchenko
2024-05-13 12:03           ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87il2mc1v3.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=mahmod.m2015@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).