-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
of a given element ... - ... clear a given attribute - ... clear the content (a.k.a. all children)
- Loading branch information
Showing
8 changed files
with
195 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use html_streaming_editor::*; | ||
|
||
const HTML_INPUT: &str = r#"<html> | ||
<head></head> | ||
<body> | ||
<h1>Title</h1> | ||
<p id="first-para">Some first text</p> | ||
<p id="second-para">Some more text, even with an <img src=""></p> | ||
<p id="third-para">Third text of <abbr>HTML</abbr>, but no <abbr>CSS</abbr></p> | ||
<ul id="list"> | ||
<li id="item-1">1</li> | ||
<li id="item-2">2</li> | ||
<li id="item-3">3</li> | ||
</ul> | ||
</body> | ||
</html>"#; | ||
|
||
#[test] | ||
fn clear_first_p_id() -> Result<(), StreamingEditorError> { | ||
let command = "ONLY{#first-para} | CLEAR-ATTR{id}"; | ||
|
||
let mut input = Box::new(HTML_INPUT.as_bytes()); | ||
let mut output = Vec::new(); | ||
let hse = HtmlStreamingEditor::new(&mut input, &mut output); | ||
|
||
let _ = hse.run(command)?; | ||
let result_string = String::from_utf8(output).unwrap(); | ||
|
||
assert_eq!(result_string, String::from(r#"<p>Some first text</p>"#)); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use html_streaming_editor::*; | ||
|
||
const HTML_INPUT: &str = r#"<html> | ||
<head></head> | ||
<body> | ||
<h1>Title</h1> | ||
<p id="first-para">Some first text</p> | ||
<p id="second-para">Some more text, even with an <img src=""></p> | ||
<p id="third-para">Third text of <abbr>HTML</abbr>, but no <abbr>CSS</abbr></p> | ||
<ul id="list"> | ||
<li id="item-1">1</li> | ||
<li id="item-2">2</li> | ||
<li id="item-3">3</li> | ||
</ul> | ||
</body> | ||
</html>"#; | ||
|
||
#[test] | ||
fn clear_first_p_content() -> Result<(), StreamingEditorError> { | ||
let command = "ONLY{#first-para} | CLEAR-CONTENT"; | ||
|
||
let mut input = Box::new(HTML_INPUT.as_bytes()); | ||
let mut output = Vec::new(); | ||
let hse = HtmlStreamingEditor::new(&mut input, &mut output); | ||
|
||
let _ = hse.run(command)?; | ||
let result_string = String::from_utf8(output).unwrap(); | ||
|
||
assert_eq!(result_string, String::from(r#"<p id="first-para"></p>"#)); | ||
|
||
Ok(()) | ||
} |