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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

stri_wrap: add indent, exdent, initial, and prefix args #118

Closed
hadley opened this Issue Nov 26, 2014 · 2 comments

Comments

Projects
None yet
2 participants
@hadley

hadley commented Nov 26, 2014

These are pretty handy to have when wrapping strings.

(BTW I love that stri_wrap() implements Knuth's line wrapping algorithm 馃槃)

@gagolews

This comment has been minimized.

Show comment
Hide comment
@gagolews

gagolews Nov 26, 2014

Owner

Never found them useful, so I decided to postpone its implementation. Guess it's about time to finally get that done. :)

Owner

gagolews commented Nov 26, 2014

Never found them useful, so I decided to postpone its implementation. Guess it's about time to finally get that done. :)

@gagolews gagolews changed the title from Equivalent to indent and exdent for string wrapping? to stri_wrap: add indent and exdent args Nov 26, 2014

@gagolews gagolews added this to the stringi-0.4 milestone Nov 26, 2014

@gagolews gagolews changed the title from stri_wrap: add indent and exdent args to stri_wrap: add indent, exdent, initial, and prefix args Dec 5, 2014

@gagolews

This comment has been minimized.

Show comment
Hide comment
@gagolews

gagolews Dec 6, 2014

Owner

DONE:

s <- stri_paste(
   "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Proin ",
   "nibh augue, suscipit a, scelerisque sed, lacinia in, mi. Cras vel ",
   "lorem. Etiam pellentesque aliquet tellus.")
> cat(stri_wrap(c(s,s), 20, 2.0, indent=5, exdent=3, prefix="> ", initial="! "), sep="\n")
!      Lorem ipsum
>    dolor sit amet,
>    consectetur
>    adipisicing
>    elit. Proin
>    nibh augue,
>    suscipit a,
>    scelerisque
>    sed, lacinia
>    in, mi.
>    Cras vel
>    lorem. Etiam
>    pellentesque
>    aliquet tellus.
>      Lorem ipsum
>    dolor sit amet,
>    consectetur
>    adipisicing
>    elit. Proin
>    nibh augue,
>    suscipit a,
>    scelerisque
>    sed, lacinia
>    in, mi.
>    Cras vel
>    lorem. Etiam
>    pellentesque
>    aliquet tellus.
Owner

gagolews commented Dec 6, 2014

DONE:

s <- stri_paste(
   "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Proin ",
   "nibh augue, suscipit a, scelerisque sed, lacinia in, mi. Cras vel ",
   "lorem. Etiam pellentesque aliquet tellus.")
> cat(stri_wrap(c(s,s), 20, 2.0, indent=5, exdent=3, prefix="> ", initial="! "), sep="\n")
!      Lorem ipsum
>    dolor sit amet,
>    consectetur
>    adipisicing
>    elit. Proin
>    nibh augue,
>    suscipit a,
>    scelerisque
>    sed, lacinia
>    in, mi.
>    Cras vel
>    lorem. Etiam
>    pellentesque
>    aliquet tellus.
>      Lorem ipsum
>    dolor sit amet,
>    consectetur
>    adipisicing
>    elit. Proin
>    nibh augue,
>    suscipit a,
>    scelerisque
>    sed, lacinia
>    in, mi.
>    Cras vel
>    lorem. Etiam
>    pellentesque
>    aliquet tellus.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment