From dbe7d85226ca68f9349cae50439c8939cddf62dc Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Thu, 18 Apr 2024 18:05:15 -0300 Subject: [PATCH 01/97] [proposal] initial commit --- src/main.art | 20 +++++++++++ test.art | 9 +++++ test/document.test.art | 0 test/element.test.art | 80 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 109 insertions(+) create mode 100644 src/main.art create mode 100644 test.art create mode 100644 test/document.test.art create mode 100644 test/element.test.art diff --git a/src/main.art b/src/main.art new file mode 100644 index 0000000..4c25a09 --- /dev/null +++ b/src/main.art @@ -0,0 +1,20 @@ + + +define :htmlModule [ + + element: method [tag :string content :block :string][ + if block? content -> + join.with: "\n" @[ + ~"<|tag|>" + indent.n: 2 join.with: "\n" @content + ~"" + ] + + if string? content -> + ~"<|tag|>|content|" + ] + +] + + +artml: to :htmlModule [] \ No newline at end of file diff --git a/test.art b/test.art new file mode 100644 index 0000000..b0aaea8 --- /dev/null +++ b/test.art @@ -0,0 +1,9 @@ +#! arturo + +import.version: 1.1.2 'unitt! + +testPath: "test" + +runTests (empty? arg)? + -> findTests.thatMatches: "*.test.art" testPath + -> map arg 'file [ ~"|testPath|/|file|.test.art" ] diff --git a/test/document.test.art b/test/document.test.art new file mode 100644 index 0000000..e69de29 diff --git a/test/element.test.art b/test/element.test.art new file mode 100644 index 0000000..c686963 --- /dev/null +++ b/test/element.test.art @@ -0,0 +1,80 @@ +import {unitt}! +import {src/main.art}! + +test "follows the right W3C tagging format when passing string" [ + result: artml\element "el" "Hello, World!" + assert -> "Hello, World!" = + result +] + + +test "follows the right W3C tagging format when passing blocks" [ + ;; This test tests multiple things: + ;; * Opening and closing tags: + ;; Each element should be opened and closed + ;; * Indentation + ;; Two spaces must be added per element nesting + ;; * Evaluation + ;; the user shouldn't use '@ to evaluate, the element must do it + + breakLine: "
" + bold: $[x][artml\element "b" x] + paragraph: $[x][artml\element "p" x] + + expect: {!html +

+ Hello, +
+ World + ! +

+ } + + result: paragraph [ + "Hello," + breakLine + bold "World" "!" + ] + + assert -> expect = result +] + +test "indentation follows the nesting of elements" [ + ;; Also verifies the nesting for strings + ;; + ;; How the formatation must work: + ;; + ;; tag "Content" + ;; ; Content + ;; + ;; tag ["Content"] + ;; ; + ;; ; Content + ;; ; + + divisory: $[x][artml\element "div" x] + + expect: {!html +
+ Level 01 +
+ Level 02 +
Level 03
+ Level 02 +
+ Level 01 +
+ } + + result: divisory [ + "Level 01" + divisory [ + "Level 02" + divisory "Level 03" + "Level 02" + ] + "Level 01" + ] + + assert -> expect = result +] \ No newline at end of file From f05ffd3af8c65a93ce7c4fc438dfb440734f9007 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Thu, 18 Apr 2024 18:10:00 -0300 Subject: [PATCH 02/97] [proposal] update and deprecate html --- info.art | 1 + main.art => main.deprecated.art | 0 src/{main.art => html.art} | 0 3 files changed, 1 insertion(+) rename main.art => main.deprecated.art (100%) rename src/{main.art => html.art} (100%) diff --git a/info.art b/info.art index ac70bab..5f566fe 100644 --- a/info.art +++ b/info.art @@ -2,4 +2,5 @@ description: "HTML generator for Arturo" author: "Yanis Zafirópulos" depends: [] +entry: {src/html} requires: [> 0.9.83] diff --git a/main.art b/main.deprecated.art similarity index 100% rename from main.art rename to main.deprecated.art diff --git a/src/main.art b/src/html.art similarity index 100% rename from src/main.art rename to src/html.art From a73a14bf3edde7d5a42ef22ff828a387f1a0d8ec Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Thu, 18 Apr 2024 18:53:17 -0300 Subject: [PATCH 03/97] [proposal] add dynamic attributes --- src/html.art | 7 +++++-- test/element.test.art | 42 +++++++++++++++++++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/src/html.art b/src/html.art index 4c25a09..2f2c1a7 100644 --- a/src/html.art +++ b/src/html.art @@ -3,15 +3,18 @@ define :htmlModule [ element: method [tag :string content :block :string][ + attributes: (join.with: " " map attrs [key value] -> render {|key|="|value|"}) + if attributes <> "" -> prepend 'attributes " " + if block? content -> join.with: "\n" @[ - ~"<|tag|>" + ~"<|tag||attributes|>" indent.n: 2 join.with: "\n" @content ~"" ] if string? content -> - ~"<|tag|>|content|" + ~"<|tag||attributes|>|content|" ] ] diff --git a/test/element.test.art b/test/element.test.art index c686963..3f90659 100644 --- a/test/element.test.art +++ b/test/element.test.art @@ -1,14 +1,14 @@ import {unitt}! -import {src/main.art}! +import {src/html.art}! -test "follows the right W3C tagging format when passing string" [ +test "generic elements follows the standard for :string" [ result: artml\element "el" "Hello, World!" assert -> "Hello, World!" = result ] -test "follows the right W3C tagging format when passing blocks" [ +test "generic elements follows the standard for nested :block s" [ ;; This test tests multiple things: ;; * Opening and closing tags: ;; Each element should be opened and closed @@ -76,5 +76,41 @@ test "indentation follows the nesting of elements" [ "Level 01" ] + assert -> expect = result +] + +test "dynamic attributes follows standard" [ + ;; We can dynamically add Elements's attributes by using Arturo's attributes + ;; + ;; How this must work: + ;; + ;; tag.class: "content" "Content" + ;; ; Content + ;; + ;; tag.author: "RickB" ["Content"] + ;; ; + ;; ; Content + ;; ; + + divisory: $[x][artml\element "div" x] + entry: $[x][artml\element .name: x "input" ""] + button: $[x][artml\element "button" x] + + expect: {!html +
+ + + + +
+ } + + result: divisory.class: "login-box" [ + entry.type: 'email "user" + entry.type: 'password "pwd" + button.class: 'enter "Log In" + button.class: 'recover "Forgot my password" + ] + assert -> expect = result ] \ No newline at end of file From 2e2b56dd1d8c4ee3d171eb3a2ec0f2c765d1e2e0 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Fri, 19 Apr 2024 22:37:59 -0300 Subject: [PATCH 04/97] [html]: create voidElement method --- src/html.art | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/html.art b/src/html.art index 2f2c1a7..4ed0d62 100644 --- a/src/html.art +++ b/src/html.art @@ -16,6 +16,27 @@ define :htmlModule [ if string? content -> ~"<|tag||attributes|>|content|" ] + + voidElement: method [tag :string :literal][ + ;; Void elements are elements without closing-tags. + ;; + ;; Format + ;; ------ + ;; They follows the pattern: ```` + ;; + ;; Features + ;; -------- + ;; Use Arturo's attributes to dynamically add html's attributes to it. + ;; + ;; Extra + ;; ----- + ;; Read more about void elements here: + ;; + + attributes: (join.with: " " map attrs [key value] -> render {|key|="|value|"}) + if attributes <> "" -> prepend 'attributes " " + ~"<|tag||attributes|/>" + ] ] From 4c8cea3a61305d1f817bdfb2d1991a549485259b Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Fri, 19 Apr 2024 22:38:38 -0300 Subject: [PATCH 05/97] [html\element] add clear documentation --- src/html.art | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/html.art b/src/html.art index 4ed0d62..681dd8b 100644 --- a/src/html.art +++ b/src/html.art @@ -2,7 +2,23 @@ define :htmlModule [ - element: method [tag :string content :block :string][ + element: method [tag :string :literal content :block :string][ + ;; Elements refers to the normal elements defined by the HTML5 standard. + ;; + ;; Format + ;; ------ + ;; * They follows the pattern: ``content``. + ;; * When ``content`` is a :block, the content will be intended by 2 spaces. + ;; + ;; Features + ;; -------- + ;; Use Arturo's attributes to dynamically add html's attributes to it. + ;; + ;; Extra + ;; ----- + ;; Read more about elements here: + ;; + attributes: (join.with: " " map attrs [key value] -> render {|key|="|value|"}) if attributes <> "" -> prepend 'attributes " " From fd37816a9a38c197065fe0306695599a3ad0577e Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Fri, 19 Apr 2024 22:39:02 -0300 Subject: [PATCH 06/97] [html] add hidden code for future reference --- src/html.art | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/html.art b/src/html.art index 681dd8b..c1ff3b9 100644 --- a/src/html.art +++ b/src/html.art @@ -2,6 +2,12 @@ define :htmlModule [ + ; newElement: method [tag :string :literal][ + ; method [content :block][ + ; this\element] ++ (@[tag]) ++ [content + ; ] + ; ] + element: method [tag :string :literal content :block :string][ ;; Elements refers to the normal elements defined by the HTML5 standard. ;; From e48859f7ef4b241824a42e66f6966892bdce45fd Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Fri, 19 Apr 2024 22:39:20 -0300 Subject: [PATCH 07/97] [html] import code from elements --- src/html.art | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/html.art b/src/html.art index c1ff3b9..85d49a2 100644 --- a/src/html.art +++ b/src/html.art @@ -2,6 +2,11 @@ define :htmlModule [ + init: method [][ + elements: #./"elements.art" + loop elements ['el 'action] -> this\[el]: var get info.get 'action 'name + ] + ; newElement: method [tag :string :literal][ ; method [content :block][ ; this\element] ++ (@[tag]) ++ [content From 95f46d480c3a61f98beb5aa39084d150c4d3e6ac Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Fri, 19 Apr 2024 22:40:02 -0300 Subject: [PATCH 08/97] [test\document] add tests for 'html --- test/document.test.art | 55 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/test/document.test.art b/test/document.test.art index e69de29..a7122fc 100644 --- a/test/document.test.art +++ b/test/document.test.art @@ -0,0 +1,55 @@ +import {unitt}! +import {src/html.art}! + +test "html returns html element with DOCTYPE, and its default value is HTML5" [ + expect: {!html + + + + Example + + +

Hello

+ + + } + + result: artml\html [ + artml\head [ + artml\title "Example" + ] + artml\body [ + artml\paragraph "Hello" + ] + ] + + assert -> equal? expect result + +] + +test "HTML4 attribute uses the right DOCTYPE" [ + expect: {!html + + + + Example + + +

Hello

+ + + } + + result: artml\html.html4 [ + artml\head [ + artml\title "Example" + ] + artml\body [ + artml\paragraph "Hello" + ] + ] + + assert -> expect = result + +] + From 767a4f8575ccd158d87a16a04a0752839847bf02 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Fri, 19 Apr 2024 22:40:22 -0300 Subject: [PATCH 09/97] [test\text] add tests for headings --- test/text.test.art | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 test/text.test.art diff --git a/test/text.test.art b/test/text.test.art new file mode 100644 index 0000000..74d94b0 --- /dev/null +++ b/test/text.test.art @@ -0,0 +1,27 @@ +import {unitt}! +import {src/html.art}! + +test "Headings are working as expected" [ + expect: {!html +
+

Text

+

Text

+

Text

+

Text

+
Text
+
Text
+
+ } + + result: artml\divisory [ + artml\h1 "Text" + artml\h2 "Text" + artml\h3 "Text" + artml\h4 "Text" + artml\h5 "Text" + artml\h6 "Text" + ] + + assert -> expect = result + +] \ No newline at end of file From 2560842483188cb06a85ba2b1e7362c051b0f8ea Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Fri, 19 Apr 2024 22:40:50 -0300 Subject: [PATCH 10/97] [html\elements] add some basic elements --- src/elements.art | 101 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 src/elements.art diff --git a/src/elements.art b/src/elements.art new file mode 100644 index 0000000..690c221 --- /dev/null +++ b/src/elements.art @@ -0,0 +1,101 @@ + +; Document Level +; ============== + +html: method [page :block][ + html4: attr 'html4 + + doctype: (html4)? + -> {!html + + } + -> {!html + + } + + join.with: "\n" @[ + doctype + this\element 'html page + ] +] + +body: method [content :block][ + this\element 'body content +] + +head: method [content :block][ + this\element 'head content +] + +title: method [title :string][ + this\element 'title title +] + + +; Text Level +; ========== + +paragraph: method [content :block :string][ + this\element 'p content +] + +link: method [url :string][ + (attr 'alt)?? + -> this\element.href: url 'a attr 'alt + -> this\element.href: url 'a url +] + +bold: method [text :string][ + this\element 'strong text +] + +emphasis: method [text :string][ + this\element 'em text +] + +alternateVoice: method [text :string][ + ;; Used for alterated voice or mood + ;; + ;; When to use it + ;; -------------- + ;; * Alternative voice + ;; * Alternative mood + ;; * Transliteration + ;; * Idiomatic Phrase + ;; * Technical Terms + ;; + ;; Extra + ;; ----- + ;; See: + ;; + this\element 'i text +] + +br: method [][ + this\voidElement 'br +] + +h1: method [text :string][ + this\element 'h1 text +] +h2: method [text :string][ + this\element 'h2 text +] +h3: method [text :string][ + this\element 'h3 text +] +h4: method [text :string][ + this\element 'h4 text +] +h5: method [text :string][ + this\element 'h5 text +] +h6: method [text :string][ + this\element 'h6 text +] + +divisory: method [content :block :text][ + this\element 'div content +] + + From 5dfa881267bbb3a0c6313aca00b634d6cbfaf64b Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sat, 20 Apr 2024 13:06:37 -0300 Subject: [PATCH 11/97] [html] void elements now hets default internal attributes from dict * Forces users to write some parameters * Allow us to use attribute notation, since we need at least one parameter --- src/html.art | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/html.art b/src/html.art index 85d49a2..bd41e31 100644 --- a/src/html.art +++ b/src/html.art @@ -44,7 +44,7 @@ define :htmlModule [ ~"<|tag||attributes|>|content|" ] - voidElement: method [tag :string :literal][ + voidElement: method [tag :string :literal htmlAttributes :dictionary][ ;; Void elements are elements without closing-tags. ;; ;; Format From 48f0ad79caba5d943b902e549636536842f1bd1e Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sat, 20 Apr 2024 13:07:14 -0300 Subject: [PATCH 12/97] [html] void elements now hets default internal attributes from dict * Forces users to write some parameters * Allow us to use attribute notation, since we need at least one parameter --- src/html.art | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/html.art b/src/html.art index bd41e31..5ca59d2 100644 --- a/src/html.art +++ b/src/html.art @@ -60,7 +60,12 @@ define :htmlModule [ ;; Read more about void elements here: ;; - attributes: (join.with: " " map attrs [key value] -> render {|key|="|value|"}) + attributes: ( + map htmlAttributes [key value] -> render {|key|="|value|"} + | append (map attrs [key value] -> render {|key|="|value|"}) + | join.with: " " + ) + if attributes <> "" -> prepend 'attributes " " ~"<|tag||attributes|/>" ] From 51a6ab6749169af30f6cf1bd45aefb365a42296e Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sat, 20 Apr 2024 17:07:11 -0300 Subject: [PATCH 13/97] [html\element] head includes title --- src/elements.art | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/elements.art b/src/elements.art index 690c221..aa49416 100644 --- a/src/elements.art +++ b/src/elements.art @@ -23,14 +23,15 @@ body: method [content :block][ this\element 'body content ] -head: method [content :block][ - this\element 'head content -] - title: method [title :string][ this\element 'title title ] +head: method [content :block][ + title: $[x][this\title x] + this\element 'head content +] + ; Text Level ; ========== From 71883e2fde3701698dde3adbcc68f4ed123daebd Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sat, 20 Apr 2024 17:07:46 -0300 Subject: [PATCH 14/97] [html] create newElements * The function is broken right now --- src/html.art | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/html.art b/src/html.art index 5ca59d2..8f7edc7 100644 --- a/src/html.art +++ b/src/html.art @@ -7,11 +7,29 @@ define :htmlModule [ loop elements ['el 'action] -> this\[el]: var get info.get 'action 'name ] - ; newElement: method [tag :string :literal][ - ; method [content :block][ - ; this\element] ++ (@[tag]) ++ [content - ; ] - ; ] + newElement: method [tag :string :literal kind :type][ + + head: [content] + body: [this\element] ++ (@[tag]) ++ [content] + + if in? kind [:group :section] -> + append 'head :block + + if in? kind [:text :inline] -> + append 'head :string + + if in? kind [:any] -> + append 'head [:block :string] + + if in? kind [:void] [ + append 'head :dictionary + drop 'body + prepend 'body [this\voidElement] + ] + + method head body + + ] element: method [tag :string :literal content :block :string][ ;; Elements refers to the normal elements defined by the HTML5 standard. From eccb970d15243350ba98df90703141443835142c Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sat, 20 Apr 2024 17:08:39 -0300 Subject: [PATCH 15/97] [test] test how newElement should work --- test/class/newElement.test.art | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 test/class/newElement.test.art diff --git a/test/class/newElement.test.art b/test/class/newElement.test.art new file mode 100644 index 0000000..80efb6d --- /dev/null +++ b/test/class/newElement.test.art @@ -0,0 +1,47 @@ +import {unitt}! +import {src/html}! + + +test.skip "new element of kind :group/:section only accepts :blocks" [ + loop [:group :section] kind [ + head: artml\newElement 'head kind + + assert -> not? throws? [head ["Hello"]] + assert -> throws? [head "Hello"] + assert -> throws? [head 'hello] + assert -> throws? [head to :word "Hello"] + assert -> throws? [head #[hello: "World"]] + ] +] + +test.skip "new element of kind :text/:inline only accepts :string-based types" [ + loop [:text :inline] kind [ + bold: artml\newElement 'b kind + + assert -> not? throws? [head "Hello"] + assert -> not? throws? [head 'hello] + assert -> not? throws? [head to :word "Hello"] + assert -> throws? [head ["Hello"]] + assert -> throws? [head #[hello: "World"]] + ] +] + +test.skip "new element of kind :any accepts :any" [ + entry: artml\newElement 'input :any + + assert -> not? throws? [head 'hello] + assert -> not? throws? [head "Hello"] + assert -> not? throws? [head to :word "Hello"] + assert -> not? throws? [head ["Hello"]] + assert -> not? throws? [head #[hello: "World"]] +] + +test.skip "new element of kind :void accepts :dictionary" [ + entry: artml\newElement 'input :void + + assert -> not? throws? [head #[hello: "World"]] + assert -> throws? [head 'hello] + assert -> throws? [head "Hello"] + assert -> throws? [head to :word "Hello"] + assert -> throws? [head ["Hello"]] +] From 15f0bb386d5d8d335c512c1cdaf64daad2518c2c Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sat, 20 Apr 2024 17:09:09 -0300 Subject: [PATCH 16/97] [html\elements] add a template of how the code should be organized --- src/elements/components.art | 8 ++++++++ src/elements/edits.art | 8 ++++++++ src/elements/embedded.art | 13 ++++++++++++ src/elements/forms.art | 19 ++++++++++++++++++ src/elements/inline.art | 38 +++++++++++++++++++++++++++++++++++ src/elements/interactives.art | 9 +++++++++ src/elements/meta.art | 14 +++++++++++++ src/elements/multimedia.art | 12 +++++++++++ src/elements/scripting.art | 8 ++++++++ src/elements/section.art | 22 ++++++++++++++++++++ src/elements/table.art | 7 +++++++ src/elements/text.art | 24 ++++++++++++++++++++++ src/root.art | 13 ++++++++++++ test/metadata.test.art | 18 +++++++++++++++++ 14 files changed, 213 insertions(+) create mode 100644 src/elements/components.art create mode 100644 src/elements/edits.art create mode 100644 src/elements/embedded.art create mode 100644 src/elements/forms.art create mode 100644 src/elements/inline.art create mode 100644 src/elements/interactives.art create mode 100644 src/elements/meta.art create mode 100644 src/elements/multimedia.art create mode 100644 src/elements/scripting.art create mode 100644 src/elements/section.art create mode 100644 src/elements/table.art create mode 100644 src/elements/text.art create mode 100644 src/root.art create mode 100644 test/metadata.test.art diff --git a/src/elements/components.art b/src/elements/components.art new file mode 100644 index 0000000..09d5340 --- /dev/null +++ b/src/elements/components.art @@ -0,0 +1,8 @@ +;; Web Components +;; ============== +;; +;; A way to create custom components. +;; For Html.art, those are injected into ``body``. + +slot: $[][] +template: $[][] \ No newline at end of file diff --git a/src/elements/edits.art b/src/elements/edits.art new file mode 100644 index 0000000..10597f5 --- /dev/null +++ b/src/elements/edits.art @@ -0,0 +1,8 @@ +;; Editing +;; ======= +;; +;; Indicates edition on the document. +;; For Html.art, those are injected into ``html``. + +delete: $[][] +insert: $[][] \ No newline at end of file diff --git a/src/elements/embedded.art b/src/elements/embedded.art new file mode 100644 index 0000000..8b5fc6f --- /dev/null +++ b/src/elements/embedded.art @@ -0,0 +1,13 @@ +;; Embedded Content +;; ================ +;; +;; For Html.art, those are injected into ``body``. + +embed: $[][] +iFrame: $[][] +object: $[][] +picture: $[][] +portal: $[][] +source: $[][] +svg: $[][] +math: $[][] \ No newline at end of file diff --git a/src/elements/forms.art b/src/elements/forms.art new file mode 100644 index 0000000..37ee757 --- /dev/null +++ b/src/elements/forms.art @@ -0,0 +1,19 @@ +;; Forms +;; ===== +;; +;; Related to forms submition. +;; For Html.art, those are injected into ``body``. + +button: $[][] +dataList: $[][] +fieldSet: $[][] +form: $[][] +input: $[][] +label: $[][] +legend: $[][] +meter: $[][] +group: $[][] ; Must be inside ``select`` +output: $[][] +progress: $[][] +select: $[][] +textArea: $[][] diff --git a/src/elements/inline.art b/src/elements/inline.art new file mode 100644 index 0000000..f244d81 --- /dev/null +++ b/src/elements/inline.art @@ -0,0 +1,38 @@ +;; Inline Text +;; =========== +;; +;; Defines the semantics and style of a text content. +;; For Html.art, those are injected into ``body``. + +link: $[][] +abbreviation: $[][] +bold: $[][] +biDirectional: $[][] +overrideDirection: $[][] +breakLine: $[][] +cite: $[][] +code: $[][] +data: $[][] +definition: $[][] +emphasis: $[][] +idiomatic: $[][] +keyboard: $[][] +mark: $[][] +quote: $[][] +strikethrough: $[][] +sample: $[][] +small: $[][] +span: $[][] +strong: $[][] +sub: $[][] +sup: $[][] +time: $[][] +underline: $[][] +variable: $[][] +wordBreak: $[][] + + +; TODO: decide how to work: +; * rt +; * ruby +; * rp \ No newline at end of file diff --git a/src/elements/interactives.art b/src/elements/interactives.art new file mode 100644 index 0000000..4748f78 --- /dev/null +++ b/src/elements/interactives.art @@ -0,0 +1,9 @@ +;; Interactives +;; ============ +;; +;; Some interactives elements. +;; For Html.art, those are injected into ``body``. + +details: $[][] +dialog: $[][] +summary: $[][] \ No newline at end of file diff --git a/src/elements/meta.art b/src/elements/meta.art new file mode 100644 index 0000000..04a7176 --- /dev/null +++ b/src/elements/meta.art @@ -0,0 +1,14 @@ +;; Metadata Content +;; ================ +;; +;; Contains information of the website. +;; For Html.art, those are injected into ``head``. + +;; head $[][] + +base: $[][] +metaLink: $[][] +meta: $[][] +style: $[][] +title: $[][] + diff --git a/src/elements/multimedia.art b/src/elements/multimedia.art new file mode 100644 index 0000000..04295fe --- /dev/null +++ b/src/elements/multimedia.art @@ -0,0 +1,12 @@ +;; Multimedia +;; ========== +;; +;; Images, videos, audios... +;; For Html.art, those are injected into ``body``. + +area: $[][] +audio: $[][] +image: $[][] +imageMap: $[][] +track: $[][] +video: $[][] \ No newline at end of file diff --git a/src/elements/scripting.art b/src/elements/scripting.art new file mode 100644 index 0000000..09374ca --- /dev/null +++ b/src/elements/scripting.art @@ -0,0 +1,8 @@ +;; Scripting +;; ========= +;; +;; Ways to make your website more dynamic. + +canvas: $[][] +noScript: $[][] +script: $[][] \ No newline at end of file diff --git a/src/elements/section.art b/src/elements/section.art new file mode 100644 index 0000000..b98d35e --- /dev/null +++ b/src/elements/section.art @@ -0,0 +1,22 @@ +;; Content Sectioning +;; ================== +;; +;; Organizes the document into semantic sections. +;; For Html.art, those are injected into ``body``. + +addr: $[][] +article: $[][] +aside: $[][] +footer: $[][] +header: $[][] +h1: $[][] +h2: $[][] +h3: $[][] +h4: $[][] +h5: $[][] +h6: $[][] +headGroup: $[][] +main: $[][] +nav: $[][] +section: $[][] +search: $[][] diff --git a/src/elements/table.art b/src/elements/table.art new file mode 100644 index 0000000..85fa09b --- /dev/null +++ b/src/elements/table.art @@ -0,0 +1,7 @@ +;; Tables +;; ====== +;; +;; Include data into table format. +;; For Html.art, those are injected into ``body``. + +;; TODO: Discuss the implementation \ No newline at end of file diff --git a/src/elements/text.art b/src/elements/text.art new file mode 100644 index 0000000..1895fc4 --- /dev/null +++ b/src/elements/text.art @@ -0,0 +1,24 @@ +;; Text Content +;; ============ +;; +;; Defines the structure of the document. +;; For Html.art, those are injected into ``body``. + +blockquote: $[][] +definition: $[][] +divisory: $[][] +figureCaption: $[][] +figure: $[][] +horizontalRule: $[][] +menu: $[][] +paragraph: $[][] +preformatted: $[][] + +; TODO: Decice the working of: +; +; * dd +; * dl +; * dt +; * ol +; * ul +; * li \ No newline at end of file diff --git a/src/root.art b/src/root.art new file mode 100644 index 0000000..8487ca4 --- /dev/null +++ b/src/root.art @@ -0,0 +1,13 @@ + + +html: $[][ + +] + +head: $[][ + +] + +body: $[][ + +] \ No newline at end of file diff --git a/test/metadata.test.art b/test/metadata.test.art new file mode 100644 index 0000000..958097d --- /dev/null +++ b/test/metadata.test.art @@ -0,0 +1,18 @@ +import {unitt}! +import {src/html.art}! + + +test " includes " [ + + expect: {!html + <head> + <title>Hello, world! + + } + + result: artml\head [ + title "Hello, world!" + ] + + assert -> expect = result +] \ No newline at end of file From fc821ac96b5ecede35c35254711a386625522c3d Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sat, 20 Apr 2024 18:11:57 -0300 Subject: [PATCH 17/97] [test\elements\meta] add some tests to have a notion of how the library must be used --- test/elements/meta.test.art | 154 ++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 test/elements/meta.test.art diff --git a/test/elements/meta.test.art b/test/elements/meta.test.art new file mode 100644 index 0000000..8acbd6c --- /dev/null +++ b/test/elements/meta.test.art @@ -0,0 +1,154 @@ +import {unitt}! +import {src/html.art}! + +suite "" [ + test.skip " must have 'href, 'target or both" [ + ; None + result: artml\base #[] + assert -> throws? [result] + + ; With href + result: artml\base #[href: "https://example.com"] + assert -> not? throws? [result] + + ; With target + result: artml\base #[target: "_blank"] + assert -> not? throws? [result] + + ; With both + result: artml\base #[href: "https://example.com" target: "_blank"] + assert -> not? throws? [result] + ] + + test.skip " must be void and follow the standard" [ + expect: {!html + + } + + result: base #[href: "https://example.com" target: "_blank"] + assert -> expect = result + ] +] + + +suite "" [ + test.skip " gets two arguments 'rel and 'href" [ + assert -> not? throws? [artml\metaLink "stylesheet" "style.css"] + assert -> throws? [artml\metaLink "stylesheet"] + assert -> throws? [artml\metaLink] + ] + + test.skip " takes :string-like arguments" [ + assert -> not? throws? [artml\metaLink "stylesheet" "style.css"] + assert -> not? throws? [artml\metaLink :stylesheet "style.css"] + assert -> not? throws? [artml\metaLink 'stylesheet "style.css"] + + assert -> not? throws? [artml\metaLink ["stylesheet"] "style.css"] + assert -> not? throws? [artml\metaLink :stylesheet ["style.css"]] + assert -> not? throws? [artml\metaLink ['stylesheet] ["style.css"]] + ] + + test.skip " .size gets an :integer and converts to standard" [ + expect: {!html + + } + + result: artml\metaLink.size: 70 "apple-touch-icon" "icon.png" + assert -> expect = result + ] + + test.skip "'s .size does not influences other attributes" [ + expect: {!html + + } + + result: artml\metaLink.size: 70 .type: "image/png" + "apple-touch-icon" "icon.png" + assert -> expect = result + ] + + test.skip " is a void element and follows the standard" [ + expect: {!html + + + + + + + } + + result: artml\head [ + title "" + link :icon "icon.ico" + link :stylesheet "style.css" + link.size: 70 "apple-touch-icon" "icon.png" + ] + + assert -> expect = result + ] + +] + +suite "" [ + test.skip " is a void element and gets a :dictionary" [ + expect: {!html + + + + + + + } + + result: artml\html [ + title "" + meta #[charset: "utf-8"] + meta #["http-equiv": "content-security-policy" content: "..."] + meta #[name: "twitter?card" content: "summary"] + ] + + assert -> expect = result + ] +] + +suite " + } + + result: artml\style {!css + p { + color: black; + } + } + + assert -> expect = result + + ] + +] + +suite "" [ + + test.skip "<title/> is a normal element and follows the standard" [ + expect: {!html + <title>Arturo Language! + } + + result: artml\title "Arturo Language!" + assert -> expect = result + + ] + +] From fb4f7bfd799c47917e857c475c3f8d6b272cde84 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sat, 27 Apr 2024 14:44:45 -0300 Subject: [PATCH 18/97] [html\element] move 'html and 'head to root.art --- src/elements.art | 22 ---------------------- src/html.art | 2 +- src/root.art | 20 +++++++++++++++++--- 3 files changed, 18 insertions(+), 26 deletions(-) diff --git a/src/elements.art b/src/elements.art index aa49416..920d459 100644 --- a/src/elements.art +++ b/src/elements.art @@ -2,23 +2,6 @@ ; Document Level ; ============== -html: method [page :block][ - html4: attr 'html4 - - doctype: (html4)? - -> {!html - - } - -> {!html - - } - - join.with: "\n" @[ - doctype - this\element 'html page - ] -] - body: method [content :block][ this\element 'body content ] @@ -27,11 +10,6 @@ title: method [title :string][ this\element 'title title ] -head: method [content :block][ - title: $[x][this\title x] - this\element 'head content -] - ; Text Level ; ========== diff --git a/src/html.art b/src/html.art index 8f7edc7..f851a2c 100644 --- a/src/html.art +++ b/src/html.art @@ -3,7 +3,7 @@ define :htmlModule [ init: method [][ - elements: #./"elements.art" + elements: #./"root.art" loop elements ['el 'action] -> this\[el]: var get info.get 'action 'name ] diff --git a/src/root.art b/src/root.art index 8487ca4..e8a95c9 100644 --- a/src/root.art +++ b/src/root.art @@ -1,11 +1,25 @@ -html: $[][ +html: $[page :block][ + html4: attr 'html4 -] + doctype: (html4)? + -> {!html + + } + -> {!html + + } -head: $[][ + join.with: "\n" @[ + doctype + this\element 'html page + ] +] +head: method [content :block][ + title: $[x][this\title x] + this\element 'head content ] body: $[][ From 41b8f49ce8ee3b21fa9fdbb625288e6f9ef919a3 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sat, 27 Apr 2024 14:51:48 -0300 Subject: [PATCH 19/97] [html\element] move 'html and 'head to root.art --- src/root.art | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/root.art b/src/root.art index e8a95c9..dfe2d7b 100644 --- a/src/root.art +++ b/src/root.art @@ -1,6 +1,6 @@ -html: $[page :block][ +html: method [page :block][ html4: attr 'html4 doctype: (html4)? @@ -22,6 +22,6 @@ head: method [content :block][ this\element 'head content ] -body: $[][ +body: method [][ ] \ No newline at end of file From 203ae072071dc3e0f2da09aa053d75f7e6c14bd2 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sat, 27 Apr 2024 14:55:09 -0300 Subject: [PATCH 20/97] [html\element] inject body and head into html --- src/root.art | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/root.art b/src/root.art index dfe2d7b..d48f04f 100644 --- a/src/root.art +++ b/src/root.art @@ -11,6 +11,9 @@ html: method [page :block][ } + head: $[x][this\head x] + body: $[x][this\body x] + join.with: "\n" @[ doctype this\element 'html page From e28f892d77b2869ad3d9171eac502583bd19fe15 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sat, 27 Apr 2024 15:08:29 -0300 Subject: [PATCH 21/97] [html\test] fix test --- test/elements/meta.test.art | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/elements/meta.test.art b/test/elements/meta.test.art index 8acbd6c..6d0c060 100644 --- a/test/elements/meta.test.art +++ b/test/elements/meta.test.art @@ -43,9 +43,9 @@ suite "" [ assert -> not? throws? [artml\metaLink :stylesheet "style.css"] assert -> not? throws? [artml\metaLink 'stylesheet "style.css"] - assert -> not? throws? [artml\metaLink ["stylesheet"] "style.css"] - assert -> not? throws? [artml\metaLink :stylesheet ["style.css"]] - assert -> not? throws? [artml\metaLink ['stylesheet] ["style.css"]] + assert -> throws? [artml\metaLink ["stylesheet"] "style.css"] + assert -> throws? [artml\metaLink :stylesheet ["style.css"]] + assert -> throws? [artml\metaLink ['stylesheet] ["style.css"]] ] test.skip " .size gets an :integer and converts to standard" [ From d00b6229eccd5127d607b0d28a1835266f53e087 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sat, 27 Apr 2024 15:18:26 -0300 Subject: [PATCH 22/97] [test\elements\meta] fix tests --- test/elements/meta.test.art | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/test/elements/meta.test.art b/test/elements/meta.test.art index 6d0c060..80cd39d 100644 --- a/test/elements/meta.test.art +++ b/test/elements/meta.test.art @@ -4,20 +4,24 @@ import {src/html.art}! suite "" [ test.skip " must have 'href, 'target or both" [ ; None - result: artml\base #[] - assert -> throws? [result] + assert -> not? throws? [ + artml\base #[] + ] ; With href - result: artml\base #[href: "https://example.com"] - assert -> not? throws? [result] + assert -> not? throws? [ + artml\base #[href: "https://example.com"] + ] ; With target - result: artml\base #[target: "_blank"] - assert -> not? throws? [result] + assert -> not? throws? [ + artml\base #[target: "_blank"] + ] ; With both - result: artml\base #[href: "https://example.com" target: "_blank"] - assert -> not? throws? [result] + assert -> not? throws? [ + artml\base #[href: "https://example.com" target: "_blank"] + ] ] test.skip " must be void and follow the standard" [ From 3d6a240927313ac77b2c0e6c4b6b58af89f37866 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sat, 27 Apr 2024 15:20:21 -0300 Subject: [PATCH 23/97] [test\elements\meta] fix tests --- test/elements/meta.test.art | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/elements/meta.test.art b/test/elements/meta.test.art index 80cd39d..ad4deba 100644 --- a/test/elements/meta.test.art +++ b/test/elements/meta.test.art @@ -4,7 +4,7 @@ import {src/html.art}! suite "" [ test.skip " must have 'href, 'target or both" [ ; None - assert -> not? throws? [ + assert -> throws? [ artml\base #[] ] @@ -29,7 +29,7 @@ suite "" [ } - result: base #[href: "https://example.com" target: "_blank"] + result: artml\base #[href: "https://example.com" target: "_blank"] assert -> expect = result ] ] From a43eff7911732d1fff817e8b4b90df3eca675574 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sat, 27 Apr 2024 15:52:16 -0300 Subject: [PATCH 24/97] [test\elements\meta] refactor base requirements test --- test/elements/meta.test.art | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/test/elements/meta.test.art b/test/elements/meta.test.art index ad4deba..bd74c97 100644 --- a/test/elements/meta.test.art +++ b/test/elements/meta.test.art @@ -2,26 +2,19 @@ import {unitt}! import {src/html.art}! suite "" [ - test.skip " must have 'href, 'target or both" [ - ; None - assert -> throws? [ - artml\base #[] - ] - - ; With href - assert -> not? throws? [ - artml\base #[href: "https://example.com"] - ] - - ; With target - assert -> not? throws? [ - artml\base #[target: "_blank"] - ] - - ; With both - assert -> not? throws? [ - artml\base #[href: "https://example.com" target: "_blank"] + + test " must have 'href, 'target or both" [ + + withHref: #[href: "https://example.com"] + withTarget: #[target: "_blank"] + withBoth: extend withHref withTarget + + assert -> throws? [artml\base #[]] + + loop @[withHref withTarget withBoth] 'dict [ + assert -> not? throws? [_: artml\base] ++ dict ] + ] test.skip " must be void and follow the standard" [ From f95b5062787b3808e3d6f135979f1c7e1acc021e Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sat, 27 Apr 2024 15:53:21 -0300 Subject: [PATCH 25/97] [test\elements\meta] unskip base's test --- test/elements/meta.test.art | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/elements/meta.test.art b/test/elements/meta.test.art index bd74c97..09b9317 100644 --- a/test/elements/meta.test.art +++ b/test/elements/meta.test.art @@ -17,7 +17,7 @@ suite "" [ ] - test.skip " must be void and follow the standard" [ + test " must be void and follow the standard" [ expect: {!html } From 580e1dbb445f963db5ab832d98770b0d07e45da3 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sat, 27 Apr 2024 15:56:17 -0300 Subject: [PATCH 26/97] [test\elements\meta] remove senseless test --- test/elements/meta.test.art | 5 ----- 1 file changed, 5 deletions(-) diff --git a/test/elements/meta.test.art b/test/elements/meta.test.art index 09b9317..6472856 100644 --- a/test/elements/meta.test.art +++ b/test/elements/meta.test.art @@ -29,11 +29,6 @@ suite "" [ suite "" [ - test.skip " gets two arguments 'rel and 'href" [ - assert -> not? throws? [artml\metaLink "stylesheet" "style.css"] - assert -> throws? [artml\metaLink "stylesheet"] - assert -> throws? [artml\metaLink] - ] test.skip " takes :string-like arguments" [ assert -> not? throws? [artml\metaLink "stylesheet" "style.css"] From 8b386683ad9169ed7c4873a97ffa8cbaac1d0546 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sat, 27 Apr 2024 16:01:32 -0300 Subject: [PATCH 27/97] [test\elements\meta] unskip and fix link's test --- test/elements/meta.test.art | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/elements/meta.test.art b/test/elements/meta.test.art index 6472856..62aaa1e 100644 --- a/test/elements/meta.test.art +++ b/test/elements/meta.test.art @@ -30,14 +30,14 @@ suite "" [ suite "" [ - test.skip " takes :string-like arguments" [ - assert -> not? throws? [artml\metaLink "stylesheet" "style.css"] - assert -> not? throws? [artml\metaLink :stylesheet "style.css"] - assert -> not? throws? [artml\metaLink 'stylesheet "style.css"] - - assert -> throws? [artml\metaLink ["stylesheet"] "style.css"] - assert -> throws? [artml\metaLink :stylesheet ["style.css"]] - assert -> throws? [artml\metaLink ['stylesheet] ["style.css"]] + test " takes :string-like arguments" [ + assert -> not? throws? [_: artml\metaLink "stylesheet" "style.css"] + assert -> not? throws? [_: artml\metaLink :stylesheet "style.css"] + assert -> not? throws? [_: artml\metaLink 'stylesheet "style.css"] + + assert -> throws? [_: artml\metaLink ["stylesheet"] "style.css"] + assert -> throws? [_: artml\metaLink :stylesheet ["style.css"]] + assert -> throws? [_: artml\metaLink ['stylesheet] ["style.css"]] ] test.skip " .size gets an :integer and converts to standard" [ From 5e430e0a6eae736e01e562b0da6451f7d1954b83 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sat, 27 Apr 2024 16:04:39 -0300 Subject: [PATCH 28/97] [test\elements\meta] unskip and fix link's test --- test/elements/meta.test.art | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/elements/meta.test.art b/test/elements/meta.test.art index 62aaa1e..c1c463e 100644 --- a/test/elements/meta.test.art +++ b/test/elements/meta.test.art @@ -40,9 +40,9 @@ suite "" [ assert -> throws? [_: artml\metaLink ['stylesheet] ["style.css"]] ] - test.skip " .size gets an :integer and converts to standard" [ + test " .size gets an :integer and converts to standard" [ expect: {!html - + } result: artml\metaLink.size: 70 "apple-touch-icon" "icon.png" From 1b9d244222139976c961745a5f53df29b3b8c42f Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sat, 27 Apr 2024 16:05:22 -0300 Subject: [PATCH 29/97] [test\elements\meta] unskip and fix link's test --- test/elements/meta.test.art | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/elements/meta.test.art b/test/elements/meta.test.art index c1c463e..b6219b2 100644 --- a/test/elements/meta.test.art +++ b/test/elements/meta.test.art @@ -49,9 +49,9 @@ suite "" [ assert -> expect = result ] - test.skip "'s .size does not influences other attributes" [ + test "'s .size does not influences other attributes" [ expect: {!html - + } result: artml\metaLink.size: 70 .type: "image/png" From 35c9224c9937bfe9ffa280d4741759e17048b4dd Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sat, 27 Apr 2024 16:30:44 -0300 Subject: [PATCH 30/97] [test\new-elements] fix syntax --- test/class/newElement.test.art | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/class/newElement.test.art b/test/class/newElement.test.art index 80efb6d..d4e2f95 100644 --- a/test/class/newElement.test.art +++ b/test/class/newElement.test.art @@ -3,7 +3,7 @@ import {src/html}! test.skip "new element of kind :group/:section only accepts :blocks" [ - loop [:group :section] kind [ + loop [:group :section] 'kind [ head: artml\newElement 'head kind assert -> not? throws? [head ["Hello"]] @@ -15,7 +15,7 @@ test.skip "new element of kind :group/:section only accepts :blocks" [ ] test.skip "new element of kind :text/:inline only accepts :string-based types" [ - loop [:text :inline] kind [ + loop [:text :inline] 'kind [ bold: artml\newElement 'b kind assert -> not? throws? [head "Hello"] From 42f42e511ad415874627ce2ae4ccd7dd2a48ce7c Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sat, 27 Apr 2024 16:31:03 -0300 Subject: [PATCH 31/97] [test] remove useless test --- test/metadata.test.art | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 test/metadata.test.art diff --git a/test/metadata.test.art b/test/metadata.test.art deleted file mode 100644 index 958097d..0000000 --- a/test/metadata.test.art +++ /dev/null @@ -1,18 +0,0 @@ -import {unitt}! -import {src/html.art}! - - -test " includes " [ - - expect: {!html - <head> - <title>Hello, world! - - } - - result: artml\head [ - title "Hello, world!" - ] - - assert -> expect = result -] \ No newline at end of file From 613c95d4abce43d29fb5265b93622ca8fa9e77c8 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sat, 27 Apr 2024 18:09:50 -0300 Subject: [PATCH 32/97] [test] add support for fragment --- test/elements/meta.test.art | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/test/elements/meta.test.art b/test/elements/meta.test.art index b6219b2..9cff8f0 100644 --- a/test/elements/meta.test.art +++ b/test/elements/meta.test.art @@ -1,18 +1,20 @@ import {unitt}! -import {src/html.art}! + +import.lean {src/html.art}! suite "" [ test " must have 'href, 'target or both" [ + base: $[x][fragment [base x]] withHref: #[href: "https://example.com"] withTarget: #[target: "_blank"] withBoth: extend withHref withTarget - assert -> throws? [artml\base #[]] + assert -> throws? [_: base #[]] loop @[withHref withTarget withBoth] 'dict [ - assert -> not? throws? [_: artml\base] ++ dict + assert -> not? throws? [_: fragment -> base] ++ dict ] ] @@ -22,7 +24,7 @@ suite "" [ } - result: artml\base #[href: "https://example.com" target: "_blank"] + result: fragment [base #[href: "https://example.com" target: "_blank"]] assert -> expect = result ] ] @@ -31,13 +33,15 @@ suite "" [ suite "" [ test " takes :string-like arguments" [ - assert -> not? throws? [_: artml\metaLink "stylesheet" "style.css"] - assert -> not? throws? [_: artml\metaLink :stylesheet "style.css"] - assert -> not? throws? [_: artml\metaLink 'stylesheet "style.css"] + link: $[x y][fragment [metaLink x y]] + + assert -> not? throws? [_: link "stylesheet" "style.css"] + assert -> not? throws? [_: link :stylesheet "style.css"] + assert -> not? throws? [_: link 'stylesheet "style.css"] - assert -> throws? [_: artml\metaLink ["stylesheet"] "style.css"] - assert -> throws? [_: artml\metaLink :stylesheet ["style.css"]] - assert -> throws? [_: artml\metaLink ['stylesheet] ["style.css"]] + assert -> throws? [_: link ["stylesheet"] "style.css"] + assert -> throws? [_: link :stylesheet ["style.css"]] + assert -> throws? [_: link ['stylesheet] ["style.css"]] ] test " .size gets an :integer and converts to standard" [ @@ -45,7 +49,10 @@ suite "" [ } - result: artml\metaLink.size: 70 "apple-touch-icon" "icon.png" + result: fragment [ + metaLink.size: 70 "apple-touch-icon" "icon.png" + ] + assert -> expect = result ] @@ -54,8 +61,10 @@ suite "" [ } - result: artml\metaLink.size: 70 .type: "image/png" - "apple-touch-icon" "icon.png" + result: fragment [ + metaLink.size: 70 .type: "image/png" "apple-touch-icon" "icon.png" + ] + assert -> expect = result ] From fed97ae820087ef31d8c5c2e41074720bae16c82 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sat, 27 Apr 2024 18:11:25 -0300 Subject: [PATCH 33/97] [html] deprecate object support and add fragments --- src/elements/_generator.art | 81 +++++++++++++++++++++++++++++++ src/html.art | 97 +++---------------------------------- src/root.art | 27 +++++------ 3 files changed, 100 insertions(+), 105 deletions(-) create mode 100644 src/elements/_generator.art diff --git a/src/elements/_generator.art b/src/elements/_generator.art new file mode 100644 index 0000000..5d97c22 --- /dev/null +++ b/src/elements/_generator.art @@ -0,0 +1,81 @@ + +element: $[tag :string :literal content :block :string][ + ;; Elements refers to the normal elements defined by the HTML5 standard. + ;; + ;; Format + ;; ------ + ;; * They follows the pattern: ``content``. + ;; * When ``content`` is a :block, the content will be intended by 2 spaces. + ;; + ;; Features + ;; -------- + ;; Use Arturo's attributes to dynamically add html's attributes to it. + ;; + ;; Extra + ;; ----- + ;; Read more about elements here: + ;; + + attributes: (join.with: " " map attrs [key value] -> render {|key|="|value|"}) + if attributes <> "" -> prepend 'attributes " " + + if block? content -> + join.with: "\n" @[ + ~"<|tag||attributes|>" + indent.n: 2 join.with: "\n" @content + ~"" + ] + + if string? content -> + ~"<|tag||attributes|>|content|" +] + +voidElement: $[tag :string :literal htmlAttributes :dictionary][ + ;; Void elements are elements without closing-tags. + ;; + ;; Format + ;; ------ + ;; They follows the pattern: ```` + ;; + ;; Features + ;; -------- + ;; Use Arturo's attributes to dynamically add html's attributes to it. + ;; + ;; Extra + ;; ----- + ;; Read more about void elements here: + ;; + + attributes: ( + map htmlAttributes [key value] -> render {|key|="|value|"} + | append (map attrs [key value] -> render {|key|="|value|"}) + | join.with: " " + ) + + if attributes <> "" -> prepend 'attributes " " + ~"<|tag||attributes|/>" +] + +newElement: $[tag :string :literal kind :type][ + + head: [content] + body: [element] ++ (@[tag]) ++ [content] + + if in? kind [:group :section] -> + append 'head :block + + if in? kind [:text :inline] -> + append 'head :string + + if in? kind [:any] -> + append 'head [:block :string] + + if in? kind [:void] [ + append 'head :dictionary + drop 'body + prepend 'body [voidElement] + ] + + method head body + +] \ No newline at end of file diff --git a/src/html.art b/src/html.art index f851a2c..2deb403 100644 --- a/src/html.art +++ b/src/html.art @@ -1,94 +1,9 @@ +import ./{elements/_generator.art}! +import ./{root.art}! -define :htmlModule [ +fragment: $[content :block][ + import ./{elements/meta.art} - init: method [][ - elements: #./"root.art" - loop elements ['el 'action] -> this\[el]: var get info.get 'action 'name - ] - - newElement: method [tag :string :literal kind :type][ - - head: [content] - body: [this\element] ++ (@[tag]) ++ [content] - - if in? kind [:group :section] -> - append 'head :block - - if in? kind [:text :inline] -> - append 'head :string - - if in? kind [:any] -> - append 'head [:block :string] - - if in? kind [:void] [ - append 'head :dictionary - drop 'body - prepend 'body [this\voidElement] - ] - - method head body - - ] - - element: method [tag :string :literal content :block :string][ - ;; Elements refers to the normal elements defined by the HTML5 standard. - ;; - ;; Format - ;; ------ - ;; * They follows the pattern: ``content``. - ;; * When ``content`` is a :block, the content will be intended by 2 spaces. - ;; - ;; Features - ;; -------- - ;; Use Arturo's attributes to dynamically add html's attributes to it. - ;; - ;; Extra - ;; ----- - ;; Read more about elements here: - ;; - - attributes: (join.with: " " map attrs [key value] -> render {|key|="|value|"}) - if attributes <> "" -> prepend 'attributes " " - - if block? content -> - join.with: "\n" @[ - ~"<|tag||attributes|>" - indent.n: 2 join.with: "\n" @content - ~"" - ] - - if string? content -> - ~"<|tag||attributes|>|content|" - ] - - voidElement: method [tag :string :literal htmlAttributes :dictionary][ - ;; Void elements are elements without closing-tags. - ;; - ;; Format - ;; ------ - ;; They follows the pattern: ```` - ;; - ;; Features - ;; -------- - ;; Use Arturo's attributes to dynamically add html's attributes to it. - ;; - ;; Extra - ;; ----- - ;; Read more about void elements here: - ;; - - attributes: ( - map htmlAttributes [key value] -> render {|key|="|value|"} - | append (map attrs [key value] -> render {|key|="|value|"}) - | join.with: " " - ) - - if attributes <> "" -> prepend 'attributes " " - ~"<|tag||attributes|/>" - ] - -] - - -artml: to :htmlModule [] \ No newline at end of file + first @content +] \ No newline at end of file diff --git a/src/root.art b/src/root.art index d48f04f..e3c5af3 100644 --- a/src/root.art +++ b/src/root.art @@ -1,6 +1,17 @@ +import ./{elements/_generator}! +head: $[content :block][ + import ./{elements/meta} -html: method [page :block][ + link: var 'metaLink + element 'head content +] + +body: $[][ + +] + +html: $[page :block][ html4: attr 'html4 doctype: (html4)? @@ -11,20 +22,8 @@ html: method [page :block][ } - head: $[x][this\head x] - body: $[x][this\body x] - join.with: "\n" @[ doctype - this\element 'html page + element 'html page ] -] - -head: method [content :block][ - title: $[x][this\title x] - this\element 'head content -] - -body: method [][ - ] \ No newline at end of file From 506aadc8f496ccc6810b25b1a6c802aaecff793a Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sat, 27 Apr 2024 18:12:28 -0300 Subject: [PATCH 34/97] [test\elements\meta] unskip and fix link's test --- test/elements/meta.test.art | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/test/elements/meta.test.art b/test/elements/meta.test.art index 9cff8f0..4bcb700 100644 --- a/test/elements/meta.test.art +++ b/test/elements/meta.test.art @@ -68,21 +68,23 @@ suite "" [ assert -> expect = result ] - test.skip " is a void element and follows the standard" [ + test " is a void element and follows the standard" [ expect: {!html - - - + + + } - result: artml\head [ - title "" - link :icon "icon.ico" - link :stylesheet "style.css" - link.size: 70 "apple-touch-icon" "icon.png" + result: fragment [ + head [ + title "" + link :icon "icon.ico" + link :stylesheet "style.css" + link.size: 70 "apple-touch-icon" "icon.png" + ] ] assert -> expect = result From a9664a9856bf64f24b224b716713dad340994c0d Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sat, 27 Apr 2024 18:15:38 -0300 Subject: [PATCH 35/97] [test\elements\meta] unskip and fix meta's test --- test/elements/meta.test.art | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/test/elements/meta.test.art b/test/elements/meta.test.art index 4bcb700..e23cd1e 100644 --- a/test/elements/meta.test.art +++ b/test/elements/meta.test.art @@ -93,21 +93,23 @@ suite "" [ ] suite "" [ - test.skip " is a void element and gets a :dictionary" [ + test " is a void element and gets a :dictionary" [ expect: {!html - - - - + + + + } - result: artml\html [ - title "" - meta #[charset: "utf-8"] - meta #["http-equiv": "content-security-policy" content: "..."] - meta #[name: "twitter?card" content: "summary"] + result: fragment [ + head [ + title "" + meta #[charset: "utf-8"] + meta #["http-equiv": "content-security-policy" content: "..."] + meta #[name: "twitter:card" content: "summary"] + ] ] assert -> expect = result From 074f0f04c22a141271e2aeac334499f30452ce0e Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sat, 27 Apr 2024 18:16:55 -0300 Subject: [PATCH 36/97] [test\elements\meta] add meta's test --- test/elements/meta.test.art | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/elements/meta.test.art b/test/elements/meta.test.art index e23cd1e..6be8f2c 100644 --- a/test/elements/meta.test.art +++ b/test/elements/meta.test.art @@ -93,6 +93,12 @@ suite "" [ ] suite "" [ + + test " must have attributes" [ + assert -> not? throws? [_: fragment [meta #[charset: "utf-8"]]] + assert -> throws? [_: fragment [meta #[]]] + ] + test " is a void element and gets a :dictionary" [ expect: {!html From 68f76284f635fb73b321f225d2ebc0cd3b4028aa Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sat, 27 Apr 2024 18:18:32 -0300 Subject: [PATCH 37/97] [test\elements\meta] remove useless test --- test/elements/meta.test.art | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/elements/meta.test.art b/test/elements/meta.test.art index 6be8f2c..24cb9ab 100644 --- a/test/elements/meta.test.art +++ b/test/elements/meta.test.art @@ -124,10 +124,6 @@ suite "" [ suite " } - result: artml\style {!css - p { - color: black; + result: fragment [ + style.media: "max-width: 720px" {!css + p { + color: black; + } } - } + ] assert -> expect = result From 8cdba6a9114b4b898d6c55752d3a6b657b7549be Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sat, 27 Apr 2024 18:29:28 -0300 Subject: [PATCH 44/97] [test\elements\meta] unskip title's test --- test/elements/meta.test.art | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/elements/meta.test.art b/test/elements/meta.test.art index 5228e02..a1e87b3 100644 --- a/test/elements/meta.test.art +++ b/test/elements/meta.test.art @@ -150,12 +150,12 @@ suite " } - result: fragment [ - style.media: "max-width: 720px" {!css + result: style.media: "max-width: 720px" + {!css p { color: black; } } - ] assert -> expect = result @@ -155,7 +151,7 @@ suite "" [ <title>Arturo Language! } - result: fragment [title "Arturo Language!"] + result: title "Arturo Language!" assert -> expect = result ] From 4ae269fca0703e2ae602eae9e550fff16d9e2ad1 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sun, 28 Apr 2024 11:10:04 -0300 Subject: [PATCH 50/97] [html\elements\main] add element --- src/elements/main.art | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/elements/main.art b/src/elements/main.art index c1e94a0..5833ad2 100644 --- a/src/elements/main.art +++ b/src/elements/main.art @@ -1,3 +1,5 @@ +import ./{_generator}! + head: $[content :block][ ; Making all meta elements available to this scope @@ -12,6 +14,8 @@ head: $[content :block][ element 'head content ] -body: $[][ +body: $[content :block][ + import ./{section}! + element 'body content ] \ No newline at end of file From 1d4386abe0b5ba5a8a7f5c20c3eb4c8189ca1742 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sun, 28 Apr 2024 11:11:06 -0300 Subject: [PATCH 51/97] [html\elements\section] create elements --- src/elements/section.art | 73 +++++++++++++++++++++++++++++++--------- 1 file changed, 57 insertions(+), 16 deletions(-) diff --git a/src/elements/section.art b/src/elements/section.art index b98d35e..5d2de95 100644 --- a/src/elements/section.art +++ b/src/elements/section.art @@ -4,19 +4,60 @@ ;; Organizes the document into semantic sections. ;; For Html.art, those are injected into ``body``. -addr: $[][] -article: $[][] -aside: $[][] -footer: $[][] -header: $[][] -h1: $[][] -h2: $[][] -h3: $[][] -h4: $[][] -h5: $[][] -h6: $[][] -headGroup: $[][] -main: $[][] -nav: $[][] -section: $[][] -search: $[][] +import ./{_generator}! + +address: $[content :string :block][ + call $[] [ + loop [ + ; Hides heading elements + 'h1 'h2 'h3 'h4 'h5 'h6 'headGroup + ; Hides section elements + 'article 'aside 'section 'nav 'header 'footer + ] => unset + + element 'address content + ][] +] + +footer: $[content :block][ + call $[][ + ; header must not be descendant of footer + unset 'header + + element 'header :section + ][] +] + +header: $[content :block][ + call $[][ + ; header must not be descendant of header + unset 'header + + element 'header :section + ][] +] + +search: $[content :block][ + ; forms.art is always available for + unless set? 'form [ + import ./{forms}! + ] + + element 'search :section +] + + +article: newElement 'article :section +aside: newElement 'aside :section + +h1: newElement 'h1 :inline +h2: newElement 'h2 :inline +h3: newElement 'h3 :inline +h4: newElement 'h4 :inline +h5: newElement 'h5 :inline +h6: newElement 'h6 :inline + +headGroup: newElement 'hgroup :group +main: newElement 'main :section +nav: newElement 'nav :section +section: newElement 'section :section From 99f396a8cd1f2a7f3ccedda8e9af350896a79059 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sun, 28 Apr 2024 11:17:25 -0300 Subject: [PATCH 52/97] [test] rename file to unit --- test/{elements => unit}/meta.test.art | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{elements => unit}/meta.test.art (100%) diff --git a/test/elements/meta.test.art b/test/unit/meta.test.art similarity index 100% rename from test/elements/meta.test.art rename to test/unit/meta.test.art From c2fe2bc9ef1882934e114813634237bb935f067f Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sun, 28 Apr 2024 11:18:58 -0300 Subject: [PATCH 53/97] [test] turn test into unit-test --- test/{class/newElement.test.art => unit/generator.art} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename test/{class/newElement.test.art => unit/generator.art} (97%) diff --git a/test/class/newElement.test.art b/test/unit/generator.art similarity index 97% rename from test/class/newElement.test.art rename to test/unit/generator.art index ba4ae53..98e8675 100644 --- a/test/class/newElement.test.art +++ b/test/unit/generator.art @@ -1,5 +1,5 @@ import {unitt}! -import {src/html}! +import {src/elements/_generator}! test.skip "new element of kind :group/:section only accepts :blocks" [ From 4cf3d2060fbdc026a4add5db18c8e5b95036a5fb Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sun, 28 Apr 2024 11:20:52 -0300 Subject: [PATCH 54/97] [test] turn test into unit-test --- test/{ => unit}/element.test.art | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) rename test/{ => unit}/element.test.art (96%) diff --git a/test/element.test.art b/test/unit/element.test.art similarity index 96% rename from test/element.test.art rename to test/unit/element.test.art index 16110ba..bf16e22 100644 --- a/test/element.test.art +++ b/test/unit/element.test.art @@ -1,10 +1,9 @@ import {unitt}! -import {src/html.art}! +import {src/elements/_generator}! test "generic elements follows the standard for :string" [ result: element "el" "Hello, World!" - assert -> "Hello, World!" = - result + assert -> "Hello, World!" = result ] From f431ec5f01f8ccbeb1dd1abf34f999b788940b39 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sun, 28 Apr 2024 11:21:24 -0300 Subject: [PATCH 55/97] [test] fix test suffix --- test/unit/{generator.art => generator.test.art} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/unit/{generator.art => generator.test.art} (100%) diff --git a/test/unit/generator.art b/test/unit/generator.test.art similarity index 100% rename from test/unit/generator.art rename to test/unit/generator.test.art From d5c954d08f8a4e5dff4402550d98cc8727d12b54 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sun, 28 Apr 2024 11:25:24 -0300 Subject: [PATCH 56/97] [html] merge root.art and html.art --- src/html.art | 20 +++++++++++++++++++- src/root.art | 20 -------------------- 2 files changed, 19 insertions(+), 21 deletions(-) delete mode 100644 src/root.art diff --git a/src/html.art b/src/html.art index ddd856d..fdca01b 100644 --- a/src/html.art +++ b/src/html.art @@ -1,7 +1,25 @@ import ./{elements/_generator.art}! -import ./{root.art}! +html: $[page :block][ + html4: attr 'html4 + + doctype: (html4)? + -> {!html + + } + -> {!html + + } + + import ./{elements/main}! + + join.with: "\n" @[ + doctype + element 'html page + ] +] + fragment: $[content :block][ import ./{elements/main}! import ./{elements/meta}! diff --git a/src/root.art b/src/root.art deleted file mode 100644 index 322b001..0000000 --- a/src/root.art +++ /dev/null @@ -1,20 +0,0 @@ -import ./{elements/_generator}! - -html: $[page :block][ - html4: attr 'html4 - - doctype: (html4)? - -> {!html - - } - -> {!html - - } - - import ./{elements/main}! - - join.with: "\n" @[ - doctype - element 'html page - ] -] \ No newline at end of file From 49a7dcd97e58d8623549bf2fe4a7c5d70e9393fa Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sun, 28 Apr 2024 11:28:07 -0300 Subject: [PATCH 57/97] [html] remove unused file --- src/elements.art | 80 ------------------------------------------------ 1 file changed, 80 deletions(-) delete mode 100644 src/elements.art diff --git a/src/elements.art b/src/elements.art deleted file mode 100644 index 920d459..0000000 --- a/src/elements.art +++ /dev/null @@ -1,80 +0,0 @@ - -; Document Level -; ============== - -body: method [content :block][ - this\element 'body content -] - -title: method [title :string][ - this\element 'title title -] - - -; Text Level -; ========== - -paragraph: method [content :block :string][ - this\element 'p content -] - -link: method [url :string][ - (attr 'alt)?? - -> this\element.href: url 'a attr 'alt - -> this\element.href: url 'a url -] - -bold: method [text :string][ - this\element 'strong text -] - -emphasis: method [text :string][ - this\element 'em text -] - -alternateVoice: method [text :string][ - ;; Used for alterated voice or mood - ;; - ;; When to use it - ;; -------------- - ;; * Alternative voice - ;; * Alternative mood - ;; * Transliteration - ;; * Idiomatic Phrase - ;; * Technical Terms - ;; - ;; Extra - ;; ----- - ;; See: - ;; - this\element 'i text -] - -br: method [][ - this\voidElement 'br -] - -h1: method [text :string][ - this\element 'h1 text -] -h2: method [text :string][ - this\element 'h2 text -] -h3: method [text :string][ - this\element 'h3 text -] -h4: method [text :string][ - this\element 'h4 text -] -h5: method [text :string][ - this\element 'h5 text -] -h6: method [text :string][ - this\element 'h6 text -] - -divisory: method [content :block :text][ - this\element 'div content -] - - From ab36429c6adf10797dcbdb5ec1d0205fda15436c Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sun, 28 Apr 2024 11:28:57 -0300 Subject: [PATCH 58/97] [html] remove unused file --- main.deprecated.art | 59 --------------------------------------------- 1 file changed, 59 deletions(-) delete mode 100644 main.deprecated.art diff --git a/main.deprecated.art b/main.deprecated.art deleted file mode 100644 index 5528edb..0000000 --- a/main.deprecated.art +++ /dev/null @@ -1,59 +0,0 @@ -;========================================== -; HTML :module -; for Arturo -; -; @file: html/main.art -; @author: drkameleon -;========================================== - -;------------------------------- -; Helper functions -;------------------------------- - -shortTag: function [name][ - attributes: "" - - loop attrs [k,v]-> - attributes: attributes ++ ~" |k|='|v|'" - - render "<|name||attributes|>" -] - - -tag: function [name,contents][ - tagStart: shortTag name - - if? :string = type contents -> - render "|tagStart||contents|" - else -> - render "|tagStart||join @contents|" -] - -;------------------------------- -; Main methods -;------------------------------- - -html: $=> tag "html" & - -head: $=> tag "head" & - -meta: $[X]-> shortTag "meta" -link: $[X]-> shortTag "link" -title: $=> tag "title" & - -body: $=> tag "body" & - -; Headers - -h1: $=> tag "h1" & -h2: $=> tag "h2" & -h3: $=> tag "h3" & -h4: $=> tag "h4" & -h5: $=> tag "h5" & -h6: $=> tag "h6" & - -p: $=> tag "p" & - -b: $=> tag "b" & - -script: $=> tag "script" & From 413dc37b0bbfc9331784550bc3b34afb3fcc7f6b Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sun, 28 Apr 2024 11:31:38 -0300 Subject: [PATCH 59/97] [test] remove deprecated test --- test/text.test.art | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 test/text.test.art diff --git a/test/text.test.art b/test/text.test.art deleted file mode 100644 index 6a37e87..0000000 --- a/test/text.test.art +++ /dev/null @@ -1,27 +0,0 @@ -import {unitt}! -import {src/html.art}! - -test "Headings are working as expected" [ - expect: {!html -
-

Text

-

Text

-

Text

-

Text

-
Text
-
Text
-
- } - - result: divisory [ - h1 "Text" - h2 "Text" - h3 "Text" - h4 "Text" - h5 "Text" - h6 "Text" - ] - - assert -> expect = result - -] \ No newline at end of file From 056df2108d74a8e6c584d849d86cea770d142e74 Mon Sep 17 00:00:00 2001 From: RickBarretto <78623871+RickBarretto@users.noreply.github.com> Date: Sun, 28 Apr 2024 13:47:00 -0300 Subject: [PATCH 60/97] [html\elements\text] create elements --- src/elements/text.art | 188 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 170 insertions(+), 18 deletions(-) diff --git a/src/elements/text.art b/src/elements/text.art index 1895fc4..40c0d65 100644 --- a/src/elements/text.art +++ b/src/elements/text.art @@ -4,21 +4,173 @@ ;; Defines the structure of the document. ;; For Html.art, those are injected into ``body``. -blockquote: $[][] -definition: $[][] -divisory: $[][] -figureCaption: $[][] -figure: $[][] -horizontalRule: $[][] -menu: $[][] -paragraph: $[][] -preformatted: $[][] - -; TODO: Decice the working of: -; -; * dd -; * dl -; * dt -; * ol -; * ul -; * li \ No newline at end of file +import ./{_generator}! + +definitions: $[list :block :dictionary][ + ;;
(Definitoin list) in HTML + ;; + ;; There are a lot of ways call this function: + ;; 1. You can use the internal function names + ;; * What helps to use custom attributes, or to explict things + ;; 2. You can use the ``pair`` or ``<`` sugar syntax + ;; * Attributes are applied only for the term, not the definition + ;; 3. You can use a ``:dictionary`` as parameter. + ;; + ;; Internal functions + ;; ------------------ + ;; * term: $[item :string] + ;; * detail: $[definition :string] + ;; * pair: $[item :string definition :string] + ;; * infixed: ``<`` + ;; + ;; Usage + ;; ----- + ;; definitions #[ + ;; "Arturo Language": "arturo-lang.io" + ;; "Ruby Language": "ruby-lang.org" + ;; ] + ;; ;
+ ;; ;
Arturo Language
+ ;; ;
arturo-lang.io
+ ;; ;
Ruby Language
+ ;; ;
ruby-lang.org
+ ;; ;
+ ;; ..................................................... + ;; definitions [ + ;; pair.class: "favorite" "Arturo" "arturo-lang.io" + ;; "Python" < "python.org" + ;; "Ruby" < "ruby-lang.org" + ;; ] + ;; ;
+ ;; ;
Arturo
+ ;; ;
arturo-lang.io
+ ;; ;
Python
+ ;; ;
python.org
+ ;; ;
Ruby
+ ;; ;
ruby-lang.org
+ ;; ;
+ ;; ..................................................... + ;; definitions [ + ;; term.class: "favorite" "Arturo" + ;; detail.class: "site" "arturo-lang.io" + ;; ] + ;; ;
+ ;; ;
Arturo
+ ;; ;
arturo-lang.io
+ ;; ;
+ ;; ..................................................... + ;; definitions [ + ;; term "Arturo" + ;; term "Python" + ;; term "RUby" + ;; detail "Dynamic Languages" + ;; ] + ;; ;
+ ;; ;
Arturo
+ ;; ;
Python
+ ;; ;
Ruby
+ ;; ;
Dynamic Languages
+ ;; ;
+ + detail: newElement 'dd :text + + pair: $[item :string definition :string][ + join.with: "\n" @[element 'dt item, detail definition] + ] + + term: $[item :string][ + (string? definition: <= attr 'definition)? + -> pair item definition + -> element 'dt item + ] + + alias.infix '< 'pair + + (block? list)? + -> element 'dl list + -> element 'dl map list => pair + + alias '< 'less? + +] + +itemList: $[items :block][ + ;;