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 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! diff --git a/src/Kelpie.jl b/src/Kelpie.jl index 1a6469f..da52885 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 @@ -126,13 +128,25 @@ function html_element(name::AbstractString, content...=nothing; kwargs...) end #function """ - html(content...) + html(content...=nothing; kwargs...) Creates a new HTML document filled with `content`. + +# Example + +```jldoctest +julia> import EzXML: prettyprint + +julia> prettyprint(html()) + + + +``` """ -function html(content...) - doc = EzXML.HTMLDocumentNode(nothing, nothing) - link_or_text!(doc, content...) +function html(content...=nothing; kwargs...) + doc = EzXML.HTMLDocumentNode("about:legacy-compat", nothing) + node = html_element("html", content...; kwargs...) + link!(doc, node) return doc end #function