d2 icon indicating copy to clipboard operation
d2 copied to clipboard

render?: not important... markdown block quote never wraps

Open vfosnar opened this issue 3 years ago • 8 comments

Markdown should probably have some limit on maximum size

vfosnar avatar Jan 09 '23 23:01 vfosnar

what do you mean by size here?

alixander avatar Jan 10 '23 00:01 alixander

I really should learn how to express myself... the width grows indefinetly and the text never wraps.

vfosnar avatar Jan 10 '23 06:01 vfosnar

i'm actually not sure about this. we got another report of it, but i feel like it's a better experience to have labels and text overrule the set width/height. I feel like I'd rather let the user control linebreaks explicitly (e.g. with newlines \n in labels, or empty lines in markdown), rather than setting width. i'm going to close for now unless someone makes a compelling argument otherwise

alixander avatar Feb 05 '23 10:02 alixander

If I change one line in a long markdown text, I don't like having to redo all the line breaks.

container: {
  description: |md
    Lorem ipsum dolor sit, amet consectetur adipisicing elit.\
    Deleniti animi voluptatibus molestiae rerum doloribus fugit\
    aperiam sapiente distinctio amet. Tenetur, ab? Debitis, minus\
    sapiente quas totam culpa iure tenetur corporis.
  |
}

If I remove "Deleniti animi voluptatibus", I have to reflow all line breaks. If the text is even longer, it is a lot of work.

container: {
  description: |md
    Lorem ipsum dolor sit, amet consectetur adipisicing elit.\
    molestiae rerum doloribus fugit aperiam sapiente distinctio\
    amet. Tenetur, ab? Debitis, minus sapiente quas totam culpa\
    iure tenetur corporis.
  |
}

I'd rather do something like this:

container: {
  description: |md
    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptatibus, ullam. Aperiam tempora, cumque nesciunt, veritatis iste accusamus nulla itaque temporibus ullam rem quisquam quam expedita? Similique quasi nulla quo quibusdam.
  | {width: 200}
}

brummelte avatar Feb 09 '24 19:02 brummelte

This is desirable but extremely difficult. Since we measure markdown dimensions manually without the aid of an HTML renderer, we don't know what the height will be if we set the width to X, given the line breaks.

One way to do this is to measure chunks until width is exceeded, manually break line, and repeat. But you have to consider padding/margins of h1's, bolds, etc.

Won't do for now.

alixander avatar May 24 '24 21:05 alixander

are these useful? (draw internally and measure size)

https://drafts.csswg.org/cssom-view/#dom-htmlelement-offsetwidth HTMLElement.offsetWidth HTMLElement.offsetHeight

bo-ku-ra avatar May 24 '24 22:05 bo-ku-ra

@bo-ku-ra Unfortunately not, these are HTML/CSS web things, and D2 avoids that dependency to measure texts. Thanks anyway

alixander avatar May 25 '24 16:05 alixander