Release 0.3.1: keep leading spaces for manual indent.
Paragraph parsing no longer strips start-of-line spaces (trailing still trimmed). Co-authored-by: Cursor <cursoragent@cursor.com>
@@ -2769,7 +2769,7 @@ checksum = "2f3a9f18d041e6d0e102a0a46750538147e5e8992d3b4873aaafee2520b00ce3"
2769
2769
2770
2770
[[package]]
2771
2771
name = "posprint"
2772
version = "0.3.0"
2772
version = "0.3.1"
2773
2773
dependencies = [
2774
2774
"barcoders",
2775
2775
"chrono",
@@ -2769,7 +2769,7 @@ checksum = "2f3a9f18d041e6d0e102a0a46750538147e5e8992d3b4873aaafee2520b00ce3"2769
2769
2770
[[package]]2770
[[package]]2771
name = "posprint"2771
name = "posprint"2772
version = "0.3.0"2772
version = "0.3.1"2773
dependencies = [2773
dependencies = [2774
"barcoders",2774
"barcoders",2775
"chrono",2775
"chrono",@@ -1,6 +1,6 @@
1
1
[package]
2
2
name = "posprint"
3
version = "0.3.0"
3
version = "0.3.1"
4
4
edition = "2021"
5
5
rust-version = "1.88"
6
6
description = "Designer for POS-print documents"
@@ -1,6 +1,6 @@1
[package]
1
[package]
2
name = "posprint"
2
name = "posprint"
3
version = "0.3.0"
3
version = "0.3.1"
4
edition = "2021"
4
edition = "2021"
5
rust-version = "1.88"
5
rust-version = "1.88"
6
description = "Designer for POS-print documents"
6
description = "Designer for POS-print documents"
@@ -6,7 +6,7 @@ Cross-platform designer for POS (point-of-sale) receipt documents. Edit template
6
6
7
7
## Status
8
8
9
**v0.3.0** — Inline checkboxes (`[]` / `[x]`) and `$[Name]` bool parameters, nested bullet lists, editor paste fixes, multi-transport printing.
9
**v0.3.1** — Preserve leading/multiple spaces for manual layout; inline checkboxes, `$[Name]` bool params, nested lists, multi-transport printing.
10
10
11
11
## Build and run
12
12
@@ -46,7 +46,7 @@ All `${Parameters}` must be supplied via `--set NAME=VALUE` or the command fails
46
46
| Linux (Arch) | `.pkg.tar.zst` (x86_64) | `sudo pacman -U posprint_*_x86_64.pkg.tar.zst` |
47
47
| Windows | `posprint.exe` | Download from GitLab release job artifacts |
48
48
49
Tag a version (e.g. `0.3.0`) to trigger release builds.
49
Tag a version (e.g. `0.3.1`) to trigger release builds.
50
50
51
51
## Features
52
52
@@ -6,7 +6,7 @@ Cross-platform designer for POS (point-of-sale) receipt documents. Edit template6
6
7
## Status7
## Status8
8
9
**v0.3.0** — Inline checkboxes (`[]` / `[x]`) and `$[Name]` bool parameters, nested bullet lists, editor paste fixes, multi-transport printing.9
**v0.3.1** — Preserve leading/multiple spaces for manual layout; inline checkboxes, `$[Name]` bool params, nested lists, multi-transport printing.10
10
11
## Build and run11
## Build and run12
12
@@ -46,7 +46,7 @@ All `${Parameters}` must be supplied via `--set NAME=VALUE` or the command fails46
| Linux (Arch) | `.pkg.tar.zst` (x86_64) | `sudo pacman -U posprint_*_x86_64.pkg.tar.zst` |46
| Linux (Arch) | `.pkg.tar.zst` (x86_64) | `sudo pacman -U posprint_*_x86_64.pkg.tar.zst` |47
| Windows | `posprint.exe` | Download from GitLab release job artifacts |47
| Windows | `posprint.exe` | Download from GitLab release job artifacts |48
48
49
Tag a version (e.g. `0.3.0`) to trigger release builds.49
Tag a version (e.g. `0.3.1`) to trigger release builds.50
50
51
## Features51
## Features52
52
@@ -18,12 +18,13 @@ A document is a sequence of **blocks**. Blank lines become paper feeds (`@feed 1
18
18
19
19
### Paragraphs
20
20
21
Plain text (and `${parameters}`). One or more consecutive non-empty lines form a paragraph. There is **no** inline bold/italic/code markup. Consecutive spaces are preserved (not collapsed) so authors can pad columns manually.
21
Plain text (and `${parameters}`). One or more consecutive non-empty lines form a paragraph. There is **no** inline bold/italic/code markup. Consecutive spaces are preserved (not collapsed), including leading indentation, so authors can pad columns manually. Trailing spaces on a line are trimmed.
22
22
23
23
```markdown
24
24
Thank you for your purchase!
25
25
Visit us again soon.
26
26
Item 12.00
27
rightish note
27
28
```
28
29
29
30
### Headings
@@ -18,12 +18,13 @@ A document is a sequence of **blocks**. Blank lines become paper feeds (`@feed 118
18
19
### Paragraphs19
### Paragraphs20
20
21
Plain text (and `${parameters}`). One or more consecutive non-empty lines form a paragraph. There is **no** inline bold/italic/code markup. Consecutive spaces are preserved (not collapsed) so authors can pad columns manually.21
Plain text (and `${parameters}`). One or more consecutive non-empty lines form a paragraph. There is **no** inline bold/italic/code markup. Consecutive spaces are preserved (not collapsed), including leading indentation, so authors can pad columns manually. Trailing spaces on a line are trimmed.22
22
23
```markdown23
```markdown24
Thank you for your purchase!24
Thank you for your purchase!25
Visit us again soon.25
Visit us again soon.26
Item 12.0026
Item 12.0027
rightish note27
```28
```28
29
29
### Headings30
### Headings@@ -47,7 +47,7 @@ A template is plain text: paragraphs, headings, lists, checkboxes, `${text}` / `
47
47
48
48
### Paragraphs
49
49
50
Consecutive non-empty lines form one paragraph. Multiple spaces in a row are kept (useful for manual column layout); they are not collapsed to one.
50
Consecutive non-empty lines form one paragraph. Multiple spaces in a row are kept (useful for manual column layout), including spaces at the start of a line. Trailing spaces on a line are ignored.
51
51
52
52
### Headings
53
53
@@ -47,7 +47,7 @@ A template is plain text: paragraphs, headings, lists, checkboxes, `${text}` / `47
47
48
### Paragraphs48
### Paragraphs49
49
50
Consecutive non-empty lines form one paragraph. Multiple spaces in a row are kept (useful for manual column layout); they are not collapsed to one.50
Consecutive non-empty lines form one paragraph. Multiple spaces in a row are kept (useful for manual column layout), including spaces at the start of a line. Trailing spaces on a line are ignored.51
51
52
### Headings52
### Headings53
53
@@ -1,6 +1,6 @@
1
1
# Maintainer: posprint contributors
2
2
pkgname=posprint
3
pkgver=0.3.0
3
pkgver=0.3.1
4
4
pkgrel=1
5
5
pkgdesc="Designer for POS-print documents with live preview and USB ESC/POS printing"
6
6
arch=('x86_64')
@@ -1,6 +1,6 @@1
# Maintainer: posprint contributors1
# Maintainer: posprint contributors2
pkgname=posprint2
pkgname=posprint3
pkgver=0.3.03
pkgver=0.3.14
pkgrel=14
pkgrel=15
pkgdesc="Designer for POS-print documents with live preview and USB ESC/POS printing"5
pkgdesc="Designer for POS-print documents with live preview and USB ESC/POS printing"6
arch=('x86_64')6
arch=('x86_64')@@ -281,22 +281,23 @@ fn parse_align_line(line: &str) -> Option<(Align, Option<&str>)> {
281
281
}
282
282
283
283
/// Split line content on embedded `:left:`, `:center:`, `:centre:`, or `:right:` markers.
284
/// Leading spaces in each segment are preserved (for manual indent); trailing spaces are trimmed.
284
285
fn split_aligned_segments(content: &str, start_align: Align) -> Vec<(Align, String)> {
285
286
let mut segments = Vec::new();
286
287
let mut align = start_align;
287
288
let mut rest = content;
288
289
289
290
while let Some((pos, new_align, marker_len)) = find_next_align_marker(rest) {
290
let before = rest[..pos].trim();
291
if !before.is_empty() {
291
let before = rest[..pos].trim_end();
292
if !before.trim().is_empty() {
292
293
segments.push((align, before.to_string()));
293
294
}
294
295
align = new_align;
295
296
rest = rest[pos + marker_len..].trim_start();
296
297
}
297
298
298
let tail = rest.trim();
299
if !tail.is_empty() {
299
let tail = rest.trim_end();
300
if !tail.trim().is_empty() {
300
301
segments.push((align, tail.to_string()));
301
302
}
302
303
segments
@@ -807,6 +808,24 @@ mod tests {
807
808
assert!(matches!(doc.blocks[1], Block::Paragraph { .. }));
808
809
}
809
810
811
#[test]
812
fn preserves_leading_spaces_in_paragraph() {
813
let doc = parse(" hoi").unwrap();
814
let Block::Paragraph { inlines, .. } = &doc.blocks[0] else {
815
panic!("expected paragraph");
816
};
817
assert_eq!(inlines_to_text(inlines), " hoi");
818
}
819
820
#[test]
821
fn trims_trailing_but_keeps_leading_spaces() {
822
let doc = parse(" hello ").unwrap();
823
let Block::Paragraph { inlines, .. } = &doc.blocks[0] else {
824
panic!("expected paragraph");
825
};
826
assert_eq!(inlines_to_text(inlines), " hello");
827
}
828
810
829
#[test]
811
830
fn parses_bullet_list() {
812
831
let doc = parse("- this\n- is then\n- a list").unwrap();
@@ -281,22 +281,23 @@ fn parse_align_line(line: &str) -> Option<(Align, Option<&str>)> {281
}
281
}
282
282
283
/// Split line content on embedded `:left:`, `:center:`, `:centre:`, or `:right:` markers.
283
/// Split line content on embedded `:left:`, `:center:`, `:centre:`, or `:right:` markers.
284
/// Leading spaces in each segment are preserved (for manual indent); trailing spaces are trimmed.
284
fn split_aligned_segments(content: &str, start_align: Align) -> Vec<(Align, String)> {
285
fn split_aligned_segments(content: &str, start_align: Align) -> Vec<(Align, String)> {
285
let mut segments = Vec::new();
286
let mut segments = Vec::new();
286
let mut align = start_align;
287
let mut align = start_align;
287
let mut rest = content;
288
let mut rest = content;
288
289
289
while let Some((pos, new_align, marker_len)) = find_next_align_marker(rest) {
290
while let Some((pos, new_align, marker_len)) = find_next_align_marker(rest) {
290
let before = rest[..pos].trim();
291
let before = rest[..pos].trim_end();
291
if !before.is_empty() {
292
if !before.trim().is_empty() {
292
segments.push((align, before.to_string()));
293
segments.push((align, before.to_string()));
293
}
294
}
294
align = new_align;
295
align = new_align;
295
rest = rest[pos + marker_len..].trim_start();
296
rest = rest[pos + marker_len..].trim_start();
296
}
297
}
297
298
298
let tail = rest.trim();
299
let tail = rest.trim_end();
299
if !tail.is_empty() {
300
if !tail.trim().is_empty() {
300
segments.push((align, tail.to_string()));
301
segments.push((align, tail.to_string()));
301
}
302
}
302
segments
303
segments
@@ -807,6 +808,24 @@ mod tests {807
assert!(matches!(doc.blocks[1], Block::Paragraph { .. }));
808
assert!(matches!(doc.blocks[1], Block::Paragraph { .. }));
808
}
809
}
809
810
811
#[test]
812
fn preserves_leading_spaces_in_paragraph() {
813
let doc = parse(" hoi").unwrap();
814
let Block::Paragraph { inlines, .. } = &doc.blocks[0] else {
815
panic!("expected paragraph");
816
};
817
assert_eq!(inlines_to_text(inlines), " hoi");
818
}
819
820
#[test]
821
fn trims_trailing_but_keeps_leading_spaces() {
822
let doc = parse(" hello ").unwrap();
823
let Block::Paragraph { inlines, .. } = &doc.blocks[0] else {
824
panic!("expected paragraph");
825
};
826
assert_eq!(inlines_to_text(inlines), " hello");
827
}
828
810
#[test]
829
#[test]
811
fn parses_bullet_list() {
830
fn parses_bullet_list() {
812
let doc = parse("- this\n- is then\n- a list").unwrap();
831
let doc = parse("- this\n- is then\n- a list").unwrap();