fix merging
This commit is contained in:
+18
-3
@@ -219,7 +219,22 @@ fn to_markdown_from_lines_with_tables(
|
|||||||
for line in lines {
|
for line in lines {
|
||||||
// Page break
|
// Page break
|
||||||
if line.page != current_page {
|
if line.page != current_page {
|
||||||
|
// Before leaving the current page, insert any remaining tables for that page
|
||||||
if current_page > 0 {
|
if current_page > 0 {
|
||||||
|
if let Some(tables) = page_tables.get(¤t_page) {
|
||||||
|
for (idx, (_, table_md)) in tables.iter().enumerate() {
|
||||||
|
if !inserted_tables.contains(&(current_page, idx)) {
|
||||||
|
if in_paragraph {
|
||||||
|
output.push_str("\n\n");
|
||||||
|
in_paragraph = false;
|
||||||
|
}
|
||||||
|
output.push('\n');
|
||||||
|
output.push_str(table_md);
|
||||||
|
output.push('\n');
|
||||||
|
inserted_tables.insert((current_page, idx));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if in_paragraph {
|
if in_paragraph {
|
||||||
output.push_str("\n\n");
|
output.push_str("\n\n");
|
||||||
in_paragraph = false;
|
in_paragraph = false;
|
||||||
@@ -319,10 +334,10 @@ fn to_markdown_from_lines_with_tables(
|
|||||||
in_paragraph = true;
|
in_paragraph = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert any remaining tables at the end
|
// Insert any remaining tables for the last page
|
||||||
for (page, tables) in &page_tables {
|
if let Some(tables) = page_tables.get(¤t_page) {
|
||||||
for (idx, (_, table_md)) in tables.iter().enumerate() {
|
for (idx, (_, table_md)) in tables.iter().enumerate() {
|
||||||
if !inserted_tables.contains(&(*page, idx)) {
|
if !inserted_tables.contains(&(current_page, idx)) {
|
||||||
if in_paragraph {
|
if in_paragraph {
|
||||||
output.push_str("\n\n");
|
output.push_str("\n\n");
|
||||||
in_paragraph = false;
|
in_paragraph = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user