emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: <tomas@tuxteam.de>
To: emacs-orgmode@gnu.org
Subject: Re: Bug: LaTeX inline maths expression \(+\) wrongly toggles strike-through face
Date: Wed, 2 Dec 2020 10:13:41 +0100	[thread overview]
Message-ID: <20201202091341.GB14592@tuxteam.de> (raw)
In-Reply-To: <87zh2x2bm8.fsf@ens-lyon.fr>

[-- Attachment #1: Type: text/plain, Size: 2727 bytes --]

On Wed, Dec 02, 2020 at 03:19:27AM +0100, Firmin Martin wrote:
> 
> Consider the following lines: 
> - $+$ foobar $+$
> - \[+\] foobar \[+\]
> - $$+$$ foobar $$+$$
> - \(+\) foobar \(+\)
> Each of them is correct LaTeX inline/display maths expressions, but only the
>   last one toggles strike-through face when it shouldn't. 
> 
> Emacs  : GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0)
>  of 2020-10-16
> Package: Org mode version 9.4 (9.4-53-gc97446-elpa)

That's interesting. Happens to me too -- but I don't understand why
the first thre are /not/ rendered as strike-through. The relevant
variables are

 - org-emphasis-regexp-components

in my installation:

   org-emphasis-regexp-components is a variable defined in ‘org.el’.
   Its value is
   ("-[:space:]('\"{" "-[:space:].,:!?;'\")}\\[" "[:space:]" "." 5)
   
   Documentation:
   Components used to build the regular expression for emphasis.
   This is a list with five entries.  Terminology:  In an emphasis string
   like " *strong word* ", we call the initial space PREMATCH, the final
   space POSTMATCH, the stars MARKERS, "s" and "d" are BORDER characters
   and "trong wor" is the body.  The different components in this variable
   specify what is allowed/forbidden in each part:
   
   pre          Chars allowed as prematch.  Beginning of line will be allowed too.
   post         Chars allowed as postmatch.  End of line will be allowed too.
   border       The chars *forbidden* as border characters.
   body-regexp  A regexp like "." to match a body character.  Don’t use
                non-shy groups here, and don’t allow newline here.
   newline      The maximum number of newlines allowed in an emphasis exp.

(I changed the value of newline to 5). Note `border' is just "[[:space:]]",
so I'd expect '$', '\' and '$' (for the first three examples) to be "allowed"
borders, and

 - org-emph-re

which is calculated from the above, and in my box, not suprprisingly,
is

     "\\([-[:space:]('\"{]\\|^\\)\\(\\([*/_+]\\)\\([^[:space:]]\\|[^[:space:]].*?\\(?:
   .*?\\)\\{0,5\\}[^[:space:]]\\)\\3\\)\\([-[:space:].,:!?;'\")}\\[]\\|$\\)"

...which would confirm my expectation above. So why are the three
examples not rendered as overstrike? There seems to be more magic
involved.

This happens for other emph markers, too.

To work around in your case, Martin, you could try to add a backslash
to your `org-emphasis-regexp-component's third element, like so:

  (setf (nth 3 org-emphasis-regexp-components) "\\\\[:space:]")

and reload Org to give it the chance to rebuild org-emph-re.

(Caveat: I didn't try it).

Cheers
 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2020-12-02 10:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-02  2:19 Bug: LaTeX inline maths expression \(+\) wrongly toggles strike-through face Firmin Martin
2020-12-02  9:13 ` tomas [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-12-03  9:02 Firmin Martin

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=20201202091341.GB14592@tuxteam.de \
    --to=tomas@tuxteam.de \
    --cc=emacs-orgmode@gnu.org \
    /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).