facelessuser / pymdown-extensions

Extensions for Python Markdown
https://facelessuser.github.io/pymdown-extensions/
Other
941 stars 251 forks source link

Multiple spans created in SQL format #2312

Closed nryberg closed 6 months ago

nryberg commented 6 months ago

Description

When I apply Superfences and inlinehilite to SQL, the text gets colorized, which is great.

However, it inserts multiple empty blocks into the output. I'd like to keep it tight together without the multiple breaks.

Have:

have

Want:

want

For this statement: `

SELECT bob, fred, george FROM sample

`

Minimal Reproduction

  1. Create Markdown text with fenced SQL using triple back ticks
  2. Apply extensions markdown.markdown(markdown_text, extensions=['tables', 'pymdownx.superfences', 'pymdownx.inlinehilite'])
  3. Results very spread out visual.

highlight

Version(s) & System Info

facelessuser commented 6 months ago

Results very spread out visual.

Neither SuperFences nor InlineHilite inherently exhibit the issue you describe. If this issue exists, it exists because you have provided bad CSS that does this.

The highlighting is controlled by Pygments, not us. They wanted to properly scope the white space as not being part of the other syntax. Scoping the white space with a span does not inject new lines, that's not how HTML works. But CSS can change how blocks are styled. And since Pymdown Extensions does not provide any CSS in our output, the bad CSS has to originate from either you or some other 3rd party CSS you are including.

Here I enter inline and block format into my documents via:

`#!sql SELECT bob, fred, george FROM sample`

```sql
SELECT bob, fred, george FROM sample


And this is what I get in my documents:

<img width="799" alt="Screenshot 2024-02-08 at 6 47 01 AM" src="https://github.com/facelessuser/pymdown-extensions/assets/1055125/d88161d1-69ed-4e26-9f6a-60bc0144f896">

You can try it out here on CodePen, the content is not spread out: https://codepen.io/facelessuser/pen/WNmgGdK.