diff --git a/test/text.test.art b/test/text.test.art
index 74d94b0..6a37e87 100644
--- a/test/text.test.art
+++ b/test/text.test.art
@@ -13,13 +13,13 @@ test "Headings are working as expected" [
}
- result: artml\divisory [
- artml\h1 "Text"
- artml\h2 "Text"
- artml\h3 "Text"
- artml\h4 "Text"
- artml\h5 "Text"
- artml\h6 "Text"
+ result: divisory [
+ h1 "Text"
+ h2 "Text"
+ h3 "Text"
+ h4 "Text"
+ h5 "Text"
+ h6 "Text"
]
assert -> expect = result
From af7ac3de684510d7c528ae51814e772f433bd7ce Mon Sep 17 00:00:00 2001
From: RickBarretto <78623871+RickBarretto@users.noreply.github.com>
Date: Sat, 27 Apr 2024 20:34:55 -0300
Subject: [PATCH 47/97] [html] move and to elements/main.art
---
src/elements/main.art | 17 +++++++++++++++++
src/html.art | 3 ++-
src/root.art | 13 ++-----------
3 files changed, 21 insertions(+), 12 deletions(-)
create mode 100644 src/elements/main.art
diff --git a/src/elements/main.art b/src/elements/main.art
new file mode 100644
index 0000000..c1e94a0
--- /dev/null
+++ b/src/elements/main.art
@@ -0,0 +1,17 @@
+head: $[content :block][
+
+ ; Making all meta elements available to this scope
+ import ./{meta}!
+
+ ; The element is called 'link on this library for semantic reasons,
+ ; but there is no reason to have it on the
,
+ ; so the metaLink is aliased here as the original tag: .
+ ; Although, both forms are available to the final user.
+ link: var 'metaLink
+
+ element 'head content
+]
+
+body: $[][
+
+]
\ No newline at end of file
diff --git a/src/html.art b/src/html.art
index 2deb403..ddd856d 100644
--- a/src/html.art
+++ b/src/html.art
@@ -3,7 +3,8 @@ import ./{root.art}!
fragment: $[content :block][
- import ./{elements/meta.art}
+ import ./{elements/main}!
+ import ./{elements/meta}!
first @content
]
\ No newline at end of file
diff --git a/src/root.art b/src/root.art
index e3c5af3..322b001 100644
--- a/src/root.art
+++ b/src/root.art
@@ -1,16 +1,5 @@
import ./{elements/_generator}!
-head: $[content :block][
- import ./{elements/meta}
-
- link: var 'metaLink
- element 'head content
-]
-
-body: $[][
-
-]
-
html: $[page :block][
html4: attr 'html4
@@ -22,6 +11,8 @@ html: $[page :block][
}
+ import ./{elements/main}!
+
join.with: "\n" @[
doctype
element 'html page
From bcfce3195b1b4d05b473af2e3fee33e7d846eb3a Mon Sep 17 00:00:00 2001
From: RickBarretto <78623871+RickBarretto@users.noreply.github.com>
Date: Sat, 27 Apr 2024 20:55:12 -0300
Subject: [PATCH 48/97] [html\generator] newElement must return a function
instead of a method
---
src/elements/_generator.art | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/elements/_generator.art b/src/elements/_generator.art
index 5d97c22..7796093 100644
--- a/src/elements/_generator.art
+++ b/src/elements/_generator.art
@@ -76,6 +76,6 @@ newElement: $[tag :string :literal kind :type][
prepend 'body [voidElement]
]
- method head body
+ function head body
]
\ No newline at end of file
From 351c6313f4ed8dbfe9110f037ec502ddbb86c70f Mon Sep 17 00:00:00 2001
From: RickBarretto <78623871+RickBarretto@users.noreply.github.com>
Date: Sun, 28 Apr 2024 11:09:28 -0300
Subject: [PATCH 49/97] [test\elements\meta] test without fragments
---
test/elements/meta.test.art | 72 ++++++++++++++++++-------------------
1 file changed, 34 insertions(+), 38 deletions(-)
diff --git a/test/elements/meta.test.art b/test/elements/meta.test.art
index a1e87b3..5592136 100644
--- a/test/elements/meta.test.art
+++ b/test/elements/meta.test.art
@@ -1,12 +1,10 @@
import {unitt}!
-import.lean {src/html.art}!
+import {src/elements/meta}!
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
@@ -14,7 +12,7 @@ suite "" [
assert -> throws? [_: base #[]]
loop @[withHref withTarget withBoth] 'dict [
- assert -> not? throws? [_: fragment -> base] ++ dict
+ assert -> not? throws? [_: base] ++ dict
]
]
@@ -24,7 +22,7 @@ suite "" [
}
- result: fragment [base #[href: "https://example.com" target: "_blank"]]
+ result: base #[href: "https://example.com" target: "_blank"]
assert -> expect = result
]
]
@@ -33,15 +31,14 @@ suite "" [
suite "" [
test " takes :string-like arguments" [
- 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 -> not? throws? [_: metaLink "stylesheet" "style.css"]
+ assert -> not? throws? [_: metaLink :stylesheet "style.css"]
+ assert -> not? throws? [_: metaLink 'stylesheet "style.css"]
- assert -> throws? [_: link ["stylesheet"] "style.css"]
- assert -> throws? [_: link :stylesheet ["style.css"]]
- assert -> throws? [_: link ['stylesheet] ["style.css"]]
+ assert -> throws? [_: metaLink ["stylesheet"] "style.css"]
+ assert -> throws? [_: metaLink :stylesheet ["style.css"]]
+ assert -> throws? [_: metaLink ['stylesheet] ["style.css"]]
]
test " .size gets an :integer and converts to standard" [
@@ -49,9 +46,7 @@ suite "" [
}
- result: fragment [
- metaLink.size: 70 "apple-touch-icon" "icon.png"
- ]
+ result: metaLink.size: 70 "apple-touch-icon" "icon.png"
assert -> expect = result
]
@@ -61,14 +56,16 @@ suite "" [
}
- result: fragment [
- metaLink.size: 70 .type: "image/png" "apple-touch-icon" "icon.png"
- ]
+ result: metaLink
+ .size: 70
+ .type: "image/png"
+ "apple-touch-icon" "icon.png"
assert -> expect = result
]
test " is a void element and follows the standard" [
+
expect: {!html
@@ -78,13 +75,13 @@ suite "" [
}
- result: fragment [
- head [
- title ""
- link :icon "icon.ico"
- link :stylesheet "style.css"
- link.size: 70 "apple-touch-icon" "icon.png"
- ]
+ import {src/elements/main}!
+
+ result: head [
+ title ""
+ link :icon "icon.ico"
+ link :stylesheet "style.css"
+ link.size: 70 "apple-touch-icon" "icon.png"
]
assert -> expect = result
@@ -95,8 +92,8 @@ suite "" [
suite "" [
test " must have attributes" [
- assert -> not? throws? [_: fragment [meta #[charset: "utf-8"]]]
- assert -> throws? [_: fragment [meta #[]]]
+ assert -> not? throws? [_: meta #[charset: "utf-8"]]
+ assert -> throws? [_: meta #[]]
]
test " is a void element and gets a :dictionary" [
@@ -109,13 +106,13 @@ suite "" [
}
- result: fragment [
- head [
- title ""
- meta #[charset: "utf-8"]
- meta #["http-equiv": "content-security-policy" content: "..."]
- meta #[name: "twitter:card" content: "summary"]
- ]
+ import {src/elements/main}!
+
+ result: head [
+ title ""
+ meta #[charset: "utf-8"]
+ meta #["http-equiv": "content-security-policy" content: "..."]
+ meta #[name: "twitter:card" content: "summary"]
]
assert -> expect = result
@@ -134,13 +131,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 "" [
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||name|>"
- else ->
- render "|tagStart||join @contents||name|>"
-]
-
-;-------------------------------
-; 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"
+ ;; ]
+ ;; ;