Przeglądaj źródła

Show line numbers on plaintext too

master
Dylan Baker 5 lat temu
rodzic
commit
66beaa59bb
1 zmienionych plików z 2 dodań i 2 usunięć
  1. 2
    2
      src/snippet.rs

+ 2
- 2
src/snippet.rs Wyświetl plik

28
 
28
 
29
 fn format_snippet(filetype: Option<String>, body: String) -> String {
29
 fn format_snippet(filetype: Option<String>, body: String) -> String {
30
     filetype.map_or(
30
     filetype.map_or(
31
-        format!("<pre class='plaintext'>{}</pre>", body),
31
+        format!("<pre class='plaintext'>\n{}\n</pre>", body),
32
         |filetype| {
32
         |filetype| {
33
             let ps = SyntaxSet::load_defaults_newlines();
33
             let ps = SyntaxSet::load_defaults_newlines();
34
             let ts = ThemeSet::load_defaults();
34
             let ts = ThemeSet::load_defaults();
35
             ps.find_syntax_by_extension(&filetype).map_or(
35
             ps.find_syntax_by_extension(&filetype).map_or(
36
-                format!("<pre class='plaintext'>{}</pre>", body),
36
+                format!("<pre class='plaintext'>\n{}\n</pre>", body),
37
                 |syntax| {
37
                 |syntax| {
38
                     highlighted_html_for_string(
38
                     highlighted_html_for_string(
39
                         &htmlescape::decode_html(&body).expect("Invalid HTML"),
39
                         &htmlescape::decode_html(&body).expect("Invalid HTML"),

Ładowanie…
Anuluj
Zapisz