diff --git a/content/blog/markdown/index.ca.md b/content/blog/markdown/index.ca.md index 27ad9174e..cbebb54e8 100644 --- a/content/blog/markdown/index.ca.md +++ b/content/blog/markdown/index.ca.md @@ -1,7 +1,7 @@ +++ title = "Exemples de Markdown" date = 2023-01-31 -updated = 2023-09-01 +updated = 2024-11-23 description = "Aquesta publicació mostra alguns exemples de format en Markdown, incloent-hi una taula, blocs de codi i etiquetes, citacions, taules i notes a peu de pàgina." [taxonomies] @@ -59,6 +59,42 @@ fn main() { } ``` +### Amb numeració de línies + +```rust,linenos +use std::collections::HashMap; + +#[derive(Debug)] +struct TwinPeaksCharacter { + name: String, + coffee_rating: f32, + pie_preference: String, +} + +fn main() { + let mut black_lodge = HashMap::new(); + + black_lodge.insert("agent", TwinPeaksCharacter { + name: String::from("Dale Cooper"), + coffee_rating: 9999.99, + pie_preference: String::from("Damn Fine Cherry"), + }); + + black_lodge.insert("giant", TwinPeaksCharacter { + name: String::from("The Fireman"), + coffee_rating: 42.424242, + pie_preference: String::from("Garmonbozia"), + }); + + // Calculate total appreciation of damn fine coffee + let total_coffee: f32 = black_lodge.values() + .map(|character| character.coffee_rating) + .sum(); + + println!("☕ Total coffee appreciation: {:.2} cups", total_coffee); +} +``` + ## Etiquetes de codi A Rust, declares una variable mutable amb `let mut x = 5;`, mentre que a Python, simplement fas `x = 5`. De manera similar, per imprimir un valor a Rust, utilitzaries `println!("Valor: {}", x);`, però a Python, és tan senzill com `print(f"Valor: {x}")`. diff --git a/content/blog/markdown/index.es.md b/content/blog/markdown/index.es.md index 6c6718f65..200bc7284 100644 --- a/content/blog/markdown/index.es.md +++ b/content/blog/markdown/index.es.md @@ -1,7 +1,7 @@ +++ title = "Ejemplos de Markdown" date = 2023-01-31 -updated = 2023-09-01 +updated = 2024-11-23 description = "Esta publicación muestra algunos ejemplos de formato Markdown, incluyendo una tabla, bloques de código y etiquetas, citas, tablas y notas al pie de página." [taxonomies] @@ -59,6 +59,42 @@ fn main() { } ``` +### Con números de línea + +```rust,linenos +use std::collections::HashMap; + +#[derive(Debug)] +struct TwinPeaksCharacter { + name: String, + coffee_rating: f32, + pie_preference: String, +} + +fn main() { + let mut black_lodge = HashMap::new(); + + black_lodge.insert("agent", TwinPeaksCharacter { + name: String::from("Dale Cooper"), + coffee_rating: 9999.99, + pie_preference: String::from("Damn Fine Cherry"), + }); + + black_lodge.insert("giant", TwinPeaksCharacter { + name: String::from("The Fireman"), + coffee_rating: 42.424242, + pie_preference: String::from("Garmonbozia"), + }); + + // Calculate total appreciation of damn fine coffee + let total_coffee: f32 = black_lodge.values() + .map(|character| character.coffee_rating) + .sum(); + + println!("☕ Total coffee appreciation: {:.2} cups", total_coffee); +} +``` + ## Etiquetas de código En Rust, declaras una variable mutable con `let mut x = 5;`, mientras que en Python, simplemente usas `x = 5`. De manera similar, para imprimir un valor en Rust, utilizarías `println!("Valor: {}", x);`, pero en Python, es tan sencillo como `print(f"Valor: {x}")`. diff --git a/content/blog/markdown/index.md b/content/blog/markdown/index.md index ab825d97f..39366f4d9 100644 --- a/content/blog/markdown/index.md +++ b/content/blog/markdown/index.md @@ -1,7 +1,7 @@ +++ title = "Markdown examples" date = 2023-01-31 -updated = 2023-09-01 +updated = 2024-11-23 description = "This post showcases some examples of Markdown formatting, including a table, code blocks and tags, quotes, tables, and footnotes." [taxonomies] @@ -59,6 +59,42 @@ fn main() { } ``` +### With line numbers + +```rust,linenos +use std::collections::HashMap; + +#[derive(Debug)] +struct TwinPeaksCharacter { + name: String, + coffee_rating: f32, + pie_preference: String, +} + +fn main() { + let mut black_lodge = HashMap::new(); + + black_lodge.insert("agent", TwinPeaksCharacter { + name: String::from("Dale Cooper"), + coffee_rating: 9999.99, + pie_preference: String::from("Damn Fine Cherry"), + }); + + black_lodge.insert("giant", TwinPeaksCharacter { + name: String::from("The Fireman"), + coffee_rating: 42.424242, + pie_preference: String::from("Garmonbozia"), + }); + + // Calculate total appreciation of damn fine coffee + let total_coffee: f32 = black_lodge.values() + .map(|character| character.coffee_rating) + .sum(); + + println!("☕ Total coffee appreciation: {:.2} cups", total_coffee); +} +``` + ## Code tags In Rust, you declare a mutable variable with `let mut x = 5;`, whereas in Python, you simply use `x = 5`. Similarly, to print a value in Rust, you would use `println!("Value: {}", x);`, but in Python, it's as straightforward as `print(f"Value: {x}")`. diff --git a/sass/parts/_code.scss b/sass/parts/_code.scss index 1d090ceab..9bc57d1bf 100644 --- a/sass/parts/_code.scss +++ b/sass/parts/_code.scss @@ -27,10 +27,13 @@ code { padding: 0rem; } + // Line number col. tbody td:first-child { - width: 2rem; + opacity: 50%; + padding-inline-end: 0.8rem; + width: 0rem; user-select: none; - text-align: start; + text-align: end; } tbody tr:nth-child(even) { @@ -54,6 +57,11 @@ pre { overflow-x: auto; line-height: 1.4; + code, + code td { + font-size: 0.8rem; // Fits ~77 characters. + } + code { display: block; border: 0rem; @@ -62,7 +70,6 @@ pre { padding: 0rem; overflow-x: auto; color: inherit; - font-size: 0.8rem; // Fits ~77 characters. white-space: pre; &::before {