@@ -133,13 +133,15 @@ impl Renderer {
133
133
write ! ( w, r#" <span class="source">{}</span>"# , text)
134
134
}
135
135
DisplaySourceLine :: Annotation { annotation, range } => {
136
+ let desc = self . get_annotation_type_style ( & annotation. annotation_type ) ;
136
137
let indent = if range. start == 0 { 0 } else { range. start + 1 } ;
137
138
write ! ( w, "{:>width$}" , "" , width = indent) ?;
138
139
let horizontal_mark = MarkKind :: get ( MarkKind :: Horizontal ) ;
139
140
if range. start == 0 {
140
141
write ! (
141
142
w,
142
- "{}{} {}" ,
143
+ r#"<span class="{}">{}{} {}</span>"# ,
144
+ desc,
143
145
repeat( horizontal_mark)
144
146
. take( range. len( ) )
145
147
. collect:: <String >( ) ,
@@ -149,7 +151,8 @@ impl Renderer {
149
151
} else {
150
152
write ! (
151
153
w,
152
- "{} {}" ,
154
+ r#"<span class="{}">{} {}</span>"# ,
155
+ desc,
153
156
repeat( horizontal_mark)
154
157
. take( range. len( ) )
155
158
. collect:: <String >( ) ,
@@ -171,33 +174,25 @@ impl Renderer {
171
174
match line {
172
175
DisplayRawLine :: Origin { path, pos } => {
173
176
write ! ( w, "{:>width$}" , "" , width = lineno_max) ?;
174
- //S::fmt(
175
- //w,
176
- //format_args!(
177
- //"{}{}>",
178
- //MarkKind::get(MarkKind::Horizontal),
179
- //MarkKind::get(MarkKind::Horizontal),
180
- //),
181
- //&[StyleType::Emphasis, StyleType::LineNo],
182
- //)?;
183
- //write!(w, " {}", path)?;
184
- //if let Some(line) = pos.0 {
185
- //write!(w, ":{}", line)?;
186
- //}
177
+ write ! (
178
+ w,
179
+ r#"<span class="ui">{}{}></span>"# ,
180
+ MarkKind :: get( MarkKind :: Horizontal ) ,
181
+ MarkKind :: get( MarkKind :: Horizontal ) ,
182
+ ) ?;
183
+ write ! ( w, " {}" , path) ?;
184
+ if let Some ( line) = pos. 0 {
185
+ write ! ( w, ":{}" , line) ?;
186
+ }
187
187
writeln ! ( w)
188
188
}
189
189
DisplayRawLine :: Annotation { annotation, .. } => {
190
190
let desc = self . get_annotation_type_style ( & annotation. annotation_type ) ;
191
- //let s = [StyleType::Emphasis, style];
192
- //S::fmt(w, desc, &s)?;
193
- //if let Some(id) = annotation.id {
194
- //S::fmt(w, format_args!("[{}]", id), &s)?;
195
- //}
196
- //S::fmt(
197
- //w,
198
- //format_args!(": {}\n", annotation.label),
199
- //&[StyleType::Emphasis],
200
- //)
191
+ write ! ( w, r#"<span class="title"><span class="{}">{}"# , desc, desc) ?;
192
+ if let Some ( id) = annotation. id {
193
+ write ! ( w, "[{}]" , id) ?;
194
+ }
195
+ write ! ( w, "</span>: {}</span>\n " , annotation. label) ?;
201
196
Ok ( ( ) )
202
197
}
203
198
}
@@ -219,20 +214,25 @@ impl Renderer {
219
214
w : & mut impl std:: io:: Write ,
220
215
display_mark : & DisplayMark ,
221
216
) -> std:: io:: Result < ( ) > {
217
+ let desc = self . get_annotation_type_style ( & display_mark. annotation_type ) ;
222
218
let ch = match display_mark. mark_type {
223
219
DisplayMarkType :: AnnotationStart => MarkKind :: get ( MarkKind :: DownRight ) ,
224
220
DisplayMarkType :: AnnotationEnd => MarkKind :: get ( MarkKind :: UpRight ) ,
225
221
DisplayMarkType :: AnnotationThrough => MarkKind :: get ( MarkKind :: Vertical ) ,
226
222
} ;
227
- write ! ( w, " {}", ch) ?;
223
+ write ! ( w, r#"<span class=" {}">{}</span>"# , desc , ch) ?;
228
224
Ok ( ( ) )
229
225
}
230
226
231
227
fn fmt_header ( & self , w : & mut impl std:: io:: Write ) -> std:: io:: Result < ( ) > {
232
228
writeln ! ( w, "<html><head><style>" ) ?;
233
- writeln ! ( w, r#".lineno {{ color: red ; }}"# ) ?;
229
+ writeln ! ( w, r#".lineno {{ color: blue ; }}"# ) ?;
234
230
writeln ! ( w, r#".line {{ color: blue; }}"# ) ?;
231
+ writeln ! ( w, r#".ui {{ color: blue; }}"# ) ?;
235
232
writeln ! ( w, r#".source {{ color: gray; }}"# ) ?;
233
+ writeln ! ( w, r#".error {{ color: red; }}"# ) ?;
234
+ writeln ! ( w, r#".warning {{ color: yellow; }}"# ) ?;
235
+ writeln ! ( w, r#".title {{ font-weight: bold; }}"# ) ?;
236
236
write ! ( w, "</style></head><body><pre>" )
237
237
}
238
238
0 commit comments