H
humn
I'm writing a script to convert Latex commands to bbcode by using the
str.replace function and I'm confused as to why this works:
if '\chapter' in line:
line = line.replace('\chapter{', '')
line = line.replace('}', '')
but this doesn't:
if '\title' in line:
line = line.replace('\title{', '')
line = line.replace('}', '')
Here is the short version of the script:
infile = open('test.tex')
outfilename = infile.name.partition('.')[0] + '.bbcode'
outfile = open(outfilename, 'w')
for line in infile:
if '\title' in line:
line = line.replace('\title{', '')
line = line.replace('}', '\n')
if '\chapter' in line:
line = line.replace('\chapter{', '')
line = line.replace('}', '')
outfile.write(line)
infile.close()
outfile.close()
str.replace function and I'm confused as to why this works:
if '\chapter' in line:
line = line.replace('\chapter{', '')
line = line.replace('}', '')
but this doesn't:
if '\title' in line:
line = line.replace('\title{', '')
line = line.replace('}', '')
Here is the short version of the script:
infile = open('test.tex')
outfilename = infile.name.partition('.')[0] + '.bbcode'
outfile = open(outfilename, 'w')
for line in infile:
if '\title' in line:
line = line.replace('\title{', '')
line = line.replace('}', '\n')
if '\chapter' in line:
line = line.replace('\chapter{', '')
line = line.replace('}', '')
outfile.write(line)
infile.close()
outfile.close()