Skip to content

Commit 260f078

Browse files
committed
Format comments in fenced code block
1 parent f45597a commit 260f078

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/syntax/src/formatter.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -693,20 +693,25 @@ window.addEventListener("scroll", () => {{
693693

694694
pub fn fenced_mech_code(&mut self, node: &Vec<(MechCode, Option<Comment>)>, interpreter_id: &u64) -> String {
695695
self.interpreter_id = *interpreter_id;
696-
let mut src = "".to_string();
696+
let mut src = String::new();
697697
for (code,cmmnt) in node {
698698
let c = match code {
699+
MechCode::Comment(cmnt) => self.comment(cmnt),
699700
MechCode::Expression(expr) => self.expression(expr),
701+
//MechCode::FsmSpecification(fsm_spec) => self.fsm_specification(fsm_spec),
702+
//MechCode::FsmImplementation(fsm_impl) => self.fsm_implementation(fsm_impl),
703+
//MechCode::FunctionDefine(func_def) => self.function_define(func_def),
700704
MechCode::Statement(stmt) => self.statement(stmt),
701-
MechCode::FsmSpecification(fsm_spec) => self.fsm_specification(fsm_spec),
702-
MechCode::FsmImplementation(fsm_impl) => self.fsm_implementation(fsm_impl),
703-
MechCode::Comment(cmnt) => self.comment(cmnt),
704705
_ => todo!(),
705706
};
707+
let formatted_comment = match cmmnt {
708+
Some(cmmt) => self.comment(cmmt),
709+
None => String::new(),
710+
};
706711
if self.html {
707-
src.push_str(&format!("<div class=\"mech-code\">{}</div>", c));
712+
src.push_str(&format!("<span class=\"mech-code\">{}{}</span>", c, formatted_comment));
708713
} else {
709-
src.push_str(&format!("{}\n", c));
714+
src.push_str(&format!("{}{}\n", c, formatted_comment));
710715
}
711716
}
712717
self.interpreter_id = 0;

0 commit comments

Comments
 (0)