Skip to main content

wrap_table_html_with_content

Function wrap_table_html_with_content 

Source
pub fn wrap_table_html_with_content(
    tokens: &[String],
    cell_texts: &[Option<String>],
) -> String
Expand description

Wraps table structure tokens into an HTML string with cell content filled in.

This follows standard HTML result logic:

  • When encountering <td></td> or </td>, insert the corresponding cell text
  • Cell texts are matched in order (td_index)

§Arguments

  • tokens - Structure tokens from table structure recognition
  • cell_texts - Cell texts to fill, in order of <td> appearance

§Example

use oar_ocr_core::processors::wrap_table_html_with_content;

let tokens = vec![
    "<tr>".to_string(),
    "<td></td>".to_string(),
    "<td></td>".to_string(),
    "</tr>".to_string()
];
let cell_texts = vec![Some("Cell 1".to_string()), Some("Cell 2".to_string())];
let html = wrap_table_html_with_content(&tokens, &cell_texts);
assert!(html.contains("Cell 1"));
assert!(html.contains("Cell 2"));