HTML format
This commit is contained in:
parent
6ceb56ade7
commit
99ce916df0
@ -17,10 +17,10 @@ As a Git repository the file isn't all that useful. You can export it in other
|
||||
```bash
|
||||
python makeJargon.py
|
||||
```
|
||||
All of the resulting documents can be found in the _docs_ subdirectory. Current formats supported are manpages, HTML and org-mode markup.
|
||||
|
||||
To install the manpage:
|
||||
|
||||
```bash
|
||||
sudo install -m 644 docs/jargon.1.gz /usr/local/share/man/man1
|
||||
```
|
||||
|
||||
The org-mode formatted document can be found in _docs/jargon-org.txt_
|
||||
|
@ -75,7 +75,7 @@ def saveLicense(fp, year, publishername):
|
||||
fp.write("A copy of the license is included in the section entitled \"GNU\n")
|
||||
fp.write("Free Documentation License\".\n\n")
|
||||
|
||||
def jargonWithDefinitions(text, definitions):
|
||||
def jargonWithDefinitions(text, definitions, isHtml):
|
||||
result = ''
|
||||
prevpos = 0
|
||||
for i in range(definitions):
|
||||
@ -83,9 +83,19 @@ def jargonWithDefinitions(text, definitions):
|
||||
if pos > -1 and i > 0:
|
||||
if result != '':
|
||||
result = result + "\n\n"
|
||||
|
||||
if not isHtml:
|
||||
result = result + text[prevpos:pos]
|
||||
else:
|
||||
result = result + "<p>" + text[prevpos:pos] + "</p>"
|
||||
|
||||
prevpos = pos
|
||||
return result + "\n\n" + text[prevpos:]
|
||||
|
||||
if not isHtml:
|
||||
result = result + "\n\n" + text[prevpos:]
|
||||
else:
|
||||
result = result + "\n\n" + "<p>" + text[prevpos:] + "</p>"
|
||||
return result
|
||||
|
||||
def jargonToManpage(manpageFilename, entries, version, publishername):
|
||||
year = int(time.strftime("%Y"))
|
||||
@ -109,7 +119,7 @@ def jargonToManpage(manpageFilename, entries, version, publishername):
|
||||
text = entry[1]
|
||||
definitions = jargonSubdefinitions(entry[1])
|
||||
if definitions > 1:
|
||||
text = jargonWithDefinitions(text, definitions)
|
||||
text = jargonWithDefinitions(text, definitions, False)
|
||||
|
||||
fp.write(".SH " + title + "\n")
|
||||
fp.write(text + "\n\n")
|
||||
@ -150,7 +160,7 @@ def jargonToOrgMode(orgFilename, entries, version, publishername):
|
||||
text = entry[1]
|
||||
definitions = jargonSubdefinitions(entry[1])
|
||||
if definitions > 1:
|
||||
text = jargonWithDefinitions(text, definitions)
|
||||
text = jargonWithDefinitions(text, definitions, False)
|
||||
|
||||
if title[0:1] != subsection:
|
||||
subsection = title[0:1]
|
||||
@ -161,9 +171,58 @@ def jargonToOrgMode(orgFilename, entries, version, publishername):
|
||||
fp.close()
|
||||
|
||||
|
||||
def jargonToHTML(htmlFilename, entries, version, publishername):
|
||||
year = int(time.strftime("%Y"))
|
||||
|
||||
if not os.path.isdir("docs"):
|
||||
os.system("mkdir docs")
|
||||
|
||||
if os.path.isfile(htmlFilename):
|
||||
os.system("rm " + htmlFilename)
|
||||
|
||||
fp = open(htmlFilename,'w')
|
||||
|
||||
fp.write("<!DOCTYPE html>\n")
|
||||
fp.write("<html>\n")
|
||||
fp.write(" <head>\n")
|
||||
fp.write(" <title>The Jargon File</title>\n")
|
||||
fp.write(" </head>\n")
|
||||
fp.write(" <body>\n")
|
||||
fp.write(" <H1>The Jargon File</H1>\n")
|
||||
fp.write(" <H2>License</H2>\n")
|
||||
fp.write(" <p>\n")
|
||||
saveLicense(fp, year, publishername)
|
||||
fp.write(" </p>\n")
|
||||
fp.write(" <H2>Glossary</H2>\n")
|
||||
|
||||
subsection = ''
|
||||
for entry in entries:
|
||||
title = entry[0]
|
||||
text = entry[1]
|
||||
|
||||
if title[0:1] != subsection:
|
||||
subsection = title[0:1]
|
||||
fp.write(" <H3>" + subsection.upper() + "</H3>\n")
|
||||
|
||||
fp.write(" <H4>" + title + "</H4>\n")
|
||||
|
||||
definitions = jargonSubdefinitions(entry[1])
|
||||
if definitions > 1:
|
||||
text = jargonWithDefinitions(text, definitions, True)
|
||||
fp.write(" " + text + "\n")
|
||||
else:
|
||||
fp.write(" <p>\n")
|
||||
fp.write(" " + text + "\n")
|
||||
fp.write(" </p>\n")
|
||||
|
||||
fp.write(" </body>\n");
|
||||
fp.write("</html>\n")
|
||||
fp.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
version = "x.xx"
|
||||
publishername = "My Name"
|
||||
entries = jargonGetEntries('entries')
|
||||
jargonToManpage("docs/jargon.1", entries, version, publishername)
|
||||
jargonToOrgMode("docs/jargon-org.txt", entries, version, publishername)
|
||||
jargonToHTML("docs/jargon.html", entries, version, publishername)
|
||||
|
Loading…
Reference in New Issue
Block a user