Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit231cf08

Browse files
committed
Finish HTML POC
1 parente438656 commit231cf08

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

‎src/renderers/ascii_default/mod.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ impl<S: StyleTrait> Renderer<S> {
126126
let styles =[StyleType::Emphasis, style];
127127
let indent =if range.start ==0{0}else{ range.start +1};
128128
write!(w,"{:>width$}","", width = indent)?;
129+
let horizontal_mark =MarkKind::get(MarkKind::Horizontal);
129130
if range.start ==0{
130-
let horizontal_mark =MarkKind::get(MarkKind::Horizontal);
131131
S::fmt(
132132
w,
133133
format_args!(
@@ -191,7 +191,7 @@ impl<S: StyleTrait> Renderer<S> {
191191
}
192192
S::fmt(
193193
w,
194-
format_args!(":{}\n", annotation.label),
194+
format_args!(": {}\n", annotation.label),
195195
&[StyleType::Emphasis],
196196
)
197197
}

‎src/renderers/html/mod.rs‎

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,15 @@ impl Renderer {
133133
write!(w,r#" <span class="source">{}</span>"#, text)
134134
}
135135
DisplaySourceLine::Annotation{ annotation, range} =>{
136+
let desc =self.get_annotation_type_style(&annotation.annotation_type);
136137
let indent =if range.start ==0{0}else{ range.start +1};
137138
write!(w,"{:>width$}","", width = indent)?;
138139
let horizontal_mark =MarkKind::get(MarkKind::Horizontal);
139140
if range.start ==0{
140141
write!(
141142
w,
142-
"{}{} {}",
143+
r#"<span class="{}">{}{} {}</span>"#,
144+
desc,
143145
repeat(horizontal_mark)
144146
.take(range.len())
145147
.collect::<String>(),
@@ -149,7 +151,8 @@ impl Renderer {
149151
}else{
150152
write!(
151153
w,
152-
"{} {}",
154+
r#"<span class="{}">{} {}</span>"#,
155+
desc,
153156
repeat(horizontal_mark)
154157
.take(range.len())
155158
.collect::<String>(),
@@ -171,33 +174,25 @@ impl Renderer {
171174
match line{
172175
DisplayRawLine::Origin{ path, pos} =>{
173176
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+
ifletSome(line) = pos.0{
185+
write!(w,":{}", line)?;
186+
}
187187
writeln!(w)
188188
}
189189
DisplayRawLine::Annotation{ annotation, ..} =>{
190190
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+
ifletSome(id) = annotation.id{
193+
write!(w,"[{}]", id)?;
194+
}
195+
write!(w,"</span>: {}</span>\n", annotation.label)?;
201196
Ok(())
202197
}
203198
}
@@ -219,20 +214,25 @@ impl Renderer {
219214
w:&mutimpl std::io::Write,
220215
display_mark:&DisplayMark,
221216
) -> std::io::Result<()>{
217+
let desc =self.get_annotation_type_style(&display_mark.annotation_type);
222218
let ch =match display_mark.mark_type{
223219
DisplayMarkType::AnnotationStart =>MarkKind::get(MarkKind::DownRight),
224220
DisplayMarkType::AnnotationEnd =>MarkKind::get(MarkKind::UpRight),
225221
DisplayMarkType::AnnotationThrough =>MarkKind::get(MarkKind::Vertical),
226222
};
227-
write!(w,"{}", ch)?;
223+
write!(w,r#"<span>{}</span>"#, desc, ch)?;
228224
Ok(())
229225
}
230226

231227
fnfmt_header(&self,w:&mutimpl std::io::Write) -> std::io::Result<()>{
232228
writeln!(w,"<html><head><style>")?;
233-
writeln!(w,r#".lineno {{ color:red; }}"#)?;
229+
writeln!(w,r#".lineno {{ color:blue; }}"#)?;
234230
writeln!(w,r#".line {{ color: blue; }}"#)?;
231+
writeln!(w,r#".ui {{ color: blue; }}"#)?;
235232
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; }}"#)?;
236236
write!(w,"</style></head><body><pre>")
237237
}
238238

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp