{"id":13395009,"url":"https://github.com/dejan/auto_html","last_synced_at":"2025-05-13T20:22:08.949Z","repository":{"id":471767,"uuid":"96776","full_name":"dejan/auto_html","owner":"dejan","description":"Collection of filters that transform plain text into HTML code.","archived":false,"fork":false,"pushed_at":"2025-03-10T22:41:24.000Z","size":501,"stargazers_count":798,"open_issues_count":3,"forks_count":185,"subscribers_count":26,"default_branch":"master","last_synced_at":"2025-04-28T11:57:17.517Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://autohtml.makeme.tools","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dejan.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2008-12-26T00:30:13.000Z","updated_at":"2025-04-18T04:27:52.000Z","dependencies_parsed_at":"2024-12-24T12:08:53.365Z","dependency_job_id":"a2a31aff-d5d6-4b03-9ca5-deb38e13a972","html_url":"https://github.com/dejan/auto_html","commit_stats":{"total_commits":400,"total_committers":52,"mean_commits":"7.6923076923076925","dds":0.275,"last_synced_commit":"efef32d3a9b1568cd10233fde01f446fb4ec1bbe"},"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dejan%2Fauto_html","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dejan%2Fauto_html/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dejan%2Fauto_html/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dejan%2Fauto_html/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dejan","download_url":"https://codeload.github.com/dejan/auto_html/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253843215,"owners_count":21972873,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T17:01:39.028Z","updated_at":"2025-05-13T20:22:08.924Z","avatar_url":"https://github.com/dejan.png","language":"Ruby","readme":"# AutoHtml\n\nAutoHtml is a collection of filters that transforms plain text into HTML code. See [live demo](https://autohtml.makeme.tools).\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'auto_html'\n```\n\nAnd then execute:\n\n```sh\n$ bundle\n```\n\nOr install it yourself as:\n\n```sh\n$ gem install auto_html\n```\n\n## Abstract\n\nAutoHtml uses concepts found in \"Pipes and Filters\" processing design pattern:\n\n* `Filter` - transforms an input. In AutoHtml context, this is any object that does the transformation through `#call(String)` method. Filter options should be passed in initializer. AutoHtml provides some filters already, ie Link, Image, Markdown, etc.\n* `Pipeline` - a composition of filters that transforms input by passing the output of one filter as input for the next filter in line. In AutoHtml context, this is the `AutoHtml::Pipeline` class. Since the same interface (method `#call`) is used to pass input, we can say that Pipeline is just another Filter, which means it can be used as a building block for other Pipelines, in a mix with other filters.\n\n## Examples\n\n```ruby\nlink_filter = AutoHtml::Link.new(target: '_blank')\nlink_filter.call('Checkout out auto_html: https://github.com/dejan/auto_html')\n# =\u003e 'Checkout out my blog: \u003ca target=\"blank\" href=\"https://github.com/dejan/auto_html\"\u003ehttps://github.com/dejan/auto_html\u003c/a\u003e'\n\nemoji_filter = AutoHtml::Emoji.new\nemoji_filter.call(':point_left: yo!')\n# =\u003e '\u003cimg src=\"/images/emoji/unicode/1f448.png\" class=\"emoji\" title=\":point_left:\" alt=\":point_left:\" height=\"20\" witdh=\"20\" align=\"absmiddle\" /\u003e yo!'\n\n# Use Pipeline to combine filters\nbase_format = AutoHtml::Pipeline.new(link_filter, emoji_filter)\nbase_format.call('Checkout out auto_html: https://github.com/dejan/auto_html :point_left: yo!')\n# =\u003e 'Checkout out my blog: \u003ca href=\"https://github.com/dejan/auto_html\"\u003ehttps://github.com/dejan/auto_html\u003c/a\u003e \u003cimg src=\"/images/emoji/unicode/1f448.png\" class=\"emoji\" title=\":point_left:\" alt=\":point_left:\" height=\"20\" witdh=\"20\" align=\"absmiddle\" /\u003e yo!'\n\n# A pipeline can be reused in another pipeline. Note that the order of filters is important - ie you want\n# `Image` before `Link` filter so that URL of the image gets transformed to `img` tag and not `a` tag.\ncomment_format = AutoHtml::Pipeline.new(AutoHtml::Markdown.new, AutoHtml::Image.new, base_format)\ncomment_format.call(\"Hello!\\n\\n Checkout out auto_html: https://github.com/dejan/auto_html :point_left: yo! \\n\\n http://gifs.joelglovier.com/boom/booyah.gif\")\n# =\u003e \"\u003cp\u003eHello!\u003c/p\u003e\\n\\n\u003cp\u003eCheckout out my blog: \u003ca href=\"\u003cimg src=\"https://github.com/dejan/auto_html\" target=\"_blank\"\u003ehttps://github.com/dejan/auto_html\u003c/a\u003e \u003cimg src=\"/images/emoji/unicode/1f448.png\" /\u003e\" class=\"emoji\" title=\":point_left:\" alt=\":point_left:\" height=\"20\" witdh=\"20\" align=\"absmiddle\" /\u003e yo! \u003c/p\u003e\\n\\n\u003cp\u003e\u003ca href=\"\u003cimg src=\"http://gifs.joelglovier.com/boom/booyah.gif\" /\u003e\" target=\"_blank\"\u003e\u003cimg src=\"http://gifs.joelglovier.com/boom/booyah.gif\" /\u003e\u003c/a\u003e\u003c/p\u003e\\n\"\n```\n\n## Bundled filters\n\nBellow is the list of bundled filters along with their optional arguments on initialization and their default values.\n\n* `AutoHtml::Emoji`\n* `AutoHtml::HtmlEscape`\n* `AutoHtml::Image`, proxy: nil, alt: nil\n* `AutoHtml::Link`, target: nil, rel: nil\n* `AutoHtml::Markdown`\n* `AutoHtml::SimpleFormat`\n\n## Using AutoHtml with ActiveRecord\n\nFor performance reasons it's a good idea to store the formated output in the database, in a separate column, to avoid generating the same content on each access.\nThis can be acomplished simply by overriding the attribute writter:\n\n```ruby\nclass Comment \u003c ActiveRecord::Base\n  FORMAT = AutoHtml::Pipeline.new(\n    AutoHtml::HtmlEscape.new,\n    AutoHtml::Markdown.new\n  )\n\n  def text=(t)\n    super(t)\n    self[:text_html] = FORMAT.call(t)\n  end\nend\n```\n\nNow, every time `text` attribute is set, `text_html` will be set as well:\n\n```Ruby\ncomment = Comment.new(text: 'Hey!')\ncomment.text_html # =\u003e '\u003cp\u003eHey!\u003c/p\u003e'\n```\n\n## Development\n\n### Install dependencies\n\n```sh\nbundle install\n```\n\n### Run Rubocop\n\n```sh\nrake rubocop\n```\n\n### Run tests\n\n```sh\nrake spec\n```\n\n## Licence\n\nAutoHtml is released under the [MIT License](https://raw.githubusercontent.com/dejan/auto_html/master/MIT-LICENSE).\n","funding_links":[],"categories":["Ruby","WebSocket","View helpers","Misc"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdejan%2Fauto_html","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdejan%2Fauto_html","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdejan%2Fauto_html/lists"}