Sean Luckett's submission#73
Open
SeanLuckett wants to merge 24 commits into
Open
Conversation
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?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.