@@ -77,7 +77,7 @@ Or more explicitly, like this:
77
77
78
78
``` php
79
79
$converter = new HtmlConverter();
80
- $converter->getConfig()->setOption( 'strip_tags', true);
80
+ $converter->setOptions([ 'strip_tags' => true] );
81
81
82
82
$html = '<span >Turnips!</span >';
83
83
$markdown = $converter->convert($html); // $markdown now contains "Turnips!"
@@ -124,14 +124,20 @@ $markdown = $converter->convert($html); // $markdown now contains "Github"
124
124
### Style options
125
125
126
126
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.
127
129
128
130
``` php
129
131
$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__"
135
141
```
136
142
137
143
### Line break options
@@ -142,11 +148,11 @@ By default, `br` tags are converted to two spaces followed by a newline characte
142
148
$converter = new HtmlConverter();
143
149
$html = '<p >test<br >line break</p >';
144
150
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"
147
153
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"
150
156
```
151
157
152
158
### Autolinking options
@@ -157,10 +163,10 @@ By default, `a` tags are converted to the easiest possible link syntax, i.e. if
157
163
$converter = new HtmlConverter();
158
164
$html = '<p ><a href =" https://thephpleague.com" >https://thephpleague.com</a ></p >';
159
165
160
- $converter->getConfig()->setOption( 'use_autolinks', true);
166
+ $converter->setOptions([ 'use_autolinks' => true] );
161
167
$markdown = $converter->convert($html); // $markdown now contains "<https: //thephpleague.com >"
162
168
163
- $converter->getConfig()->setOption( 'use_autolinks', false); // default
169
+ $converter->setOptions([ 'use_autolinks' => false] ); // default
164
170
$markdown = $converter->convert($html); // $markdown now contains "[https://thephpleague.com](https://thephpleague.com)"
165
171
```
166
172
0 commit comments