Commit 3c6954d
authored
Apply the ten code-review findings on the freshly-merged Markdown +
bulk export workflow. No new features; correctness and UI/UX only.
Converter (tsv_odf_converter.py):
- _MD_LINE_START_RE: require whitespace (or end of string) after the
digits-dot pattern so paragraphs starting with a decimal like
"1.5 million" or "2025.06 release" are no longer mangled to
"\1.5 million".
- _emit_kv: emit blank lines before and after so adjacent KV elements
no longer collapse into one CommonMark paragraph and the bolded key
stays visually distinct.
- _emit_paragraph: when DocElement.raw_lines preserved per-line breaks
(multi-line addresses, poetry), emit each line with a CommonMark
hard break (two trailing spaces) instead of collapsing into a single
run-on line.
Markdown export UI (conclusion_export_mixin.py):
- _export_markdown_file: write to "<path>.tmp" then os.replace so a
failed/cancelled conversion no longer destroys a pre-existing file
the user picked to overwrite via FileDialog.
- _on_md_save_response: guard against Gio.File.get_path() == None
(remote/MTP/GVfs locations) and surface a clear toast instead of an
AttributeError swallowed as a generic "Export failed".
- _on_md_export_clicked → _on_md_save_response → _export_markdown_file
→ _on_md_export_finished: pass include_front_matter and open_after
through the closure chain instead of self attributes, so overlapping
per-row exports can no longer clobber each other's settings.
- _on_folder_chosen (bulk): show _EXPORT_FAILED_MSG on non-Dismiss
errors so the user gets feedback instead of a silently-vanishing
dialog; also guards remote folders with the same toast as the
single-file path.
- _run_bulk_export / _bulk_convert_one: snapshot md_include_front_matter
and odf_include_images once at batch start and pass them via an
options dict, so a mid-batch toggle from another dialog can no longer
produce a non-uniform batch.
- _bulk_convert_one (md branch): write to "<path>.tmp" and os.replace,
matching the single-file atomic-write pattern.
- _bulk_export_worker: when fmt is not in _BULK_EXTENSIONS, close the
dialog and toast a real export-failed message instead of falling
back to a misleading "Saved 0 files".
- _build_progress_dialog: cancel handler now disables the button,
swaps its label and AT-SPI accessible name to "Cancelling…", and
rewrites the subtitle to "Finishing current step…". The progress
callback short-circuits after cancel so the message doesn't get
overwritten by late per-file updates. Gives the user immediate
feedback while parse_tsv_pages finishes its current step on a long
PDF.
Settings persistence (services/settings.py):
- Add _load_md_settings / _save_md_settings handling the
md_export.include_front_matter and md_export.open_after_export
config keys; hooked into load_settings / _save_all_settings.
- _update_md_setting (UI) now calls settings._save_md_settings()
before config.save() so the Markdown toggles actually persist
across restarts, matching the ODF flow.
Tests (test_markdown_export.py):
- TestEscapeMd.test_decimal_at_line_start_not_escaped: pins the new
decimal-aware behavior; "1." alone still escapes via the end-of-
string boundary.
- TestCreateMarkdown.test_kv_elements_separated_by_blank_line: pins
the new KV separator rule.
- TestCreateMarkdown.test_paragraph_preserves_raw_lines: pins the new
hard-break handling for multi-line OCR paragraphs.
- TestSaveMdSettings.{test_save_md_settings_writes_both_keys,
test_load_md_settings_reads_both_keys,
test_save_md_settings_defaults_when_unset}: cover the new persistence
path end-to-end with a minimal config double.
364 passing tests, ruff clean.
1 parent f5791e3 commit 3c6954d
4 files changed
Lines changed: 294 additions & 52 deletions
File tree
- src/bigocrpdf
- services
- ui
- utils
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
145 | 146 | | |
146 | 147 | | |
147 | 148 | | |
| |||
197 | 198 | | |
198 | 199 | | |
199 | 200 | | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
200 | 205 | | |
201 | 206 | | |
202 | 207 | | |
| |||
473 | 478 | | |
474 | 479 | | |
475 | 480 | | |
| 481 | + | |
476 | 482 | | |
477 | 483 | | |
478 | 484 | | |
| |||
536 | 542 | | |
537 | 543 | | |
538 | 544 | | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
539 | 557 | | |
540 | 558 | | |
541 | 559 | | |
| |||
641 | 659 | | |
642 | 660 | | |
643 | 661 | | |
644 | | - | |
645 | | - | |
646 | | - | |
647 | | - | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
648 | 668 | | |
649 | | - | |
650 | | - | |
651 | | - | |
652 | | - | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
653 | 675 | | |
654 | | - | |
655 | | - | |
656 | | - | |
657 | | - | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
658 | 682 | | |
659 | 683 | | |
660 | 684 | | |
| |||
0 commit comments