-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from librasteve/steve-01
Basic Tag Load and Export
- Loading branch information
Showing
9 changed files
with
339 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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": "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 '<h1> to <h6>' row | ||
for ^6 { @lines.append: 'h' ~ ++$ }; # put in h1..h6 rows | ||
|
||
spurt "../resources/html5-tags-list.csv", @lines.sort.join: "\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env raku | ||
use v6.d; | ||
|
||
use HTMX; | ||
|
||
|
||
say h1('text', :class<jumbotron>); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 `<h1>text</h1>` 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 ~ '</' ~ $tag ~ '>' | ||
} | ||
|
||
# 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 <[email protected]> | |
=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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.