Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/phlex-ruby/phlex-markdown
https://github.com/phlex-ruby/phlex-markdown
markdown phlex ruby
Last synced: 4 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/phlex-ruby/phlex-markdown
- Owner: phlex-ruby
- License: mit
- Created: 2022-11-17T10:22:51.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-13T05:18:41.000Z (8 months ago)
- Last Synced: 2024-10-31T13:58:01.478Z (16 days ago)
- Topics: markdown, phlex, ruby
- Language: Ruby
- Homepage:
- Size: 22.5 KB
- Stars: 23
- Watchers: 2
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# `phlex-markdown`
`Phlex::Markdown` is a [Phlex](https://phlex.fun) view that renders Markdown into HTML using Phlex. You could use it directly — it takes a String of markdown and renders it to safe HTML.
Alternatively, you can define a sub-class and override various methods to customise the output.
For example, here we override `h1` and `ul`, adding some Tailwind classes to them.
```ruby
class MyMarkdown < Phlex::Markdown
def h1 = super(class: "font-bold text-xl")
def ul = super(class: "ml-4 pt-2")
end
```When we render the view.
```ruby
content = <<~MD
# Hello World- A
- B
- C
MDoutput = MyMarkdown.new(content).call
```The `output` will use the attributes from our methods.
```html
Hello World
- A
- B
- C
```
You could also wrap the whole document in an `` element by overriding `template`.
```ruby
class MyMarkdownArticle < Phlex::Markdown
def template
article(class: "prose") { super }
end
end
```
### Community 🙌
Everyone interacting in Phlex codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/joeldrapper/phlex/blob/main/CODE_OF_CONDUCT.md).
### Sponsorship 💖
Maintaining a library is a lot of work. If your company benefits from this work or is likely to benefit from it in the future, please consider [sponsorship](https://github.com/sponsors/joeldrapper). Phlex is actively developed and maintained by **[Joel Drapper](https://github.com/sponsors/joeldrapper)**.
### Security 🚨
If you’ve found a potential security issue, please email [[email protected]](mailto:[email protected]).