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

Added markdown support for italics and bold #9

Merged
merged 6 commits into from
Sep 24, 2021

Conversation

gusmccallum
Copy link
Contributor

  • Created 2 new functions, italicize and boldify which will be applied to any lines containing either markdown symbols in a loop until all markdown is converted to HTML appropriately
  • Simplified a few lines with size_t checks to just check string.find results instead

@joshuali7536
Copy link
Owner

The changes look good, the only few things would be for the if statements at Line 167, I would wrap them in an if statement checking for fileType 2 instead of adding that into all the if statements, that way it is cleaner when more syntax is added. And you might be missing a != string::npos in that if statement, if my understanding is correct.

Also, the functionality where when first line is followed by two blank lines and it turns the first line into the title and header. I think this functionality should only happen when the file is a .txt file. So add an if statement that handles the title for both .txt and .md files.

- Removed extraneous logic from markdown check
- Removed title assign logic from .md
@joshuali7536
Copy link
Owner

The if statement at Line 134 needs fixing. It currently will skip the html if the file isn't a .txt, so .md will won't be a proper html file. You need to either place the if statement somewhere better to avoid this or add logic to fix this.

Also, what I meant by wrapping the if statements was to do:

if (filetype == 2){
    if (line.find("**") != string::npos || line.find("__") != string::npos){}

    if (line.find("*") != string::npos || line.find("_") != string::npos){}
}

Please update these if statements here.

@joshuali7536
Copy link
Owner

Almost what I wanted. Just fix the redundant if statement by merging them instead.
Merge this and this so it matches my previous example.

if (filetype == 2){
    if (line.find("**") != string::npos || line.find("__") != string::npos){
          line = boldify(line);
    }

    if (line.find("*") != string::npos || line.find("_") != string::npos){
          line = italicize(line);
    }
}

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.

None yet

2 participants