Skip to content

Commit

Permalink
remove extra whitespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilTaken committed Jun 2, 2024
1 parent f475b41 commit af83472
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
36 changes: 18 additions & 18 deletions src/xmleam/xml_builder.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub fn new_advanced_document(version: String, encoding: String) -> XmlBuilder {
|> string_builder.append(version)
|> string_builder.append("\" encoding=\"")
|> string_builder.append(encoding)
|> string_builder.append("\"?> \n")
|> string_builder.append("\"?>\n")
|> Ok
}

Expand Down Expand Up @@ -90,11 +90,11 @@ pub fn tag(document: XmlBuilder, label: String, contents: String) -> XmlBuilder
string_builder.new()
|> append("<")
|> append(label)
|> append("> ")
|> append(">")
|> append(contents)
|> append(" </")
|> append("</")
|> append(label)
|> append("> \n")
|> append(">\n")
|> append_builder(
to: result.unwrap(document, string_builder.new()),
suffix: _,
Expand All @@ -119,13 +119,13 @@ pub fn cdata_tag(document: XmlBuilder, label: String, contents: String) {
string_builder.new()
|> append("<")
|> append(label)
|> append("> \n")
|> append(">\n")
|> append("<![CDATA[\n \t")
|> append(contents)
|> append("\n]]> \n")
|> append("\n]]>\n")
|> append("</")
|> append(label)
|> append("> \n")
|> append(">\n")
|> append_builder(
to: result.unwrap(document, string_builder.new()),
suffix: _,
Expand Down Expand Up @@ -157,11 +157,11 @@ pub fn option_content_tag(
|> append("<")
|> append(label)
|> append_builder(string_options(options))
|> append("> ")
|> append(">")
|> append(contents)
|> append(" </")
|> append("</")
|> append(label)
|> append("> \n")
|> append(">\n")
|> append_builder(
to: result.unwrap(document, string_builder.new()),
suffix: _,
Expand All @@ -186,7 +186,7 @@ pub fn option_tag(document: XmlBuilder, label: String, options: List(Option)) {
|> append("<")
|> append(label)
|> append_builder(string_options(options))
|> append(" />\n")
|> append("/>\n")
|> append_builder(
to: result.unwrap(document, string_builder.new()),
suffix: _,
Expand Down Expand Up @@ -231,11 +231,11 @@ pub fn block_tag(document: XmlBuilder, label: String, inner: XmlBuilder) {
string_builder.new()
|> append("<")
|> append(label)
|> append("> \n")
|> append(">\n")
|> append_builder(result.unwrap(inner, string_builder.new()))
|> append("</")
|> append(label)
|> append("> \n")
|> append(">\n")
|> append_builder(
to: result.unwrap(document, string_builder.new()),
suffix: _,
Expand Down Expand Up @@ -272,11 +272,11 @@ pub fn option_block_tag(
|> append("<")
|> append(label)
|> append_builder(string_options(options))
|> append("> \n")
|> append(">\n")
|> append_builder(result.unwrap(inner, string_builder.new()))
|> append(" </")
|> append("</")
|> append(label)
|> append("> \n")
|> append(">\n")
|> append_builder(
to: result.unwrap(document, string_builder.new()),
suffix: _,
Expand Down Expand Up @@ -324,9 +324,9 @@ pub fn block_comment(document: XmlBuilder, inner: XmlBuilder) {

False ->
string_builder.new()
|> append("<!-- \n")
|> append("<!--\n")
|> append_builder(result.unwrap(inner, string_builder.new()))
|> append("--> \n")
|> append("-->\n")
|> append_builder(
to: result.unwrap(document, string_builder.new()),
suffix: _,
Expand Down
8 changes: 4 additions & 4 deletions test/xmleam_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub fn xml_builder_cdata_test() {
|> xml_builder.end_xml
|> result.unwrap("ERROR")
|> should.equal(
"<link> \n<![CDATA[\n \t<a href=\"https://example.com\"> link </a>\n]]> \n</link> \n",
"<link>\n<![CDATA[\n \t<a href=\"https://example.com\"> link </a>\n]]>\n</link>\n",
)
}

Expand All @@ -48,7 +48,7 @@ pub fn xml_builder_full_test() {
|> end_xml()
|> result.unwrap("ERROR")
|> should.equal(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rss xmlns:itunes=\"http://www.itunes.com/dtds/podcast-1.0.dtd\"> \n<channel> \n<title> Example RSS Feed </title> \n<description> this is a teaching example for xmleam </description> \n</channel> \n<item> \n<title> Example Item </title> \n</item> \n </rss> \n",
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rss xmlns:itunes=\"http://www.itunes.com/dtds/podcast-1.0.dtd\">\n<channel>\n<title>Example RSS Feed</title>\n<description>this is a teaching example for xmleam</description>\n</channel>\n<item>\n<title>Example Item</title>\n</item>\n</rss>\n",
)

xml_builder.new_document()
Expand All @@ -57,7 +57,7 @@ pub fn xml_builder_full_test() {
|> end_xml()
|> result.unwrap("ERROR")
|> should.equal(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<link href=\"https://example.com\" idk=\"N/A\" />\n<hello world=\"Earth\"> AAAAAAA </hello> \n",
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<link href=\"https://example.com\" idk=\"N/A\"/>\n<hello world=\"Earth\">AAAAAAA</hello>\n",
)

xml_builder.new()
Expand All @@ -73,5 +73,5 @@ pub fn xml_builder_full_test() {
})
|> end_xml()
|> result.unwrap("ERROR")
|> should.equal("<!-- \n<hello> world </hello> \n--> \n")
|> should.equal("<!--\n<hello>world</hello>\n-->\n")
}

0 comments on commit af83472

Please sign in to comment.