Description:
The askama indent filter does not apply the specified indentation (4 spaces) when the input string exceeds a certain length (e.g., 10,000 characters). Instead, the output string lacks the expected indentation.
Steps to Reproduce:
-
Create a project with the following Cargo.toml:
[package]
name = "indent-test"
version = "0.1.0"
edition = "2024"
[dependencies]
askama = { version = "0.14.0", features = ["code-in-doc"] }
-
Use the following lib.rs:
use askama::Template;
/// ~~~askama
/// {{ text | indent(4) }}
/// ~~~
#[derive(Template)]
#[template(ext = "txt", in_doc = true)]
pub struct IndentTest {
text: String,
}
pub fn run(limit: usize) {
let rendered = IndentTest {
text: format!("a\n{}", "b".repeat(limit - 2)),
}
.render()
.unwrap();
assert_eq!(&rendered[0..10], "a\n bbbb");
}
#[test]
fn test_9999() {
run(9999);
}
#[test]
fn test_10000() {
run(10000);
}
-
Run cargo test.
Expected Behavior:
The indent filter should prepend 4 spaces to each line after the first, regardless of input size. For test_10000, the first 10 characters of the rendered output should be "a\n bbbb".
Actual Behavior:
For inputs with 9,999 characters, the output is correct ("a\n bbbb"). For 10,000 characters, the indentation is missing, resulting in "a\nbbbbbbbb".
Environment:
- Rust edition: v1.86.0
- Askama version: 0.14.0
Description:
The
askamaindentfilter does not apply the specified indentation (4 spaces) when the input string exceeds a certain length (e.g., 10,000 characters). Instead, the output string lacks the expected indentation.Steps to Reproduce:
Create a project with the following
Cargo.toml:Use the following
lib.rs:Run
cargo test.Expected Behavior:
The
indentfilter should prepend 4 spaces to each line after the first, regardless of input size. Fortest_10000, the first 10 characters of the rendered output should be"a\n bbbb".Actual Behavior:
For inputs with 9,999 characters, the output is correct (
"a\n bbbb"). For 10,000 characters, the indentation is missing, resulting in"a\nbbbbbbbb".Environment: