use crate::options::ListIndentType;
pub fn indent_table_for_list(
table_content: &str,
list_depth: usize,
options: &crate::options::ConversionOptions,
) -> String {
if list_depth == 0 {
return table_content.to_string();
}
let Some(mut indent) = continuation_indent_string(list_depth, options) else {
return table_content.to_string();
};
if matches!(options.list_indent_type, ListIndentType::Spaces) {
let space_count = indent.chars().filter(|c| *c == ' ').count();
if space_count < 4 {
for _ in 0..(4 - space_count) {
indent.push(' ');
}
}
}
let mut result = String::with_capacity(table_content.len() + indent.len() * 4);
for segment in table_content.split_inclusive('\n') {
if segment.starts_with('|') {
result.push_str(&indent);
result.push_str(segment);
} else {
result.push_str(segment);
}
}
result
}
fn continuation_indent_string(list_depth: usize, options: &crate::options::ConversionOptions) -> Option<String> {
use crate::converter::list::utils::continuation_indent_string;
continuation_indent_string(list_depth, options)
}