From e15381c1cb5e828d302c9d3333857c2d7839bdc6 Mon Sep 17 00:00:00 2001 From: Wilson Lin Date: Fri, 27 Dec 2019 21:52:49 +1100 Subject: [PATCH] Handle text script content --- {src/spec/tag => archive}/child/blacklist.c | 0 {src/spec/tag => archive}/child/whitelist.c | 0 {src/spec/tag => archive}/parent/blacklist.c | 0 {src/spec/tag => archive}/parent/whitelist.c | 0 notes/Processing.md | 14 ++- notes/Tag omission.md | 19 --- notes/Text script content.md | 125 +++++++++++++++++++ src/proc.rs | 23 +++- src/unit/attr/mod.rs | 30 +++-- src/unit/attr/value.rs | 12 +- src/unit/{script.rs => script/js.rs} | 6 +- src/unit/script/mod.rs | 2 + src/unit/script/text.rs | 37 ++++++ src/unit/tag.rs | 43 ++++++- 14 files changed, 257 insertions(+), 54 deletions(-) rename {src/spec/tag => archive}/child/blacklist.c (100%) rename {src/spec/tag => archive}/child/whitelist.c (100%) rename {src/spec/tag => archive}/parent/blacklist.c (100%) rename {src/spec/tag => archive}/parent/whitelist.c (100%) delete mode 100644 notes/Tag omission.md create mode 100644 notes/Text script content.md rename src/unit/{script.rs => script/js.rs} (92%) create mode 100644 src/unit/script/mod.rs create mode 100644 src/unit/script/text.rs diff --git a/src/spec/tag/child/blacklist.c b/archive/child/blacklist.c similarity index 100% rename from src/spec/tag/child/blacklist.c rename to archive/child/blacklist.c diff --git a/src/spec/tag/child/whitelist.c b/archive/child/whitelist.c similarity index 100% rename from src/spec/tag/child/whitelist.c rename to archive/child/whitelist.c diff --git a/src/spec/tag/parent/blacklist.c b/archive/parent/blacklist.c similarity index 100% rename from src/spec/tag/parent/blacklist.c rename to archive/parent/blacklist.c diff --git a/src/spec/tag/parent/whitelist.c b/archive/parent/whitelist.c similarity index 100% rename from src/spec/tag/parent/whitelist.c rename to archive/parent/whitelist.c diff --git a/notes/Processing.md b/notes/Processing.md index e7ab5f9..ff813ab 100644 --- a/notes/Processing.md +++ b/notes/Processing.md @@ -2,16 +2,18 @@ ## Redundant requires -Sometimes the code will look like it duplicates matching logic. For example: +Sometimes the code will look like it does redundant matching logic. For example: ```rust -fn process_comment(proc: &mut Proc) -> () { - proc.matches("").skip(); + chain!(proc.match_while_not_seq(&SinglePattern::new(b"-->")).discard()); - proc.matches("-->").require_reason("comment end").skip(); + chain!(proc.match_seq(b"-->").require_with_reason("comment end")?.discard()); + + Ok(()) } ``` -At first glance, it might appear that the second call `while_not_matches` makes it redundant to require it again immediately afterwards. However, it's possible that the `while_not_matches` actually stops for some other reason, such as reaching EOF. Even if it's guaranteed, it's still nice to have a declared invariant, like an assertion statement. +At first glance, it might appear that the second call `match_while_not_seq` makes it redundant to require it again immediately afterwards. However, it's possible that the `match_while_not_seq` actually stops for some other reason, such as reaching EOF. Even if it's guaranteed, it's still nice to have a declared invariant, like an assertion statement. diff --git a/notes/Tag omission.md b/notes/Tag omission.md deleted file mode 100644 index 8fb3f3b..0000000 --- a/notes/Tag omission.md +++ /dev/null @@ -1,19 +0,0 @@ -# Tag omission - -|Tag name|Details| -|---|---| -|`li`| The end tag can be omitted if the list item is immediately followed by another `
  • ` element, or if there is no more content in its parent element.| -|`p`| The start tag is required. The end tag may be omitted if the `

    ` element is immediately followed by an `

    `, `
    `, `