PrismJS / PrismJS/prism

command-line plugin doesn't recalculate width size for floats; forces horizontal scrollbars

Open
#965 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug plugins
Dominant language
JavaScript
Stars
13k
Forks
1.4k
Avg merge
15h 36m
Merged PRs (30d)
3

Description

I have a something like this:

<figure style="float:left; max-width: 50%;">
  <pre><code class="language-bash">cd foo/bar</code></pre>
<figure>

In other words, I have my Prism code section in a figure, and I float the entire figure on the left side, telling it that it can take up to 50% of the page. And it looks great! Obviously on most screens this figure is far smaller than the half the screen, so there is no scrollbars whatsoever.

But then if I turn on the command-line plugin, I have a problem:

<figure style="float:left; max-width: 50%;">
  <pre class="command-line"><code class="language-bash">cd foo/bar</code></pre>
<figure>

The command-line plugin adds a left section with the *nix command prompt. Great---that's what I wanted. Unfortunately the size of the floated figure does not expand horizontally, even though there is plenty of room on the left half of the screen. Because the <code> section needs more room horizontally than the <pre> element gives it, the <code> section develops horizontal scrollbars. But they are unnecessary---the entire figure should have simply expanded horizontally!

In summary, the addition of the command-line plugin makes the <code> element require more room with the addition of the command prompt, but the outer <pre> element apparently still only reserves enough space for the <code> without the command prompt, resulting in unnecessary horizontal scrollbars.

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

Reproduce the issue with the floated

,
, and Bash code shown in the report, then inspect the command-line plugin's sizing behavior. The work is done when adding the command prompt allows the floated figure to use available width without unnecessary horizontal scrollbars.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.