Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML tags #34

Merged
merged 32 commits into from
Apr 2, 2016
Merged

Conversation

Frulenzo
Copy link
Collaborator

Hi,
It would be nice to format text with some HTML tags, right? No problem, now we have it 👍
What is new?

Token Class

Just simple class which represent a token. Token has TokenType and token's data.

TokenType Enum

There is multiple token's type :

  • TEXT - this type contains only plain text
  • POSSIBLE_WRAP_POINT - this type is used when we are dealing with possible wrap point
  • WRAP_POINT - this type is used when we are dealing with "must-have" wrap point
  • OPEN_TAG - this type says that we are dealing with opening html tag
  • CLOSE_TAG - this type says that we are dealing with closing html tag
  • PADDING - this type is used for certain paddings (e.g tab in the lists)
  • BULLET - this type is used for indentifying bullet points in unordered lists
  • ORDERING - this type is used for keeping ordering numbers from elements in ordered list

Tokenizer class

This is the class which main focus is simple parsing text in designated Tokens. Class has only one method tokenize(final String text, final WrappingFunction wrappingFunction). First argumen is text that we want to parse and the second argument is our well known wrapping function which determine how the text will be parsed.

TokenizerTest

Simple class with multiple JUnit tests as : testWrapPoints(), testSimpleItalic(), testBoldAndItalic() etc..

PipelineLayer class

Main focus of this class is to ensure correct "breaking" lines inside Paragraph depending on width. There is two usage of this class, as textInLine which represent a pipeline of current line text and sinceLastWrapPoint which represent a pipeline of text since last wrap point. We always iterate through many tokens and always calculating if we can add text since last wrap point to our current line text. You can view this also like this :

  • textInLine - "safe" line text which will be certainly drawn
  • sinceLastWrapPoint - line text since last wrap point which we want to add our current text in line if current width is not broken.

Supported tags :

  • Bold,italic, bold-italic (<b>, </b>, <i>, </i>, <b><i></i></b>)
  • Paragraph (<p></p>)
  • Line break <br>, <br />
  • Ordered/Unordered lists (<ol><li></li></ol>, <ul><li></li></ul>)

Example
BoxableSample5.pdf

…by adding current pipeline text to width sum
Conflicts:
	src/main/java/be/quodlibet/boxable/Table.java
…and implemented text rotation with tokens

Conflicts:
	src/main/java/be/quodlibet/boxable/Cell.java
	src/main/java/be/quodlibet/boxable/Table.java
Conflicts:
	src/main/java/be/quodlibet/boxable/Table.java
Conflicts:
	src/main/java/be/quodlibet/boxable/Cell.java
	src/main/java/be/quodlibet/boxable/Table.java
@dhorions
Copy link
Owner

dhorions commented Apr 1, 2016

I'll try to find time to review this over the weekend, it looks nice and if I don't find any issues will merge it into the main branch.

@dhorions dhorions self-assigned this Apr 1, 2016
@dhorions dhorions merged commit 58002fd into dhorions:master Apr 2, 2016
@dhorions
Copy link
Owner

dhorions commented Apr 2, 2016

This is really useful, thanks a lot!

@Frulenzo Frulenzo mentioned this pull request Apr 4, 2016
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.

2 participants