{"id":20315244,"url":"https://github.com/sysread/html-untidy","last_synced_at":"2026-02-02T01:02:54.438Z","repository":{"id":56831761,"uuid":"106869358","full_name":"sysread/HTML-Untidy","owner":"sysread","description":"Yet another way to write HTML quickly and programmatically in perl","archived":false,"fork":false,"pushed_at":"2017-10-27T18:25:11.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-11T12:59:38.144Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Perl 6","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sysread.png","metadata":{"files":{"readme":"README.pod","changelog":"Changes","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-13T20:16:51.000Z","updated_at":"2017-10-13T20:20:36.000Z","dependencies_parsed_at":"2022-08-28T21:02:37.439Z","dependency_job_id":null,"html_url":"https://github.com/sysread/HTML-Untidy","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/sysread/HTML-Untidy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysread%2FHTML-Untidy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysread%2FHTML-Untidy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysread%2FHTML-Untidy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysread%2FHTML-Untidy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sysread","download_url":"https://codeload.github.com/sysread/HTML-Untidy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysread%2FHTML-Untidy/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260452734,"owners_count":23011540,"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-11-14T18:18:29.119Z","updated_at":"2026-02-02T01:02:54.395Z","avatar_url":"https://github.com/sysread.png","language":"Perl 6","funding_links":[],"categories":[],"sub_categories":[],"readme":"=pod\n\n=encoding UTF-8\n\n=head1 NAME\n\nHTML::Untidy - yet another way to write HTML quickly and programmatically\n\n=head1 VERSION\n\nversion 0.02\n\n=head1 SYNOPSIS\n\n  use HTML::Untidy;\n\n  sub bootstrap4_modal {\n    my ($content, $indent) = @_;\n\n    # Set number of spaces to indent\n    local $HTML::Untidy::INDENT = $indent || 0;\n\n    div {\n      class 'modal';\n\n      div {\n        class 'modal-dialog';\n\n        div {\n          class 'modal-header';\n          h5 { class 'modal-title'; text 'Modal title' };\n          button { class 'close'; attr 'type' =\u003e 'button', 'data-dismiss' =\u003e 'modal'; raw '\u0026times;'; };\n        };\n\n        div { class 'modal-body'; raw $content; };\n\n        div {\n          class 'modal-footer';\n          button { class 'btn btn-primary'; attr 'type' =\u003e 'button'; text 'Save changes'; };\n          button { class 'btn btn-secondary'; attr 'type' =\u003e 'button', 'data-dismiss' =\u003e 'modal'; text 'Close'; };\n        };\n      };\n    };\n  }\n\n  my $modal = bootstrap4_modal('Here is my modal!', 2);\n\n  # Resulting string:\n  #\n  # \u003cdiv class=\"modal\"\u003e\n  #   \u003cdiv class=\"modal-dialog\"\u003e\n  #     \u003cdiv class=\"modal-header\"\u003e\n  #       \u003ch5 class=\"modal-title\"\u003e\n  #         Modal title\n  #       \u003c/h5\u003e\n  #       \u003cbutton class=\"close\" type=\"button\" data-dismiss=\"modal\"\u003e\n  #         \u0026times;\n  #       \u003c/button\u003e\n  #     \u003c/div\u003e\n  #     \u003cdiv class=\"modal-body\"\u003e\n  #       Here is my modal!\n  #     \u003c/div\u003e\n  #     \u003cdiv class=\"modal-footer\"\u003e\n  #       \u003cbutton class=\"btn btn-primary\" type=\"button\"\u003e\n  #         Save changes\n  #       \u003c/button\u003e\n  #       \u003cbutton class=\"btn btn-secondary\" type=\"button\" data-dismiss=\"modal\"\u003e\n  #         Close\n  #       \u003c/button\u003e\n  #     \u003c/div\u003e\n  #   \u003c/div\u003e\n  # \u003c/div\u003e\n\n=head1 DESCRIPTION\n\nThis is adapted from a series of short scripts I had written for use in vim. I\nfigured someone else might find them useful so I cleaned them up a bit and\nspent the rest of the afternoon trying to figure out what the hell to call it.\n\n=head1 NAME\n\nHTML::Untidy\n\n=head1 PURPOSE\n\nSometimes I don't want to have a proper separation of concerns. Sometimes I\njust want to generate HTML programmatically and easily from perl because I hate\nwriting HTML or I want to build a page from componentized parts.\n\nIsn't this just L\u003cCGI::HTML::Functions\u003e? Yeah, kinda. But so are React and Vue.\nComplain and maybe I'll write\nL\u003cInline::HTML|https://reactjs.org/docs/introducing-jsx.html\u003e.\n\nI think I got all of the HTML5 tags added. If there are any I missed, it's\nsimple enough to add your own.\n\n  *blink   = sub(\u0026){ unshift @_, 'blink';   goto \\\u0026element; });\n  *marquee = sub(\u0026){ unshift @_, 'marquee'; goto \\\u0026element; });\n\n=head1 EXPORTED SUBROUTINES\n\n=head2 :base\n\nBase functions everything else is built from.\n\n=head3 element\n\nAccepts a tag name and subroutine to generate its components. In scalar\ncontext, returns a formatted string of HTML. In void context within another\ncall to C\u003celement\u003e, the generated string is appended to the parent element.\n\n=head3 class\n\nAccepts a list of strings to use as the class list for the element. Multiple\nclasses may share the same string, separated by whitespace. No deduplication is\ndone on these.\n\n=head3 attr\n\nTakes key/value pairs as a hash and generates attributes. Again, no\ndeduplication, and the attributes are displayed in the order in which they are\npassed.\n\n=head3 prop\n\nAdds a property which has no value (e.g. C\u003cdisabled\u003e or C\u003chidden\u003e).\n\n=head3 text\n\nAdds escaped text to the body of the tag.\n\n=head3 raw\n\nAdds unescaped text to the body of the tag.\n\n=head3 note\n\nAdds an HTML comment to the body of the tag.\n\n=head3 indentation\n\nIf you want indentation, set C\u003c$HTML::Untidy::INDENT\u003e to the number of\nspaces you want per level.\n\n  local $HTML::Untidy::INDENT = 2;\n  \n  element 'div', sub{\n    element 'button', sub{\n      class 'btn btn-primary';\n      attr id =\u003e 'some-button', 'data-toggle' =\u003e 'modal', 'data-target' =\u003e 'my-modal-id';\n\n      if ($some_condition) {\n        text 'Click me';\n      }\n      else {\n        prop 'disabled' if $some_condition;\n        text \"Don't click me\";\n      }\n    };\n  };\n\n=head2 :common\n\nExports the following curried aliases of L\u003c/element\u003e for the most commonly used\nHTML tags.\n\n  html head body title meta link script style h1 h2 h3 h4 h5 h6 div p hr pre nav\n  code img a b i u em strong sup sub small table tbody thead tr th td ul dl ol\n  li dd dt form input textarea select option button label canvas\n\n=head2 :all\n\nExports every HTML5 tag I could find.\n\n  a abbr address area article aside audio b base bdi bdo blockquote body br\n  button canvas caption cite code col colgroup data datalist dd del details dfn\n  dialog div dl dt em embed fieldset figcaption figure footer form h1 h2 h3 h4\n  h5 h6 head header hgroup hr html i iframe img input ins kbd label legend li\n  link main map mark menu menuitem meta meter nav noframes noscript object ol\n  optgroup option output p param picture pre progress q rp rt rtc ruby s samp\n  script section select slot small source span strong style sub summary sup\n  table tbody td template textarea tfoot th thead time title tr track u ul var\n  video wbr\n\n=head1 SEE ALSO\n\n=over\n\n=item L\u003cHTML::Builder\u003e\n\n=back\n\n=head1 AUTHOR\n\nJeff Ober \u003csysread@fastmail.fm\u003e\n\n=head1 LICENSE\n\nPerl5\n\n=head1 AUTHOR\n\nJeff Ober \u003csysread@fastmail.fm\u003e\n\n=head1 COPYRIGHT AND LICENSE\n\nThis software is copyright (c) 2017 by Jeff Ober.\n\nThis is free software; you can redistribute it and/or modify it under\nthe same terms as the Perl 5 programming language system itself.\n\n=cut\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsysread%2Fhtml-untidy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsysread%2Fhtml-untidy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsysread%2Fhtml-untidy/lists"}