File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -156,7 +156,12 @@ Creating Custom Converters
156
156
157
157
If you have a special usecase that calls for a special conversion, you can
158
158
always inherit from ``MarkdownConverter `` and override the method you want to
159
- change:
159
+ change.
160
+ The function that handles a HTML tag named ``abc `` is called
161
+ ``convert_abc(self, el, text, convert_as_inline) `` and returns a string
162
+ containing the converted HTML tag.
163
+ The ``MarkdownConverter `` object will handle the conversion based on the
164
+ function names:
160
165
161
166
.. code :: python
162
167
@@ -173,6 +178,21 @@ change:
173
178
def md (html , ** options ):
174
179
return ImageBlockConverter(** options).convert(html)
175
180
181
+ .. code :: python
182
+
183
+ from markdownify import MarkdownConverter
184
+
185
+ class IgnoreParagraphsConverter (MarkdownConverter ):
186
+ """
187
+ Create a custom MarkdownConverter that ignores paragraphs
188
+ """
189
+ def convert_p (self , el , text , convert_as_inline ):
190
+ return ' '
191
+
192
+ # Create shorthand method for conversion
193
+ def md (html , ** options ):
194
+ return IgnoreParagraphsConverter(** options).convert(html)
195
+
176
196
177
197
Command Line Interface
178
198
======================
You can’t perform that action at this time.
0 commit comments