Skip to content

Instantly share code, notes, and snippets.

@Omi98
Last active July 18, 2024 21:32
Show Gist options
  • Save Omi98/c6c394f6cf90a4d85456e6c9af98005e to your computer and use it in GitHub Desktop.
Save Omi98/c6c394f6cf90a4d85456e6c9af98005e to your computer and use it in GitHub Desktop.
A simple Python code to input and generate html escape characters.
# A simple code in python to generate encoded characters
# for your HTML <pre> or <code> block.
import html
import sys
code = sys.stdin.readlines() # Press <ctrl-d> to end input
print()
print(f"\n\n»»———- Copy the below code & paste it in your html code block ———-««\n")
for line in code:
line.splitlines()
if len(line) != 0:
code_modified = line.strip()
print(html.escape(code_modified))
print()
# Characters include <, >, ", ', and &.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment