Skip to content

Commit 6d2df3f

Browse files
authored
Update README.md
Upgrade and BugFix
1 parent 0ddbd43 commit 6d2df3f

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

README.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Or more explicitly, like this:
7777

7878
```php
7979
$converter = new HtmlConverter();
80-
$converter->getConfig()->setOption('strip_tags', true);
80+
$converter->setOptions(['strip_tags' => true]);
8181

8282
$html = '<span>Turnips!</span>';
8383
$markdown = $converter->convert($html); // $markdown now contains "Turnips!"
@@ -124,14 +124,20 @@ $markdown = $converter->convert($html); // $markdown now contains "Github"
124124
### Style options
125125

126126
By default bold tags are converted using the asterisk syntax, and italic tags are converted using the underlined syntax. Change these by using the `bold_style` and `italic_style` options.
127+
If you want to clear the format of some of them, set them to `null`.
128+
If you want their format to remain as HTML tags, set them to the empty string.
127129

128130
```php
129131
$converter = new HtmlConverter();
130-
$converter->getConfig()->setOption('italic_style', '*');
131-
$converter->getConfig()->setOption('bold_style', '__');
132-
133-
$html = '<em>Italic</em> and a <strong>bold</strong>';
134-
$markdown = $converter->convert($html); // $markdown now contains "*Italic* and a __bold__"
132+
$converter->setOptions([
133+
'italic_style' => '*',
134+
'bold_style' => '__',
135+
'underline_style' => null,
136+
'strikethrough_style' => ''
137+
);
138+
139+
$html = '<u>Underline</u>, <del>Strikethrough</del> and <em>Italic</em> and a <strong>bold</strong>';
140+
$markdown = $converter->convert($html); // $markdown now contains "Underline and a <del>Strikethrough</del> and *Italic* and a __bold__"
135141
```
136142

137143
### Line break options
@@ -142,11 +148,11 @@ By default, `br` tags are converted to two spaces followed by a newline characte
142148
$converter = new HtmlConverter();
143149
$html = '<p>test<br>line break</p>';
144150

145-
$converter->getConfig()->setOption('hard_break', true);
146-
$markdown = $converter->convert($html); // $markdown now contains "test\nline break"
151+
$converter->setOptions(['hard_break' => true]);
152+
$markdown = $converter->convert($html); // $markdown now contains "underline test\nline break"
147153

148-
$converter->getConfig()->setOption('hard_break', false); // default
149-
$markdown = $converter->convert($html); // $markdown now contains "test \nline break"
154+
$converter->setOptions(['hard_break' => false]); // default
155+
$markdown = $converter->convert($html); // $markdown now contains "underline test \nline break"
150156
```
151157

152158
### Autolinking options
@@ -157,10 +163,10 @@ By default, `a` tags are converted to the easiest possible link syntax, i.e. if
157163
$converter = new HtmlConverter();
158164
$html = '<p><a href="https://thephpleague.com">https://thephpleague.com</a></p>';
159165

160-
$converter->getConfig()->setOption('use_autolinks', true);
166+
$converter->setOptions(['use_autolinks' => true]);
161167
$markdown = $converter->convert($html); // $markdown now contains "<https://thephpleague.com>"
162168

163-
$converter->getConfig()->setOption('use_autolinks', false); // default
169+
$converter->setOptions(['use_autolinks' => false]); // default
164170
$markdown = $converter->convert($html); // $markdown now contains "[https://thephpleague.com](https://thephpleague.com)"
165171
```
166172

0 commit comments

Comments
 (0)