diff --git a/.gitignore b/.gitignore index 3d42088..088a90c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,13 @@ -.precomp/ -/HTMX-* +.DS_Store +.precomp +.lib/precomp +.swp +.ipynb_checkpoints/* +.log +.p6.swp +.pm6.swp +.Dockerfile.swp +.json.swp +.yaml.swp +.pem +.iml diff --git a/Build.rakumod b/Build.rakumod new file mode 100644 index 0000000..97b0194 --- /dev/null +++ b/Build.rakumod @@ -0,0 +1,18 @@ +use v6.d; + +class Build { + method build($dist-path) { + + #| also specified in en_SI.rakumod + my $rahx = '.rahx-config'; + my $file = 'html5-tags-list.csv'; + + #| mkdir will use existing if present + mkdir "$*HOME/$rahx"; + + copy "resources/$file", "$*HOME/$rahx/$file"; + + exit 0 + } +} + diff --git a/META6.json b/META6.json index a9449d3..280a359 100644 --- a/META6.json +++ b/META6.json @@ -1,25 +1,23 @@ { - "auth": "zef:librasteve", + "name": "HTMX", + "description": "blah blah blah", + "version": "0.0.1", + "perl": "6.d", "authors": [ "librasteve" ], - "build-depends": [ - ], - "depends": [ - ], - "description": "blah blah blah", - "license": "Artistic-2.0", - "name": "HTMX", - "perl": "6.d", + "auth": "zef:librasteve", + "depends": [], + "build-depends": [], + "test-depends": [], "provides": { "HTMX": "lib/HTMX.rakumod" }, "resources": [ + "html5-tags-w3schools.csv", + "html5-tags-list.csv" ], - "source-url": "", - "tags": [ - ], - "test-depends": [ - ], - "version": "0.0.1" -} + "license": "Artistic-2.0", + "tags": [], + "source-url": "" +} \ No newline at end of file diff --git a/README.md b/README.md index 76b5d5f..9ada881 100644 --- a/README.md +++ b/README.md @@ -9,10 +9,13 @@ TODOS #### Minimum Lovable Product (`MLP`) -- [ ] Get a definitive list of HTML tags -- [ ] Export them so that `h1("text")` makes `

text

` and so on +- [x] Get a definitive list of HTML tags +- [x] Export them so that `h1("text")` makes `

text

` and so on +- [x] Pass and format the HTMX attributes +- [ ] Bring in synopsis from design - [ ] Do the ¶ term - [ ] Make a parse script (& instructions how to watch a dir) +- [ ] Write some tests - [ ] Write some docs in POD6 - [ ] Release with App::Mi6 - [ ] Publish as raku-htmx on the htmx Discord diff --git a/bin/html5-tags-extract.raku b/bin/html5-tags-extract.raku new file mode 100755 index 0000000..54f4283 --- /dev/null +++ b/bin/html5-tags-extract.raku @@ -0,0 +1,18 @@ +#!/usr/bin/env/raku + +# This script extracts HTML5 tag names from the table at +# https://www.w3schools.com/tags/default.asp + +my @lines = "../resources/html5-tags-w3schools.csv".IO.lines; + +@lines.shift; # remove header row +@lines.shift; # remove !-- -- +@lines.shift; # remove !DOCTYPE +@lines .= grep: {! /'Not supported in HTML5'/}; # remove deprecated +@lines .= map: *.split(",")[0]; # take column 1 +@lines .= map: *.subst('<', ''); # \ rm angle brackets +@lines .= map: *.subst('>', ''); # / +@lines .= grep: {! /'h1'/}; # remove '

to

' row +for ^6 { @lines.append: 'h' ~ ++$ }; # put in h1..h6 rows + +spurt "../resources/html5-tags-list.csv", @lines.sort.join: "\n"; diff --git a/bin/synopsis-rahx b/bin/synopsis-rahx new file mode 100755 index 0000000..4b56d50 --- /dev/null +++ b/bin/synopsis-rahx @@ -0,0 +1,7 @@ +#!/usr/bin/env raku +use v6.d; + +use HTMX; + + +say h1('text', :class); \ No newline at end of file diff --git a/lib/HTMX.rakumod b/lib/HTMX.rakumod index 92d6dc2..f6b0548 100644 --- a/lib/HTMX.rakumod +++ b/lib/HTMX.rakumod @@ -1,5 +1,32 @@ unit class HTMX; +constant term:<¶> = $?NL; + + +##### HTMX Tag Export ##### + +my Str @tags = "$*HOME/.rahx-config/html5-tags-list.csv".IO.lines; + +# Export them so that `h1("text")` makes `

text

` and so on +# eg sub h1(Str $inner) {do-tag 'h1', $inner} + +sub do-tag( $tag, $inner, *%h ) { + + my Str $attrs = (+%h ?? ' ' !! '') ~ %h.map({ .key ~ '="' ~ .value ~ '"' }).join(' '); + + '<' ~ $tag ~ $attrs ~ '>' ~ $inner ~ '' +} + +# put in all the tags programmatically +# viz. https://docs.raku.org/language/modules#Exporting_and_selective_importing + +my package EXPORT::DEFAULT { + for @tags -> $tag { + OUR::{'&' ~ $tag} := sub ($inner, *%h) { do-tag( "$tag", $inner, |%h ) } + } +} + + =begin pod @@ -25,7 +52,7 @@ librasteve =head1 COPYRIGHT AND LICENSE -Copyright 2024 librasteve +Copyright (c) 2024 Henley Cloud Consulting Ltd. This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0. diff --git a/resources/html5-tags-list.csv b/resources/html5-tags-list.csv new file mode 100644 index 0000000..2902ced --- /dev/null +++ b/resources/html5-tags-list.csv @@ -0,0 +1,113 @@ +a +abbr +address +area +article +aside +audio +b +base +bdi +bdo +blockquote +body +br +button +canvas +caption +cite +code +col +colgroup +data +datalist +dd +del +details +dfn +dialog +div +dl +dt +em +embed +fieldset +figcaption +figure +footer +form +h1 +h2 +h3 +h4 +h5 +h6 +head +header +hgroup +hr +html +i +iframe +img +input +ins +kbd +label +legend +li +link +main +map +mark +menu +meta +meter +nav +noscript +object +ol +optgroup +option +output +p +param +picture +pre +progress +q +rp +rt +ruby +s +samp +script +search +section +select +small +source +span +strong +style +sub +summary +sup +svg +table +tbody +td +template +textarea +tfoot +th +thead +time +title +tr +track +u +ul +var +video +wbr \ No newline at end of file diff --git a/resources/html5-tags-w3schools.csv b/resources/html5-tags-w3schools.csv new file mode 100644 index 0000000..73b6bbf --- /dev/null +++ b/resources/html5-tags-w3schools.csv @@ -0,0 +1,123 @@ +Tag,Description +,Defines a comment +,Defines the document type +,Defines a hyperlink +,Defines an abbreviation or an acronym +,Not supported in HTML5. Use instead. Defines an acronym +
,Defines contact information for the author/owner of a document +,Not supported in HTML5. Use or instead. Defines an embedded applet +,Defines an area inside an image map +
,Defines an article +