diff options
author | George Abbott <george@gabbott.dev> | 2023-10-04 20:20:57 +0100 |
---|---|---|
committer | George Abbott <george@gabbott.dev> | 2023-10-04 20:20:57 +0100 |
commit | 08cec360e16615b1ae157e4926e7317d16765f7e (patch) | |
tree | 3a03e0a1acf89973de92e7f6f7a08b2a587b7485 /source/html.d | |
parent | 8e4092347975db7fe90b0895f605bdd79de47410 (diff) |
Progress thus far
Diffstat (limited to 'source/html.d')
-rw-r--r-- | source/html.d | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/source/html.d b/source/html.d new file mode 100644 index 0000000..768e270 --- /dev/null +++ b/source/html.d @@ -0,0 +1,38 @@ +// Represents all functions for process the raw HTML and +// extracting information from it, transforming it, etc. +// All fns operate on strings. + +import std.algorithm : findSplitAfter, find; + + +// Given the haystack (the full HTML) search for the RSS comment +// representing that attribute. +string find_rss_comment(string attr, string haystack) +in (haystack !is null) +{ + immutable string needle = "<!-- rss-" ~ attr ~ ":"; + string found = haystack.find(needle); + + if (found is null) + return null; + + // As otherwise comment begin will be in `found`. + found = found[needle.length .. $]; + + // And get before the closing comment. + string result = found.findSplitAfter("-->")[0]; + return result; +} + +string find_html_title(string htmltext) +{ + // TODO: implement. + immutable string init_tag = "<title>"; + string found = htmltext.find(init_tag); + if (found is null) + return null; + + found = found[init_tag.length .. $]; + string result = found.findSplitAfter("</title>")[0]; + return result; +} |