The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

Pretty Print HTML In Python With BeautifulSoup

TODO: Pull subtitle into page object
Code
from bs4 import BeautifulSoup as bs

input = """<html><head><title>
Pretty Print Example</title>
</head><body><p>Alfa Bravo Charlie</p>
</body></html>"""

soup = bs(input)

pretty_html = soup.prettify()

print(pretty_html)
Results
<html>
 <head>
  <title>
   Pretty Print Example
  </title>
 </head>
 <body>
  <p>
   Alfa Bravo Charlie
  </p>
 </body>
</html>

Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

Pretty Print HTML In Python With BeautifulSoup

-- code
-- python

from bs4 import BeautifulSoup as bs

input = """<html><head><title>
Pretty Print Example</title>
</head><body><p>Alfa Bravo Charlie</p>
</body></html>"""

soup = bs(input)

pretty_html = soup.prettify()

print(pretty_html)

-- results/

<html>
 <head>
  <title>
   Pretty Print Example
  </title>
 </head>
 <body>
  <p>
   Alfa Bravo Charlie
  </p>
 </body>
</html>

-- /results


-- categories
-- Python 

-- metadata
-- date: 2023-12-06 16:37:41
-- id: 2zbbx7ed
-- site: aws
-- type: post
-- status: draft