Add Code Files

Author

Shafayet Khan Shafee

Published

February 11, 2023

Note: View the source code of this document by clicking </> Code on top-right corner.

filename

Using filename does not align properly with code-folding.

fizz-buzz.rs
Code
fn main() {
    for number in 1..101 {
        if number % 3 == 0 && number % 5 == 0 {
            println!("FizzBuzz");
        } else if number % 3 == 0 {
            println!("Fizz");
        } else if number % 5 == 0 {
            println!("Buzz");
        } else {
            println!("{}", number);
        }
    }
}

code-filename

Instead we can use code-filename attribute.

Code
#!/usr/bin/julia

for i = 1:100
    str = i % 3 == 0 ? "Fizz" : ""
    str *= i % 5 == 0 ? "Buzz" : ""
    if isempty(str)
        str = i
    end
    println(str)
end

Therefore, use code-filename only when using code-fold: true, otherwise use filename (for non HTML format or for html format without code-fold: true).