From 33cddd980bb0ac1e49bae540f9c4af0781fde8a9 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Tue, 5 Apr 2022 15:25:14 -0500 Subject: [PATCH 1/6] Fix the DOCTYPE to be HTML5 Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com> --- src/Kelpie.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Kelpie.jl b/src/Kelpie.jl index 1a6469f..109526a 100644 --- a/src/Kelpie.jl +++ b/src/Kelpie.jl @@ -131,7 +131,7 @@ end #function Creates a new HTML document filled with `content`. """ function html(content...) - doc = EzXML.HTMLDocumentNode(nothing, nothing) + doc = EzXML.HTMLDocumentNode("about:legacy-compat", nothing) link_or_text!(doc, content...) return doc end #function From 6c8268f50c9ac6bfaba308ce2b76fca491ef3fc9 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Tue, 5 Apr 2022 15:33:50 -0500 Subject: [PATCH 2/6] Add node to html function Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com> --- src/Kelpie.jl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Kelpie.jl b/src/Kelpie.jl index 109526a..2e46c82 100644 --- a/src/Kelpie.jl +++ b/src/Kelpie.jl @@ -126,13 +126,14 @@ function html_element(name::AbstractString, content...=nothing; kwargs...) end #function """ - html(content...) + html(content...=nothing; kwargs...) Creates a new HTML document filled with `content`. """ -function html(content...) +function html(content...=nothing; kwargs...) doc = EzXML.HTMLDocumentNode("about:legacy-compat", nothing) - link_or_text!(doc, content...) + node = html_element("html", content...; kwargs...) + link!(doc, node) return doc end #function From 6152004356bb21645f64c8b8464d1676e3b3c384 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Tue, 5 Apr 2022 15:35:37 -0500 Subject: [PATCH 3/6] Add check for nothingness to link_or_text! Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com> --- src/Kelpie.jl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Kelpie.jl b/src/Kelpie.jl index 2e46c82..b7cd44f 100644 --- a/src/Kelpie.jl +++ b/src/Kelpie.jl @@ -83,10 +83,12 @@ julia> prettyprint(link_or_text!(ElementNode("div"), "The end", ElementNode("hr" """ function link_or_text!(node, content...) for con in content - if typeof(con) <: EzXML.Node - link!(node, con) - else - link!(node, EzXML.TextNode(string(con))) + if !isnothing(con) + if typeof(con) <: EzXML.Node + link!(node, con) + else + link!(node, EzXML.TextNode(string(con))) + end #if end #if end #for From 8a86c309de796cccc205cc670eddc3b926e1bade Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Tue, 5 Apr 2022 15:38:34 -0500 Subject: [PATCH 4/6] Add doctest for html function Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com> --- src/Kelpie.jl | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Kelpie.jl b/src/Kelpie.jl index b7cd44f..da52885 100644 --- a/src/Kelpie.jl +++ b/src/Kelpie.jl @@ -131,6 +131,17 @@ end #function html(content...=nothing; kwargs...) Creates a new HTML document filled with `content`. + +# Example + +```jldoctest +julia> import EzXML: prettyprint + +julia> prettyprint(html()) + + + +``` """ function html(content...=nothing; kwargs...) doc = EzXML.HTMLDocumentNode("about:legacy-compat", nothing) From 4683189f5c18eb7b1687df9a08382664442d9649 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Tue, 5 Apr 2022 15:41:36 -0500 Subject: [PATCH 5/6] Update CHANGELOG Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com> --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf531ac..36bdf73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Arrays of content replaced with argument splatting ([#2](https://github.com/MillironX/Kelpie.jl/pull/2)) +### Fixed + +- `html()` now returns an `` node, not just a document ([#3](https://github.com/MillironX/Kelpie.jl/pull/3)) + ## [0.1.0] - 2022-04-04 ### Added From e340ab4e26105043cfbeb7096a307462b5496409 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Tue, 5 Apr 2022 15:43:06 -0500 Subject: [PATCH 6/6] Update README example with html node Signed-off-by: Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com> --- README.md | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index db72766..d8012ac 100644 --- a/README.md +++ b/README.md @@ -60,22 +60,24 @@ Turns into ```html - - - Kelpie.jl is awesome! - - -
-

Dogs are cool

-

Julia is cool

-
-
- A Kelpie herding sheep -

Kelpies make great herding dogs for cows.

-

Kelpies make great herding dogs for sheep.

-

Kelpies make great herding dogs for chickens.

-
- + + + + Kelpie.jl is awesome! + + +
+

Dogs are cool

+

Julia is cool

+
+
+ A Kelpie herding sheep +

Kelpies make great herding dogs for cows.

+

Kelpies make great herding dogs for sheep.

+

Kelpies make great herding dogs for chickens.

+
+ + ``` Everything is pure Julia, so your imagination is the limit!