Open xxchan opened 2 years ago
By the way, should them be added to Logseq's doc?...
I came across this because of seeing what I think is too-aggressive math parsing. In the US, we often need to write about finances, so:
- dinner was $41.56, and breakfast will be $12.00.
It would be great if logseq could somehow figure out that this should not be parsed as math -- maybe if the trailing (second) $
is immediately followed by digits?
I know users can work around this by using \$
but that is not intuitive to me, and breaks the journaling "flow". What do you think?
@garyo IIRC your example can be handled correctlu in logseq?
Because there is a space before the second $
Yes, you're right. I've gotten into the habit of prefixing all my $
with \
because it's hard to know exactly when it'll go into math mode, but if space before the "trailing" (every other) $
works, that is good to know!
Here's a case that's unfortunately too close to math mode:
- 8 mo x $400 = $3200, vs $695+$850+$66x4x8=$3657
but if I add spaces, then it's OK (no math mode, the $
signs still show up):
8 mo x $400 = $3200, vs $695 + $850+ $66x4x8 = $3657
Was this improved some time recently? I find a lot of \$
in my md files that I can now remove and they look OK. So I guess this is less important now than I thought.
One case that could still be improved is if there is emphasis around the dollar figure:
result is $1000 or, over a longer time, **$5000**
That currently in logseq still switches into math mode.
Was this improved some time recently?
This is the behavior since the very beginning, but I proposed to change it in this issue. Now I think this behavior makes some sense.
One case that could still be improved is if there is emphasis around the dollar figure
IMHO it's almost impossible to handle this case (or other similar complicated ones) correctly. Otherwise math mode won't work correctly. In theory, maybe we can add an config option to opt-out math mode (or maybe only double $$
for math mode? but that's a big breaking change), but that may bring some complexity and may have rather low priority for LogSeq. So in practice, I would suggest always add a space or a \
before $
in your use case :)
current situation
types:
Latex_Environment
&Displayed_Math
Latex_Fragment Inline/Display
syntax:
$content$
, TeX delimiters for inline math ->Latex_Fragment Inline
$$content$$
, TeX delimiters for displayed math$$
appears at the start of a line ->Displayed_Math
$$content$$
in one line, no other content later$$content$$ content
https://github.com/logseq/logseq/issues/4066Latex_Fragment Display
\( content \)
, LaTeX delimiters for inline math ->Latex_Fragment Inline
\[ content \]
, LaTeX delimiters for displayed math ->Latex_Fragment Display
\begin{env} content \end{env}
, LaTeX environment->Latex_Environment
My improvement ideas
Allow multi-line for all
Latex_Fragment
. And allow$ content $
I'm actually interested why they don't support multi-line now. Is there a design consideration?
By the way, I don't understand why
\(\)
and\[\]
don't support multi-line text, since they useend_string
. (Instead,$
usetake_while (fun x -> x <> '$' && x <> '\r' && x <> '\n')
, which banned\n
explicitlyRemove
Displayed_Math
since it's confusing. And in Logseq, letLatex_Fragment Display
rendered in display mode.For
$$
, If there's nothing before the starting$$
and nothing after the ending$$
, parse it intoLatex_Fragment Display
. OtherwiseLatex_Fragment Inline
.i.e.,
and
are displayed math. But
and
is equivalent to
$a$b
For reference (and also an aternative), Typora's behavior:
$$
and$
can both be multi-lineThe first two examples above are both inline math.