quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.92k stars 323 forks source link

Whitespace problems with markdown parsing. #6713

Open ralmond opened 1 year ago

ralmond commented 1 year ago

Bug description

Parsing of the markdown seems to be dependent on whitespace on ways that are not documented.

1) When using $ delimiters for LaTeX equations, if there is whitespace between the delimiter and the equation, quarto quotes the delimiters instead of rendering the equation.

2) When using bulleted lists, if there is not a blank line between the end of the paragraph and the start of the list, then the bullet characters are quoted and the list is run into the paragraph.

This happens both when rendering in Quarto and when switching back and forth between the R Studio source and visual modes.

These restrictions on syntax do not appear to be documented (certainly not in the quick help from RStudio).

Steps to reproduce

---
title: "Syntax Issues"
---

Putting whitespace between the dollar sign and the equation produces problems.

This works $H \rightarrow E$

But this does not $ H \rightarrow E $

Not leaving a blank line before the item causes a problem. 
* Item 1 
* Item 2

But if I leave a blank line it works.

*  Item 1
*  Item 2

This renders as follows:

syntaxIssues.pdf

Expected behavior

I expect both examples in both cases to be the same:

1) I expect the equation to be rendered twice.

2) I expect both lists to look the same.

Actual behavior

With extra whitespace, the equation does not render. Switching from source->visual->source in R studio changes the equation to \$ H \rightarrow \$.

Without the blank line, the list is run into the same paragraph. Switching from source->visual->source produces

Not leaving a blank line before the item causes a problem.  \* Item 1 \* Item 2

Your environment

Quarto check output

(base) [ralmond@cherry: ReECD]$ quarto check

[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.1: OK
      Dart Sass version 1.55.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.3.450
      Path: /opt/quarto/bin

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.9.7 (Conda)
      Path: /home/ralmond/anaconda3/bin/python
      Jupyter: 4.8.1
      Kernels: python3

[✓] Checking Jupyter engine render....OK

[✓] Checking R installation...........OK
      Version: 4.3.1
      Path: /usr/lib/R
      LibPaths:
        - /home/ralmond/R/x86_64-pc-linux-gnu-library/4.3
        - /usr/local/lib/R/site-library
        - /usr/lib/R/site-library
        - /usr/lib/R/library
      knitr: 1.43.1
      rmarkdown: 2.24

[✓] Checking Knitr engine render......OK
cscheid commented 1 year ago

This is how Pandoc parses those equations; that's not a bug. I believe you might be expecting that coming from authoring .tex documents directly. But Markdown is actually different syntax, and requires no whitespace there. (With that said, I agree that we could document this more clearly).