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

Implement Capitalization #118

Merged
merged 4 commits into from
Aug 25, 2021
Merged

Conversation

lepasq
Copy link
Contributor

@lepasq lepasq commented Aug 13, 2021

Fixes #100 (adds lower and upper case styling).

I used an example, in which h1 and h3 tags were wrongly capitalized. This produced the following output:
arrows

You can rerun the example, by running go run examples/capitalization/main.go and by making h1 upper case and h3 lower case by adding the following lines to styles.go:

2021-08-13_21-57

@lepasq
Copy link
Contributor Author

lepasq commented Aug 13, 2021

I realized that upper should make all letters upper case, not just the initial one.
This is what the output looks like now, using the same input text as before:
image

@muesli
Copy link
Contributor

muesli commented Aug 24, 2021

This looks nice, thank you! I imagine an option for using title case would also be appreciated. Could you also try and add a test-case for these styling options?

@lepasq
Copy link
Contributor Author

lepasq commented Aug 24, 2021

Sure, I'm going to work on that!

@lepasq
Copy link
Contributor Author

lepasq commented Aug 24, 2021

I got rid of the example file, since there now is a unit test for the capitalization options.
I wasn't sure if there is a way to assign a value to a nil-pointer without creating a new variable.
Therefore, I used the following workaround:

var s bool = true
var p *bool = &s

style := DarkStyleConfig
style.H1.Upper = p
style.H2.Title = p
style.H3.Lower = p

Is there a cleaner way to do this?

@muesli
Copy link
Contributor

muesli commented Aug 25, 2021

Is there a cleaner way to do this?

Only slightly, but still nicer to read:

b := true
style.H1.Upper = &b

@lepasq
Copy link
Contributor Author

lepasq commented Aug 25, 2021

Thanks! I updated that section in the code.

@muesli muesli merged commit e9eb518 into charmbracelet:master Aug 25, 2021
@muesli
Copy link
Contributor

muesli commented Aug 25, 2021

Thank you for your contribution! ❤️

@muesli muesli added the enhancement New feature or request label Aug 25, 2021
@lepasq lepasq deleted the capitalization-style branch August 25, 2021 14:03
@lepasq
Copy link
Contributor Author

lepasq commented Aug 25, 2021

You're welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add style to capitalize/lowercase text
2 participants