Skip to content

Sean Luckett's submission#73

Open
SeanLuckett wants to merge 24 commits into
vikingeducation:masterfrom
SeanLuckett:master
Open

Sean Luckett's submission#73
SeanLuckett wants to merge 24 commits into
vikingeducation:masterfrom
SeanLuckett:master

Conversation

@SeanLuckett

Copy link
Copy Markdown

No description provided.

This moves the Tag struct into the test scope to prevent collisions with other Tag declarations for non-warmup.
This parser is specific to warmup exercise. That is, it expects html to be in a newline delineated string. It also assumes tags have no attributes.
The parser constructs the tree. The parser ignores element attributes like name, src, etc. It also assumes all tags are properly closed and nested. It also accepts a limited number of punctuation marks for text elements.
Also, a little refactoring to eliminate a bit of redundancy
Parser, working with DomTree, can now recreate html to a file. It is similar, but not the same as original. For one, it's too complicated to add indentation and keep text all on one line when it has embedded tags. So, every parsed tag and text element has its own line.
The TagElement and TextElement structs are too simplistic and make for a lot of excess code to print them and deal with whether they have children or not. This creates a base class requiring #to_html and #children? methods.
The TagElement now can print itself to html without excess recursive code in a completely separate class. This also refactors DomParser and DomTree to use new TagElement; gets rid of TagElement struct.
The TextElement prints its content. This also refactors DomParser and DomTree to use new TextElement; gets rid of TextElement struct.
Tag/Text elements have changed the way they work with their children so the original logic failed. It was looking at each element's children collection. Now, it just calls #children?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant