holoviz / panel

Panel: The powerful data exploration & web app framework for Python
https://panel.holoviz.org
BSD 3-Clause "New" or "Revised" License
4.7k stars 510 forks source link

Markdown Code highlighting doesn't work in clean install #3799

Open CmpCtrl opened 2 years ago

CmpCtrl commented 2 years ago

ALL software version info

Python 3.10.2

Package            Version
------------------ ---------
bleach             5.0.1    
bokeh              2.4.3
certifi            2022.6.15
charset-normalizer 2.1.1
colorama           0.4.5
idna               3.3
Jinja2             3.1.2
Markdown           3.4.1
MarkupSafe         2.1.1
numpy              1.23.2
packaging          21.3
panel              0.13.1
param              1.12.2
Pillow             9.2.0
pip                21.2.4
pyct               0.4.8
pyparsing          3.0.9
pyviz-comms        2.2.1
PyYAML             6.0
requests           2.28.1
setuptools         58.1.0
six                1.16.0
tornado            6.2
tqdm               4.64.0
typing_extensions  4.3.0
urllib3            1.26.12
webencodings       0.5.1

Description of expected behavior and the observed behavior

Code highlighting in a Markdown pane doesn't work in a clean install of Panel.

@Hoxbro pointed out that it does work after installing jupyterlab. However, i dont use that so i do not want to depend on it.

Curiously when i installed jupyterlab it broke inline LaTeX math that i had been using in my application, but i havent been able to replicate that here in this example. The inline LaTeX doesnt work in either a clean panel install or with jupyterlab. So presumably there is something else installed in my app workspace that helped the inline LaTeX work there, prior to installing jupyterlab. i'll expand on this in the other issue i had started for the LaTeX rendering issues. #3792

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

Note: Using double ticks for code blocks in the example so github can render it better

"""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)

Screenshots or screencasts of the bug in action

Clean install of Panel: image

With jupyterlab installed: image

hoxbro commented 2 years ago

I don’t think it is jupyterlab that fixes the problem but one of its decencies.

philippjfr commented 2 years ago

Suspect it's probably pygments.

philippjfr commented 2 years ago

Annoying it's fairly large and I'm not entirely sure I want it as a default dependency. At minimum however we should document the requirement in the Markdown reference page.

CmpCtrl commented 2 years ago

10 4. Presumably this documentation applies. https://python-markdown.github.io/extensions/code_hilite/