Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💄 style: fix numbered code blocks #437

Merged
merged 1 commit into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion content/blog/markdown/index.ca.md
Original file line number Diff line number Diff line change
@@ -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]
Expand Down Expand Up @@ -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}")`.
Expand Down
38 changes: 37 additions & 1 deletion content/blog/markdown/index.es.md
Original file line number Diff line number Diff line change
@@ -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]
Expand Down Expand Up @@ -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}")`.
Expand Down
38 changes: 37 additions & 1 deletion content/blog/markdown/index.md
Original file line number Diff line number Diff line change
@@ -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]
Expand Down Expand Up @@ -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}")`.
Expand Down
13 changes: 10 additions & 3 deletions sass/parts/_code.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand All @@ -62,7 +70,6 @@ pre {
padding: 0rem;
overflow-x: auto;
color: inherit;
font-size: 0.8rem; // Fits ~77 characters.
white-space: pre;

&::before {
Expand Down