From 2078a094f46996a474f62cb5600864ebde52f027 Mon Sep 17 00:00:00 2001 From: RumovZ Date: Fri, 12 Mar 2021 20:31:23 +0100 Subject: [PATCH 1/2] Fix formatting of invalid regex error Preserve whitespace, special characters and use monospace font. --- rslib/src/err.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rslib/src/err.rs b/rslib/src/err.rs index 0849adb59..b0d24ebce 100644 --- a/rslib/src/err.rs +++ b/rslib/src/err.rs @@ -158,7 +158,7 @@ impl AnkiError { SearchErrorKind::InvalidPropOperator(ctx) => i18n .trn(TR::SearchInvalidPropOperator, tr_strs!["val"=>(ctx)]) .into(), - SearchErrorKind::Regex(text) => text.into(), + SearchErrorKind::Regex(text) => format!("
`{}`
", text.replace('`', "'")).into(), SearchErrorKind::Other(Some(info)) => info.into(), SearchErrorKind::Other(None) => i18n.tr(TR::SearchInvalidOther), SearchErrorKind::InvalidNumber { provided, context } => i18n From e033f21767b09b4aa9af5431ee3ab103b2cca853 Mon Sep 17 00:00:00 2001 From: RumovZ Date: Fri, 12 Mar 2021 20:32:38 +0100 Subject: [PATCH 2/2] Fix markdown escaping in search errors --- rslib/src/err.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/rslib/src/err.rs b/rslib/src/err.rs index b0d24ebce..9e46dae15 100644 --- a/rslib/src/err.rs +++ b/rslib/src/err.rs @@ -139,20 +139,20 @@ impl AnkiError { SearchErrorKind::UnknownEscape(ctx) => i18n .trn( TR::SearchUnknownEscape, - tr_strs!["val"=>(htmlescape::encode_minimal(ctx))], + tr_strs!["val"=>(ctx.replace('`', "'"))], ) .into(), SearchErrorKind::InvalidState(state) => i18n .trn( TR::SearchInvalidArgument, - tr_strs!("term" => "is:", "argument" => state), + tr_strs!("term" => "is:", "argument" => state.replace('`', "'")), ) .into(), SearchErrorKind::InvalidFlag => i18n.tr(TR::SearchInvalidFlag), SearchErrorKind::InvalidPropProperty(prop) => i18n .trn( TR::SearchInvalidArgument, - tr_strs!("term" => "prop:", "argument" => prop), + tr_strs!("term" => "prop:", "argument" => prop.replace('`', "'")), ) .into(), SearchErrorKind::InvalidPropOperator(ctx) => i18n @@ -164,31 +164,31 @@ impl AnkiError { SearchErrorKind::InvalidNumber { provided, context } => i18n .trn( TR::SearchInvalidNumber, - tr_strs!["provided"=>provided, "context"=>context], + tr_strs!["provided"=>provided.replace('`', "'"), "context"=>context.replace('`', "'")], ) .into(), SearchErrorKind::InvalidWholeNumber { provided, context } => i18n .trn( TR::SearchInvalidWholeNumber, - tr_strs!["provided"=>provided, "context"=>context], + tr_strs!["provided"=>provided.replace('`', "'"), "context"=>context.replace('`', "'")], ) .into(), SearchErrorKind::InvalidPositiveWholeNumber { provided, context } => i18n .trn( TR::SearchInvalidPositiveWholeNumber, - tr_strs!["provided"=>provided, "context"=>context], + tr_strs!["provided"=>provided.replace('`', "'"), "context"=>context.replace('`', "'")], ) .into(), SearchErrorKind::InvalidNegativeWholeNumber { provided, context } => i18n .trn( TR::SearchInvalidNegativeWholeNumber, - tr_strs!["provided"=>provided, "context"=>context], + tr_strs!["provided"=>provided.replace('`', "'"), "context"=>context.replace('`', "'")], ) .into(), SearchErrorKind::InvalidAnswerButton { provided, context } => i18n .trn( TR::SearchInvalidAnswerButton, - tr_strs!["provided"=>provided, "context"=>context], + tr_strs!["provided"=>provided.replace('`', "'"), "context"=>context.replace('`', "'")], ) .into(), };