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

Improvements/additions to Subtitle Line parsing #32

Merged
merged 6 commits into from
Jul 19, 2021

Conversation

GrumpyBear57
Copy link
Contributor

@GrumpyBear57 GrumpyBear57 commented Jul 9, 2021

This PR will include several changes:

  • Add a blurb to the readme about the writers (totally forgot to do that in the last PR -- sorry!)
  • Resolve the TODO for splitting SSA/ASS dialogue lines on newline chars (\n and/or \N, depending on the wrap style) into multiple items in the SubtitleItem.Lines list.
  • Add a 'plaintext lines' property to SubtitleItem which will strip off any formatting/styles from the string in the file. As with my previous PR, this will likely be limited to only a subset of the available formats (SSA and SRT), as I'm not familiar and don't require the others.

I wanted to open the PR now in case you don't want to include the last feature in the library. It'll likely be another couple days before I finish that, so if you do want to include it, maybe just drop a comment so I know I'm good to push it to the PR when I'm done. If you don't want to include it, go ahead and handle this PR right away.

/// <returns>A SsaWrapStyle corresponding to the value parsed from the input string</returns>
public static SsaWrapStyle FromString(this string rawString) =>
int.TryParse(rawString, out int rawInt) == false ?
SsaWrapStyle.None: // basically an arbitrary choice, could also throw an exception here instead
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just wanted to draw your attention to this, as I'm not sure what you'd prefer the library do when it fails to parse the value. If you'd rather have it throw an exception, I can change it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm also looking at this again and realizing the == false is redundant since it's a ternary operator instead of the if statement I originally had...

Will leave it unless you want it changed, or if I go in there anyways to change to throwing an exception.

Copy link
Owner

Choose a reason for hiding this comment

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

Indeed, the two options have their pros and cons.
You can leave it like this for the moment. I can't quite get cases where things could go wrong but if I have some in the future, I'll consider if the other option (throwing an exception) is more adapted.

@AlexPoint
Copy link
Owner

Thanks for PR.
I'll definitely include it when you're done so feel free to notify when you're good to go.

Currently only SSA and SRT remove formatting/styles
(which are actually removed from beginning of the following line)
@GrumpyBear57
Copy link
Contributor Author

This should be good for you to take a look at and merge now.

@AlexPoint AlexPoint merged commit b364500 into AlexPoint:master Jul 19, 2021
@AlexPoint
Copy link
Owner

It's merged! Thanks for your contribution and our discussion.

@GrumpyBear57 GrumpyBear57 deleted the subtitle-lines branch July 19, 2021 23:13
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.

2 participants