Skip to content

Commit aca0e5d

Browse files
authored
Merge pull request #15 from 8fold/container
Container
2 parents 0e30c5e + 9a9c1c4 commit aca0e5d

File tree

9 files changed

+336
-414
lines changed

9 files changed

+336
-414
lines changed

.github/workflows/php82.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: PHP 8.2
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
16+
- name: Setup PHP Action
17+
uses: shivammathur/setup-php@2.15.0
18+
with:
19+
php-version: '8.2'
20+
21+
- name: Validate composer.json and composer.lock
22+
run: composer validate
23+
24+
- name: Install dependencies
25+
run: composer install --prefer-dist --no-progress
26+
27+
- name: Run style check
28+
run: composer run style
29+
30+
- name: Run static analyzer
31+
run: composer run stan
32+
33+
- name: Run tests
34+
run: composer run test

README.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ There are two entry classes:
2121

2222
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/).
2323

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

2626
### Markdown
2727

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

3333
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.
3434

35+
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).
36+
3537
Write some markdown:
3638

3739
```markdown
@@ -89,12 +91,37 @@ Output:
8991

9092
```
9193

92-
The Mardkown extends the FluentCommonMark class.
94+
The Markdown extends the FluentCommonMark class.
9395

9496
### FluentMarkdown
9597

9698
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.
9799

100+
### Container
101+
102+
The Container class is a singleton that may contain one or more converter configurations.
103+
104+
This is useful if you find yourself instantiating multiple markdown converters:
105+
106+
1. With each server request.
107+
2. With the same configuration and options.
108+
109+
By placing those converters in the Container, they only need to be instantiated once and you should see a performance increase by doing so.
110+
111+
```
112+
Container::instance()->addConverter(
113+
Markdown::create()->abbreviations()
114+
)->addConverter(
115+
FluentCommonMark::create()->descriptionLists()
116+
);
117+
118+
// Returns the Markdown instance (first converter in list)
119+
$html = Container::instance()->converter()->convert('');
120+
121+
// Returns HTML converted by FluentCommonMark insance
122+
$html = Container::instance()->converter()->convertToHtml('');
123+
```
124+
98125
### Extensions
99126

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

0 commit comments

Comments
 (0)