Skip to content

Commit

Permalink
Modify readme
Browse files Browse the repository at this point in the history
Signed-off-by: Maharshi Basu <[email protected]>
  • Loading branch information
MashyBasker committed Jun 22, 2024
1 parent f2cab6e commit 0dedcc5
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 39 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# TXTPlus

An effort to make `.txt` files a bit more beautiful without a lot of work.
An effort to make `.txt` files a bit more beautiful without a lot of work.

<div style="display: flex; justify-content: center;">
<img src="media/source.png" alt="source" style="width: 500px; height: 400px; margin-right: 0px;">
<img src="media/render.png" alt="render" style="width: 500px; height: 400px; margin-left: 0px;">
</div>
Binary file added media/render.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/source.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ mod textbox;
mod utils;

fn main() -> std::io::Result<()> {
let srcfile = "./testdata/input/test.txt";
let srcfile = "./testdata/mock/test.txt";
parser::parse_and_render(&srcfile)?;
Ok(())
}
21 changes: 10 additions & 11 deletions src/textbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ Long sentences will be broken down into multiple line,
*/

use std::{fs::OpenOptions, iter::repeat};
use std::io::Write;
use std::{fs::OpenOptions, iter::repeat};

use regex::Regex;

Expand Down Expand Up @@ -96,7 +96,8 @@ fn box_to_file(fpath: &String, textboxes: Vec<String>) -> std::io::Result<()> {

let mut f = OpenOptions::new().append(true).open(fpath)?;
for i in 0..max_len {
let line = split_boxes.iter()
let line = split_boxes
.iter()
.map(|bxline| {
if i < bxline.len() {
bxline[i].clone()
Expand All @@ -109,18 +110,18 @@ fn box_to_file(fpath: &String, textboxes: Vec<String>) -> std::io::Result<()> {
writeln!(f, "{}", line)?;
}
Ok(())

}

fn newline_string(strings: Vec<&str>) -> Vec<String> {
strings.into_iter()
strings
.into_iter()
.map(|s| {
s.split_whitespace()
.collect::<Vec<&str>>()
.chunks(3)
.map(|chunk| chunk.join(" "))
.collect::<Vec<String>>()
.join("\n")
.collect::<Vec<&str>>()
.chunks(3)
.map(|chunk| chunk.join(" "))
.collect::<Vec<String>>()
.join("\n")
})
.collect::<Vec<String>>()
}
Expand All @@ -133,8 +134,6 @@ fn draw_texbox(file: &String, cmd_line: &String) -> std::io::Result<()> {
Ok(())
}



#[allow(unused)]
pub fn render_box(file: &String, directive_cmd: &mut Vec<String>) {
// println!("{:?}", directive_cmd);
Expand Down
27 changes: 11 additions & 16 deletions testdata/mock/test.plus.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
Hello this is a test
This is a test

+-------+ +-------+ +------+
| Hello | | World | | Good |
+-------+ +-------+ +------+
+-------+ +-------+
| Hello | | World |
+-------+ +-------+

The lines
Still keep
Long sentences will be broken down

Continuing

Oh No!! Another DIRECTIVE

+-----+ +-----+ +----------------------+
| hey | | man | | An idiot admires |
+-----+ +-----+ | complexity, a genius |
| admires simplicity |
+----------------------+
+----------------------+
| And idiot admires |
| complexity, a genius |
| admires simplicity |
+----------------------+
+-------------+
| Another one |
| Terry Davis |
+-------------+
16 changes: 6 additions & 10 deletions testdata/mock/test.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
Hello this is a test
This is a test

@@start::box

[Hello] [World] [Good] bro
[Hello] [World]

@@end::box

The lines
Still keep

Continuing

Oh No!! Another DIRECTIVE
Long sentences will be broken down

@@start::box

[hey] [man] [An idiot admires complexity, a genius admires simplicity]
[Another one]
[And idiot admires complexity, a genius admires simplicity]

[Terry Davis]

@@end::box

0 comments on commit 0dedcc5

Please sign in to comment.