panel icon indicating copy to clipboard operation
panel copied to clipboard

Markdown emphasis bug

Open CmpCtrl opened this issue 3 years ago • 2 comments

ALL software version info

panel 0.13.1 param 1.12.1

Description of expected behavior and the observed behavior

In a Markdown pane, I expect * inside $$ $$ to be interpreted as latex and render a *.

It seems that it is being interpreted as emphasis. image

Expected: image

Complete, minimal, self-contained example code that reproduces the issue

"""markdown emphasis bug"""
import panel as pn


def main():
    """test"""
    mkdn = """
# Test

would result in $${(100+10)*2=220}$$ **NOT** $${100+10*2=120}$$ like you would expect
    """

    col = pn.Column(pn.pane.Markdown(mkdn))
    col.servable()

    return col


pn.serve(main)

CmpCtrl avatar Aug 29 '22 15:08 CmpCtrl

An update to this issue, it seems the problem occurs when there are 2 * characters in a single paragraph.

image

Also, a curious note. In chasing the code highlighting issue we found it needs jupyterlab installed to work, which when installed broke inline LaTeX statements that i had been using in my app. However, i havent been able to make inline LaTeX work at all in this example implying that something else in my app's working directory is different. I'm just pointing this out to note that other packages seem to influence the behavior.

"""markdown tests"""
import panel as pn


def main():
    """test"""
    mkdn = """

# Latex Test

## display style latex math:  

### two statements with \* in 1 paragraph
$${(100+10)*2=220}$$  
$${(100+10)*2=220}$$  

### In its own paragraph
$${(100+10)*2=220}$$

### Using \\times
$${(100+10)\\times 2=220}$$  


## inline style latex math:  
${(100+10)*2=220}$   
${(100+10)\\times 2=220}$  

# Code highlight test

## Python
``python
def test():
    this=False
    that=10
    return this
``

## json
``json
{
  "selected_sigs": ["Ambient Pressure", "CAN Bus 1 Diagnostic"],
  "fits": {
    "Engine.Efficiency.Value": {
      "f_orig": 0.07,
      "f_smooth": [0.11, 0.16]
      }
    }
}
``

# footnote test
test footnote anchor[^1]

[^1]: the test footnote
    """

    col = pn.Column(pn.pane.Markdown(mkdn),sizing_mode='stretch_width')
    col.servable()

    return col


pn.serve(main)

CmpCtrl avatar Aug 31 '22 15:08 CmpCtrl

Sounds like the Markdown parser somehow needs to be made aware of the $$ delimiters because the markdown conversion happens server-side and therefore happens first and the LaTeX parsing happens client-side. In the worst case we can escape the markdown characters like * and ~ inside the LaTeX delimiters manually.

philippjfr avatar Sep 05 '22 10:09 philippjfr