Skip to content

Conversation

@KennedyTedesco
Copy link
Contributor

@KennedyTedesco KennedyTedesco commented Nov 19, 2023

Following: #136

With this new implementation, users now have two options for formatting their texts:

  1. Using style methods
  2. Parsing directly

So, this style:

image

Can be achieved by doing either:

Line::fromSpans([
    Span::fromString('Hello ')->black()->onBlue()->bold()->italic(),
    Span::fromString('Wor')->white()->onRed()->crossedout(),
    Span::fromString('ld')->black()->onBlue()->bold()->italic(),
    Span::fromString(' PHP'),
]),

or:

Line::parse('<fg=black;bg=blue;options=bold,italic>Hello <fg=white;bg=red;options=crossedout>Wor</>ld</> PHP')

Other examples:

// Style methods
$title = Title::fromLine(Line::fromSpans([
    Span::fromString('Titles')->red()->onWhite(),
]));

// Parsing instead:
$title = Title::parse('<fg=red;bg=white>Titles</>');

@dantleech
Copy link
Collaborator

Nice work! Looks good from a quick once over ,will have a better look later.

@dantleech dantleech merged commit a5c51d3 into php-tui:main Nov 19, 2023
@dantleech
Copy link
Collaborator

Nice work!

@KennedyTedesco KennedyTedesco deleted the span-parser branch November 19, 2023 20:42
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