summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThang Pham <phamducthang1234@gmail.com>2021-07-15 20:52:43 +0900
committerThang Pham <phamducthang1234@gmail.com>2021-07-15 20:52:43 +0900
commit4296da5fbef86fddd0fa30615b3f4c6780e9f798 (patch)
treeaa109fc029d7f2d2ed2a6530e01a7a6fa9897d59
parentf8db976585eb541ff4ad46719b5a697a2134ed15 (diff)
replace `\t` by 4 spaces when rendering in `article_view`
-rw-r--r--hackernews_tui/src/view/article_view.rs18
1 files changed, 10 insertions, 8 deletions
diff --git a/hackernews_tui/src/view/article_view.rs b/hackernews_tui/src/view/article_view.rs
index e7af8c2..5ca16e0 100644
--- a/hackernews_tui/src/view/article_view.rs
+++ b/hackernews_tui/src/view/article_view.rs
@@ -30,19 +30,21 @@ impl Article {
}
impl Article {
+ fn get_content(&self) -> String {
+ let content = self.content.replace("\t", " ");
+ if get_config().allow_unicode {
+ content
+ } else {
+ content.chars().filter(|c| allow_unicode_char(c)).collect()
+ }
+ }
+
/// parse links from the article's content (in markdown format)
pub fn parse_link(&self, raw_md: bool) -> (StyledString, Vec<String>) {
// escape characters in markdown: \ ` * _ { } [ ] ( ) # + - . ! =
let md_escape_char_re = Regex::new(r"\\(?P<char>[\\`\*_\{\}\[\]\(\)#\+\-\.!=])").unwrap();
- let content = if get_config().allow_unicode {
- self.content.clone()
- } else {
- self.content
- .chars()
- .filter(|c| allow_unicode_char(c))
- .collect()
- };
+ let content = self.get_content();
// if raw_md is true, don't parse link
if raw_md {