Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/singond/crystal-poor
A poor man's rich text for Crystal
https://github.com/singond/crystal-poor
Last synced: 10 days ago
JSON representation
A poor man's rich text for Crystal
- Host: GitHub
- URL: https://github.com/singond/crystal-poor
- Owner: Singond
- License: mit
- Created: 2024-05-28T21:02:10.000Z (7 months ago)
- Default Branch: master
- Last Pushed: 2024-09-05T18:35:14.000Z (4 months ago)
- Last Synced: 2024-11-06T20:42:11.146Z (about 2 months ago)
- Language: Crystal
- Size: 42 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Poor: A poor man's rich text for Crystal
Poor is a library for producing basic formatted text from Crystal programs.
```
Poor is a Crystal library for producing formatted text programmatically. It
enables you to mark up text with formatting commands and render it into one
of the supported formats.This is a sample text produced with Poor. Features of the library include:
1. Wrapping text to specified width with optional margins. Line breaks only
occur at word boundaries, hyphenation is not implemented yet. This
example was set to wrap at 80 characters with a left and right margin of
2 characters.
2. Marking up paragraphs, ordered and unordered lists. This is an ordered
list in one paragraph with the preceding few sentences (starting with
“This is a sample”).
3. Text justification by widening existing whitespace. This example is
justified.
```The above exapmle was produced with the following source code:
```
lipsum = Poor.markup(
Poor.paragraph(<<-PAR),
Poor is a Crystal library for producing formatted text \
programmatically. \
It enables you to mark up text with formatting commands \
and render it into one of the supported formats.
PAR
Poor.paragraph(
"This is a sample text produced with Poor. ",
"Features of the library include:",
Poor.ordered_list(
Poor.item(<<-ITEM),
Wrapping text to specified width with optional margins. \
Line breaks only occur at word boundaries, \
hyphenation is not implemented yet. \
This example was set to wrap at 80 characters \
with a left and right margin of 2 characters.
ITEM
Poor.item(<<-ITEM),
Marking up paragraphs, ordered and unordered lists. \
This is an ordered list in one paragraph with the preceding \
few sentences (starting with “This is a sample”).
ITEM
Poor.item(<<-ITEM)
Text justification by widening existing whitespace. \
This example is justified.
ITEM
)
)
)
style = Poor::TerminalStyle.new
style.line_width = 80
style.left_margin = 2
style.right_margin = 2
style.justify = true
Poor.format(lipsum, style: style)
```## Installation
1. Add the dependency to your `shard.yml`:
```yaml
dependencies:
poor:
github: singond/crystal-poor
```2. Run `shards install`
## Usage
```crystal
require "poor"# Define text
text = Poor.markup("Hello ", "world");# Print it into terminal
Poor.format(text)
```## Contributing
1. Fork it ()
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request## Contributors
- [Jan Singon Slany](https://github.com/singond) - creator and maintainer