├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── 1_Conversion_error.yaml │ ├── 2_Bug_report.yaml │ └── 3_Feature_request.yaml ├── SECURITY.md ├── renovate.json ├── stale.yml └── workflows │ └── tests.yml ├── CHANGELOG.md ├── CONDUCT.md ├── LICENSE ├── README.md ├── bin └── html-to-markdown ├── composer.json ├── phpcs.xml.dist ├── phpstan.neon.dist ├── psalm.xml └── src ├── Coerce.php ├── Configuration.php ├── ConfigurationAwareInterface.php ├── Converter ├── BlockquoteConverter.php ├── CodeConverter.php ├── CommentConverter.php ├── ConverterInterface.php ├── DefaultConverter.php ├── DivConverter.php ├── EmphasisConverter.php ├── HardBreakConverter.php ├── HeaderConverter.php ├── HorizontalRuleConverter.php ├── ImageConverter.php ├── LinkConverter.php ├── ListBlockConverter.php ├── ListItemConverter.php ├── ParagraphConverter.php ├── PreformattedConverter.php ├── TableConverter.php └── TextConverter.php ├── Element.php ├── ElementInterface.php ├── Environment.php ├── HtmlConverter.php ├── HtmlConverterInterface.php └── PreConverterInterface.php /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: colinodell 2 | tidelift: "packagist/league/html-to-markdown" 3 | custom: ["https://www.colinodell.com/sponsor", "https://www.paypal.me/colinpodell/10.00"] 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/1_Conversion_error.yaml: -------------------------------------------------------------------------------- 1 | name: "📃 Bug Report (Incorrect Markdown)" 2 | description: I'm not getting the Markdown I expect 3 | body: 4 | - type: input 5 | id: affected-versions 6 | attributes: 7 | label: Version(s) affected 8 | placeholder: x.y.z 9 | validations: 10 | required: true 11 | - type: textarea 12 | id: description 13 | attributes: 14 | label: Description 15 | description: A clear and concise description of the problem. 16 | validations: 17 | required: true 18 | - type: textarea 19 | id: how-to-reproduce 20 | attributes: 21 | label: How to reproduce 22 | description: | 23 | Provide the HTML input and any other information that would help us reproduce the problem. 24 | validations: 25 | required: true 26 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/2_Bug_report.yaml: -------------------------------------------------------------------------------- 1 | name: "🐛 Bug Report (Other)" 2 | description: Report all other errors and problems 3 | body: 4 | - type: input 5 | id: affected-versions 6 | attributes: 7 | label: Version(s) affected 8 | placeholder: x.y.z 9 | validations: 10 | required: true 11 | - type: textarea 12 | id: description 13 | attributes: 14 | label: Description 15 | description: A clear and concise description of the problem. 16 | validations: 17 | required: true 18 | - type: textarea 19 | id: how-to-reproduce 20 | attributes: 21 | label: How to reproduce 22 | description: | 23 | HTML and/or any other information needed to reproduce the problem. 24 | validations: 25 | required: true 26 | - type: textarea 27 | id: possible-solution 28 | attributes: 29 | label: Possible solution 30 | description: | 31 | Optional: only if you have suggestions on a fix/reason for the bug 32 | - type: textarea 33 | id: additional-context 34 | attributes: 35 | label: Additional context 36 | description: | 37 | Optional: any other context about the problem: log messages, screenshots, etc. 38 | - type: textarea 39 | id: feedback 40 | attributes: 41 | label: Did this project help you today? Did it make you happy in any way? 42 | description: | 43 | Optional: Sometimes we get tired of reading bug reports and working on complex features, so if you have anything positive to share about how this library might have helped you we'd love to hear it! 44 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/3_Feature_request.yaml: -------------------------------------------------------------------------------- 1 | name: "🚀 Feature Request" 2 | description: RFC and ideas for new features and improvements 3 | labels: 4 | - enhancement 5 | body: 6 | - type: textarea 7 | id: description 8 | attributes: 9 | label: Description 10 | description: A clear and concise description of the problem. 11 | validations: 12 | required: true 13 | - type: textarea 14 | id: example 15 | attributes: 16 | label: Example 17 | description: | 18 | A simple example of the new feature in action (include PHP code, sample HTML/Markdown, etc.) 19 | If the new feature changes an existing feature, include a simple before/after comparison. 20 | validations: 21 | required: true 22 | - type: textarea 23 | id: feedback 24 | attributes: 25 | label: Did this project help you today? Did it make you happy in any way? 26 | description: | 27 | Optional: Sometimes we get tired of reading bug reports and working on complex features, so if you have anything positive to share about how this library might have helped you we'd love to hear it! 28 | -------------------------------------------------------------------------------- /.github/SECURITY.md: -------------------------------------------------------------------------------- 1 | # SECURITY POLICY 2 | 3 | ## Supported Versions 4 | 5 | When a new **minor** version (`5.x`) is released, the previous one will continue to receive security and bug fixes for *at least* 3 months. 6 | 7 | When a new **major** version is released (`4.0`, `5.0`, etc), the previous one will receive bug fixes for *at least* 3 months and security updates for 6 months after that new release comes out. 8 | 9 | (This policy may change in the future and exceptions may be made on a case-by-case basis.) 10 | 11 | ## Reporting a Vulnerability 12 | 13 | If you discover a security vulnerability within this package, please use the [Tidelift security contact form](https://tidelift.com/security) or email Colin O'Dell at . All security vulnerabilities will be promptly addressed. Please do not disclose security-related issues publicly until a fix has been announced. 14 | -------------------------------------------------------------------------------- /.github/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "config:base", 5 | ":disableDependencyDashboard" 6 | ], 7 | "enabledManagers": ["github-actions", "composer"], 8 | "packageRules": [ 9 | { 10 | "matchManagers": ["github-actions"], 11 | "extends": ["schedule:weekly"], 12 | "automerge": true 13 | }, 14 | { 15 | "matchManagers": ["composer"], 16 | "matchDepTypes": ["devDependencies"], 17 | "rangeStrategy": "widen", 18 | "automerge": true 19 | }, 20 | { 21 | "matchManagers": ["composer"], 22 | "rangeStrategy": "widen" 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Number of days of inactivity before an issue becomes stale 2 | daysUntilStale: 90 3 | # Number of days of inactivity before a stale issue is closed 4 | daysUntilClose: 30 5 | # Issues with these labels will never be considered stale 6 | exemptLabels: 7 | - pinned 8 | - on hold 9 | - security 10 | # Label to use when marking an issue as stale 11 | staleLabel: stale 12 | # Comment to post when marking an issue as stale. Set to `false` to disable 13 | markComment: > 14 | This issue has been automatically marked as stale because it has not had 15 | recent activity. It will be closed if no further activity occurs. Thank you 16 | for your contributions. 17 | # Comment to post when closing a stale issue. Set to `false` to disable 18 | closeComment: false 19 | -------------------------------------------------------------------------------- /.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | 3 | on: 4 | push: ~ 5 | pull_request: ~ 6 | 7 | jobs: 8 | phpcs: 9 | name: PHPCS 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: actions/checkout@v4 14 | 15 | - uses: shivammathur/setup-php@v2 16 | with: 17 | php-version: 7.2 18 | extensions: curl, mbstring 19 | coverage: none 20 | tools: composer:v2, cs2pr 21 | 22 | - run: composer update --no-progress 23 | 24 | - run: vendor/bin/phpcs -q --report=checkstyle | cs2pr 25 | 26 | phpunit: 27 | name: PHPUnit on ${{ matrix.php }} ${{ matrix.composer-flags }} 28 | runs-on: ubuntu-latest 29 | strategy: 30 | matrix: 31 | php: ['7.2', '7.3', '7.4', '8.0', '8.1'] 32 | coverage: [true] 33 | composer-flags: [''] 34 | include: 35 | - php: '8.2' 36 | coverage: false 37 | composer-flags: '--ignore-platform-req=php' 38 | - php: '7.2' 39 | coverage: false 40 | composer-flags: '--prefer-lowest' 41 | 42 | steps: 43 | - uses: actions/checkout@v4 44 | 45 | - uses: shivammathur/setup-php@v2 46 | with: 47 | php-version: ${{ matrix.php }} 48 | extensions: curl, mbstring 49 | coverage: pcov 50 | tools: composer:v2 51 | 52 | - run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" 53 | 54 | - name: "Use PHPUnit 9.3+ on PHP 8" 55 | run: composer require --no-update --dev phpunit/phpunit:^9.3 56 | if: "matrix.php >= '8.0'" 57 | 58 | - run: composer update --no-progress ${{ matrix.composer-flags }} 59 | 60 | - run: vendor/bin/phpunit --no-coverage 61 | if: ${{ !matrix.coverage }} 62 | 63 | - run: vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover 64 | if: ${{ matrix.coverage }} 65 | 66 | - run: php vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover 67 | if: ${{ matrix.coverage }} 68 | continue-on-error: true 69 | 70 | phpstan: 71 | name: PHPStan 72 | runs-on: ubuntu-latest 73 | 74 | steps: 75 | - uses: actions/checkout@v4 76 | 77 | - uses: shivammathur/setup-php@v2 78 | with: 79 | php-version: 7.2 80 | extensions: curl, mbstring 81 | coverage: none 82 | tools: composer:v2 83 | 84 | - run: composer update --no-progress 85 | 86 | - run: vendor/bin/phpstan analyse --no-progress 87 | 88 | psalm: 89 | name: Psalm 90 | runs-on: ubuntu-latest 91 | 92 | steps: 93 | - uses: actions/checkout@v4 94 | 95 | - uses: shivammathur/setup-php@v2 96 | with: 97 | php-version: 7.2 98 | extensions: curl, mbstring 99 | coverage: none 100 | tools: composer:v2 101 | 102 | - run: composer update --no-progress 103 | 104 | - run: vendor/bin/psalm --no-progress --output-format=github 105 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. 3 | Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles. 4 | 5 | ## [Unreleased][unreleased] 6 | 7 | ## [5.1.1] - 2023-07-12 8 | 9 | ### Fixed 10 | 11 | - Fixed `
` tags with attributes not being parsed (#215, #238)
 12 | - Fixed missing type checks and coercions
 13 | 
 14 | ## [5.1.0] - 2022-03-02
 15 | 
 16 | ### Changed
 17 | 
 18 |  - Changed horizontal rule style (#218, #219)
 19 | 
 20 | ### Fixed
 21 | 
 22 |  - Fixed `Element::getValue()` not handling possible nulls
 23 | 
 24 | ## [5.0.2] - 2021-11-06
 25 | 
 26 | ### Fixed
 27 | 
 28 |  - Fixed missplaced comment nodes appearing at the start of the HTML input (#212)
 29 | 
 30 | ## [5.0.1] - 2021-09-17
 31 | 
 32 | ### Fixed
 33 | 
 34 |  - Fixed lists not using the correct amount of indentation (#211)
 35 | 
 36 | ## [5.0.0] - 2021-03-28
 37 | 
 38 | ### Added
 39 | 
 40 |  - Added support for tables (#203)
 41 |     - This feature is disable by default - see README for how to enable it
 42 |  - Added new `strip_placeholder_links` option to strip `` tags without `href` attributes (#196)
 43 |  - Added new methods to `ElementInterface`:
 44 |     - `hasParent()`
 45 |     - `getNextSibling()`
 46 |     - `getPreviousSibling()`
 47 |     - `getListItemLevel()`
 48 |  - Added several parameter and return types across all classes
 49 |  - Added new `PreConverterInterface` to allow converters to perform any necessary pre-parsing
 50 | 
 51 | ### Changed
 52 | 
 53 |  - Supported PHP versions increased to PHP 7.2 - 8.0
 54 |  - `HtmlConverter::convert()` may now throw a `\RuntimeException` when unexpected `DOMDocument`-related errors occur
 55 | 
 56 | ### Fixed
 57 | 
 58 |  - Fixed complex nested lists containing heading and paragraphs (#198)
 59 |  - Fixed consecutive emphasis producing incorrect markdown (#202)
 60 | 
 61 | ## [4.10.0] - 2020-06-30
 62 | ### Added
 63 | 
 64 |  - Added the ability to disable autolinking with a configuration option (#187, #188)
 65 | 
 66 | ## [4.9.1] - 2019-12-27
 67 | ### Fixed
 68 |  - Fixed issue with HTML entity escaping in text (#184)
 69 | 
 70 | ## [4.9.0] - 2019-11-02
 71 | ### Added
 72 |  - Added new option to preserve comments (#177, #179)
 73 | 
 74 | ## [4.8.3] - 2019-10-31
 75 | ### Fixed
 76 |  - Fixed whitespace preservation around `` tags (#174, #178)
 77 | 
 78 | ## [4.8.2] - 2019-08-02
 79 | ### Fixed
 80 |  - Fixed headers not being placed onto a new line in some cases (#172)
 81 |  - Fixed handling of links containing spaces (#175)
 82 | 
 83 | ### Removed
 84 |  - Removed support for HHVM
 85 | 
 86 | ## [4.8.1] - 2018-12-24
 87 | ### Added
 88 |  - Added support for PHP 7.3
 89 | 
 90 | ### Fixed
 91 |  - Fixed paragraphs following tables (#165, #166)
 92 |  - Fixed incorrect list item escaping (#168, #169)
 93 | 
 94 | ## [4.8.0] - 2018-09-18
 95 | ### Added
 96 |  - Added support for email auto-linking
 97 |  - Added a new interface (`HtmlConverterInterface`) for the main `HtmlConverter` class
 98 |  - Added additional test cases (#14)
 99 | 
100 | ### Changed
101 |  - The `italic_style` option now defaults to `'*'` so that in-word emphasis is handled properly (#75)
102 | 
103 | ### Fixed
104 |  - Fixed several issues of `` and `
` tags not converting to blocks or inlines properly (#26, #70, #102, #140, #161, #162)
105 |  - Fixed in-word emphasis using underscores as delimiter (#75)
106 |  - Fixed character escaping inside of `
` elements 107 | - Fixed header edge cases 108 | 109 | ### Deprecated 110 | - The `bold_style` and `italic_style` options have been deprecated (#75) 111 | 112 | ## [4.7.0] - 2018-05-19 113 | ### Added 114 | - Added `setOptions()` function for chainable calling (#149) 115 | - Added new `list_item_style_alternate` option for converting every-other list with a different character (#155) 116 | 117 | ### Fixed 118 | - Fixed insufficient newlines after code blocks (#144, #148) 119 | - Fixed trailing spaces not being preserved in link anchors (#157) 120 | - Fixed list-like lines not being escaped inside of lists items (#159) 121 | 122 | ## [4.6.2] 123 | ### Fixed 124 | - Fixed issue with emphasized spaces (#146) 125 | 126 | ## [4.6.1] 127 | ### Fixed 128 | - Fixed conversion of `
` tags (#145)
129 | 
130 | ## [4.6.0]
131 | ### Added
132 |  - Added support for ordered lists starting at numbers other than 1
133 | 
134 | ### Fixed
135 |  - Fixed overly-eager escaping of list-like text (#141)
136 | 
137 | ## [4.5.0]
138 | ### Added
139 |  - Added configuration option for list item style (#135, #136)
140 | 
141 | ## [4.4.1]
142 | 
143 | ### Fixed
144 |  - Fixed autolinking of invalid URLs (#129)
145 | 
146 | ## [4.4.0]
147 | 
148 | ### Added
149 |  - Added `hard_break` configuration option (#112, #115)
150 |  - The `HtmlConverter` can now be instantiated with an `Environment` (#118)
151 | 
152 | ### Fixed
153 |  - Fixed handling of paragraphs in list item elements (#47, #110)
154 |  - Fixed phantom spaces when newlines follow `br` elements (#116, #117)
155 |  - Fixed link converter not sanitizing inner spaces properly (#119, #120)
156 | 
157 | ## [4.3.1]
158 | ### Changed
159 |  - Revised the sanitization implementation (#109)
160 | 
161 | ### Fixed
162 |  - Fixed tag-like content not being escaped (#67, #109)
163 |  - Fixed thematic break-like content not being escaped (#65, #109)
164 |  - Fixed codefence-like content not being escaped (#64, #109)
165 | 
166 | ## [4.3.0]
167 | ### Added
168 |  - Added full support for PHP 7.0 and 7.1
169 | 
170 | ### Changed
171 |  - Changed `
` and `
` conversions to use backticks instead of indendation (#102)
172 | 
173 | ### Fixed
174 |  - Fixed issue where specified code language was not preserved (#70, #102)
175 |  - Fixed issue where `` tags nested in `
` was not converted properly (#70, #102)
176 |  - Fixed header-like content not being escaped (#76, #105)
177 |  - Fixed blockquote-like content not being escaped (#77, #103)
178 |  - Fixed ordered list-like content not being escaped (#73, #106)
179 |  - Fixed unordered list-like content not being escaped (#71, #107)
180 | 
181 | ## [4.2.2]
182 | ### Fixed
183 |  - Fixed sanitization bug which sometimes removes desired content (#63, #101)
184 | 
185 | ## [4.2.1]
186 | ### Fixed
187 |  - Fixed path to autoload.php when used as a library (#98)
188 |  - Fixed edge case for tags containing only whitespace (#99)
189 | 
190 | ### Removed
191 |  - Removed double HTML entity decoding, as this is not desireable (#60)
192 | 
193 | ## [4.2.0]
194 | 
195 | ### Added
196 |  - Added the ability to invoke HtmlConverter objects as functions (#85)
197 | 
198 | ### Fixed
199 |  - Fixed improper handling of nested list items (#19 and #84)
200 |  - Fixed preceeding or trailing spaces within emphasis tags (#83)
201 | 
202 | ## [4.1.1]
203 | 
204 | ### Fixed
205 |  - Fixed conversion of empty paragraphs (#78)
206 |  - Fixed `preg_replace` so it wouldn't break UTF-8 characters (#79)
207 | 
208 | ## [4.1.0]
209 | 
210 | ### Added
211 |  - Added `bin/html-to-markdown` script
212 | 
213 | ### Changed
214 |  - Changed default italic character to `_` (#58)
215 | 
216 | ## [4.0.1]
217 | 
218 | ### Fixed
219 |  - Added escaping to avoid * and _ in a text being rendered as emphasis (#48)
220 | 
221 | ### Removed
222 |  - Removed the demo (#51)
223 |  - `.styleci.yml` and `CONTRIBUTING.md` are no longer included in distributions (#50)
224 | 
225 | ## [4.0.0]
226 | 
227 | This release changes the visibility of several methods/properties. #42 and #43 brought to light that some visiblities were
228 | not ideally set, so this releases fixes that. Moving forwards this should reduce the chance of introducing BC-breaking changes.
229 | 
230 | ### Added
231 |  - Added new `HtmlConverter::getEnvironment()` method to expose the `Environment` (#42, #43)
232 | 
233 | ### Changed
234 |  - Changed `Environment::addConverter()` from `protected` to `public`, enabling custom converters to be added (#42, #43)
235 |  - Changed `HtmlConverter::createDOMDocument()` from `protected` to `private`
236 |  - Changed `Element::nextCached` from `protected` to `private`
237 |  - Made the `Environment` class `final`
238 | 
239 | ## [3.1.1]
240 | ### Fixed
241 |  - Empty HTML strings now result in empty Markdown documents (#40, #41)
242 | 
243 | ## [3.1.0]
244 | ### Added
245 |  - Added new `equals` method to `Element` to check for equality
246 | 
247 | ### Changes
248 |  - Use Linux line endings consistently instead of plaform-specific line endings (#36)
249 | 
250 | ### Fixed
251 |  - Cleaned up code style
252 | 
253 | ## [3.0.0]
254 | ### Changed
255 |  - Changed namespace to `League\HTMLToMarkdown`
256 |  - Changed packagist name to `league/html-to-markdown`
257 |  - Re-organized code into several separate classes
258 |  - `` tags with identical href and inner text are now rendered using angular bracket syntax (#31)
259 |  - `
` elements are now treated as block-level elements (#33) 260 | 261 | ## [2.2.2] 262 | ### Added 263 | - Added support for PHP 5.6 and HHVM 264 | - Enabled testing against PHP 7 nightlies 265 | - Added this CHANGELOG.md 266 | 267 | ### Fixed 268 | - Fixed whitespace preservation between inline elements (#9 and #10) 269 | 270 | ## [2.2.1] 271 | ### Fixed 272 | - Preserve placeholder links (#22) 273 | 274 | ## [2.2.0] 275 | ### Added 276 | - Added CircleCI config 277 | 278 | ### Changed 279 | - `
` blocks are now treated as code elements
280 | 
281 | ### Removed
282 |  - Dropped support for PHP 5.2
283 |  - Removed incorrect README comment regarding `#text` nodes (#17)
284 | 
285 | ## [2.1.2]
286 | ### Added
287 |  - Added the ability to blacklist/remove specific node types (#11)
288 | 
289 | ### Changed
290 |  - Line breaks are now placed after divs instead of before them
291 |  - Newlines inside of link texts are now removed
292 |  - Updated the minimum PHPUnit version to 4.*
293 | 
294 | ## [2.1.1]
295 | ### Added
296 |  - Added options to customize emphasis characters
297 | 
298 | ## [2.1.0]
299 | ### Added
300 |  - Added option to strip HTML tags without Markdown equivalents
301 |  - Added `convert()` method for converter reuse
302 |  - Added ability to set options after instance construction
303 |  - Documented the required PHP extensions (#4)
304 | 
305 | ### Changed
306 |  - ATX style now used for h1 and h2 tags inside blockquotes
307 | 
308 | ### Fixed
309 |  - Newlines inside blockquotes are now started with a bracket
310 |  - Fixed some incorrect docblocks
311 |  - `__toString()` now returns an empty string if input is empty
312 |  - Convert head tag if body tag is empty (#7)
313 |  - Preserve special characters inside tags without md equivalents (#6)
314 | 
315 | 
316 | ## [2.0.1]
317 | ### Fixed
318 |  - Fixed first line indentation for multi-line code blocks
319 |  - Fixed consecutive anchors get separating spaces stripped (#3)
320 | 
321 | ## [2.0.0]
322 | ### Added
323 |  - Initial release
324 | 
325 | [unreleased]: https://github.com/thephpleague/html-to-markdown/compare/5.1.1...master
326 | [5.1.1]: https://github.com/thephpleague/html-to-markdown/compare/5.1.0...5.1.1
327 | [5.1.0]: https://github.com/thephpleague/html-to-markdown/compare/5.0.2...5.1.0
328 | [5.0.2]: https://github.com/thephpleague/html-to-markdown/compare/5.0.1...5.0.2
329 | [5.0.1]: https://github.com/thephpleague/html-to-markdown/compare/5.0.0...5.0.1
330 | [5.0.0]: https://github.com/thephpleague/html-to-markdown/compare/4.10.0...5.0.0
331 | [4.10.0]: https://github.com/thephpleague/html-to-markdown/compare/4.9.1...4.10.0
332 | [4.9.1]: https://github.com/thephpleague/html-to-markdown/compare/4.9.0...4.9.1
333 | [4.9.0]: https://github.com/thephpleague/html-to-markdown/compare/4.8.3...4.9.0
334 | [4.8.3]: https://github.com/thephpleague/html-to-markdown/compare/4.8.2...4.8.3
335 | [4.8.2]: https://github.com/thephpleague/html-to-markdown/compare/4.8.1...4.8.2
336 | [4.8.1]: https://github.com/thephpleague/html-to-markdown/compare/4.8.0...4.8.1
337 | [4.8.0]: https://github.com/thephpleague/html-to-markdown/compare/4.7.0...4.8.0
338 | [4.7.0]: https://github.com/thephpleague/html-to-markdown/compare/4.6.2...4.7.0
339 | [4.6.2]: https://github.com/thephpleague/html-to-markdown/compare/4.6.1...4.6.2
340 | [4.6.1]: https://github.com/thephpleague/html-to-markdown/compare/4.6.0...4.6.1
341 | [4.6.0]: https://github.com/thephpleague/html-to-markdown/compare/4.5.0...4.6.0
342 | [4.5.0]: https://github.com/thephpleague/html-to-markdown/compare/4.4.1...4.5.0
343 | [4.4.1]: https://github.com/thephpleague/html-to-markdown/compare/4.4.0...4.4.1
344 | [4.4.0]: https://github.com/thephpleague/html-to-markdown/compare/4.3.1...4.4.0
345 | [4.3.1]: https://github.com/thephpleague/html-to-markdown/compare/4.3.0...4.3.1
346 | [4.3.0]: https://github.com/thephpleague/html-to-markdown/compare/4.2.2...4.3.0
347 | [4.2.2]: https://github.com/thephpleague/html-to-markdown/compare/4.2.1...4.2.2
348 | [4.2.1]: https://github.com/thephpleague/html-to-markdown/compare/4.2.0...4.2.1
349 | [4.2.0]: https://github.com/thephpleague/html-to-markdown/compare/4.1.1...4.2.0
350 | [4.1.1]: https://github.com/thephpleague/html-to-markdown/compare/4.1.0...4.1.1
351 | [4.1.0]: https://github.com/thephpleague/html-to-markdown/compare/4.0.1...4.1.0
352 | [4.0.1]: https://github.com/thephpleague/html-to-markdown/compare/4.0.0...4.0.1
353 | [4.0.0]: https://github.com/thephpleague/html-to-markdown/compare/3.1.1...4.0.0
354 | [3.1.1]: https://github.com/thephpleague/html-to-markdown/compare/3.1.0...3.1.1
355 | [3.1.0]: https://github.com/thephpleague/html-to-markdown/compare/3.0.0...3.1.0
356 | [3.0.0]: https://github.com/thephpleague/html-to-markdown/compare/2.2.2...3.0.0
357 | [2.2.2]: https://github.com/thephpleague/html-to-markdown/compare/2.2.1...2.2.2
358 | [2.2.1]: https://github.com/thephpleague/html-to-markdown/compare/2.2.0...2.2.1
359 | [2.2.0]: https://github.com/thephpleague/html-to-markdown/compare/2.1.2...2.2.0
360 | [2.1.2]: https://github.com/thephpleague/html-to-markdown/compare/2.1.1...2.1.2
361 | [2.1.1]: https://github.com/thephpleague/html-to-markdown/compare/2.1.0...2.1.1
362 | [2.1.0]: https://github.com/thephpleague/html-to-markdown/compare/2.0.1...2.1.0
363 | [2.0.1]: https://github.com/thephpleague/html-to-markdown/compare/2.0.0...2.0.1
364 | [2.0.0]: https://github.com/thephpleague/html-to-markdown/compare/775f91e...2.0.0
365 | 
366 | 


--------------------------------------------------------------------------------
/CONDUCT.md:
--------------------------------------------------------------------------------
 1 | # Contributor Code of Conduct
 2 | 
 3 | As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
 4 | 
 5 | We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality.
 6 | 
 7 | Examples of unacceptable behavior by participants include:
 8 | 
 9 | * The use of sexualized language or imagery
10 | * Personal attacks
11 | * Trolling or insulting/derogatory comments
12 | * Public or private harassment
13 | * Publishing other's private information, such as physical or electronic addresses, without explicit permission
14 | * Other unethical or unprofessional conduct.
15 | 
16 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team.
17 | 
18 | This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community.
19 | 
20 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
21 | 
22 | This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)
23 | 


--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
 1 | The MIT License (MIT)
 2 | 
 3 | Copyright (c) 2015 Colin O'Dell; Originally created by Nick Cernis
 4 | 
 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
 6 | this software and associated documentation files (the "Software"), to deal in
 7 | the Software without restriction, including without limitation the rights to
 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
 9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 | 
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 | 
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
  1 | HTML To Markdown for PHP
  2 | ========================
  3 | 
  4 | [![Latest Version](https://img.shields.io/packagist/v/league/html-to-markdown.svg?style=flat-square)](https://packagist.org/packages/league/html-to-markdown)
  5 | [![Software License](http://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
  6 | [![Build Status](https://img.shields.io/github/workflow/status/thephpleague/html-to-markdown/Tests/master.svg?style=flat-square)](https://github.com/thephpleague/html-to-markdown/actions?query=workflow%3ATests+branch%3Amaster)
  7 | [![Coverage Status](https://img.shields.io/scrutinizer/coverage/g/thephpleague/html-to-markdown.svg?style=flat-square)](https://scrutinizer-ci.com/g/thephpleague/html-to-markdown/code-structure)
  8 | [![Quality Score](https://img.shields.io/scrutinizer/g/thephpleague/html-to-markdown.svg?style=flat-square)](https://scrutinizer-ci.com/g/thephpleague/html-to-markdown)
  9 | [![Total Downloads](https://img.shields.io/packagist/dt/league/html-to-markdown.svg?style=flat-square)](https://packagist.org/packages/league/html-to-markdown)
 10 | 
 11 | Library which converts HTML to [Markdown](http://daringfireball.net/projects/markdown/) for your sanity and convenience.
 12 | 
 13 | 
 14 | **Requires**: PHP 7.2+
 15 | 
 16 | **Lead Developer**: [@colinodell](http://twitter.com/colinodell)
 17 | 
 18 | **Original Author**: [@nickcernis](http://twitter.com/nickcernis)
 19 | 
 20 | 
 21 | ### Why convert HTML to Markdown?
 22 | 
 23 | *"What alchemy is this?"* you mutter. *"I can see why you'd convert [Markdown to HTML](https://github.com/thephpleague/commonmark),"* you continue, already labouring the question somewhat, *"but why go the other way?"*
 24 | 
 25 | Typically you would convert HTML to Markdown if:
 26 | 
 27 | 1. You have an existing HTML document that needs to be edited by people with good taste.
 28 | 2. You want to store new content in HTML format but edit it as Markdown.
 29 | 3. You want to convert HTML email to plain text email.
 30 | 4. You know a guy who's been converting HTML to Markdown for years, and now he can speak Elvish. You'd quite like to be able to speak Elvish.
 31 | 5. You just really like Markdown.
 32 | 
 33 | ### How to use it
 34 | 
 35 | Require the library by issuing this command:
 36 | 
 37 | ```bash
 38 | composer require league/html-to-markdown
 39 | ```
 40 | 
 41 | Add `require 'vendor/autoload.php';` to the top of your script.
 42 | 
 43 | Next, create a new HtmlConverter instance, passing in your valid HTML code to its `convert()` function:
 44 | 
 45 | ```php
 46 | use League\HTMLToMarkdown\HtmlConverter;
 47 | 
 48 | $converter = new HtmlConverter();
 49 | 
 50 | $html = "

Quick, to the Batpoles!

"; 51 | $markdown = $converter->convert($html); 52 | ``` 53 | 54 | The `$markdown` variable now contains the Markdown version of your HTML as a string: 55 | 56 | ```php 57 | echo $markdown; // ==> ### Quick, to the Batpoles! 58 | ``` 59 | 60 | The included `demo` directory contains an HTML->Markdown conversion form to try out. 61 | 62 | ### Conversion options 63 | 64 | > [!CAUTION] 65 | > By default, this library preserves HTML tags without Markdown equivalents, like ``, `
`, `