Repository: vscode
Issue: "Format Notebook" damages LaTeX in Markdown cells
Labels: bug,notebook-format

Type: <b>Bug</b>

For reproduction:
- add an empty Jupyter notebook (.ipynb) file
- add a markdown cell containing:
\begin{equation}
\|a\|\1
\end{equation}
- add a code cell containing: b=1
- run format notebook (ctrl+shift+i)

The equation changes during the autoformating.
There are also other kinds of changes in the equation, but that should help to find the bug.
I use the black formatter.

VS Code version: Code 1.81.1 (6c3e3dba23e8fadc360aed75ce363ba185c49794, 2023-08-09T22:18:39.991Z)
OS version: Linux x64 5.15.0-83-generic
Modes:

<details>
<summary>System Info</summary>

|Item|Value|
|---|---|
|CPUs|Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz (6 x 2591)|
|GPU Status|2d_canvas: unavailable_software<br>canvas_oop_rasterization: disabled_off<br>direct_rendering_display_compositor: disabled_off_ok<br>gpu_compositing: disabled_software<br>multiple_raster_threads: enabled_on<br>opengl: disabled_off<br>rasterization: disabled_software<br>raw_draw: disabled_off_ok<br>video_decode: disabled_software<br>video_encode: disabled_software<br>vulkan: disabled_off<br>webgl: unavailable_software<br>webgl2: unavailable_software<br>webgpu: disabled_off|
|Load (avg)|1, 1, 1|
|Memory (System)|23.02GB (15.96GB free)|
|Process Argv|. --crash-reporter-id 574f540c-3290-4534-a6a9-6d182d854876|
|Screen Reader|no|
|VM|100%|
|DESKTOP_SESSION|ubuntu|
|XDG_CURRENT_DESKTOP|Unity|
|XDG_SESSION_DESKTOP|ubuntu|
|XDG_SESSION_TYPE|x11|
</details><details><summary>Extensions (39)</summary>

Extension|Author (truncated)|Version
---|---|---
vscode-django|bat|1.11.0
markdown-mermaid|bie|1.19.0
markdown-preview-github-styles|bie|2.0.2
my-nbpreviewer|col|1.2.2
vscode-markdownlint|Dav|0.51.0
python-environment-manager|don|1.0.4
python-extension-pack|don|1.7.0
gitlens|eam|14.3.0
prettier-vscode|esb|10.1.0
myst-highlight|Exe|0.11.0
gitlab-workflow|Git|3.77.0
vscode-h5web|h5w|0.0.10
nbpreviewer|jit|1.2.2
vsc-python-indent|Kev|1.18.0
black-formatter|ms-|2023.4.1
python|ms-|2023.15.12301911
vscode-pylance|ms-|2023.9.10
jupyter|ms-|2023.7.1002162226
jupyter-keymap|ms-|1.1.2
jupyter-renderers|ms-|1.0.17
vscode-jupyter-cell-tags|ms-|0.1.8
vscode-jupyter-powertoys|ms-|0.0.8
vscode-jupyter-slideshow|ms-|0.1.5
remote-containers|ms-|0.309.0
remote-ssh|ms-|0.102.0
remote-ssh-edit|ms-|0.86.0
remote-wsl|ms-|0.81.3
vscode-remote-extensionpack|ms-|0.24.0
remote-explorer|ms-|0.4.1
remote-server|ms-|1.4.3
autodocstring|njp|0.6.1
jupyter-notebook-vscode|sam|0.0.2
markdown-preview-enhanced|shd|0.7.3
code-spell-checker|str|3.0.1
intellicode-api-usage-examples|Vis|0.2.8
vscodeintellicode|Vis|1.2.30
jinja|who|0.0.8
markdown-pdf|yza|1.5.0
markdown-all-in-one|yzh|3.5.1


</details><details>
<summary>A/B Experiments</summary>

```
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscoreces:30445986
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
pythonvs932:30410667
py29gd2263cf:30792227
vsclangdf:30486550
c4g48928:30535728
dsvsc012cf:30540253
pynewext54:30695312
azure-dev_surveyone:30548225
vscccc:30803845
3biah626:30602489
f6dab269:30613381
a9j8j154:30646983
showlangstatbar:30737416
03d35959:30757346
57b77579:30736110
pythonfmttext:30731395
fixshowwlkth:30771522
showindicator:30805244
pythongtdpath:30769146
i26e3531:30792625
pythonnosmt12:30797651
pythonidxpt:30805730
pythonnoceb:30805159
dsvsc013:30795093
dsvsc014:30804076
diffeditorv2:30821572
dsvsc015:30829745

```

</details>

<!-- generated by issue reporter -->