fix: Initial chardata was being thrown away
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				test / test (push) Has been cancelled
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	test / test (push) Has been cancelled
				
			This commit is contained in:
		@@ -44,12 +44,19 @@ pub type Element {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
pub fn main() {
 | 
					pub fn main() {
 | 
				
			||||||
  parse_document(
 | 
					  parse_document(
 | 
				
			||||||
    "<?xml version=\"1.1\" encoding='UTF-8'?>\r\n   <!-- hello-world -->   \n<b><a attr='ha &#38;ha' battr='baba' ref='&'/><!-- ma comment --><![CDATA[Testing&&<haha>]]><?test asuhashd ?></b>",
 | 
					    //"<?xml version=\"1.1\" encoding='UTF-8'?>\r\n   <!-- hello-world -->   \n<b blah:test='1'><a attr='ha &#38;ha' battr='baba' ref='&'/><!-- ma comment --><![CDATA[Testing&&<haha>]]><?test asuhashd ?></b>",
 | 
				
			||||||
 | 
					    // "<doc>
 | 
				
			||||||
 | 
					    "<doc>
 | 
				
			||||||
 | 
					<A a=\"asdf>'">
 | 
				
			||||||
 | 
					asdf
 | 
				
			||||||
 | 
						?>%\"/>
 | 
				
			||||||
 | 
					<A a='\"\">'"'/>
 | 
				
			||||||
 | 
					</doc>",
 | 
				
			||||||
  )
 | 
					  )
 | 
				
			||||||
  |> echo
 | 
					  |> echo
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub fn default_entities() -> dict.Dict(String, Entity) {
 | 
					fn default_entities() -> dict.Dict(String, Entity) {
 | 
				
			||||||
  dict.from_list([
 | 
					  dict.from_list([
 | 
				
			||||||
    #("lt", InternalEntity("<")),
 | 
					    #("lt", InternalEntity("<")),
 | 
				
			||||||
    #("gt", InternalEntity(">")),
 | 
					    #("gt", InternalEntity(">")),
 | 
				
			||||||
@@ -144,7 +151,7 @@ fn parse_content(
 | 
				
			|||||||
  content: List(Element),
 | 
					  content: List(Element),
 | 
				
			||||||
) -> Result(#(List(Element), String), Nil) {
 | 
					) -> Result(#(List(Element), String), Nil) {
 | 
				
			||||||
  use #(chardata, doc) <- result.try(parse_chardata(doc, doctype, ""))
 | 
					  use #(chardata, doc) <- result.try(parse_chardata(doc, doctype, ""))
 | 
				
			||||||
  let new_content = case chardata {
 | 
					  let content = case chardata {
 | 
				
			||||||
    "" -> content
 | 
					    "" -> content
 | 
				
			||||||
    _ -> [Text(chardata), ..content]
 | 
					    _ -> [Text(chardata), ..content]
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -163,10 +170,10 @@ fn parse_content(
 | 
				
			|||||||
        )
 | 
					        )
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        Ok(#(element, doc)) -> parse_content(doc, doctype, [element, ..content])
 | 
					        Ok(#(element, doc)) -> parse_content(doc, doctype, [element, ..content])
 | 
				
			||||||
        Error(_) -> Ok(#(list.reverse(new_content), doc))
 | 
					        Error(_) -> Ok(#(list.reverse(content), doc))
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    _ -> Ok(#(list.reverse(new_content), doc))
 | 
					    _ -> Ok(#(list.reverse(content), doc))
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -592,7 +599,7 @@ fn parse_digit(doc: String) -> Result(#(String, String), Nil) {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub fn parse_hex_digit(str: String) -> Result(#(String, String), Nil) {
 | 
					fn parse_hex_digit(str: String) -> Result(#(String, String), Nil) {
 | 
				
			||||||
  case str {
 | 
					  case str {
 | 
				
			||||||
    "0" as digit <> tail
 | 
					    "0" as digit <> tail
 | 
				
			||||||
    | "1" as digit <> tail
 | 
					    | "1" as digit <> tail
 | 
				
			||||||
@@ -831,7 +838,7 @@ fn try_parsers(
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub fn parse_multiple(
 | 
					fn parse_multiple(
 | 
				
			||||||
  to_parse str: String,
 | 
					  to_parse str: String,
 | 
				
			||||||
  with to_run: fn(String) -> Result(#(String, String), Nil),
 | 
					  with to_run: fn(String) -> Result(#(String, String), Nil),
 | 
				
			||||||
) -> Result(#(String, String), Nil) {
 | 
					) -> Result(#(String, String), Nil) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user