Skip to content

Markdown viewers containing code blocks render a horizontal scroll when no overflow is occurring #790

@Lambeaux

Description

@Lambeaux

Reproduce

Consider the following notebook:

^{:nextjournal.clerk/visibility {:code :hide :result :hide}}
(ns bug-reproduce
  (:require [nextjournal.clerk :as clerk]))

^{:nextjournal.clerk/visibility {:code :hide :result :show}}
(clerk/md
 "## Clerk Markdown Bug?
  So, is it true that I can just write markdown here?
  ```clojure
  (+ 1 1)
  ```
  Dang, that's pretty sweet! What if I add even more?
  ```clojure
  (+ 2 2)
  ```")

The rendered output adds a horizontal scroll bar when no scroll bar is necessary. It appears to be adding it to the entire markdown result, not just the code blocks.

Image

Only occurs with code blocks

If you remove all the code blocks, the horizontal scroll disappears.

Image

Current DOM being rendered

I was poking around with Chrome dev tools (as one does) and found what may be the culprit. There appears to be an overflow-x CSS property being set on a div wrapping the final viewer div.

Here is the majority of the relevant DOM.

Image

Problematic CSS

Here is the property still enabled.

Image

Disable the CSS property

If I disable that property...

Image

Problem solved

...the problem is resolved.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions