-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a38c999
commit 215f72e
Showing
5 changed files
with
63 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,56 @@ | ||
pub fn is_ignored(line: &str) -> bool { | ||
line.ends_with("%tex-fmt-ignore-line") | ||
pub struct Ignore { | ||
skip: bool, | ||
block: bool, | ||
} | ||
|
||
impl Ignore { | ||
pub fn new() -> Self { | ||
Ignore { | ||
skip: false, | ||
block: false, | ||
} | ||
} | ||
} | ||
|
||
pub fn get_ignore(line: &str, prev_ignore: Ignore) -> Ignore { | ||
let skip = contains_ignore_skip(line); | ||
let start = contains_ignore_start(line); | ||
let end = contains_ignore_end(line); | ||
let mut block = prev_ignore.block; | ||
|
||
if !prev_ignore.block { | ||
// not currently in ignore block | ||
if start { | ||
block = true | ||
} | ||
if end { | ||
// TODO ERROR | ||
} | ||
} else { | ||
// currently in ignore block | ||
if start { | ||
// TODO ERROR | ||
} | ||
if end { | ||
block = false | ||
} | ||
} | ||
|
||
Ignore { skip, block } | ||
} | ||
|
||
pub fn is_ignored(ignore: &Ignore) -> bool { | ||
ignore.skip || ignore.block | ||
} | ||
|
||
fn contains_ignore_skip(line: &str) -> bool { | ||
line.ends_with("% tex-fmt: skip") | ||
} | ||
|
||
fn contains_ignore_start(line: &str) -> bool { | ||
line.ends_with("% tex-fmt: off") | ||
} | ||
|
||
fn contains_ignore_end(line: &str) -> bool { | ||
line.ends_with("% tex-fmt: on") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters