[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lojban] lojban grammer html errors



This python script fixes it, except chapter 1 and 14.
But, there are more problems. For example, in chapter 14, many paragraphes don't have 
<p></p> tages.

 Xah
 xah@xahlee.org
â?? http://xahlee.org/

# -*- coding: utf-8 -*-
# Python

import os,sys,shutil

mydir= '/Users/t/web/lojban/hrefgram'

findreplace = [
('</h3>','</a></h3>'),
(u'''


    <title>''',
'<title>'),
('''</title>





<link''',
'''</title>
<link'''),

('''
<meta''',
'''<meta'''),

('''    <div class="main" >''',
''),

]

def replaceStringInFile(filePath):
   "replaces all findStr by repStr in file filePath"
   print filePath
   tempName=filePath+'~x~'
   backupName=filePath+'~~'

   inF = open(filePath,'rb')
   s=unicode(inF.read(),'utf-8')
   inF.close()

   for couple in findreplace:
       outtext=s.replace(couple[0],couple[1])
       s=outtext
   outF = open(tempName,'wb')
   outF.write(outtext.encode('utf-8'))
   outF.close()

   shutil.copy2(filePath,backupName)
   os.remove(filePath)
   os.rename(tempName,filePath)

def myfun(dummy, dirr, filess):
    for child in filess:
        if '.html' == os.path.splitext(child)[1] and os.path.isfile(dirr+'/'+child):
            replaceStringInFile(dirr+'/'+child)
            print child

os.path.walk(mydir, myfun, 'dummy')


--------------------------------------------------
On Jun 9, 2005, at 5:33 PM, Xah Lee wrote:


the lojban ref grammar HTML seems to have some errors.

example:

http://lojban.org/publications/reference_grammar/chapter8.html
CSS Error (24/5): Invalid class selector.
http://lojban.org/publications/reference_grammar/chapter8.html
HTML error (256/62): The end tag </a> is missing.
HTML error (403/64): The end tag </a> is missing.
HTML error (508/53): The end tag </a> is missing.
HTML error (755/72): The end tag </a> is missing.
HTML error (843/76): The end tag </a> is missing.
HTML error (894/69): The end tag </a> is missing.
HTML error (1092/53): The end tag </a> is missing.
HTML error (1201/81): The end tag </a> is missing.
HTML error (1338/73): The end tag </a> is missing.
HTML error (1413/80): The end tag </a> is missing.
HTML error (1457/70): The end tag </a> is missing.
HTML error (1508/7): The end tag </div> is missing.
HTML error (1509/7): The end tag </div> is missing.

(validation report by iCab browser)

replacing every </h3> by </a></h3> seems to fix one type of problem....

 Xah
 xah@xahlee.org
âË?â?? http://xahlee.org/



 â??