mirror of
https://github.com/sharkdp/bat.git
synced 2026-02-08 00:32:08 +00:00
Move the strip_overstrike check
This commit is contained in:
@@ -263,34 +263,34 @@ impl<'a> InteractivePrinter<'a> {
|
|||||||
|| matches!(config.binary, BinaryBehavior::AsText))
|
|| matches!(config.binary, BinaryBehavior::AsText))
|
||||||
&& (config.colored_output || config.strip_ansi == StripAnsiMode::Auto);
|
&& (config.colored_output || config.strip_ansi == StripAnsiMode::Auto);
|
||||||
|
|
||||||
let (is_plain_text, highlighter_from_set, syntax_name) = if needs_to_match_syntax {
|
let (is_plain_text, strip_overstrike, highlighter_from_set) = if needs_to_match_syntax {
|
||||||
// Determine the type of syntax for highlighting
|
// Determine the type of syntax for highlighting
|
||||||
const PLAIN_TEXT_SYNTAX: &str = "Plain Text";
|
const PLAIN_TEXT_SYNTAX: &str = "Plain Text";
|
||||||
|
const MANPAGE_SYNTAX: &str = "Manpage";
|
||||||
|
const COMMAND_HELP_SYNTAX: &str = "Command Help";
|
||||||
match assets.get_syntax(config.language, input, &config.syntax_mapping) {
|
match assets.get_syntax(config.language, input, &config.syntax_mapping) {
|
||||||
Ok(syntax_in_set) => {
|
Ok(syntax_in_set) => (
|
||||||
let syntax_name = syntax_in_set.syntax.name.as_str();
|
syntax_in_set.syntax.name == PLAIN_TEXT_SYNTAX,
|
||||||
(
|
syntax_in_set.syntax.name == MANPAGE_SYNTAX
|
||||||
syntax_name == PLAIN_TEXT_SYNTAX,
|
|| syntax_in_set.syntax.name == COMMAND_HELP_SYNTAX,
|
||||||
Some(HighlighterFromSet::new(syntax_in_set, theme)),
|
Some(HighlighterFromSet::new(syntax_in_set, theme)),
|
||||||
syntax_name,
|
),
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
Err(Error::UndetectedSyntax(_)) => (
|
Err(Error::UndetectedSyntax(_)) => (
|
||||||
true,
|
true,
|
||||||
|
false,
|
||||||
Some(
|
Some(
|
||||||
assets
|
assets
|
||||||
.find_syntax_by_name(PLAIN_TEXT_SYNTAX)?
|
.find_syntax_by_name(PLAIN_TEXT_SYNTAX)?
|
||||||
.map(|s| HighlighterFromSet::new(s, theme))
|
.map(|s| HighlighterFromSet::new(s, theme))
|
||||||
.expect("A plain text syntax is available"),
|
.expect("A plain text syntax is available"),
|
||||||
),
|
),
|
||||||
PLAIN_TEXT_SYNTAX,
|
|
||||||
),
|
),
|
||||||
|
|
||||||
Err(e) => return Err(e),
|
Err(e) => return Err(e),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
(false, None, "")
|
(false, false, None)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Determine when to strip ANSI sequences
|
// Determine when to strip ANSI sequences
|
||||||
@@ -302,9 +302,6 @@ impl<'a> InteractivePrinter<'a> {
|
|||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Strip overstrike for man pages and help messages.
|
|
||||||
let strip_overstrike = matches!(syntax_name, "Manpage" | "Command Help");
|
|
||||||
|
|
||||||
Ok(InteractivePrinter {
|
Ok(InteractivePrinter {
|
||||||
panel_width,
|
panel_width,
|
||||||
colors,
|
colors,
|
||||||
|
|||||||
Reference in New Issue
Block a user