posit-dev / posit-dev/py-shiny

Markdown code block rendering has spacing problems

Open
#222 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.8k
Forks
135
Avg merge
2d 18h
Merged PRs (30d)
21

Description

Example link:

from shiny import ui, App

app_ui = ui.page_fluid(
    ui.markdown(
        """
        Text text text

        ```
        a = 1
        b = a * 2
        c = b * 2
        ```

        Text text text        
        """
    ),
)

app = App(app_ui, None)

This is what it looks like:
image


I think the problem is with the padding for the code selector. If the padding is unchecked below, then it looks normal.

image

With text_output_verbatim(), we put the content directly in a <pre>, as in:

<pre>Content\nMore content</pre>

But with ui.markdown, it is in <pre></code>:

<pre><code>Content\nMore content</code></pre>

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproducible ui.markdown example and compare its generated

 structure with text_output_verbatim()'s 
. Inspect the padding applied to the code selector. Done when fenced Markdown code blocks render without excess spacing while text_output_verbatim() remains correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
markdown, python
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.