- Saved searches
- Use saved searches to filter your results more quickly
- License
- nate-parrott/beautiful_print
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- About
- html5print 0.1.2
- Introduction
- Installation
- Uninstallation
- Command Line Tool
- Synopsis
- Example
- Python API
- Pretty Print HTML
- Pretty Print CSS
- Pretty Print JavaScript
- Testing
- License
- HTML5 Print¶
- Introduction¶
- Installation¶
- Uninstallation¶
- Command Line Tool¶
- Synopsis¶
- Example¶
- Testing¶
- License¶
- Python API¶
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Prettier pretty-printing of HTML, in Python.
License
nate-parrott/beautiful_print
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
Better pretty-printing of HTML in Python
Sometimes you want to take ugly HTML and fix it up, adding proper indentation and consistent style and all that. The best way I found to do this in Python was through BeautifulSoup ‘s prettify function, but it didn’t do everything I needed. beautiful_print does.
- choose the whitespace you want to use for indentation
- break long lines
- treat certain tags like as inline, and don’t insert new lines every time they’re encountered
And it’s built atop the HTML-parsing magic of BeautifulSoup.
$ pip install beautiful_print
from beautiful_print import beautiful_print ugly_html = """ it sure is hot inside this div! right? Yep!
""" print beautiful_print(ugly_html) it sure is hot inside this div! right? Yep!
About
Prettier pretty-printing of HTML, in Python.
html5print 0.1.2
This tool pretty print your HTML, CSS and JavaScript file. The package comes with two parts:
Introduction
This module reformat web page code and make it more readable. It is targeted for developers, hence is not optimized for speed. I start out looking for a tool, ended up created this module. Hope it helps you!
- Pretty print HTML as well as embedded CSS and JavaScript within it
- Pretty print pure CSS and JavaScript
- Try to fix fragmented HTML5
- Try to fix HTML with broken unicode encoding
- Try to guess encoding of the document, and in some cases manage to convert 8-bit byte code back into correct UTF-8 format
- Support both Python 2 and 3
Installation
Uninstallation
$ pip uninstall html5print pip uninstall bs4 html5lib slimit tinycss2 requests chardet
Command Line Tool
Synopsis
$ html5-print —help html5-print OUTFILE INDENT_WIDTH ENCODING infile HTML5, CSS, JavaScript — Version Bernard Yue tool reformat the input and a beautified version, unicode. arguments: infile filename url -, a dash, which represents stdin arguments: -h, —help show this message and -o OUTFILE, —output OUTFILE filename formatted HTML, stdout omitted -s INDENT_WIDTH, —indent-width INDENT_WIDTH number of space indentation, default -e ENCODING, —encoding ENCODING encoding of input, default UTF-8 -t —filetype of file to parse, default -v, —version show program version number and
Example
$ html5-print -s4 - Ctrl-D when finished HTML page margin: 10px 20px color: black myFunction text testing