diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml
new file mode 100644
index 00000000..763e3c56
--- /dev/null
+++ b/.github/workflows/prettier.yml
@@ -0,0 +1,43 @@
+name: Format with Prettier
+
+on:
+ push:
+ branches:
+ - main
+ pull_request:
+ paths:
+ - "**.php"
+ - "**.md"
+ - "**.js"
+ - "**.css"
+
+jobs:
+ prettier:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout Pull Request
+ if: ${{ github.event_name == 'pull_request' }}
+ uses: actions/checkout@v3
+ with:
+ repository: ${{ github.event.pull_request.head.repo.full_name }}
+ ref: ${{ github.event.pull_request.head.ref }}
+
+ - name: Checkout Push
+ if: ${{ github.event_name != 'pull_request' }}
+ uses: actions/checkout@v3
+
+ - name: Install prettier and plugin-php
+ run: npm install --global prettier @prettier/plugin-php
+
+ - name: Check formatting with Prettier
+ continue-on-error: true
+ run: composer format:check
+
+ - name: Prettify code
+ run: composer format
+
+ - name: Commit changes
+ uses: EndBug/add-and-commit@v9
+ with:
+ message: "style: Formatted code with Prettier"
+ default_author: github_actions
diff --git a/.prettierignore b/.prettierignore
new file mode 100644
index 00000000..ace57274
--- /dev/null
+++ b/.prettierignore
@@ -0,0 +1,2 @@
+vendor
+*.min.js
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 699e59e3..c2c22eaa 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -50,8 +50,21 @@ Before you can run tests, PHPUnit must be installed. You can install it using Co
composer install
```
+### Format and test the code
+
+Run the following command to format the code with Prettier:
+```
+composer run format
+```
+
+Run the following command to check if your code is formatted properly:
+```
+composer run format:check
+```
+> **Note** You need to have [`prettier`](https://prettier.io/) and the [prettier-php plugin](https://github.com/prettier/plugin-php) installed globally in order to run this command.
+
Run the following command to run the PHPUnit test script which will verify that the tested functionality is still working.
```bash
composer test
-```
\ No newline at end of file
+```
diff --git a/composer.json b/composer.json
index b824ffd7..463fdb4c 100644
--- a/composer.json
+++ b/composer.json
@@ -28,6 +28,8 @@
},
"scripts": {
"start": "php7 -S localhost:8000 -t src || php -S localhost:8000 -t src",
- "test": "./vendor/bin/phpunit --testdox tests"
+ "test": "./vendor/bin/phpunit --testdox tests",
+ "format:check": "prettier --check *.md **/**/*.{php,md,js,css} --print-width 120",
+ "format": "prettier --write *.md **/**/*.{php,md,js,css} --print-width 120"
}
-}
\ No newline at end of file
+}
diff --git a/docs/faq.md b/docs/faq.md
index 2f69e229..e88cd298 100644
--- a/docs/faq.md
+++ b/docs/faq.md
@@ -12,9 +12,11 @@ Markdown files on GitHub support embedded images using Markdown or HTML. You can
### HTML
+
```html
-
+
```
+
## The text is getting cut off at the end, how do I fix it?
@@ -30,11 +32,13 @@ https://readme-typing-svg.demolab.com/?lines=Your+Long+Message+With+A+Long+Width
To center align images, you must use the HTML syntax and wrap it in an element with the HTML attribute `align="center"`.
+
```html