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

Add initial support for markdown files with italicization parser #10

Merged
merged 6 commits into from
Sep 23, 2022

Conversation

cychu42
Copy link
Contributor

@cychu42 cychu42 commented Sep 22, 2022

Overview

This pull request is meant to resolve #8.
The request adds support for markdown files, as well as parser for italicization from markdown input files.

Features

  • Adds support for markdown files conversion to html files.
    • Italicized text in input file will be reflected in the html output file
    • Updated README.md to reflect the support with examples

Code Changes

  • Added isMd boolean variable as flag for processing .md files
  • Added code to use isMd when a file has the .md extension, to process them correctly
  • Amended extension checking to include .md files for markdown file support
  • Changed one error message to include markdown file when user uses a single invalid file as input, to update the message for the new markdown support
  • Added code to wrap italicized markdown text (*text* or _text_) with <i> tag when writing output files, to support italicization in markdown files

@cychu42
Copy link
Contributor Author

cychu42 commented Sep 22, 2022

Oh, I forgot to revert the split condition back to "\n\r".

@cychu42
Copy link
Contributor Author

cychu42 commented Sep 23, 2022

OK. I reverted the split condition back to "\n\r". Let me know if you need anything else.

@alexsam29
Copy link
Owner

I have noticed one issue where it doesn't italicize paragraphs or or words with punctuation.

Paragraphs:
image
image

Punctuation:
image
image

@alexsam29
Copy link
Owner

alexsam29 commented Sep 23, 2022

The paragraph issue might be a bit of a challenge, so a new issue could be created for that.

However the punctuation issue is more within this scope.

Copy link
Owner

@alexsam29 alexsam29 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a bug where the parser is not italicizing text when there is punctuation after it.
Ex: _Silver Blaze?_

index.js line 121 and line 126 is the problem. Something seems to wrong with the regex where it's not catching punctuation.

Try these regex's:
/_(.*?)_/
/\*(.*?)\*/

@cychu42
Copy link
Contributor Author

cychu42 commented Sep 23, 2022

It seems the issue is the regex not catching certain special characters, so I ended up listing them manually, like: /_[—!@#$%^&()+;/<>.\s\w\d,?"“”-]+_/
There's no issue with entire paragraph, it's just certain special characters in a paragraph weren't caught in the previous version.
It should be fine now. If you can, let me know if there's an easier way to do this, instead of listing bunch of special characters.

sample input:
image

sample output:
image

@cychu42
Copy link
Contributor Author

cychu42 commented Sep 23, 2022

Oh, reverted split, again. Really have to remember it before I push.

Copy link
Owner

@alexsam29 alexsam29 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regex seems to work. The ideas I had to try and make it simpler didn't work, so this will do for now.

@alexsam29 alexsam29 merged commit ce60fd9 into alexsam29:main Sep 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

markdown parser support
2 participants