kueblc / LDT

Lightweight in browser syntax highlighting
https://kueblc.github.io/LDT/
159 stars 17 forks source link

Getting a tighter fit around the text #27

Open pygy opened 7 months ago

pygy commented 7 months ago

Adding

    if (input.charAt(input.length - 1) === '\n') input += "\n"

at the start of color() and

.ldt pre:empty::after {
  display:block;
  content: " "
}

in the CSS file lets one set the rows to the exact number of lines at the end of update().

This results in a better behavior IMO (no container overflow).

Live example with a "gutter" plugin adapted to the new number of rows.

Edit: :empty is IE9+. I don't know how important IE7 compat is to you and the LDT user base at this point... I'd expect it to be low... I can send a PR if you're interested.