scalameta / mdoc

Typechecked markdown documentation for Scala

Home Page:https://scalameta.org/mdoc/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

support clipping (or scrolling) long errors

erikerlandson opened this issue · comments

I have a code block that creates an error, but the long length of the error is a bit distracting.
Is there a way to tell mdoc to clip the error message to the first n lines, or just tell it to have a maximum code block height,
with a scroll bar? Setting something like mdoc:height=10 doesn't fix this particular problem.

Screen-shot of my long error:

image

@erikerlandson do you have a branch I can look at? We can support this at the rendering level by adding a custom CSS style.

Basically something like this:

pre {
  max-height: 100px;
  overflow: scroll;
}

@armanbilge thanks!

For reference, what I ultimately ended up doing was this:

/* when mdoc renders "long" comments, clip them and provide a scrollbar */
.comment {
  /* set display as block or the other settings don't work */
  display: block;
  /* most comments are short, and display normally */
  max-height: 100px;
  /* add a scrollbar only when necessary */
  overflow: auto;
}

Which adds a scrollbar only for "long" comments, like this:

image

Might be useful to have a special class for "multi-line-comment" or "mdoc-output-comment" to distinguish between comments the programmer wrote and comments generated by mdoc itself.

Or some new mdoc tag. ```scala mdoc:maxoutputlines=3:overflow=scroll:fail

Possibly not related but now seeing this strange behavior:
erikerlandson/coulomb#309