Skip to content

Commit

Permalink
Merge pull request #15 from 8fold/container
Browse files Browse the repository at this point in the history
Container
  • Loading branch information
joshbruce authored Dec 17, 2022
2 parents 0e30c5e + 9a9c1c4 commit aca0e5d
Show file tree
Hide file tree
Showing 9 changed files with 336 additions and 414 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/php82.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: PHP 8.2

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP Action
uses: shivammathur/[email protected]
with:
php-version: '8.2'

- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run style check
run: composer run style

- name: Run static analyzer
run: composer run stan

- name: Run tests
run: composer run test
31 changes: 29 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ There are two entry classes:

The naming convention for methods that are not part of the League CommonMark implementation follow the convention established by [PSR-7](https://www.php-fig.org/psr/psr-7/).

Methods prefixed by the word `with` will return a new instance to facilitate immunitability.
Methods prefixed by the word `with` will return a new instance to facilitate immutability.

### Markdown

Expand All @@ -32,6 +32,8 @@ The Markdown class makes some presumptions the FluentCommonMark class does not:

The Markdown class uses the the default configuration provided by CommonMark with modifications recommended by the [security](https://commonmark.thephpleague.com/2.0/security/) page of the CommonMark documentation.

The Markdown class also affords users the ability to use the [8fold CommonMark Abbreviations](https://github.com/8fold/commonmark-abbreviations) and [8fold CommonMark Accessible Heading Permalinks](https://github.com/8fold/commonmark-accessible-heading-permalinks) extensions whereas FluentCommonMark is strictly vanilla [League CommonMark](https://commonmark.thephpleague.com).

Write some markdown:

```markdown
Expand Down Expand Up @@ -89,12 +91,37 @@ Output:

```

The Mardkown extends the FluentCommonMark class.
The Markdown extends the FluentCommonMark class.

### FluentMarkdown

The FluentMarkdown class is designed to mimic the behavior and feel of the CommonMark library. There are additional methods in place to facilitate the fully fluent nature of this library.

### Container

The Container class is a singleton that may contain one or more converter configurations.

This is useful if you find yourself instantiating multiple markdown converters:

1. With each server request.
2. With the same configuration and options.

By placing those converters in the Container, they only need to be instantiated once and you should see a performance increase by doing so.

```
Container::instance()->addConverter(
Markdown::create()->abbreviations()
)->addConverter(
FluentCommonMark::create()->descriptionLists()
);
// Returns the Markdown instance (first converter in list)
$html = Container::instance()->converter()->convert('');
// Returns HTML converted by FluentCommonMark insance
$html = Container::instance()->converter()->convertToHtml('');
```

### Extensions

Each internal [CommonMark extension](https://commonmark.thephpleague.com/2.0/extensions/overview/) is available via the fluent API along with
Expand Down
Loading

0 comments on commit aca0e5d

Please sign in to comment.