Saravanan666/pypi-org huggingface dataset:
Package: html2text
html2texthtml2text is a Python script that converts a page of HTML into clean, easy-to-read plain ASCII text. Better yet, that ASCII also happens to be valid Markdown (a text-to-HTML format).Usage:html2text [filename [encoding]]OptionDescription--versionShow program's version number and exit-h,--helpShow this help message and exit--ignore-linksDon't include any formatting for links--escape-allEscape all special characters.  Output is less readable, but avoids corner case formatting issues.--reference-linksUse reference links instead of links to create markdown--mark-codeMark preformatted and code blocks with [code]...[/code]For a complete list of options see thedocsOr you can use it from withinPython:>>> import html2text
>>>
>>> print(html2text.html2text("<p><strong>Zed's</strong> dead baby, <em>Zed's</em> dead.</p>"))
**Zed's** dead baby, _Zed's_ dead.Or with some configuration options:>>> import html2text
>>>
>>> h = html2text.HTML2Text()
>>> # Ignore converting links from HTML
>>> h.ignore_links = True
>>> print h.handle("<p>Hello, <a href='https://www.google.com/earth/'>world</a>!")
Hello, world!

>>> print(h.handle("<p>Hello, <a href='https://www.google.com/earth/'>world</a>!"))

Hello, world!

>>> # Don't Ignore links anymore, I like links
>>> h.ignore_links = False
>>> print(h.handle("<p>Hello, <a href='https://www.google.com/earth/'>world</a>!"))
Hello, [world](https://www.google.com/earth/)!Originally written by Aaron Swartz. This code is distributed under the GPLv3.How to installhtml2textis available on pypihttps://pypi.org/project/html2text/$ pip install html2textHow to run unit teststoxTo see the coverage results:coverage htmlthen open the./htmlcov/index.htmlfile in your browser.DocumentationDocumentation liveshere
Package: html2text-rs-py
html2text_rs_pyA Python library backed by Rust'shtml2textto convert HTML to plain text. The project leverages the power of Rust to ensure fast and efficient operations, while providing an easy-to-use Python interface.Note this entire thing was done with GPT-4 and it's my first time touching Rust -- just a bit of a weekend sidequest/learning experience. As a wise man once said:"I'm in the arena trying stuff. Some will work, some won't. But always learning."Table of ContentsInstallationUsageContributingLicenseNote on benchmarksBenchmarksInstallationPrerequisites:Ensure you have bothRustand Python installed on your machine.Installmaturin:pipinstallmaturinBuilding and Installing:Option 1: Use precompiled binaries from PyPIYou can use the precompiled binaries available on PyPI. This means you don't need to compile anything yourself, and the Rust toolchain is not required.pipinstallhtml2text_rs_pyOption 2: Building from source:If you prefer to compile the Rust code yourself, or if you're interested in developing, you can build directly from the source code:First, ensure you have the Rust toolchain installed. If you don't have it, get it from rustup.rs.Clone this repo:gitclonehttps://github.com/mpr1255/html2text_rs_py.gitcdhtml2text_rs_pyBuild and install the Python package:maturindevelop--releaseThis will compile the Rust code and link it with the Python wrapper, making the module available for Python.UsageAfter installing, you can use the Rust functions directly in Python:fromhtml2text_rs_pyimportconvert_html_directory_to_text,convert_html_file_to_text_py,convert_html_files_to_text_batch_pyconvert_html_directory_to_text("./input_directory","./output_directory")# Convert a single HTML file to textconvert_html_file_to_text_py("input_file.html","output_file.txt")# Convert multiple HTML files to text in a batchinput_files=["input1.html","input2.html"]output_files=["output1.txt","output2.txt"]convert_html_files_to_text_batch_py(input_files,output_files)ContributingPull requests are welcome. For major changes, please open an issue first to discuss what you'd like to change. Please make sure to update tests as appropriate.LicenseMITNote on benchmarksSpeed was the motivation for this little project. To make sure the comparison was 1:1, I generated a ~1gb dataset of html files that do NOT contain links  (because the Rust html2text library does not expose a flag to stop generating the hyperlinked URLs, and I don't know enough Rust to figure it out). This shows that it's only ~6x faster than the normal python implementation and only ~3x faster than the Tika... Not that great... However, I will say there is a lot of boilerplate overhead with those (multithreading) whereas this wrapper has three very simple functions you can call, and the multithreading happens for free under the hood with Rust's rayon.BenchmarksMethodThreadingDocuments ProcessedTotal Output Size (bytes)ErrorsTime (seconds)tikasingle-threaded30071500926103094.76html2textsingle-threaded300715003406460184.90tikamulti-threaded30071500926103014.29html2textmulti-threaded30071500340646025.65rustmulti-threaded3007153182927303.92
Package: html2texttg
html2texttghtml2text-tg is a Python script that converts a page of HTML into clean, easy-to-read plain ASCII text. Better yet, that ASCII also happens to be valid Markdown (a text-to-HTML format).Markdown supported by telegramUsage:html2texttg [(filename|url) [encoding]]OptionDescription--versionShow program's version number and exit-h,--helpShow this help message and exit--ignore-linksDon't include any formatting for links--escape-allEscape all special characters.  Output is less readable, but avoids corner case formatting issues.--reference-linksUse reference links instead of links to create markdown--mark-codeMark preformatted and code blocks with [code]...[/code]For a complete list of options see thedocsOr you can use it from withinPython:>>> import html2texttg
>>>
>>> print(html2texttg.html2text("<p><strong>Zed's</strong> dead baby, <em>Zed's</em> dead.</p>"))
**Zed's** dead baby, _Zed's_ dead.Or with some configuration options:>>> import html2texttg
>>>
>>> h = html2texttg.HTML2Text()
>>> # Ignore converting links from HTML
>>> h.ignore_links = True
>>> print h.handle("<p>Hello, <a href='http://earth.google.com/'>world</a>!")
Hello, world!

>>> print(h.handle("<p>Hello, <a href='http://earth.google.com/'>world</a>!"))

Hello, world!

>>> # Don't Ignore links anymore, I like links
>>> h.ignore_links = False
>>> print(h.handle("<p>Hello, <a href='http://earth.google.com/'>world</a>!"))
Hello, [world](http://earth.google.com/)!Originally written by Aaron Swartz. This code is distributed under the GPLv3.How to installhtml2texttgis available on pypihttps://pypi.python.org/pypi/html2texttg$ pip install html2texttgHow to run unit tests$ python -m unittestDocumentationDocumentation liveshere
Package: html2txt
html2txthtml2txt converts HTML to markdown.UsageImport the module.fromhtml2txtimportconvertersCall theHtml2Markdownconverter on HTML text to convert it to markdown.markdown=converters.Html2Markdown().convert(html)Run converter for unit testing>cdhtml2txt/converters
>python3-Bhtml2markdown.py--pathpath-to-html-directoryTestsCreate Virtual Environment>cdhtml2txt

>python3-mvenvvenv

>source./venv/bin/activateMaking TestsTheCommonmarkandBreakdancetests were written for converting markdown to HTML so many tests fail with differences of whitespace and choices of markdown representation.Breakdance is used byDillinger, a markdown editor.>cdhtml2txt/tests

>python3-B./config/mkhtml2txt.py--path.

>python3-B./config/mkcommonmark.py--path.

>python3-B./config/mkbreakdance.py--path.

>python3-B./config/mksvgweb.py--path.

>python3-B./config/mkmathml.py--path.Running Tests>pytest-vv
Package: html3docx
html3docxA fork ofhttps://github.com/pqzx/html2docx.  This version will focus on expedient changes for our particular use case.Dependencies:python-docx&bs4To installpip install html3docxImprovementsFix for KeyError when handling an img tag without a src attribute.Images with a width attribute will be scaled according to that width.Fix for AttributeError when handling a leading br tag, either at the top of the HTML snippet, or within a td or th cell.Fix for IndexError when a table has more cells in latter rows than in the first row.Original READMEUsageAdd strings of html to an existing docx.Document objectfrom docx import Document
from htmldocx import HtmlToDocx

document = Document()
new_parser = HtmlToDocx()
# do stuff to document

html = '<h1>Hello world</h1>'
new_parser.add_html_to_document(html, document)

# do more stuff to document
document.save('your_file_name')Convert files directlyfrom htmldocx import HtmlToDocx

new_parser = HtmlToDocx()
new_parser.parse_html_file(input_html_file_path, output_docx_file_path)Convert files from a stringfrom htmldocx import HtmlToDocx

new_parser = HtmlToDocx()
docx = new_parser.parse_html_string(input_html_file_string)Change table stylesTables are not styled by default. Use thetable_styleattribute on the parser to set a table
style. The style is used for all tables.from htmldocx import HtmlToDocx

new_parser = HtmlToDocx()
new_parser.table_style = 'Light Shading Accent 4'To add borders to tables, use theTableGridstyle:new_parser.table_style = 'TableGrid'Default table styles can be found
here:https://python-docx.readthedocs.io/en/latest/user/styles-understanding.html#table-styles-in-default-templateChange default paragraph styleNo style is applied to the paragraphs by default. Use theparagraph_styleattribute on the parser
to set a default paragraph style. The style is used for all paragraphs. If additional styling (
color, background color, alignment...) is defined in the HTML, it will be applied after the
paragraph style.from htmldocx import HtmlToDocx

new_parser = HtmlToDocx()
new_parser.paragraph_style = 'Quote'Default paragraph styles can be found
here:https://python-docx.readthedocs.io/en/latest/user/styles-understanding.html#paragraph-styles-in-default-template
Package: html4docx
html4docxA package to convert docx files to html with added features on top of mammoth library.Developed by Paras Jain (c) 2023FeaturesAdded support for all-types of images.Images like .emf are converted to .png type.Image dimensions present in the file are converted for html with preset same width and height.NoteTo convert .emf image types to .png, linux env is necessary with inkscape installed.Examples of How To UseConvert docx to htmlfromhtml4docx.convertimportdocx_to_htmlhtml=docx_to_html("your_docx_filepath_here",is_convert)your_docx_filepath_here: Your docx file pathis_convert: is a boolean to convert .emf imgs to .png
Package: html5builder
HTML5BuilderHTML5Builder is a Python module
for simply generating strings of HTML5 documents and document fragments.RequirementPython 2.7 or aboveInstallationpipinstallhtml5builderBasic Usage>>>fromhtml5builderimportHTML5Builder>>>tag=HTML5Builder()>>>img=tag.img(src='image.jpg')>>>str(img)'<img src="image.jpg">'>>>anchor=tag.a([img,'link'],cls='link',href='target.html')>>>str(anchor)'<a href="target.html" class="link"><img src="image.jpg">link</a>'>>>div=tag.div()>>>div.child.append(anchor)>>>str(div)'<div><a href="target.html" class="link"><img src="image.jpg">link</a></div>'>>>doc=tag.html([tag.head(''),tag.body('')],lang='ja')>>>str(tag.doctype+str(doc))'<!DOCTYPE html><html lang="ja"><head></head><body></body></html>'DocumentationDocumentation isavailable online.
Package: html5charref
Python library for escaping/unescaping HTML5 Named Character References.The standard python library includes theHTMLParserpackage
for unescaping HTML named entities and HTML unicode escapes.  Unfortunately,
it doesn’t include any of the named character entity references defined inHTML5.  This library intends to provide a solution for
escaping/unescaping HTML character references defined in HTML5.Github Project:GithubDocumentation:Rtd
Package: html5forms
Author: Adam CupiałContributors: Andrei Antoukh, Ben Lopatin# DescriptionFormfields in django are not suited for HTML5, hence this app# Installationclone repository git clone git://github.com/adamcupial/django-html5-forms.git, put it somewhere in your python pathadd ‘html5forms’ to INSTALLED_APPS (not required)use appropriate form fields in your forms (since the widgets requires some additional attributes passed from forms, you should use fields)# Fields## All fields### Attributesall the core attributes from django fieldplaceholder :text, which displays on the field when it is empty and unfocusedautofocus (true/false), automaticaly set focus to element on page load## Html5CharFieldwidget: Html5TextInputTypical CharField, most common field in the internet, allows datalist choices, which is great autocomplete featureall the attr of django CharFielddatalist: list or tuple, of words for autocompletion (sng like autocomplete in firefox or chrome)## Html5PasswordFieldwidget: Html5PasswordInputTypical PasswordField, does not allow datalist choicesall the attr of django CharField/PasswordField## Html5SearchFieldwidget: Html5SearchInputNew field in HTML5 - the same as CharField only different input type, should be used in search fields, allows datalistsall the attr of django CharField/PasswordField## Html5EmailFieldwidget: Html5EmailInput## Html5UrlField## Html5IntegerFieldwidget: Html5NumberInputAttributes:required = [True/False]min_valuemax_value## Html5BooleanFieldwidget: Html5CheckboxInput## Html5RangeFieldwidget: Html5RangeInputAttributes:same as Html5IntegerFieldstep## Html5TelFieldwidget: Html5TelInputNew field in HTML5 - provides defaults for minimum and maximum length that
should accept most phone numbers.Attributes:same as Html5CharField
Package: html5lib-truncation
html5lib-truncationis ahtml5libfilter implementation, which can
truncate HTML to specific length in display, but never breaks HTML tags.There is a shortcut function, the simplest way to use it:>>>fromhtml5lib_truncationimporttruncate_html>>>>>>html=u'<p>A <a href="#">very very long link</a></p>'>>>truncate_html(html,8)u'<p>A <a href=#>very</a>'>>>truncate_html(html,8,break_words=True)u'<p>A <a href=#>very ve</a>'>>>truncate_html(html,20,end='...')u'<p>A <a href=#>very very...</a>'>>>truncate_html(html,20,end='...',break_words=True)u'<p>A <a href=#>very very lon...</a>'Installationpip install html5lib-truncationDon’t forget to put it into yourrequirements.txtorsetup.py.API OverviewThe core API of html5lib-truncation is the filter:importhtml5libfromhtml5lib_truncationimportTruncationFilteretree=html5lib.parse(u'<p>A <a href="#">very very long link</a></p>')walker=html5lib.getTreeWalker('etree')stream=walker(etree)stream=TruncationFilter(stream,20,end='...',break_words=True)serializer=html5lib.serializer.HTMLSerializer()serialized=serializer.serialize(stream)print(u''.join(serialized).strip())The output is<p>A <ahref=#>veryverylon...</a>.IssuesIf you want to report bugs or other issues, please create issues onGitHub Issues.ContributesYou can send a pull reueqst onGitHub.
Package: html5validate
HTML5 text validation, provided by HTML5lib.  Designed to integrate easily in
django or other web development environments, to ensure templates actually render
as intented, without dangling tags, or other nonsense.Currently just uses HTML5lib’s parsing and linting, which is enough for me
right now - it would be nice to have some more comprehensive checking, and
possibly even write some valid-attribute checking - although that’s a BIG
project.Usage:>>>fromhtml5validateimportvalidate>>>validate('<!doctype html><html><body><h1>Hi World!</h1></body></html>')None>>>validate('<!doctype html><html><body><h1>Hi World!</body></html>')Traceback(mostrecentcalllast):...html5lib.html5parser.ParseError:Expectedclosingtag.Unexpectedendoffile.So.  You run ‘validate’ on some text, and it either returns None, or throws
some kind of error at you.With Django in tests:fromdjango.testimportTestCasefromhtml5validateimportvalidateclassTestIndexViewValid(TestCase):deftest_basic_index(self):validate(self.client.get(reverse('index'),follow=True))Status:Very Early - I just pulled this out of some django view testing code in one of
my other projects, as it seemed more sensible to have it as a stand-alone
library that could be unit-tested and stuff, and I can use again easily.Initial basic tests are here - but it should really have a LOT of tests written.Roadmap:Write a bunch of tests to see how strict it really is.Write some extra tree walkers and checkers to look for valid tags, and throw
some decent exceptions, and have customisability, specify what tags users
want, etc.
Package: html5witch
html5witch offers Pythonic HTML5 generation based on xmlwitch. BSD-licensed.Usage>>> import html5witch
>>> doc = html5witch.Builder()
>>> with doc.html:
...     with doc.head:
...        doc.title('Title')
...     with doc.body:
...        doc.p('Hello World')
...        with doc.form(action="/", method="post"):
...            doc.input(type="input", name="my_input_field")
...
>>> print(doc)
<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Title</title>
  </head>
  <body>
    <p>Hello World</p>
    <form action="/" method="post">
      <input type="input" name="my_input_field">
    </form>
  </body>
</html>Setup$ pip install html5witch # or
$ easy_install html5witch # or
$ cd xmlwitch-0.2.1; python setup.py install
$ cd html5witch-0.2.1; python setup.py installLinksFull documentationDevelopment repositoryAuthor’s website
Package: html-and-py
html_and_pyA lightweight solution to generating HTML-formatted strings, in Python.Open source available onGitHubandPyPI.InstallationInstall from pip:py -m pip install html_and_pyUpdate to the latest version from pip:py -m pip install html_and_py --upgradeUninstall from pip:py -m pip uninstall html_and_pyBuilding from sourcesIt is possible to build from sources by running this command from the
package directory in your filesystem:py -m buildCommunityOpen a new issuefor support
Package: htmlatex
HtmLaTeXWork in ProgressLike HTML, but not LaTeX? HtmLaTeX compiles HTML code to LaTeX.For example, the following HTML code:<!DOCTYPE html><htmllang="de"><head><metacharset="utf-8"><metaname="viewport"content="width=device-width, initial-scale=1"><title>My Paper</title><metaname="date"content="2022-09-02"><metaname="author"content="Linus"><linkrel="icon"type="image/png"href="logo.png"></head><body><div><ahref="#">link</a></div><h1id="section-1">Hello World</h1><p>This is a paragraph.</p><imgsrc="a"></body></html>...compiles to the following LaTeX code:%%%%%% HEAD START %%%%%%\title{My Paper}\date{2022-09-02}\author{Linus}%%%%%% HEAD END %%%%%%%%%%%% MAIN DOCUMENT START %%%%%%\begin{document}\maketitle\section{Hello World}\label{section-1}This is a paragraph.\includegraphics{a}\end{document}%%%%%% MAIN DOCUMENT END %%%%%%Installation$pipinstallHtmLaTeXUsageAs binary$python3-mhtmlatexpaper.htmlThis will create a file calledpaper.texin the current directory.As libraryimportioimportbs4fromhtmlateximportHandlers,htmlatex# Declare handlers for HTML tags# Collection of handlers for HTML tagshandlers=Handlers()# Register a handler for the <h1> tag@handlers.register()defh1(node:bs4.element.Tag):section_name=node.stringsection_id=node.attrs['id']yield[r"\section{%s}"%section_name,r"\label{%s}"%section_id,]# ... more handlers ...# Destination for generated LaTeXgenerated_latex=io.StringIO()# HTML to be convertedhtml="..."# And compilehtmlatex(html,generated_latex,handlers=handlers)
Package: htmlBuilder
HtmlBuilderHtmlBuilder is a python library that allows you to render HTML files by writing python code. And to make use of python features, clean syntax, and object-oriented design to their full potential.Why should you care about this library?When rendering HTML programmatically, there are other options available (template engines and other rendering libraries). Still, these are often limited in what they can do, or it's necessary to learn a new level of abstraction before being productive. HtmlBuilder tries to improve on this by following the next few ideas:Minimal learning curve: Users should need no more than  Python and HTML knowledge to be productive using this tool.Real python code: The final code looks and behaves as you would expect from other python code.Easily testable: Users can introspect and unit test the HTML object structurebeforerendering the HTML string.Installationrunpip install htmlbuilderUse examples:A simple example# import necessary tags and attributesfromhtmlBuilder.tagsimport*fromhtmlBuilder.attributesimportClass,StyleasInlineStyle# html tags are represented by classeshtml=Html([],# any tag can receive another tag as constructor parameterHead([],Title([],"A beautiful site")),Body([Class('btn btn-success'),InlineStyle(background_color='red',bottom='35px')],Hr(),Div([],Div())))# no closing tags are required# call the render() method to return tag instances as html textprint(html.render(pretty=True))Output<html><head><title>A beautiful site</title></head><bodyclass='btn btn-success'style='background-color: red; bottom: 35px'><hr/><div><div></div></div></body></html>A not so simple examplefromhtmlBuilder.attributesimportClassfromhtmlBuilder.tagsimportHtml,Head,Title,Body,Nav,Div,Footer,Ul,Li# declare datausers=[{"name":"Jose","movies":['A beautiful mind','Red'],"favorite-number":42,},{"name":"Jaime","movies":['The breakfast club','Fight club'],"favorite-number":7,},{"name":"Jhon","movies":['The room','Yes man'],"favorite-number":987654321,},]# functions can be used to handle recurring tag structuresdefmy_custom_nav():# these functions can return a tag or a list of tags ( [tag1,tag2,tag3] )returnNav([Class("nav pretty")],Div([],"A beautiful NavBar"))html=Html([],Head([],Title([],"An awesome site")),Body([],my_custom_nav(),# calling previously defined function[Div([Class(f"user-{user['name'].lower()}")],Div([],user['name']),Ul([],[Li([],movie)formovieinuser["movies"]]# list comprehensions can be used to easily render multiple tags)ifuser['favorite-number']<100else"Favorite number is too high"# python's ternary operation is allowed too)foruserinusers],Footer([],"My Footer"),))print(html.render(pretty=True,doctype=True))# pass doctype=True to add a document declarationOutput<!DOCTYPE html><html><head><title>An awesome site</title></head><body><navclass='nav pretty'><div>A beautiful NavBar</div></nav><divclass='user-jose'><div>Jose</div><ul><li>A beautiful mind</li><li>Red</li></ul></div><divclass='user-jaime'><div>Jaime</div><ul><li>The breakfast club</li><li>Fight club</li></ul></div><divclass='user-jhon'><div>Jhon</div>Favorite number is too high</div><footer>My Footer</footer></body></html>
Package: html-calendar
This module has the simple purpose of building html calendar tables with links
and formatting. It is totally framework agnostic.The module provides thehtmlcalendarPython function that takes an starting
date and a number of months for rendering the HTML Tables containing the
specified months with formated cells and HTML links on day’s numbers.Formatting is provided by passing a callback function as theclassesparameters that takes the date and returns a list of CSS classes that are
applied to the date’s cell.Linking dates to URLs is also provided by a callback function passed as thelinksparameter that takes the date and returns a fully qualified HTML link
if required orNoneif not.You can also format the days that are not in the month but appear in the table
with the optionno_month_class. And the classes for formatting the headers
and the table using the optionsth_classesandtable_classes.It also supports North American calendar with the optioncaltypeputting
its value to 1.fromflaskimportFlaskfromdatetimeimportdatefromhtmlcalendarimporthtmlcalendarapp=Flask("party")deflinks(date):ifdate.weekday()==5:return"https://github.com/llou/html-calendar"defcss_class(date):ifdate.weekday()==5:return["party"]@app.route("/")defparty_calendar():returnhtmlcalendar(date.today(),months=1,links=links,classes=css_class)You can read the documentation athttps://html-calendar.readthedocs.io/en/latest/