Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown broken for single-character bold and italics #4259

Closed
jbednar opened this issue Dec 10, 2018 · 24 comments
Closed

Markdown broken for single-character bold and italics #4259

jbednar opened this issue Dec 10, 2018 · 24 comments

Comments

@jbednar
Copy link

jbednar commented Dec 10, 2018

Jupyter 5.7.2's Markdown parser seems to be unable to deal with single characters in italics, if more than two appear in any one cell. E.g. I think all of these combinations should be legal ways to specify italics, yet only a single instance, or up to two if one uses underscores and one uses asterixes, actually work:

screen shot 2018-12-10 at 11 38 05 am

Is there some reason this shouldn't be expected to work?

@jbednar
Copy link
Author

jbednar commented Dec 15, 2018

I just noticed that this problem also applies to single-character bold text, which I'm sure used to work:

image

@jbednar jbednar changed the title Markdown broken for single-character italics Markdown broken for single-character bold and italics Dec 15, 2018
@laowantong
Copy link

@jbednar In the meantime, you can use ​a ZERO WIDTH SPACE (Unicode: U+200B, UTF-8: E2 80 8B).

@jbednar
Copy link
Author

jbednar commented Dec 16, 2018

I can also use html markup, but that's not much of a fix...

@philippjfr
Copy link
Contributor

philippjfr commented Dec 17, 2018

Note that this problem is also present in JupyterLab. So my guess is that the JS library used to perform the Markdown rendering (i.e. probably CodeMirror?!) is responsible and is used across both notebook implementations.

@jbednar
Copy link
Author

jbednar commented Dec 17, 2018

It looks like rendering of single characters was fine for notebook versions up to 5.3.1:

image

In notebook 5.4.1 and 5.5.0, bold and italics worked fine with asterixes, but italics with underscores stopped working at all for single characters (and also for two-character words, not shown here):

image

The current behavior started in notebook 5.6.0 and remains an issue with notebook 5.7.2:

image

@philippjfr
Copy link
Contributor

Given your version info I suspect the regression occurred when upgrading to marked 0.4 in this PR: #3686

@cems2
Copy link

cems2 commented Jan 6, 2019

It appears to me the problem is just related to single characters!!
GUESS: It looks like it has to do with incorrect greedy regex that is parsing this internally.

the problem occurs when two different occurences of italics occur in a single line like this
**x** some text in the middle **y** some text

What happens is that the first ** before the x is treated as the italics-open mark, and the very last ** after the y is treated as the close-italics markdown. And everything in the middle including the other**marks is just treated as raw text to be italicized.

You can work around this by using __y__ instead of **y**.

it looks exactly like what you would get for a regex that was doing this:
\*\*(+*)\*\*
which will extract everything between the first and last ** it finds. Since regex is greedy it will match the longest rather than shortest next match.

to fix this, alter the regex syntax to match the shortest next match not the longest next match (the defualt).

@jbednar
Copy link
Author

jbednar commented Jan 14, 2019

You can work around this by using __y__ instead of **y**.

I don't think that works in general, when there are several single-digit bold or italic characters in the same cell. The only workaround I've found is to insert a bogus space character into the definition, as in __x __, and then omitting the trailing space. That renders fine, though of course it makes the Markdown source unreadable and very mysterious. I'd hope that the Jupyter team can fix this before the world fills up with notebooks hacked up in this way!

@cems2
Copy link

cems2 commented Jan 14, 2019 via email

@juandm
Copy link

juandm commented Mar 5, 2019

For italics, you can workaround this issue using the LaTex inline support, just like this:

given to sets $A$ and $B$

$A$ -> A
$B$ -> B

@mick-d
Copy link

mick-d commented Apr 27, 2019

I confirm the bug

@csevast
Copy link

csevast commented Apr 28, 2019

I confirm the bug either.

@csmyth93
Copy link

csmyth93 commented May 7, 2019

It's still buggy for me

@jwatson27
Copy link

I am running Jupyter version 5.7.8 and I am getting this error as well.

I found a workaround while we are waiting for this issue to be resolved. I am simply adding a non-printable character inside the ** ** section. For instance, to get a bold k, I use **k</t>**. Not exactly sure what this is doing, but it seems to work. If someone has more insight on this, that would be helpful.

@gurunars
Copy link

I confirm the bug

@jasongrout
Copy link
Member

This sounds very similar to jupyterlab/jupyterlab#5375, which we fixed in JLab by upgrading the marked package.

@Seve1995
Copy link

Seve1995 commented May 21, 2019

I'm also having the bug, Jupyter v. 5.7.8. My current workaround is to use a <span> inside the markdown, e.g. :
**x<span>**

@vanvae
Copy link

vanvae commented May 28, 2019

confirm the bug in Jupyter notebook 5.7.8

@oesst
Copy link

oesst commented Dec 19, 2019

Confirming the bug in Jupyter Notebook 5.6.0

@rasbot
Copy link

rasbot commented Dec 25, 2019

This is definitely still a bug. Since this hasn't been fixed in over a year I'm assuming it won't be fixed or isn't a priority. With how many people use Jupyter Notebook, that is unfortunate.

@norvig
Copy link

norvig commented Feb 5, 2020

Still a bug; still bugs me.

@mwermelinger
Copy link

I'm using Jupyter 6.1.4 and can't replicate the error, neither for italics nor bold.

@jbednar
Copy link
Author

jbednar commented May 13, 2021

Oh thank god! I just tried it on jupyter-notebook 6.1.4 and it all appears to be working again. Happily closing this issue.

@jbednar jbednar closed this as completed May 13, 2021
@kevin-bates
Copy link
Member

Yes - it appears the bump to marked 0.7 via #5617 has been magical. This is consistent with Jason's #4259 (comment) and this first appeared in 6.1 (consistent with recent successes).

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests