Open itsnottakenme opened 11 years ago
That's an interersting idea, I hadn't thought of that yet at all... Unfortunately that means it's also not on the plan. The next big thing I have planned for HtmlPlanner is CSS support, since I need that for PageTurner... if you come up with a nice solution I'd love to merge it though.
hmm... ok. Well I think that is a little over my head currently, but if I ever I get the time to look at the code and make a decent implementation I will most definitely send it your way.
I'll keep this issue open, since I do think it would make an excellent addition to HtmlSpanner.
My priority is the development of PageTurner though, which means I tend to focus on the HTML parsing / displaying side...
Hey again. I've been working on this the last couple weeks. I think I've hit on a decent working implementation. Here are the basics:
The spanToHtml handlers are subclasses of SpanInfo. SpanInfo contains the span and associated start and end indexes. Its subclasses (eg. BulletSpanInfo) return the properly formatted open and close html tags.
In HtmlSpanner I have added the variable private Map<Class, Class> mSpanInfos;
It associates spans with spaninfos. (eg. BulletSpan and BulletSpanInfo) and toHtml() uses reflection to create the correct subclass of SpanInfo for each Span.
Issues: It appears that HtmlSpanner and what I am trying to do may have slightly different goals so combining them back together may not necessarily work so well... Let me know what you think of the compromises :)
1) TagNodeHandler and SpanInfo should be merged into a single base class. TagNodeHandler helps turn html tags to spans. SpanInfo does the opposite. Think of them as encoding/decoding pairs. If the encoding scheme changes, the decoding part needs know about it. I think its essential that these 2 are made into the same base class. Just creating an interface for SpanInfo would not be good either as some of the methods are implemented
2) Make TagNodeHandler methods protected... I would like to subclass them to make handleTagNode() work properly with my implementation but this is currently not possible
3) fromHtml() appears to have a bug that it moves span ends 1 index to the right of where they should be.... (from 1 version ago. Not sure if its related to the   issue)
4) Basically related to 3... I'm not experienced at collabarative projects like this.... What do you think the easiest way to do this is? My coding style is much different than yours so I think it would probably be easiest for me to finish everything ( different code base) before submitting what I end up with. I originally had HtmlSpanner subclassed... but due to the issue 2 (i believe... can't remember now haha) I ended doing all the changes to HtmlSpanner itself... I guess I should just go back to having it subclassed so that if I find any issues with the original code I can just submit the bug reports/fixes to you
5) Is there a junit test modules for this project?
Hopefully what I read makes sense. Feel free to ask for clarification/let me know what you think
I'm having a very busy couple of days right now, but I'll take a look at your code when I get a chance... it does sound like something I'd like to merge.
I don't have any junit tests yet for HtmlSpanner.. It took me a while to figure out a working setup for Android unit tests.. I have a working setup with Robolectric now in the PageTurner sources.
Ok, I guess what I'll do is take out all my code out of HtmlSpanner and then put it in a subclass called HtmlSpannerJunior. Then I'll try figure out how to put it on my Github.I'm guessing that is the proabably the easiest way to keep things clean before the merge. For this to work though, I may need some of the members of HtmlSpanner changed to protected.
I think having Junit tests are really important for standardizing expectations and communicating our issues to each other.
Some updates to the above numbered list if issues 1) I guess this can be done as an interface and abstract class without needing to alter your implementation as follows: abstract class TagAndSpanHandler extends TagNodeHandler implements SpanInfo
3) Having a junit test module for this project that I could modify would greatly help communicate/demonstrate the issues I have run into.
And again if you have any ideas for how we can collaborate more efficiently let me kniow
I seem to be having a lot of issues putting my code on github...
Can I just zip up my code and send it to you somehow?
Sure... Send it to alex@nightwhistler.net... Sorry if my response may have seemed a bit luke-warm, but my focus has been getting a new PageTurner release out the door. I plan to release that in the next couple of days, and after that we can coordinate how to get your changes into the HtmlSpanner main line.
No worries Alex. I've emailed you the code.
Alex did you receive my email with the code?
Thanks for the awesome project NIghtWhistler.
Is there any plan to to add a toHtml() function? I would love to be able to use HtmlSpanner to save spanned text from an EditText