Skip to content

Commit 1dbf541

Browse files
committed
docs for new html functions
1 parent 93194a2 commit 1dbf541

File tree

7 files changed

+62
-4
lines changed

7 files changed

+62
-4
lines changed
177 Bytes
Binary file not shown.

docs/_build/doctrees/index.doctree

7.56 KB
Binary file not shown.

docs/_build/html/genindex.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ <h2 id="C">C</h2>
125125
<dt><a href="index.html#string_utils.camel_case_to_snake">camel_case_to_snake() (in module string_utils)</a>
126126
</dt>
127127

128+
</dl></td>
129+
<td style="width: 33%" valign="top"><dl>
130+
131+
<dt><a href="index.html#string_utils.contains_html">contains_html() (in module string_utils)</a>
132+
</dt>
133+
128134
</dl></td>
129135
</tr></table>
130136

@@ -199,6 +205,10 @@ <h2 id="S">S</h2>
199205
<dt><a href="index.html#module-string_utils">string_utils (module)</a>
200206
</dt>
201207

208+
209+
<dt><a href="index.html#string_utils.strip_html">strip_html() (in module string_utils)</a>
210+
</dt>
211+
202212
</dl></td>
203213
</tr></table>
204214

docs/_build/html/index.html

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,26 @@ <h1>Welcome to Python String Utils&#8217;s documentation!<a class="headerlink" h
351351
</table>
352352
</dd></dl>
353353

354+
<dl class="function">
355+
<dt id="string_utils.contains_html">
356+
<code class="descclassname">string_utils.</code><code class="descname">contains_html</code><span class="sig-paren">(</span><em>string</em><span class="sig-paren">)</span><a class="headerlink" href="#string_utils.contains_html" title="Permalink to this definition"></a></dt>
357+
<dd><p>Checks if the given string contains html code.
358+
By design, this function is very permissive regarding what to consider html code, don&#8217;t expect to use it
359+
as an html validator, its goal is to detect &#8220;malicious&#8221; or undesired html tags in the text.</p>
360+
<table class="docutils field-list" frame="void" rules="none">
361+
<col class="field-name" />
362+
<col class="field-body" />
363+
<tbody valign="top">
364+
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>string</strong> (<em>str</em>) &#8211; Text to check</td>
365+
</tr>
366+
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">True if string contains html, false otherwise.</td>
367+
</tr>
368+
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">bool</td>
369+
</tr>
370+
</tbody>
371+
</table>
372+
</dd></dl>
373+
354374
<dl class="function">
355375
<dt id="string_utils.camel_case_to_snake">
356376
<code class="descclassname">string_utils.</code><code class="descname">camel_case_to_snake</code><span class="sig-paren">(</span><em>string</em>, <em>separator='_'</em><span class="sig-paren">)</span><a class="headerlink" href="#string_utils.camel_case_to_snake" title="Permalink to this definition"></a></dt>
@@ -454,6 +474,30 @@ <h1>Welcome to Python String Utils&#8217;s documentation!<a class="headerlink" h
454474
</table>
455475
</dd></dl>
456476

477+
<dl class="function">
478+
<dt id="string_utils.strip_html">
479+
<code class="descclassname">string_utils.</code><code class="descname">strip_html</code><span class="sig-paren">(</span><em>string</em>, <em>keep_tag_content=False</em><span class="sig-paren">)</span><a class="headerlink" href="#string_utils.strip_html" title="Permalink to this definition"></a></dt>
480+
<dd><p>Remove html code contained into the given string.</p>
481+
<table class="docutils field-list" frame="void" rules="none">
482+
<col class="field-name" />
483+
<col class="field-body" />
484+
<tbody valign="top">
485+
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
486+
<li><strong>string</strong> (<em>str</em>) &#8211; String to manipulate.</li>
487+
<li><strong>keep_tag_content</strong> (<em>bool</em>) &#8211; True to preserve tag content, False to remove tag and its content too (default).</li>
488+
</ul>
489+
</td>
490+
</tr>
491+
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">String with html removed.</p>
492+
</td>
493+
</tr>
494+
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">str</p>
495+
</td>
496+
</tr>
497+
</tbody>
498+
</table>
499+
</dd></dl>
500+
457501
</div>
458502
<div class="section" id="indices-and-tables">
459503
<h1>Indices and tables<a class="headerlink" href="#indices-and-tables" title="Permalink to this headline"></a></h1>

docs/_build/html/objects.inv

16 Bytes
Binary file not shown.

docs/_build/html/searchindex.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

string_utils.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,10 +388,14 @@ def shuffle(string):
388388

389389
def strip_html(string, keep_tag_content=False):
390390
"""
391+
Remove html code contained into the given string.
391392
392-
:param string:
393-
:param keep_tag_content:
394-
:return:
393+
:param string: String to manipulate.
394+
:type string: str
395+
:param keep_tag_content: True to preserve tag content, False to remove tag and its content too (default).
396+
:type keep_tag_content: bool
397+
:return: String with html removed.
398+
:rtype: str
395399
"""
396400
r = HTML_TAG_ONLY_RE if keep_tag_content else HTML_RE
397401
return r.sub('', string)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy