https://github.com/lorenzwalthert/stylermd
Make markdown or plain text fit 80 characters. Or any limit you want.
https://github.com/lorenzwalthert/stylermd
formatting line-width styler
Last synced: about 1 year ago
JSON representation
Make markdown or plain text fit 80 characters. Or any limit you want.
- Host: GitHub
- URL: https://github.com/lorenzwalthert/stylermd
- Owner: lorenzwalthert
- Archived: true
- Created: 2017-07-06T10:38:04.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2019-04-04T07:32:53.000Z (about 7 years ago)
- Last Synced: 2025-03-12T21:31:50.209Z (over 1 year ago)
- Topics: formatting, line-width, styler
- Language: R
- Homepage:
- Size: 97.7 KB
- Stars: 21
- Watchers: 2
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.Rmd
Awesome Lists containing this project
README
---
output: github_document
---
# Style your markdown
[](https://www.tidyverse.org/lifecycle/#experimental)
[](https://travis-ci.org/lorenzwalthert/stylermd)
[](https://ci.appveyor.com/project/lorenzwalthert/stylermd)
> Just keep up one rule: 80 characters per line. I promise it will take 80% of
your time. -- Lorenz Walthert
The main motivation for creating this package was because when working with
bookdown / blogdown or Rmarkdown in general, I spent **way too much time** just
keeping up the 80 character width rule as every word you add or remove in a
paragraph affects all subsequent lines.
**Functionality**
This package is similar to styler, but it styles non-code elements and files and
it does really just one thing: Making every line at most 80 characters, or a
custom line width you can set with the option `stylermd.line_width`, i.e.
`options(stylermd.line_width = 60)`. It supports:
* Both adding and removing line breaks for float text, nested enumerations and
bullet lists.
* Files with and without code chunks (any extension).
* Ignoring code chunks and latex equations.
* Files with YAML Header.
* Preserves paragraphs.
You can install it from GitHub:
```{r, eval = FALSE}
remotes::install_github("lorenzwalthert/stylermd")
```
**API**
You can use:
* `tidy_text()`.
* `tidy_file()`.
* the RStudio Addins (restarting RStudio after installation). One styles the
highlighted text, the other styles the active file, remembering the cursor
position. Set the environment variable `save_after_styling` to `TRUE`, for
example in your `.Rprofile` to enable saving after styling. Hint: Assign a
keyboard short-cut for the Addin with *Menu -> Tools -> Modify Keyboard
Shortcuts* for most productive use.
**Example**
```{r, comment = ""}
library(magrittr)
text <- "1. introduced above. We do this by first creating a style guide with the designated wrapper function `create_style_guide()`. It takes transformer"
stylermd::tidy_text(text) %>%
cat(sep = "\n")
```