Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

output files missing text after first line of the original text #9

Open
cychu42 opened this issue Sep 21, 2022 · 7 comments
Open

output files missing text after first line of the original text #9

cychu42 opened this issue Sep 21, 2022 · 7 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@cychu42
Copy link

cychu42 commented Sep 21, 2022

Operating Environment

Operation System: Windows 10
Node version: v16.13.2

Issue

The tool generates output files that miss text after the title in the original input files.
html output example:
image

Original input file example:
image

Command-line message:
image

Expected Behaviour

The output html files should have

wrap around each line of text and include them inside the body

@cychu42
Copy link
Author

cychu42 commented Sep 21, 2022

Replicating the Issue

Also, what I did was that I entered "node ./bin/app -i ./testFiles" in the command-line, while inside the tool's directory.
I didn't used "ssg -i ./testFiles", because "ssg" is not recognized according to command-line message, which might be an OS issue according to another project partner I worked with.

@cychu42
Copy link
Author

cychu42 commented Sep 21, 2022

I found the issue.
The function HTMLcreate is splitting the content of txt files by "\n\r", which doesn't work for sentences end with just "\n", so nothing gets split and there's only one item at index 0 (using the Sherlock Holmes test files).
Because the code is told to ignore index 0 to avoid printing title twice, nothing gets printed, except the title that's already printed separately.
It can be easily fixed by changing "\n\r" to "\n" for var body = content.split("\n"), at least for the Sherlock Holmes test files.
image

Or we can use regualr expression, which I assume might be closer to what you want to do?
Example: var body = content.split(/[\n\r]/);
This should split by \n or \r.

@alexsam29
Copy link
Owner

alexsam29 commented Sep 21, 2022

Still unable to replicate the issue. Keeping \n\r outputs the correct result on my end.
image

Removing \r from the split function changes the output to a less readable version:
image
New output (\n) on the left, current (\n\r) output on the right.

@cychu42
Copy link
Author

cychu42 commented Sep 21, 2022

What if we use/[\n\r]\n/?
It produces the desired version on my end. Does it do so correctly on yours?
My result:
image

@alexsam29
Copy link
Owner

Using /[\n\r][\n]/ I do not get expected output. It still looks like the left side picture of my previous comment.

Also all text appears to be one line in the HTML file, with no separation between tags:
image

@cychu42
Copy link
Author

cychu42 commented Sep 21, 2022

Hmmm, I wonder if this is related to return characters for our OSs.
What OS do you have?

I managed to produce the more readable version with just "\n\n" for my machine, and I'm thinking we can try OR for this, so maybe try "\n\n" || "\n\r". It supposed to use left(mine) or right(yours) depending on which one the user has, and this works for me.

@alexsam29
Copy link
Owner

I am on Windows 11 with nodejs version 16.13.

When I use "\n\n" || "\n\r" I get a blank file with only the title in the body. Similar to your original issue.
image

At this point I'm not sure what the issue could be.

@alexsam29 alexsam29 added bug Something isn't working help wanted Extra attention is needed labels Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants