emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug: Math mode doesn't work if followed by a dash [9.4 (nil @ /home/


From: Berry, Charles
Subject: Re: Bug: Math mode doesn't work if followed by a dash [9.4 (nil @ /home/gutin/.emacs.d/.local/straight/build/org-mode/)]
Date: Tue, 29 Sep 2020 22:06:18 +0000

See below.

> On Sep 29, 2020, at 11:53 AM, Richard Lawrence <wyley.r@gmail.com> wrote:
> 
> "Berry, Charles" <ccberry@health.ucsd.edu> writes:
> 
>> The case Gutin describes conforms to the documentation, viz. `$x\beta$-` 
>> should produce math mode LaTeX as I read the next paragraph. 
>> 
>> From (info "(org) LaTeX fragments"):
>> 
>>   • Text within the usual LaTeX math delimiters.  To avoid conflicts
>>     with currency specifications, single ‘$’ characters are only
>>     recognized as math delimiters if the enclosed text contains at most
>>     two line breaks, is directly attached to the ‘$’ characters with no
>>     whitespace in between, and if the closing ‘$’ is followed by
>>     whitespace, punctuation or a dash.
> 
> Hmm, good point.
> 
> It looks to me like the relevant function is
> org-element-latex-fragment-parser, and the code for that hasn't changed
> much in several years (last change was 2017). (Also, I was wrong,
> parsing latex fragments is not done with just a regexp.) I can confirm
> that this function parses "$foo" in "$foo$ bar" as a latex fragment, but
> not in "$foo$-bar"
> 
> Not sure if the problem here is the code or the documentation. Perhaps
> the documentation should be updated to reflect the current behavior?
> 

Using 

"\\(-\\|\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|'\\|$\\)"

as the regexp for the `looking-at-p` seems to resolve this. To save you some 
eyestrain, there is "-\\|" added near the beginning right after "\\(" to match 
the trailing dash.

Per (info (elisp) "Syntax Class Table"), neither \\s. nor \\s- include the 
dash. \\s_ includes dash, but also $, so that seems like trouble. 

Caveat: I've not run `make test`, so am unsure if there is a subtle gotcha 
hidden here.

HTH,

Chuck

reply via email to

[Prev in Thread] Current Thread [Next in Thread]