From: Christian Heller Date: Sat, 14 Feb 2026 18:09:39 +0000 (+0100) Subject: Clean up whitespace handling in templates. X-Git-Url: https://plomlompom.com/repos/booking/test?a=commitdiff_plain;h=HEAD;p=ledgplom Clean up whitespace handling in templates. --- diff --git a/src/templates/_macros.tmpl b/src/templates/_macros.tmpl index fc8964f..ae06af8 100644 --- a/src/templates/_macros.tmpl +++ b/src/templates/_macros.tmpl @@ -82,7 +82,7 @@ Detected redundant empty lines in gaps, diff --git a/src/templates/ledger_raw.html b/src/templates/ledger_raw.html index 08003ee..f66de15 100644 --- a/src/templates/ledger_raw.html +++ b/src/templates/ledger_raw.html @@ -7,6 +7,9 @@ table { font-family: monospace; } +table > tbody > tr > td.line { + white-space-collapse: preserve; +} {% endblock %} @@ -20,8 +23,8 @@ table { {{ macros.ledger_block_columns('raw', block) -}} {##}{% for line in block.lines %} {# -#} - - {{- line.raw }} {# -#} + + {{- line.raw or " " -}} {# -#} {##}{% endfor %} diff --git a/src/templates/ledger_structured.html b/src/templates/ledger_structured.html index dae16b0..bf3555a 100644 --- a/src/templates/ledger_structured.html +++ b/src/templates/ledger_structured.html @@ -5,6 +5,10 @@ {% block css %} {{ macros.css_ledger() }} {{ macros.css_tabular_money() }} +table > tbody > tr > td.comment { + font-family: monospace; + white-space-collapse: preserve; +} {% endblock %} @@ -18,7 +22,7 @@ {{ macros.ledger_block_columns('structured', block) -}} {##}{% for line in block.gap_lines %} - {{ line.raw }}  + {{ line.raw or " " }} {##}{% endfor %} {##}{% if block.booking %} @@ -27,7 +31,7 @@ if block.booking.intro_line.errors }}> {{- block.booking.date }} {{ block.booking.target -}} - {{ block.booking.intro_line.comment }} + {{ block.booking.intro_line.comment }} {####}{% for line in block.booking.body_lines %} @@ -41,9 +45,9 @@ {{- line.account -}} - {{ line.comment }} + {{ line.comment }} {######}{% else %} - {{ line.comment }} + {{ line.comment or " " }} {######}{% endif %} {####}{% endfor %} diff --git a/src/tests/empty.ledger_raw b/src/tests/empty.ledger_raw index a479a03..b804233 100644 --- a/src/tests/empty.ledger_raw +++ b/src/tests/empty.ledger_raw @@ -37,6 +37,9 @@ td.block_column { table { font-family: monospace; } +table > tbody > tr > td.line { + white-space-collapse: preserve; +} diff --git a/src/tests/empty.ledger_structured b/src/tests/empty.ledger_structured index 8654781..f9384bb 100644 --- a/src/tests/empty.ledger_structured +++ b/src/tests/empty.ledger_structured @@ -42,6 +42,10 @@ td.currency { font-family: monospace; font-size: 1.25em; } +table > tbody > tr > td.comment { + font-family: monospace; + white-space-collapse: preserve; +} @@ -58,7 +62,7 @@ td.currency {
- + - - - - - - - - + + + + + + + + - - - - + + + + - - - - - + + + + + - - - - - - + + + + + + - - - - - - - - + + + + + + + +
diff --git a/src/tests/full.ledger_raw b/src/tests/full.ledger_raw index 8cd3a0e..ba988cf 100644 --- a/src/tests/full.ledger_raw +++ b/src/tests/full.ledger_raw @@ -37,6 +37,9 @@ td.block_column { table { font-family: monospace; } +table > tbody > tr > td.line { + white-space-collapse: preserve; +} @@ -70,14 +73,14 @@ Detected redundant empty lines in gaps, e]
;#description bar:x bla bla bla 
 
2001-01-01 test ; foo 
; in-body comment 1 
foo 10 € 
; in-body comment 2 
bar -10 € 
; in-body comment 3 
;#description bar:x bla bla bla
2001-01-01 test ; foo
; in-body comment 1
foo 10 €
; in-body comment 2
bar -10 €
; in-body comment 3
@@ -93,10 +96,10 @@ Detected redundant empty lines in gaps, e]
 
2001-01-02 test test 
bar -10 € ; bar 
baz 10 € 
2001-01-02 test test
bar -10 € ; bar
baz 10 €
@@ -112,11 +115,11 @@ Detected redundant empty lines in gaps, e]
 
 
2001-01-02 test 
bar 20 € 
baz -20 € ; baz 
2001-01-02 test
bar 20 €
baz -20 € ; baz
@@ -132,12 +135,12 @@ Detected redundant empty lines in gaps, e]
 
2001-01-03 test 
foo:x 10 € 
foo:x 1 USD 
bar:x:y -10 € 
bar:z -1 USD 
2001-01-03 test
foo:x 10 €
foo:x 1 USD
bar:x:y -10 €
bar:z -1 USD
@@ -153,14 +156,14 @@ Detected redundant empty lines in gaps, e]
 
;#description bar:x bla foo bla 
 
2001-01-03 test 
foo:x 10 € 
foo:x 3 USD 
bar:x:y -9 € 
bar:z -1 USD 
;#description bar:x bla foo bla
2001-01-03 test
foo:x 10 €
foo:x 3 USD
bar:x:y -9 €
bar:z -1 USD
diff --git a/src/tests/full.ledger_structured b/src/tests/full.ledger_structured index 6e2774f..0620c54 100644 --- a/src/tests/full.ledger_structured +++ b/src/tests/full.ledger_structured @@ -42,6 +42,10 @@ td.currency { font-family: monospace; font-size: 1.25em; } +table > tbody > tr > td.comment { + font-family: monospace; + white-space-collapse: preserve; +} @@ -60,7 +64,7 @@ Detected redundant empty lines in gaps, - + @@ -76,37 +80,37 @@ Detected redundant empty lines in gaps, ;#description bar:x bla bla bla  + ;#description bar:x bla bla bla -   + 2001-01-01 test - foo + foo - in-body comment 1 + in-body comment 1 10.00 € foo - + - in-body comment 2 + in-body comment 2 -10.00 € bar - + - in-body comment 3 + in-body comment 3 - + @@ -122,25 +126,25 @@ Detected redundant empty lines in gaps,   + 2001-01-02 test test - + -10.00 € bar - bar + bar 10.00 € baz - + - + @@ -156,28 +160,28 @@ Detected redundant empty lines in gaps,   + -   + 2001-01-02 test - + 20.00 € bar - + -20.00 € baz - baz + baz - + @@ -193,37 +197,37 @@ Detected redundant empty lines in gaps,   + 2001-01-03 test - + 10.00 € foo:x - + 1.00 USD foo:x - + -10.00 € bar:x:y - + -1.00 USD bar:z - + - + @@ -239,41 +243,41 @@ Detected redundant empty lines in gaps,   + - ;#description bar:x bla foo bla  + ;#description bar:x bla foo bla -   + 2001-01-03 test - + 10.00 € foo:x - + 3.00 USD foo:x - + -9.00 € bar:x:y - + -1.00 USD bar:z - +