emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: Tom Alexander <tom@fizz.buzz>
Cc: emacs-orgmode@gnu.org
Subject: Re: Subscript with parenthesis
Date: Fri, 22 Sep 2023 09:14:12 +0000	[thread overview]
Message-ID: <875y42zi1n.fsf@localhost> (raw)
In-Reply-To: <3cb9366e-7915-481d-be74-1953a8dd5847@app.fastmail.com>

"Tom Alexander" <tom@fizz.buzz> writes:

> Some additional things I'm noticing:
>
> - when using parenthesis, :use-brackets-p is nil, so they're not equivalent to curly braces.

`org-element-subscript-parser' uses `org-match-substring-regexp', which
indeed allows foo_(...). This is not documented in org-syntax.org and in
the manual (12.3 Subscripts and Superscripts).

> - it does not support objects inside the parenthesis, just plain text, which again means they're not equivalent to braces.

Not true. I tried

b^(*asd*) and bold inside superscript does get parsed.

> - it, however, seems to require that the parenthesis are balanced because this test document does NOT contain a subscript:
> ```
> foo_(b(ar)
> ```
> which is closer to the curly braces requirement since that seems to be the only part of the subscript/superscript documentation that mentions needing balance.

Yup - the regexp used is the same with what we do for curly braces:

(defconst org-match-substring-regexp
  (concat
   "\\(\\S-\\)\\([_^]\\)\\("
   "\\(?:" (org-create-multibrace-regexp "{" "}" org-match-sexp-depth) "\\)"
   "\\|"
   "\\(?:" (org-create-multibrace-regexp "(" ")" org-match-sexp-depth) "\\)"
   "\\|"
   "\\(?:\\*\\|[+-]?[[:alnum:].,\\]*[[:alnum:]]\\)\\)")
  "The regular expression matching a sub- or superscript.")

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


  reply	other threads:[~2023-09-22  9:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-21 22:45 Subscript with parenthesis Tom Alexander
2023-09-21 23:02 ` Tom Alexander
2023-09-22  9:14   ` Ihor Radchenko [this message]
2023-09-29 16:12     ` Tom Alexander
2024-02-17 14:06     ` [DISCUSSION] What should we do with undocumented x^(superscript inside /round/ braces) syntax? (was: Subscript with parenthesis) Ihor Radchenko
2024-02-17 19:36       ` William Denton
2024-02-17 20:03         ` Thomas Dye
2024-02-17 21:22       ` Mark Barton
2024-02-19 18:15       ` [DISCUSSION] What should we do with undocumented x^(superscript inside /round/ braces) syntax? Fraga, Eric
2024-02-19 18:30         ` Ihor Radchenko
2024-03-20 13:57           ` Ihor Radchenko
2024-04-21  9:44             ` 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=875y42zi1n.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=tom@fizz.buzz \
    /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).