diff options
author | bptato <nincsnevem662@gmail.com> | 2022-01-19 21:09:21 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2022-01-19 21:09:21 +0100 |
commit | f93f67cdd0f34409f88b1507252055ca4c5fb9bc (patch) | |
tree | 2a8f3bfd3afc26a30df1afba28d359db763a9962 | |
parent | 04e33d8052b974a90308a931e71442cad7d5ae5c (diff) | |
download | chawan-f93f67cdd0f34409f88b1507252055ca4c5fb9bc.tar.gz |
Fix whitespace issues after newline
-rw-r--r-- | src/layout/engine.nim | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/layout/engine.nim b/src/layout/engine.nim index f74c5f6c..afd66c72 100644 --- a/src/layout/engine.nim +++ b/src/layout/engine.nim @@ -525,24 +525,22 @@ proc finishRow(ictx: InlineContext) = proc addAtom(ictx: InlineContext, atom: InlineAtom, maxwidth: int, specified: CSSSpecifiedValues) = # Whitespace between words + var shift = 0 + let whitespacepre = specified{"white-space"} in {WHITESPACE_PRE, WHITESPACE_PRE_WRAP} if ictx.whitespace: - if ictx.thisrow.atoms.len > 0: - inc ictx.thisrow.width - ictx.whitespace = false - elif specified{"white-space"} in {WHITESPACE_PRE, WHITESPACE_PRE_WRAP}: - inc ictx.thisrow.width - else: - ictx.whitespace = false + if ictx.thisrow.atoms.len > 0 or whitespacepre: + shift = 1 + ictx.whitespace = false # Line wrapping if specified{"white-space"} notin {WHITESPACE_NOWRAP, WHITESPACE_PRE}: if specified{"word-break"} == WORD_BREAK_NORMAL and ictx.thisrow.width + atom.width > maxwidth: ictx.finishRow() + if not whitespacepre: + # No whitespace on newline + shift = 0 - # Whitespace (from pre/pre-wrap) - if ictx.whitespace: - inc ictx.thisrow.relx - ictx.whitespace = false + ictx.thisrow.width += shift atom.relx = ictx.thisrow.width ictx.thisrow.width += atom.width |