Skip to content

Commit

Permalink
Add configuration option to disable the default hidelines feature for…
Browse files Browse the repository at this point in the history
… rust
  • Loading branch information
zgtm committed Jan 3, 2025
1 parent 0bf6751 commit 9b4cf94
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,13 +697,24 @@ impl Default for Playground {
}

/// Configuration for tweaking how the HTML renderer handles code blocks.
#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "kebab-case")]
pub struct Code {
/// Enable or disable the default line hiding with '#' for rust. Default: `true`.
pub default_hidelines: bool,
/// A prefix string to hide lines per language (one or more chars).
pub hidelines: HashMap<String, String>,
}

impl Default for Code {
fn default() -> Code {
Code {
default_hidelines: true,
hidelines: HashMap::<String, String>::default(),
}
}
}

/// Configuration of the search functionality of the HTML renderer.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "kebab-case")]
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/html_handlebars/hbs_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ fn hide_lines(html: &str, code_config: &Code) -> String {
let classes = &caps[2];
let code = &caps[3];

if classes.contains("language-rust") {
if classes.contains("language-rust") && code_config.default_hidelines {
format!(
"<code class=\"{}\">{}</code>",
classes,
Expand Down

0 comments on commit 9b4cf94

Please sign in to comment.