改进标题渲染:按层级差异化显示(字号/加粗/间距/对齐)
This commit is contained in:
@@ -65,10 +65,11 @@ pub fn strip_html(input: &str) -> String {
|
||||
// Emit text before the tag
|
||||
if tag_start > pos {
|
||||
let text = decode_entities(&input[pos..tag_start]);
|
||||
if heading_level.is_some() {
|
||||
out.push_str("\x01");
|
||||
if let Some(level) = heading_level {
|
||||
out.push('\x01');
|
||||
out.push(char::from_digit(level, 10).unwrap_or('1'));
|
||||
out.push_str(&text);
|
||||
out.push_str("\x02");
|
||||
out.push('\x02');
|
||||
} else {
|
||||
out.push_str(&text);
|
||||
}
|
||||
@@ -182,7 +183,7 @@ pub struct TocEntry {
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ContentBlock {
|
||||
pub text: String,
|
||||
pub is_heading: bool,
|
||||
pub heading_level: u8, // 0 = body, 1-6 = h1-h6
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
||||
Reference in New Issue
Block a user