Comments (3)
Yeah, the current API is probably not lazy by definition, and I think 2 is probably the right solution - but I'm not super sure. I've never used this API in anger, so it's really something best directed by real use cases. Having it not be lazy at all is probably a bad solution - it effectively caps the size of documents that can be processed, and it doesn't look like it should be that hard to make it lazy.
from tagsoup.
Probably the cleanest solution to number 2 would look sort of like this:
data Trees = Branch {tag :: String, afterOpen :: Trees, afterClose :: Maybe Trees} | NoTrees
(that type is simplified of course). afterClose
is Nothing
if there is no closing tag. tag
and afterOpen
can be determined lazily. Evaluating afterClose
to Nothing
or Just _
would requires tracing the document until you reach the closing tag or the end of the enclosing tag or the end of the document.
We could implement option 3 in addition to option 1 right now without changing the API. It would be a function like:
tagTreeLazy :: Eq str => (str -> Bool) -> [Tag str] -> [TagTree str]
Where the str -> Bool
is whether or not the tag should have a closing tag. The only thing left to consider for that solution is what happens when it's wrong.
from tagsoup.
I'm not adverse to an API change if that's what we think is needed. I'm not sure I have enough a good model for an API. Perhaps the existing data type with:
tagTree :: Eq str => (str -> Bool) -> [Tag str] -> ([TagTree str], [str])
That gives you the pipe of TagTree
values, plus the second component being the list of things that were expected to get shut but didn't. You would never emit a TagClose
unless it was unmatched. Then the "sanity" condition would be that the first list doesn't contain TagClose and the second list is empty.
from tagsoup.
Related Issues (20)
- Issue about working with `OverloadedStrings` extension HOT 1
- Research language agnostic test suites
- TagPosition not updated properly before bare & character HOT 10
- Idea: Make TagTree a Monad! HOT 4
- Incorrect source position before comment. HOT 5
- Incorrect source position before bogus comment HOT 2
- Link to Samples is broken HOT 1
- Link to Java version of TagSoup is broken HOT 1
- Escape single quote (') characters as ' HOT 2
- Parsing arbitrary numerical tags HOT 1
- `tagsoup` binary no longer avaliable. HOT 1
- Modify HTML
- What is the long term status of Text.HTML.TagSoup.Tree? HOT 6
- StringLike CaseInsensitive HOT 3
- Bad tagsoup performance HOT 4
- rendering attribute with empty string value HOT 2
- `innerText` alternative with more expected spacing HOT 2
- Incorrect decoding (truncation) of `ByteString`, but not `Text` HOT 5
- `x-partial` warnings with GHC 9.8 HOT 2
- "Simon's papers" README example broken HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tagsoup.