@@ -80,22 +80,31 @@ impl<S: StyleTrait> Renderer<S> {
80
80
inline_marks,
81
81
line,
82
82
} => {
83
+ let style = & [ StyleType :: LineNo ] ;
83
84
if let Some ( lineno) = lineno {
84
85
S :: fmt (
85
86
w,
86
- format_args ! ( "{:>1$} " , lineno, lineno_max) ,
87
- & [ StyleType :: LineNo , StyleType :: Bold ] ,
87
+ format_args ! ( "{:>width$} | " , lineno, width = lineno_max) ,
88
+ style ,
88
89
) ?;
89
90
} else {
90
- write ! ( w, "{:>1$}" , "" , lineno_max) ?;
91
+ S :: fmt (
92
+ w,
93
+ format_args ! ( "{:>width$} | " , "" , width = lineno_max) ,
94
+ style,
95
+ ) ?;
91
96
}
92
- S :: fmt ( w, " | " , & [ StyleType :: LineNo , StyleType :: Bold ] ) ?;
93
- write ! ( w, "{:>1$}" , "" , inline_marks_width - inline_marks. len( ) ) ?;
97
+ write ! (
98
+ w,
99
+ "{:>width$}" ,
100
+ "" ,
101
+ width = inline_marks_width - inline_marks. len( )
102
+ ) ?;
94
103
for mark in inline_marks {
95
104
self . fmt_display_mark ( w, mark) ?;
96
105
}
97
106
self . fmt_source_line ( w, line) ?;
98
- write ! ( w, " \n " )
107
+ writeln ! ( w)
99
108
}
100
109
DisplayLine :: Raw ( l) => self . fmt_raw_line ( w, l, lineno_max) ,
101
110
}
@@ -110,15 +119,27 @@ impl<S: StyleTrait> Renderer<S> {
110
119
DisplaySourceLine :: Content { text } => write ! ( w, " {}" , text) ,
111
120
DisplaySourceLine :: Annotation { annotation, range } => {
112
121
let ( _, style) = self . get_annotation_type_style ( & annotation. annotation_type ) ;
113
- let styles = [ StyleType :: Bold , style] ;
122
+ let styles = [ StyleType :: Emphasis , style] ;
114
123
let indent = if range. start == 0 { 0 } else { range. start + 1 } ;
115
124
write ! ( w, "{:>1$}" , "" , indent) ?;
116
125
if range. start == 0 {
117
- S :: fmt ( w, format_args ! ( "{:_>1$} " , "^" , range. len( ) + 1 ) , & styles) ?;
126
+ S :: fmt (
127
+ w,
128
+ format_args ! (
129
+ "{:_>width$} {}" ,
130
+ "^" ,
131
+ annotation. label,
132
+ width = range. len( ) + 1
133
+ ) ,
134
+ & styles,
135
+ )
118
136
} else {
119
- S :: fmt ( w, format_args ! ( "{:->1$} " , "" , range. len( ) ) , & styles) ?;
137
+ S :: fmt (
138
+ w,
139
+ format_args ! ( "{:->width$} {}" , "" , annotation. label, width = range. len( ) ) ,
140
+ & styles,
141
+ )
120
142
}
121
- S :: fmt ( w, annotation. label , & styles)
122
143
}
123
144
DisplaySourceLine :: Empty => Ok ( ( ) ) ,
124
145
}
@@ -133,24 +154,24 @@ impl<S: StyleTrait> Renderer<S> {
133
154
match line {
134
155
DisplayRawLine :: Origin { path, pos } => {
135
156
write ! ( w, "{:>1$}" , "" , lineno_max) ?;
136
- S :: fmt ( w, "-->" , & [ StyleType :: Bold , StyleType :: LineNo ] ) ?;
157
+ S :: fmt ( w, "-->" , & [ StyleType :: Emphasis , StyleType :: LineNo ] ) ?;
137
158
write ! ( w, " {}" , path) ?;
138
159
if let Some ( line) = pos. 0 {
139
160
write ! ( w, ":{}" , line) ?;
140
161
}
141
- write ! ( w, " \n " )
162
+ writeln ! ( w)
142
163
}
143
164
DisplayRawLine :: Annotation { annotation, .. } => {
144
165
let ( desc, style) = self . get_annotation_type_style ( & annotation. annotation_type ) ;
145
- let s = [ StyleType :: Bold , style] ;
166
+ let s = [ StyleType :: Emphasis , style] ;
146
167
S :: fmt ( w, desc, & s) ?;
147
168
if let Some ( id) = annotation. id {
148
169
S :: fmt ( w, format_args ! ( "[{}]" , id) , & s) ?;
149
170
}
150
171
S :: fmt (
151
172
w,
152
173
format_args ! ( ": {}\n " , annotation. label) ,
153
- & [ StyleType :: Bold ] ,
174
+ & [ StyleType :: Emphasis ] ,
154
175
)
155
176
}
156
177
}
0 commit comments