Skip to content

Commit

Permalink
fixed tab issues, improved escapeinside behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
TomLebeda committed Nov 4, 2023
1 parent b59d98c commit 1ebd1a6
Show file tree
Hide file tree
Showing 17 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/target
.vimproject
sample_latex_project
builder_script.sh
Empty file modified Cargo.lock
100644 → 100755
Empty file.
Empty file modified Cargo.toml
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified examples/config-example.json
100644 → 100755
Empty file.
Empty file modified examples/example_full.pdf
100644 → 100755
Empty file.
Empty file modified examples/example_julia.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified examples/example_rust.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified examples/highlights-json.scm
100644 → 100755
Empty file.
Empty file modified examples/highlights-julia.scm
100644 → 100755
Empty file.
Empty file modified examples/highlights-python.scm
100644 → 100755
Empty file.
Empty file modified examples/highlights-rust.scm
100644 → 100755
Empty file.
Empty file modified readme.md
100644 → 100755
Empty file.
4 changes: 3 additions & 1 deletion src/formatter.rs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ impl HighlightedText {
.replace('{', "\\{")
.replace("\\textbackslash", "\\textbackslash{}") // now add the empty braces to break the command without escaping them
.replace(' ', "\\ ")
.replace('\t', "\\ ".repeat(conf.tab_size).as_str())
.replace('_', "\\_")
.replace('^', " \\^") // the space in front is necessary otherwise it would add hat to letters
.replace('&', "\\&")
Expand Down Expand Up @@ -70,7 +71,8 @@ pub fn generate_latex_verbatim(
captionpos=b, % put the caption at the bottom (b) or top (t) or both (bt)
label={lst:CHANGE ME}, % label to be referenced via \ref{}
numbers=left, % line numbers on the left
numberstyle={\scriptsize\ttfamily\color{black!60}} % the style for line numbers
numberstyle={\scriptsize\ttfamily\color{black!60}}, % the style for line numbers
escapeinside={<@}{@>} % between those sequences are command evaluated
]";
let footer = r"\end{lstlisting}";
let mut buffer = "".to_string();
Expand Down
6 changes: 5 additions & 1 deletion src/main.rs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::path::Path;
#[derive(Parser)]
#[command(
author = "Tomáš Lebeda <[email protected]>",
version = "1.0.0",
version = "1.0.1",
about = "Generate LaTeX for highlighted code listings with the power of TreeSitter."
)]
pub struct CliArgs {
Expand All @@ -34,6 +34,10 @@ pub struct CliArgs {
#[arg(long, default_value_t = String::from("@>"))]
pub escape_end: String,

/// Tab size as a number of spaces
#[arg(long, default_value_t = 4)]
pub tab_size: usize,

/// If enabled, the output will not be wrapped by verbatim environment, it will be only the "raw insides".
#[arg(short, long)]
pub raw: bool,
Expand Down
Empty file modified src/parser.rs
100644 → 100755
Empty file.
Empty file modified src/validator.rs
100644 → 100755
Empty file.

0 comments on commit 1ebd1a6

Please sign in to comment.