feat(02-02): add code block borders with syntax highlighting and GFM table grid
- emit_code_block: ╭─ {lang} ─╮ / │ content │ / ╰──╯ rounded borders; lang label in Yellow; content via highlight_code()
- emit_table: ┌┬┐├┼┤└┴┘ full box-drawing grid; bold LightCyan header row; Left/Right/Center cell alignment
- Rename stub methods to emit_code_block_now / emit_table_now (clean naming; delegates to full emitters)
- Remove unused push_fg / push_fg_mod helper methods
- cargo check passes; 19 expected dead_code warnings (modules wired in Plan 03)
This commit is contained in:
+10
-20
@@ -92,18 +92,6 @@ impl RenderState {
|
|||||||
self.style_stack.push(new_style);
|
self.style_stack.push(new_style);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Push a completely new foreground-colored style.
|
|
||||||
fn push_fg(&mut self, color: Color) {
|
|
||||||
let new_style = Style::default().fg(color);
|
|
||||||
self.style_stack.push(new_style);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Push a new style with a foreground color and modifier.
|
|
||||||
fn push_fg_mod(&mut self, color: Color, modifier: Modifier) {
|
|
||||||
let new_style = Style::default().fg(color).add_modifier(modifier);
|
|
||||||
self.style_stack.push(new_style);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ── Line flushing ─────────────────────────────────────────────────────────
|
// ── Line flushing ─────────────────────────────────────────────────────────
|
||||||
|
|
||||||
/// Flush `current_spans` into a `Line`, optionally prepending blockquote borders.
|
/// Flush `current_spans` into a `Line`, optionally prepending blockquote borders.
|
||||||
@@ -184,20 +172,22 @@ impl RenderState {
|
|||||||
self.push_blank();
|
self.push_blank();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Code block stub ───────────────────────────────────────────────────────
|
// ── Code block emitter ────────────────────────────────────────────────────
|
||||||
// (will be replaced in Task 2 with full border + highlighting)
|
|
||||||
|
|
||||||
fn emit_code_block_stub(&mut self) {
|
/// Flush the accumulated code buffer and emit a bordered, syntax-highlighted
|
||||||
|
/// code block into `self.lines`.
|
||||||
|
fn emit_code_block_now(&mut self) {
|
||||||
let code = std::mem::take(&mut self.code_buf);
|
let code = std::mem::take(&mut self.code_buf);
|
||||||
let lang = std::mem::take(&mut self.code_lang);
|
let lang = std::mem::take(&mut self.code_lang);
|
||||||
let width = self.width;
|
let width = self.width;
|
||||||
emit_code_block(&code, &lang, width, &mut self.lines);
|
emit_code_block(&code, &lang, width, &mut self.lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Table stub ────────────────────────────────────────────────────────────
|
// ── Table emitter ─────────────────────────────────────────────────────────
|
||||||
// (will be replaced in Task 2 with full box-drawing grid)
|
|
||||||
|
|
||||||
fn emit_table_stub(&mut self) {
|
/// Flush the accumulated table rows and emit a full box-drawing grid table
|
||||||
|
/// into `self.lines`.
|
||||||
|
fn emit_table_now(&mut self) {
|
||||||
let alignments = std::mem::take(&mut self.table_alignments);
|
let alignments = std::mem::take(&mut self.table_alignments);
|
||||||
let rows = std::mem::take(&mut self.table_rows);
|
let rows = std::mem::take(&mut self.table_rows);
|
||||||
emit_table(&alignments, &rows, &mut self.lines);
|
emit_table(&alignments, &rows, &mut self.lines);
|
||||||
@@ -284,7 +274,7 @@ fn handle_event(state: &mut RenderState, event: Event) {
|
|||||||
}
|
}
|
||||||
Event::End(TagEnd::CodeBlock) => {
|
Event::End(TagEnd::CodeBlock) => {
|
||||||
state.in_code_block = false;
|
state.in_code_block = false;
|
||||||
state.emit_code_block_stub();
|
state.emit_code_block_now();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Lists ─────────────────────────────────────────────────────────────
|
// ── Lists ─────────────────────────────────────────────────────────────
|
||||||
@@ -388,7 +378,7 @@ fn handle_event(state: &mut RenderState, event: Event) {
|
|||||||
}
|
}
|
||||||
Event::End(TagEnd::Table) => {
|
Event::End(TagEnd::Table) => {
|
||||||
state.in_table = false;
|
state.in_table = false;
|
||||||
state.emit_table_stub();
|
state.emit_table_now();
|
||||||
}
|
}
|
||||||
Event::Start(Tag::TableHead) => {
|
Event::Start(Tag::TableHead) => {
|
||||||
state.in_table_head = true;
|
state.in_table_head = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user