I don't have BeautifulSoup installed so I am unable to tell whether
a) for line in all_kbd:
processes one line at a time as given in the input, or do you get the clean
text in single lines in a list as shown in the example in the doc
for line in all_kbd:
if line.string == None:
I modified your code slightly:
for line in all_kbd:
print(line)
sys.exit()
if line.string == None:
Running the new script yields:
$ python shibly.py
kbd class=command
cp -v --remove-destination /usr/share/zoneinfo/
em
Hi,
###in.txt
kbd class=command
cp -v --remove-destination /usr/share/zoneinfo/
em class=replaceablecodexxx/code/em
\
/etc/localtime
/kbd
import sys
import unicodedata
from bs4 import BeautifulSoup
file_name=in.txt
html_doc=open(file_name,'r')
soup=BeautifulSoup(html_doc)