Open Media Library Platform
This commit is contained in:
commit
411ad5b16f
5849 changed files with 1778641 additions and 0 deletions
24
Linux/lib/python2.7/site-packages/twisted/lore/__init__.py
Normal file
24
Linux/lib/python2.7/site-packages/twisted/lore/__init__.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
# Copyright (c) Twisted Matrix Laboratories.
|
||||
# See LICENSE for details.
|
||||
|
||||
"""
|
||||
The Twisted Documentation Generation System. Deprecated since Twisted 14.0,
|
||||
please use Sphinx instead.
|
||||
|
||||
The lore2sphinx tool at <https://bitbucket.org/khorn/lore2sphinx> may be of use
|
||||
migrating from Lore.
|
||||
|
||||
Maintainer: Andrew Bennetts
|
||||
"""
|
||||
|
||||
# TODO
|
||||
# Abstract
|
||||
# Bibliography
|
||||
# Index
|
||||
# Allow non-web image formats (EPS, specifically)
|
||||
# Allow pickle output and input to minimize parses
|
||||
# Numbered headers
|
||||
# Navigational aides
|
||||
|
||||
from twisted.lore._version import version
|
||||
__version__ = version.short()
|
||||
11
Linux/lib/python2.7/site-packages/twisted/lore/_version.py
Normal file
11
Linux/lib/python2.7/site-packages/twisted/lore/_version.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Copyright (c) Twisted Matrix Laboratories.
|
||||
# See LICENSE for details.
|
||||
|
||||
# This is an auto-generated file. Do not edit it.
|
||||
|
||||
"""
|
||||
Provides Twisted version information.
|
||||
"""
|
||||
|
||||
from twisted.python import versions
|
||||
version = versions.Version('twisted.lore', 14, 0, 0)
|
||||
56
Linux/lib/python2.7/site-packages/twisted/lore/default.py
Normal file
56
Linux/lib/python2.7/site-packages/twisted/lore/default.py
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
# Copyright (c) Twisted Matrix Laboratories.
|
||||
# See LICENSE for details.
|
||||
|
||||
"""
|
||||
Default processing factory plugin.
|
||||
"""
|
||||
|
||||
from xml.dom import minidom as dom
|
||||
|
||||
from twisted.lore import tree, latex, lint, process
|
||||
from twisted.web import sux
|
||||
|
||||
htmlDefault = {'template': 'template.tpl', 'baseurl': '%s', 'ext': '.html'}
|
||||
|
||||
class ProcessingFunctionFactory:
|
||||
|
||||
def getDoFile(self):
|
||||
return tree.doFile
|
||||
|
||||
def generate_html(self, options, filenameGenerator=tree.getOutputFileName):
|
||||
n = htmlDefault.copy()
|
||||
n.update(options)
|
||||
options = n
|
||||
try:
|
||||
fp = open(options['template'])
|
||||
templ = dom.parse(fp)
|
||||
except IOError, e:
|
||||
raise process.NoProcessorError(e.filename+": "+e.strerror)
|
||||
except sux.ParseError, e:
|
||||
raise process.NoProcessorError(str(e))
|
||||
df = lambda file, linkrel: self.getDoFile()(file, linkrel, options['ext'],
|
||||
options['baseurl'], templ, options, filenameGenerator)
|
||||
return df
|
||||
|
||||
latexSpitters = {None: latex.LatexSpitter,
|
||||
'section': latex.SectionLatexSpitter,
|
||||
'chapter': latex.ChapterLatexSpitter,
|
||||
'book': latex.BookLatexSpitter,
|
||||
}
|
||||
|
||||
def generate_latex(self, options, filenameGenerator=None):
|
||||
spitter = self.latexSpitters[None]
|
||||
for (key, value) in self.latexSpitters.items():
|
||||
if key and options.get(key):
|
||||
spitter = value
|
||||
df = lambda file, linkrel: latex.convertFile(file, spitter)
|
||||
return df
|
||||
|
||||
def getLintChecker(self):
|
||||
return lint.getDefaultChecker()
|
||||
|
||||
def generate_lint(self, options, filenameGenerator=None):
|
||||
checker = self.getLintChecker()
|
||||
return lambda file, linkrel: lint.doFile(file, checker)
|
||||
|
||||
factory = ProcessingFunctionFactory()
|
||||
68
Linux/lib/python2.7/site-packages/twisted/lore/docbook.py
Normal file
68
Linux/lib/python2.7/site-packages/twisted/lore/docbook.py
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
# Copyright (c) Twisted Matrix Laboratories.
|
||||
# See LICENSE for details.
|
||||
|
||||
"""
|
||||
DocBook output support for Lore.
|
||||
"""
|
||||
|
||||
import os, cgi
|
||||
from xml.dom import minidom as dom
|
||||
|
||||
from twisted.lore import latex
|
||||
|
||||
|
||||
class DocbookSpitter(latex.BaseLatexSpitter):
|
||||
|
||||
currentLevel = 1
|
||||
|
||||
def writeNodeData(self, node):
|
||||
self.writer(node.data)
|
||||
|
||||
def visitNode_body(self, node):
|
||||
self.visitNodeDefault(node)
|
||||
self.writer('</section>'*self.currentLevel)
|
||||
|
||||
def visitNodeHeader(self, node):
|
||||
level = int(node.tagName[1])
|
||||
difference, self.currentLevel = level-self.currentLevel, level
|
||||
self.writer('<section>'*difference+'</section>'*-difference)
|
||||
if difference<=0:
|
||||
self.writer('</section>\n<section>')
|
||||
self.writer('<title>')
|
||||
self.visitNodeDefault(node)
|
||||
|
||||
def visitNode_a_listing(self, node):
|
||||
fileName = os.path.join(self.currDir, node.getAttribute('href'))
|
||||
self.writer('<programlisting>\n')
|
||||
self.writer(cgi.escape(open(fileName).read()))
|
||||
self.writer('</programlisting>\n')
|
||||
|
||||
def visitNode_a_href(self, node):
|
||||
self.visitNodeDefault(node)
|
||||
|
||||
def visitNode_a_name(self, node):
|
||||
self.visitNodeDefault(node)
|
||||
|
||||
def visitNode_li(self, node):
|
||||
for child in node.childNodes:
|
||||
if getattr(child, 'tagName', None) != 'p':
|
||||
new = dom.Element('p')
|
||||
new.childNodes = [child]
|
||||
node.replaceChild(new, child)
|
||||
self.visitNodeDefault(node)
|
||||
|
||||
visitNode_h2 = visitNode_h3 = visitNode_h4 = visitNodeHeader
|
||||
end_h2 = end_h3 = end_h4 = '</title><para />'
|
||||
start_title, end_title = '<section><title>', '</title><para />'
|
||||
start_p, end_p = '<para>', '</para>'
|
||||
start_strong, end_strong = start_em, end_em = '<emphasis>', '</emphasis>'
|
||||
start_span_footnote, end_span_footnote = '<footnote><para>', '</para></footnote>'
|
||||
start_q = end_q = '"'
|
||||
start_pre, end_pre = '<programlisting>', '</programlisting>'
|
||||
start_div_note, end_div_note = '<note>', '</note>'
|
||||
start_li, end_li = '<listitem>', '</listitem>'
|
||||
start_ul, end_ul = '<itemizedlist>', '</itemizedlist>'
|
||||
start_ol, end_ol = '<orderedlist>', '</orderedlist>'
|
||||
start_dl, end_dl = '<variablelist>', '</variablelist>'
|
||||
start_dt, end_dt = '<varlistentry><term>', '</term>'
|
||||
start_dd, end_dd = '<listitem><para>', '</para></listitem></varlistentry>'
|
||||
49
Linux/lib/python2.7/site-packages/twisted/lore/htmlbook.py
Normal file
49
Linux/lib/python2.7/site-packages/twisted/lore/htmlbook.py
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
# Copyright (c) Twisted Matrix Laboratories.
|
||||
# See LICENSE for details.
|
||||
|
||||
from twisted.python.compat import execfile
|
||||
|
||||
|
||||
def getNumber(filename):
|
||||
return None
|
||||
|
||||
def getReference(filename):
|
||||
return None
|
||||
|
||||
class Book:
|
||||
|
||||
def __init__(self, filename):
|
||||
self.chapters = []
|
||||
self.indexFilename = None
|
||||
|
||||
global Chapter
|
||||
Chapter = self.Chapter
|
||||
global getNumber
|
||||
getNumber = self.getNumber
|
||||
global getReference
|
||||
getReference = self.getNumber
|
||||
global Index
|
||||
Index = self.Index
|
||||
|
||||
if filename:
|
||||
execfile(filename, globals())
|
||||
|
||||
def getFiles(self):
|
||||
return [c[0] for c in self.chapters]
|
||||
|
||||
def getNumber(self, filename):
|
||||
for c in self.chapters:
|
||||
if c[0] == filename:
|
||||
return c[1]
|
||||
return None
|
||||
|
||||
def getIndexFilename(self):
|
||||
return self.indexFilename
|
||||
|
||||
def Chapter(self, filename, number):
|
||||
self.chapters.append((filename, number))
|
||||
|
||||
def Index(self, filename):
|
||||
self.indexFilename = filename
|
||||
|
||||
#_book = Book(None)
|
||||
53
Linux/lib/python2.7/site-packages/twisted/lore/indexer.py
Normal file
53
Linux/lib/python2.7/site-packages/twisted/lore/indexer.py
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
# Copyright (c) Twisted Matrix Laboratories.
|
||||
# See LICENSE for details.
|
||||
|
||||
indexFilename = None
|
||||
entries = None
|
||||
|
||||
|
||||
def setIndexFilename(filename='index.xhtml'):
|
||||
global indexFilename
|
||||
indexFilename = filename
|
||||
|
||||
def getIndexFilename():
|
||||
global indexFilename
|
||||
return indexFilename
|
||||
|
||||
def addEntry(filename, anchor, text, reference):
|
||||
global entries
|
||||
if text not in entries:
|
||||
entries[text] = []
|
||||
entries[text].append((filename, anchor, reference))
|
||||
|
||||
def clearEntries():
|
||||
global entries
|
||||
entries = {}
|
||||
|
||||
def generateIndex():
|
||||
global entries
|
||||
global indexFilename
|
||||
|
||||
if not indexFilename:
|
||||
return
|
||||
|
||||
f = open(indexFilename, 'w')
|
||||
sortedEntries = [(e.lower(), e) for e in entries]
|
||||
sortedEntries.sort()
|
||||
sortedEntries = [e[1] for e in sortedEntries]
|
||||
for text in sortedEntries:
|
||||
refs = []
|
||||
f.write(text.replace('!', ', ') + ': ')
|
||||
for (file, anchor, reference) in entries[text]:
|
||||
refs.append('<a href="%s#%s">%s</a>' % (file, anchor, reference))
|
||||
if text == 'infinite recursion':
|
||||
refs.append('<em>See Also:</em> recursion, infinite\n')
|
||||
if text == 'recursion!infinite':
|
||||
refs.append('<em>See Also:</em> infinite recursion\n')
|
||||
f.write('%s<br />\n' % ", ".join(refs))
|
||||
f.close()
|
||||
|
||||
def reset():
|
||||
clearEntries()
|
||||
setIndexFilename()
|
||||
|
||||
reset()
|
||||
482
Linux/lib/python2.7/site-packages/twisted/lore/latex.py
Normal file
482
Linux/lib/python2.7/site-packages/twisted/lore/latex.py
Normal file
|
|
@ -0,0 +1,482 @@
|
|||
# -*- test-case-name: twisted.lore.test.test_latex -*-
|
||||
# Copyright (c) Twisted Matrix Laboratories.
|
||||
# See LICENSE for details.
|
||||
|
||||
"""
|
||||
LaTeX output support for Lore.
|
||||
"""
|
||||
|
||||
from xml.dom import minidom as dom
|
||||
import os.path, re
|
||||
from cStringIO import StringIO
|
||||
import urlparse
|
||||
|
||||
from twisted.web import domhelpers
|
||||
from twisted.python import procutils
|
||||
|
||||
import tree
|
||||
|
||||
escapingRE = re.compile(r'([\[\]#$%&_{}^~\\])')
|
||||
lowerUpperRE = re.compile(r'([a-z])([A-Z])')
|
||||
|
||||
def _escapeMatch(match):
|
||||
c = match.group()
|
||||
if c == '\\':
|
||||
return '$\\backslash$'
|
||||
elif c == '~':
|
||||
return '\\~{}'
|
||||
elif c == '^':
|
||||
return '\\^{}'
|
||||
elif c in '[]':
|
||||
return '{'+c+'}'
|
||||
else:
|
||||
return '\\' + c
|
||||
|
||||
def latexEscape(txt):
|
||||
txt = escapingRE.sub(_escapeMatch, txt)
|
||||
return txt.replace('\n', ' ')
|
||||
|
||||
entities = {'amp': '\&', 'gt': '>', 'lt': '<', 'quot': '"',
|
||||
'copy': '\\copyright', 'mdash': '---', 'rdquo': '``',
|
||||
'ldquo': "''"}
|
||||
|
||||
|
||||
def realpath(path):
|
||||
# Normalise path
|
||||
cwd = os.getcwd()
|
||||
path = os.path.normpath(os.path.join(cwd, path))
|
||||
return path.replace('\\', '/') # windows slashes make LaTeX blow up
|
||||
|
||||
|
||||
def getLatexText(node, writer, filter=lambda x:x, entities=entities):
|
||||
if hasattr(node, 'eref'):
|
||||
return writer(entities.get(node.eref, ''))
|
||||
if hasattr(node, 'data'):
|
||||
if isinstance(node.data, unicode):
|
||||
data = node.data.encode('utf-8')
|
||||
else:
|
||||
data = node.data
|
||||
return writer(filter(data))
|
||||
for child in node.childNodes:
|
||||
getLatexText(child, writer, filter, entities)
|
||||
|
||||
class BaseLatexSpitter:
|
||||
|
||||
def __init__(self, writer, currDir='.', filename=''):
|
||||
self.writer = writer
|
||||
self.currDir = currDir
|
||||
self.filename = filename
|
||||
|
||||
def visitNode(self, node):
|
||||
if isinstance(node, dom.Comment):
|
||||
return
|
||||
if not hasattr(node, 'tagName'):
|
||||
self.writeNodeData(node)
|
||||
return
|
||||
getattr(self, 'visitNode_'+node.tagName, self.visitNodeDefault)(node)
|
||||
|
||||
def visitNodeDefault(self, node):
|
||||
self.writer(getattr(self, 'start_'+node.tagName, ''))
|
||||
for child in node.childNodes:
|
||||
self.visitNode(child)
|
||||
self.writer(getattr(self, 'end_'+node.tagName, ''))
|
||||
|
||||
def visitNode_a(self, node):
|
||||
if node.hasAttribute('class'):
|
||||
if node.getAttribute('class').endswith('listing'):
|
||||
return self.visitNode_a_listing(node)
|
||||
if node.hasAttribute('href'):
|
||||
return self.visitNode_a_href(node)
|
||||
if node.hasAttribute('name'):
|
||||
return self.visitNode_a_name(node)
|
||||
self.visitNodeDefault(node)
|
||||
|
||||
def visitNode_span(self, node):
|
||||
if not node.hasAttribute('class'):
|
||||
return self.visitNodeDefault(node)
|
||||
node.tagName += '_'+node.getAttribute('class')
|
||||
self.visitNode(node)
|
||||
|
||||
visitNode_div = visitNode_span
|
||||
|
||||
def visitNode_h1(self, node):
|
||||
pass
|
||||
|
||||
def visitNode_style(self, node):
|
||||
pass
|
||||
|
||||
|
||||
class LatexSpitter(BaseLatexSpitter):
|
||||
|
||||
baseLevel = 0
|
||||
diaHack = bool(procutils.which("dia"))
|
||||
|
||||
def writeNodeData(self, node):
|
||||
buf = StringIO()
|
||||
getLatexText(node, buf.write, latexEscape)
|
||||
self.writer(buf.getvalue().replace('<', '$<$').replace('>', '$>$'))
|
||||
|
||||
|
||||
def visitNode_head(self, node):
|
||||
authorNodes = domhelpers.findElementsWithAttribute(node, 'rel', 'author')
|
||||
authorNodes = [n for n in authorNodes if n.tagName == 'link']
|
||||
|
||||
if authorNodes:
|
||||
self.writer('\\author{')
|
||||
authors = []
|
||||
for aNode in authorNodes:
|
||||
name = aNode.getAttribute('title')
|
||||
href = aNode.getAttribute('href')
|
||||
if href.startswith('mailto:'):
|
||||
href = href[7:]
|
||||
if href:
|
||||
if name:
|
||||
name += ' '
|
||||
name += '$<$' + href + '$>$'
|
||||
if name:
|
||||
authors.append(name)
|
||||
|
||||
self.writer(' \\and '.join(authors))
|
||||
self.writer('}')
|
||||
|
||||
self.visitNodeDefault(node)
|
||||
|
||||
|
||||
def visitNode_pre(self, node):
|
||||
"""
|
||||
Writes a I{verbatim} block when it encounters a I{pre} element.
|
||||
|
||||
@param node: The element to process.
|
||||
@type node: L{xml.dom.minidom.Element}
|
||||
"""
|
||||
self.writer('\\begin{verbatim}\n')
|
||||
buf = StringIO()
|
||||
getLatexText(node, buf.write)
|
||||
self.writer(tree._removeLeadingTrailingBlankLines(buf.getvalue()))
|
||||
self.writer('\\end{verbatim}\n')
|
||||
|
||||
|
||||
def visitNode_code(self, node):
|
||||
fout = StringIO()
|
||||
getLatexText(node, fout.write, latexEscape)
|
||||
data = lowerUpperRE.sub(r'\1\\linebreak[1]\2', fout.getvalue())
|
||||
data = data[:1] + data[1:].replace('.', '.\\linebreak[1]')
|
||||
self.writer('\\texttt{'+data+'}')
|
||||
|
||||
def visitNode_img(self, node):
|
||||
fileName = os.path.join(self.currDir, node.getAttribute('src'))
|
||||
target, ext = os.path.splitext(fileName)
|
||||
if self.diaHack and os.access(target + '.dia', os.R_OK):
|
||||
ext = '.dia'
|
||||
fileName = target + ext
|
||||
f = getattr(self, 'convert_'+ext[1:], None)
|
||||
if not f:
|
||||
return
|
||||
target = os.path.join(self.currDir, os.path.basename(target)+'.eps')
|
||||
f(fileName, target)
|
||||
target = os.path.basename(target)
|
||||
self._write_img(target)
|
||||
|
||||
def _write_img(self, target):
|
||||
"""Write LaTeX for image."""
|
||||
self.writer('\\begin{center}\\includegraphics[%%\n'
|
||||
'width=1.0\n'
|
||||
'\\textwidth,height=1.0\\textheight,\nkeepaspectratio]'
|
||||
'{%s}\\end{center}\n' % target)
|
||||
|
||||
def convert_png(self, src, target):
|
||||
# XXX there's a *reason* Python comes with the pipes module -
|
||||
# someone fix this to use it.
|
||||
r = os.system('pngtopnm "%s" | pnmtops -noturn > "%s"' % (src, target))
|
||||
if r != 0:
|
||||
raise OSError(r)
|
||||
|
||||
def convert_dia(self, src, target):
|
||||
# EVIL DISGUSTING HACK
|
||||
data = os.popen("gunzip -dc %s" % (src)).read()
|
||||
pre = '<dia:attribute name="scaling">\n <dia:real val="1"/>'
|
||||
post = '<dia:attribute name="scaling">\n <dia:real val="0.5"/>'
|
||||
f = open('%s_hacked.dia' % (src), 'wb')
|
||||
f.write(data.replace(pre, post))
|
||||
f.close()
|
||||
os.system('gzip %s_hacked.dia' % (src,))
|
||||
os.system('mv %s_hacked.dia.gz %s_hacked.dia' % (src,src))
|
||||
# Let's pretend we never saw that.
|
||||
|
||||
# Silly dia needs an X server, even though it doesn't display anything.
|
||||
# If this is a problem for you, try using Xvfb.
|
||||
os.system("dia %s_hacked.dia -n -e %s" % (src, target))
|
||||
|
||||
def visitNodeHeader(self, node):
|
||||
level = (int(node.tagName[1])-2)+self.baseLevel
|
||||
self.writer('\n\n\\'+level*'sub'+'section{')
|
||||
spitter = HeadingLatexSpitter(self.writer, self.currDir, self.filename)
|
||||
spitter.visitNodeDefault(node)
|
||||
self.writer('}\n')
|
||||
|
||||
|
||||
def visitNode_a_listing(self, node):
|
||||
"""
|
||||
Writes a I{verbatim} block when it encounters a code listing
|
||||
(represented by an I{a} element with a I{listing} class).
|
||||
|
||||
@param node: The element to process.
|
||||
@type node: C{xml.dom.minidom.Element}
|
||||
"""
|
||||
fileName = os.path.join(self.currDir, node.getAttribute('href'))
|
||||
self.writer('\\begin{verbatim}\n')
|
||||
lines = map(str.rstrip, open(fileName).readlines())
|
||||
skipLines = int(node.getAttribute('skipLines') or 0)
|
||||
lines = lines[skipLines:]
|
||||
self.writer(tree._removeLeadingTrailingBlankLines('\n'.join(lines)))
|
||||
self.writer('\\end{verbatim}')
|
||||
|
||||
# Write a caption for this source listing
|
||||
fileName = os.path.basename(fileName)
|
||||
caption = domhelpers.getNodeText(node)
|
||||
if caption == fileName:
|
||||
caption = 'Source listing'
|
||||
self.writer('\parbox[b]{\linewidth}{\\begin{center}%s --- '
|
||||
'\\begin{em}%s\\end{em}\\end{center}}'
|
||||
% (latexEscape(caption), latexEscape(fileName)))
|
||||
|
||||
|
||||
def visitNode_a_href(self, node):
|
||||
supported_schemes=['http', 'https', 'ftp', 'mailto']
|
||||
href = node.getAttribute('href')
|
||||
if urlparse.urlparse(href)[0] in supported_schemes:
|
||||
text = domhelpers.getNodeText(node)
|
||||
self.visitNodeDefault(node)
|
||||
if text != href:
|
||||
self.writer('\\footnote{%s}' % latexEscape(href))
|
||||
else:
|
||||
path, fragid = (href.split('#', 1) + [None])[:2]
|
||||
if path == '':
|
||||
path = self.filename
|
||||
else:
|
||||
path = os.path.join(os.path.dirname(self.filename), path)
|
||||
#if path == '':
|
||||
#path = os.path.basename(self.filename)
|
||||
#else:
|
||||
# # Hack for linking to man pages from howtos, i.e.
|
||||
# # ../doc/foo-man.html -> foo-man.html
|
||||
# path = os.path.basename(path)
|
||||
|
||||
path = realpath(path)
|
||||
|
||||
if fragid:
|
||||
ref = path + 'HASH' + fragid
|
||||
else:
|
||||
ref = path
|
||||
self.writer('\\textit{')
|
||||
self.visitNodeDefault(node)
|
||||
self.writer('}')
|
||||
self.writer('\\loreref{%s}' % ref)
|
||||
|
||||
def visitNode_a_name(self, node):
|
||||
self.writer('\\label{%sHASH%s}' % (
|
||||
realpath(self.filename), node.getAttribute('name')))
|
||||
self.visitNodeDefault(node)
|
||||
|
||||
def visitNode_table(self, node):
|
||||
rows = [[col for col in row.childNodes
|
||||
if getattr(col, 'tagName', None) in ('th', 'td')]
|
||||
for row in node.childNodes if getattr(row, 'tagName', None)=='tr']
|
||||
numCols = 1+max([len(row) for row in rows])
|
||||
self.writer('\\begin{table}[ht]\\begin{center}')
|
||||
self.writer('\\begin{tabular}{@{}'+'l'*numCols+'@{}}')
|
||||
for row in rows:
|
||||
th = 0
|
||||
for col in row:
|
||||
self.visitNode(col)
|
||||
self.writer('&')
|
||||
if col.tagName == 'th':
|
||||
th = 1
|
||||
self.writer('\\\\\n') #\\ ends lines
|
||||
if th:
|
||||
self.writer('\\hline\n')
|
||||
self.writer('\\end{tabular}\n')
|
||||
if node.hasAttribute('title'):
|
||||
self.writer('\\caption{%s}'
|
||||
% latexEscape(node.getAttribute('title')))
|
||||
self.writer('\\end{center}\\end{table}\n')
|
||||
|
||||
def visitNode_span_footnote(self, node):
|
||||
self.writer('\\footnote{')
|
||||
spitter = FootnoteLatexSpitter(self.writer, self.currDir, self.filename)
|
||||
spitter.visitNodeDefault(node)
|
||||
self.writer('}')
|
||||
|
||||
def visitNode_span_index(self, node):
|
||||
self.writer('\\index{%s}\n' % node.getAttribute('value'))
|
||||
self.visitNodeDefault(node)
|
||||
|
||||
visitNode_h2 = visitNode_h3 = visitNode_h4 = visitNodeHeader
|
||||
|
||||
start_title = '\\title{'
|
||||
end_title = '}\n'
|
||||
|
||||
start_sub = '$_{'
|
||||
end_sub = '}$'
|
||||
|
||||
start_sup = '$^{'
|
||||
end_sup = '}$'
|
||||
|
||||
start_html = '''\\documentclass{article}
|
||||
\\newcommand{\\loreref}[1]{%
|
||||
\\ifthenelse{\\value{page}=\\pageref{#1}}%
|
||||
{ (this page)}%
|
||||
{ (page \\pageref{#1})}%
|
||||
}'''
|
||||
|
||||
start_body = '\\begin{document}\n\\maketitle\n'
|
||||
end_body = '\\end{document}'
|
||||
|
||||
start_dl = '\\begin{description}\n'
|
||||
end_dl = '\\end{description}\n'
|
||||
start_ul = '\\begin{itemize}\n'
|
||||
end_ul = '\\end{itemize}\n'
|
||||
|
||||
start_ol = '\\begin{enumerate}\n'
|
||||
end_ol = '\\end{enumerate}\n'
|
||||
|
||||
start_li = '\\item '
|
||||
end_li = '\n'
|
||||
|
||||
start_dt = '\\item['
|
||||
end_dt = ']'
|
||||
end_dd = '\n'
|
||||
|
||||
start_p = '\n\n'
|
||||
|
||||
start_strong = start_em = '\\begin{em}'
|
||||
end_strong = end_em = '\\end{em}'
|
||||
|
||||
start_q = "``"
|
||||
end_q = "''"
|
||||
|
||||
start_div_note = '\\begin{quotation}\\textbf{Note:}'
|
||||
end_div_note = '\\end{quotation}'
|
||||
|
||||
start_th = '\\textbf{'
|
||||
end_th = '}'
|
||||
|
||||
|
||||
class SectionLatexSpitter(LatexSpitter):
|
||||
|
||||
baseLevel = 1
|
||||
|
||||
start_title = '\\section{'
|
||||
|
||||
def visitNode_title(self, node):
|
||||
self.visitNodeDefault(node)
|
||||
#self.writer('\\label{%s}}\n' % os.path.basename(self.filename))
|
||||
self.writer('\\label{%s}}\n' % realpath(self.filename))
|
||||
|
||||
end_title = end_body = start_body = start_html = ''
|
||||
|
||||
|
||||
class ChapterLatexSpitter(SectionLatexSpitter):
|
||||
baseLevel = 0
|
||||
start_title = '\\chapter{'
|
||||
|
||||
|
||||
class HeadingLatexSpitter(BaseLatexSpitter):
|
||||
start_q = "``"
|
||||
end_q = "''"
|
||||
|
||||
writeNodeData = LatexSpitter.writeNodeData.im_func
|
||||
|
||||
|
||||
class FootnoteLatexSpitter(LatexSpitter):
|
||||
"""For multi-paragraph footnotes, this avoids having an empty leading
|
||||
paragraph."""
|
||||
|
||||
start_p = ''
|
||||
|
||||
def visitNode_span_footnote(self, node):
|
||||
self.visitNodeDefault(node)
|
||||
|
||||
def visitNode_p(self, node):
|
||||
self.visitNodeDefault(node)
|
||||
self.start_p = LatexSpitter.start_p
|
||||
|
||||
class BookLatexSpitter(LatexSpitter):
|
||||
def visitNode_body(self, node):
|
||||
tocs=domhelpers.locateNodes([node], 'class', 'toc')
|
||||
domhelpers.clearNode(node)
|
||||
if len(tocs):
|
||||
toc=tocs[0]
|
||||
node.appendChild(toc)
|
||||
self.visitNodeDefault(node)
|
||||
|
||||
def visitNode_link(self, node):
|
||||
if not node.hasAttribute('rel'):
|
||||
return self.visitNodeDefault(node)
|
||||
node.tagName += '_'+node.getAttribute('rel')
|
||||
self.visitNode(node)
|
||||
|
||||
def visitNode_link_author(self, node):
|
||||
self.writer('\\author{%s}\n' % node.getAttribute('text'))
|
||||
|
||||
def visitNode_link_stylesheet(self, node):
|
||||
if node.hasAttribute('type') and node.hasAttribute('href'):
|
||||
if node.getAttribute('type')=='application/x-latex':
|
||||
packagename=node.getAttribute('href')
|
||||
packagebase,ext=os.path.splitext(packagename)
|
||||
self.writer('\\usepackage{%s}\n' % packagebase)
|
||||
|
||||
start_html = r'''\documentclass[oneside]{book}
|
||||
\usepackage{graphicx}
|
||||
\usepackage{times,mathptmx}
|
||||
'''
|
||||
|
||||
start_body = r'''\begin{document}
|
||||
\maketitle
|
||||
\tableofcontents
|
||||
'''
|
||||
|
||||
start_li=''
|
||||
end_li=''
|
||||
start_ul=''
|
||||
end_ul=''
|
||||
|
||||
|
||||
def visitNode_a(self, node):
|
||||
if node.hasAttribute('class'):
|
||||
a_class=node.getAttribute('class')
|
||||
if a_class.endswith('listing'):
|
||||
return self.visitNode_a_listing(node)
|
||||
else:
|
||||
return getattr(self, 'visitNode_a_%s' % a_class)(node)
|
||||
if node.hasAttribute('href'):
|
||||
return self.visitNode_a_href(node)
|
||||
if node.hasAttribute('name'):
|
||||
return self.visitNode_a_name(node)
|
||||
self.visitNodeDefault(node)
|
||||
|
||||
def visitNode_a_chapter(self, node):
|
||||
self.writer('\\chapter{')
|
||||
self.visitNodeDefault(node)
|
||||
self.writer('}\n')
|
||||
|
||||
def visitNode_a_sect(self, node):
|
||||
base,ext=os.path.splitext(node.getAttribute('href'))
|
||||
self.writer('\\input{%s}\n' % base)
|
||||
|
||||
|
||||
|
||||
def processFile(spitter, fin):
|
||||
# XXX Use Inversion Of Control Pattern to orthogonalize the parsing API
|
||||
# from the Visitor Pattern application. (EnterPrise)
|
||||
dom = tree.parseFileAndReport(fin.name, lambda x: fin).documentElement
|
||||
spitter.visitNode(dom)
|
||||
|
||||
|
||||
def convertFile(filename, spitterClass):
|
||||
fout = open(os.path.splitext(filename)[0]+".tex", 'w')
|
||||
spitter = spitterClass(fout.write, os.path.dirname(filename), filename)
|
||||
fin = open(filename)
|
||||
processFile(spitter, fin)
|
||||
fin.close()
|
||||
fout.close()
|
||||
213
Linux/lib/python2.7/site-packages/twisted/lore/lint.py
Normal file
213
Linux/lib/python2.7/site-packages/twisted/lore/lint.py
Normal file
|
|
@ -0,0 +1,213 @@
|
|||
# Copyright (c) Twisted Matrix Laboratories.
|
||||
# See LICENSE for details.
|
||||
|
||||
"""
|
||||
Checker for common errors in Lore documents.
|
||||
"""
|
||||
|
||||
from xml.dom import minidom as dom
|
||||
import parser
|
||||
import urlparse
|
||||
import os.path
|
||||
|
||||
from twisted.lore import tree, process
|
||||
from twisted.web import domhelpers
|
||||
from twisted.python import reflect
|
||||
from twisted.python.versions import Version
|
||||
from twisted.python.deprecate import deprecatedModuleAttribute
|
||||
|
||||
|
||||
parserErrors = (SyntaxError,)
|
||||
deprecatedModuleAttribute(
|
||||
Version("Twisted", 13, 1, 0),
|
||||
"parserErrors is deprecated",
|
||||
__name__,
|
||||
"parserErrors")
|
||||
|
||||
|
||||
class TagChecker:
|
||||
|
||||
def check(self, dom, filename):
|
||||
self.hadErrors = 0
|
||||
for method in reflect.prefixedMethods(self, 'check_'):
|
||||
method(dom, filename)
|
||||
if self.hadErrors:
|
||||
raise process.ProcessingFailure("invalid format")
|
||||
|
||||
def _reportError(self, filename, element, error):
|
||||
hlint = element.hasAttribute('hlint') and element.getAttribute('hlint')
|
||||
if hlint != 'off':
|
||||
self.hadErrors = 1
|
||||
pos = getattr(element, '_markpos', None) or (0, 0)
|
||||
print "%s:%s:%s: %s" % ((filename,)+pos+(error,))
|
||||
|
||||
|
||||
class DefaultTagChecker(TagChecker):
|
||||
|
||||
def __init__(self, allowedTags, allowedClasses):
|
||||
self.allowedTags = allowedTags
|
||||
self.allowedClasses = allowedClasses
|
||||
|
||||
def check_disallowedElements(self, dom, filename):
|
||||
def m(node, self=self):
|
||||
return not self.allowedTags(node.tagName)
|
||||
for element in domhelpers.findElements(dom, m):
|
||||
self._reportError(filename, element,
|
||||
'unrecommended tag %s' % element.tagName)
|
||||
|
||||
def check_disallowedClasses(self, dom, filename):
|
||||
def matcher(element, self=self):
|
||||
if not element.hasAttribute('class'):
|
||||
return 0
|
||||
checker = self.allowedClasses.get(element.tagName, lambda x:0)
|
||||
return not checker(element.getAttribute('class'))
|
||||
for element in domhelpers.findElements(dom, matcher):
|
||||
self._reportError(filename, element,
|
||||
'unknown class %s' %element.getAttribute('class'))
|
||||
|
||||
def check_quote(self, doc, filename):
|
||||
def matcher(node):
|
||||
return ('"' in getattr(node, 'data', '') and
|
||||
not isinstance(node, dom.Comment) and
|
||||
not [1 for n in domhelpers.getParents(node)[1:-1]
|
||||
if n.tagName in ('pre', 'code')])
|
||||
for node in domhelpers.findNodes(doc, matcher):
|
||||
self._reportError(filename, node.parentNode, 'contains quote')
|
||||
|
||||
def check_styleattr(self, dom, filename):
|
||||
for node in domhelpers.findElementsWithAttribute(dom, 'style'):
|
||||
self._reportError(filename, node, 'explicit style')
|
||||
|
||||
def check_align(self, dom, filename):
|
||||
for node in domhelpers.findElementsWithAttribute(dom, 'align'):
|
||||
self._reportError(filename, node, 'explicit alignment')
|
||||
|
||||
def check_style(self, dom, filename):
|
||||
for node in domhelpers.findNodesNamed(dom, 'style'):
|
||||
if domhelpers.getNodeText(node) != '':
|
||||
self._reportError(filename, node, 'hand hacked style')
|
||||
|
||||
def check_title(self, dom, filename):
|
||||
doc = dom.documentElement
|
||||
title = domhelpers.findNodesNamed(dom, 'title')
|
||||
if len(title)!=1:
|
||||
return self._reportError(filename, doc, 'not exactly one title')
|
||||
h1 = domhelpers.findNodesNamed(dom, 'h1')
|
||||
if len(h1)!=1:
|
||||
return self._reportError(filename, doc, 'not exactly one h1')
|
||||
if domhelpers.getNodeText(h1[0]) != domhelpers.getNodeText(title[0]):
|
||||
self._reportError(filename, h1[0], 'title and h1 text differ')
|
||||
|
||||
def check_80_columns(self, dom, filename):
|
||||
for node in domhelpers.findNodesNamed(dom, 'pre'):
|
||||
# the ps/pdf output is in a font that cuts off at 80 characters,
|
||||
# so this is enforced to make sure the interesting parts (which
|
||||
# are likely to be on the right-hand edge) stay on the printed
|
||||
# page.
|
||||
for line in domhelpers.gatherTextNodes(node, 1).split('\n'):
|
||||
if len(line.rstrip()) > 80:
|
||||
self._reportError(filename, node,
|
||||
'text wider than 80 columns in pre')
|
||||
for node in domhelpers.findNodesNamed(dom, 'a'):
|
||||
if node.getAttribute('class').endswith('listing'):
|
||||
try:
|
||||
fn = os.path.dirname(filename)
|
||||
fn = os.path.join(fn, node.getAttribute('href'))
|
||||
lines = open(fn,'r').readlines()
|
||||
except:
|
||||
self._reportError(filename, node,
|
||||
'bad listing href: %r' %
|
||||
node.getAttribute('href'))
|
||||
continue
|
||||
|
||||
for line in lines:
|
||||
if len(line.rstrip()) > 80:
|
||||
self._reportError(filename, node,
|
||||
'listing wider than 80 columns')
|
||||
|
||||
def check_pre_py_listing(self, dom, filename):
|
||||
for node in domhelpers.findNodesNamed(dom, 'pre'):
|
||||
if node.getAttribute('class') == 'python':
|
||||
try:
|
||||
text = domhelpers.getNodeText(node)
|
||||
# Fix < and >
|
||||
text = text.replace('>', '>').replace('<', '<')
|
||||
# Strip blank lines
|
||||
lines = filter(None,[l.rstrip() for l in text.split('\n')])
|
||||
# Strip leading space
|
||||
while not [1 for line in lines if line[:1] not in ('',' ')]:
|
||||
lines = [line[1:] for line in lines]
|
||||
text = '\n'.join(lines) + '\n'
|
||||
try:
|
||||
parser.suite(text)
|
||||
except SyntaxError:
|
||||
# Pretend the "..." idiom is syntactically valid
|
||||
text = text.replace("...","'...'")
|
||||
parser.suite(text)
|
||||
except SyntaxError as e:
|
||||
self._reportError(filename, node,
|
||||
'invalid python code:' + str(e))
|
||||
|
||||
def check_anchor_in_heading(self, dom, filename):
|
||||
headingNames = ['h%d' % n for n in range(1,7)]
|
||||
for hname in headingNames:
|
||||
for node in domhelpers.findNodesNamed(dom, hname):
|
||||
if domhelpers.findNodesNamed(node, 'a'):
|
||||
self._reportError(filename, node, 'anchor in heading')
|
||||
|
||||
def check_texturl_matches_href(self, dom, filename):
|
||||
for node in domhelpers.findNodesNamed(dom, 'a'):
|
||||
if not node.hasAttribute('href'):
|
||||
continue
|
||||
text = domhelpers.getNodeText(node)
|
||||
proto = urlparse.urlparse(text)[0]
|
||||
if proto and ' ' not in text:
|
||||
if text != node.getAttribute('href'):
|
||||
self._reportError(filename, node,
|
||||
'link text does not match href')
|
||||
|
||||
def check_lists(self, dom, filename):
|
||||
for node in (domhelpers.findNodesNamed(dom, 'ul')+
|
||||
domhelpers.findNodesNamed(dom, 'ol')):
|
||||
if not node.childNodes:
|
||||
self._reportError(filename, node, 'empty list')
|
||||
for child in node.childNodes:
|
||||
if child.nodeName != 'li':
|
||||
self._reportError(filename, node,
|
||||
'only list items allowed in lists')
|
||||
|
||||
|
||||
def list2dict(l):
|
||||
d = {}
|
||||
for el in l:
|
||||
d[el] = None
|
||||
return d
|
||||
|
||||
classes = list2dict(['shell', 'API', 'python', 'py-prototype', 'py-filename',
|
||||
'py-src-string', 'py-signature', 'py-src-parameter',
|
||||
'py-src-identifier', 'py-src-keyword'])
|
||||
|
||||
tags = list2dict(["html", "title", "head", "body", "h1", "h2", "h3", "ol", "ul",
|
||||
"dl", "li", "dt", "dd", "p", "code", "img", "blockquote", "a",
|
||||
"cite", "div", "span", "strong", "em", "pre", "q", "table",
|
||||
"tr", "td", "th", "style", "sub", "sup", "link"])
|
||||
|
||||
span = list2dict(['footnote', 'manhole-output', 'index'])
|
||||
|
||||
div = list2dict(['note', 'boxed', 'doit'])
|
||||
|
||||
a = list2dict(['listing', 'py-listing', 'html-listing', 'absolute'])
|
||||
|
||||
pre = list2dict(['python', 'shell', 'python-interpreter', 'elisp'])
|
||||
|
||||
allowed = {'code': classes.has_key, 'span': span.has_key, 'div': div.has_key,
|
||||
'a': a.has_key, 'pre': pre.has_key, 'ul': lambda x: x=='toc',
|
||||
'ol': lambda x: x=='toc', 'li': lambda x: x=='ignoretoc'}
|
||||
|
||||
def getDefaultChecker():
|
||||
return DefaultTagChecker(tags.__contains__, allowed)
|
||||
|
||||
def doFile(file, checker):
|
||||
doc = tree.parseFileAndReport(file)
|
||||
if doc:
|
||||
checker.check(doc, file)
|
||||
85
Linux/lib/python2.7/site-packages/twisted/lore/lmath.py
Normal file
85
Linux/lib/python2.7/site-packages/twisted/lore/lmath.py
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
# Copyright (c) Twisted Matrix Laboratories.
|
||||
# See LICENSE for details.
|
||||
|
||||
"""
|
||||
LaTeX-defined image support for Lore documents.
|
||||
"""
|
||||
|
||||
import os, tempfile
|
||||
from xml.dom import minidom as dom
|
||||
|
||||
from twisted.web import domhelpers
|
||||
import latex, tree, lint, default
|
||||
|
||||
|
||||
class MathLatexSpitter(latex.LatexSpitter):
|
||||
|
||||
start_html = '\\documentclass{amsart}\n'
|
||||
|
||||
def visitNode_div_latexmacros(self, node):
|
||||
self.writer(domhelpers.getNodeText(node))
|
||||
|
||||
def visitNode_span_latexformula(self, node):
|
||||
self.writer('\[')
|
||||
self.writer(domhelpers.getNodeText(node))
|
||||
self.writer('\]')
|
||||
|
||||
def formulaeToImages(document, dir, _system=os.system):
|
||||
# gather all macros
|
||||
macros = ''
|
||||
for node in domhelpers.findElementsWithAttribute(document, 'class',
|
||||
'latexmacros'):
|
||||
macros += domhelpers.getNodeText(node)
|
||||
node.parentNode.removeChild(node)
|
||||
i = 0
|
||||
for node in domhelpers.findElementsWithAttribute(document, 'class',
|
||||
'latexformula'):
|
||||
latexText='''\\documentclass[12pt]{amsart}%s
|
||||
\\begin{document}\[%s\]
|
||||
\\end{document}''' % (macros, domhelpers.getNodeText(node))
|
||||
# This file really should be cleaned up by this function, or placed
|
||||
# somewhere such that the calling code can find it and clean it up.
|
||||
file = tempfile.mktemp()
|
||||
f = open(file+'.tex', 'w')
|
||||
f.write(latexText)
|
||||
f.close()
|
||||
_system('latex %s.tex' % file)
|
||||
_system('dvips %s.dvi -o %s.ps' % (os.path.basename(file), file))
|
||||
baseimgname = 'latexformula%d.png' % i
|
||||
imgname = os.path.join(dir, baseimgname)
|
||||
i += 1
|
||||
_system('pstoimg -type png -crop a -trans -interlace -out '
|
||||
'%s %s.ps' % (imgname, file))
|
||||
newNode = dom.parseString(
|
||||
'<span><br /><img src="%s" /><br /></span>' % (
|
||||
baseimgname,)).documentElement
|
||||
node.parentNode.replaceChild(newNode, node)
|
||||
|
||||
|
||||
def doFile(fn, docsdir, ext, url, templ, linkrel='', d=None):
|
||||
d = d or {}
|
||||
doc = tree.parseFileAndReport(fn)
|
||||
formulaeToImages(doc, os.path.dirname(fn))
|
||||
cn = templ.cloneNode(1)
|
||||
tree.munge(doc, cn, linkrel, docsdir, fn, ext, url, d)
|
||||
cn.writexml(open(os.path.splitext(fn)[0]+ext, 'wb'))
|
||||
|
||||
|
||||
class ProcessingFunctionFactory(default.ProcessingFunctionFactory):
|
||||
|
||||
latexSpitters = {None: MathLatexSpitter}
|
||||
|
||||
def getDoFile(self):
|
||||
return doFile
|
||||
|
||||
def getLintChecker(self):
|
||||
checker = lint.getDefaultChecker()
|
||||
checker.allowedClasses = checker.allowedClasses.copy()
|
||||
oldDiv = checker.allowedClasses['div']
|
||||
oldSpan = checker.allowedClasses['span']
|
||||
checker.allowedClasses['div'] = lambda x:oldDiv(x) or x=='latexmacros'
|
||||
checker.allowedClasses['span'] = (lambda x:oldSpan(x) or
|
||||
x=='latexformula')
|
||||
return checker
|
||||
|
||||
factory = ProcessingFunctionFactory()
|
||||
295
Linux/lib/python2.7/site-packages/twisted/lore/man2lore.py
Normal file
295
Linux/lib/python2.7/site-packages/twisted/lore/man2lore.py
Normal file
|
|
@ -0,0 +1,295 @@
|
|||
# -*- test-case-name: twisted.lore.test.test_man2lore -*-
|
||||
# Copyright (c) Twisted Matrix Laboratories.
|
||||
# See LICENSE for details.
|
||||
|
||||
"""
|
||||
man2lore: Converts man page source (i.e. groff) into lore-compatible html.
|
||||
|
||||
This is nasty and hackish (and doesn't support lots of real groff), but is good
|
||||
enough for converting fairly simple man pages.
|
||||
"""
|
||||
|
||||
import re, os
|
||||
|
||||
quoteRE = re.compile('"(.*?)"')
|
||||
|
||||
|
||||
|
||||
def escape(text):
|
||||
text = text.replace('<', '<').replace('>', '>')
|
||||
text = quoteRE.sub('<q>\\1</q>', text)
|
||||
return text
|
||||
|
||||
|
||||
|
||||
def stripQuotes(s):
|
||||
if s[0] == s[-1] == '"':
|
||||
s = s[1:-1]
|
||||
return s
|
||||
|
||||
|
||||
|
||||
class ManConverter(object):
|
||||
"""
|
||||
Convert a man page to the Lore format.
|
||||
|
||||
@ivar tp: State variable for handling text inside a C{TP} token. It can
|
||||
take values from 0 to 3:
|
||||
- 0: when outside of a C{TP} token.
|
||||
- 1: once a C{TP} token has been encountered. If the previous value
|
||||
was 0, a definition list is started. Then, at the first line of
|
||||
text, a definition term is started.
|
||||
- 2: when the first line after the C{TP} token has been handled.
|
||||
The definition term is closed, and a definition is started with
|
||||
the next line of text.
|
||||
- 3: when the first line as definition data has been handled.
|
||||
@type tp: C{int}
|
||||
"""
|
||||
state = 'regular'
|
||||
name = None
|
||||
tp = 0
|
||||
dl = 0
|
||||
para = 0
|
||||
|
||||
def convert(self, inf, outf):
|
||||
self.write = outf.write
|
||||
longline = ''
|
||||
for line in inf.readlines():
|
||||
if line.rstrip() and line.rstrip()[-1] == '\\':
|
||||
longline += line.rstrip()[:-1] + ' '
|
||||
continue
|
||||
if longline:
|
||||
line = longline + line
|
||||
longline = ''
|
||||
self.lineReceived(line)
|
||||
self.closeTags()
|
||||
self.write('</body>\n</html>\n')
|
||||
outf.flush()
|
||||
|
||||
|
||||
def lineReceived(self, line):
|
||||
if line[0] == '.':
|
||||
f = getattr(self, 'macro_' + line[1:3].rstrip().upper(), None)
|
||||
if f:
|
||||
f(line[3:].strip())
|
||||
else:
|
||||
self.text(line)
|
||||
|
||||
|
||||
def continueReceived(self, cont):
|
||||
if not cont:
|
||||
return
|
||||
if cont[0].isupper():
|
||||
f = getattr(self, 'macro_' + cont[:2].rstrip().upper(), None)
|
||||
if f:
|
||||
f(cont[2:].strip())
|
||||
else:
|
||||
self.text(cont)
|
||||
|
||||
|
||||
def closeTags(self):
|
||||
if self.state != 'regular':
|
||||
self.write('</%s>' % self.state)
|
||||
if self.tp == 3:
|
||||
self.write('</dd>\n\n')
|
||||
self.tp = 0
|
||||
if self.dl:
|
||||
self.write('</dl>\n\n')
|
||||
self.dl = 0
|
||||
if self.para:
|
||||
self.write('</p>\n\n')
|
||||
self.para = 0
|
||||
|
||||
|
||||
def paraCheck(self):
|
||||
if not self.tp and not self.para:
|
||||
self.write('<p>')
|
||||
self.para = 1
|
||||
|
||||
|
||||
def macro_TH(self, line):
|
||||
self.write(
|
||||
'<?xml version="1.0"?>\n'
|
||||
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"\n'
|
||||
' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n')
|
||||
self.write('<html><head>\n')
|
||||
parts = [stripQuotes(x) for x in line.split(' ', 2)] + ['', '']
|
||||
title, manSection = parts[:2]
|
||||
self.write('<title>%s.%s</title>' % (title, manSection))
|
||||
self.write('</head>\n<body>\n\n')
|
||||
self.write('<h1>%s.%s</h1>\n\n' % (title, manSection))
|
||||
|
||||
macro_DT = macro_TH
|
||||
|
||||
|
||||
def macro_SH(self, line):
|
||||
self.closeTags()
|
||||
self.write('<h2>')
|
||||
self.para = 1
|
||||
self.text(stripQuotes(line))
|
||||
self.para = 0
|
||||
self.closeTags()
|
||||
self.write('</h2>\n\n')
|
||||
|
||||
|
||||
def macro_B(self, line):
|
||||
words = line.split()
|
||||
words[0] = '\\fB' + words[0] + '\\fR '
|
||||
self.text(' '.join(words))
|
||||
|
||||
|
||||
def macro_NM(self, line):
|
||||
if not self.name:
|
||||
self.name = line
|
||||
self.text(self.name + ' ')
|
||||
|
||||
|
||||
def macro_NS(self, line):
|
||||
parts = line.split(' Ns ')
|
||||
i = 0
|
||||
for l in parts:
|
||||
i = not i
|
||||
if i:
|
||||
self.text(l)
|
||||
else:
|
||||
self.continueReceived(l)
|
||||
|
||||
|
||||
def macro_OO(self, line):
|
||||
self.text('[')
|
||||
self.continueReceived(line)
|
||||
|
||||
|
||||
def macro_OC(self, line):
|
||||
self.text(']')
|
||||
self.continueReceived(line)
|
||||
|
||||
|
||||
def macro_OP(self, line):
|
||||
self.text('[')
|
||||
self.continueReceived(line)
|
||||
self.text(']')
|
||||
|
||||
|
||||
def macro_FL(self, line):
|
||||
parts = line.split()
|
||||
self.text('\\fB-%s\\fR' % parts[0])
|
||||
self.continueReceived(' '.join(parts[1:]))
|
||||
|
||||
|
||||
def macro_AR(self, line):
|
||||
parts = line.split()
|
||||
self.text('\\fI %s\\fR' % parts[0])
|
||||
self.continueReceived(' '.join(parts[1:]))
|
||||
|
||||
|
||||
def macro_PP(self, line):
|
||||
self.closeTags()
|
||||
|
||||
|
||||
def macro_IC(self, line):
|
||||
cmd = line.split(' ', 1)[0]
|
||||
args = line[line.index(cmd) + len(cmd):]
|
||||
args = args.split(' ')
|
||||
text = cmd
|
||||
while args:
|
||||
arg = args.pop(0)
|
||||
if arg.lower() == "ar":
|
||||
text += " \\fU%s\\fR" % (args.pop(0),)
|
||||
elif arg.lower() == "op":
|
||||
args.pop(0)
|
||||
text += " [\\fU%s\\fR]" % (args.pop(0),)
|
||||
|
||||
self.text(text)
|
||||
|
||||
|
||||
def macro_TP(self, line):
|
||||
"""
|
||||
Handle C{TP} token: start a definition list if it's first token, or
|
||||
close previous definition data.
|
||||
"""
|
||||
if self.tp == 3:
|
||||
self.write('</dd>\n\n')
|
||||
self.tp = 1
|
||||
else:
|
||||
self.tp = 1
|
||||
self.write('<dl>')
|
||||
self.dl = 1
|
||||
|
||||
|
||||
def macro_BL(self, line):
|
||||
self.write('<dl>')
|
||||
self.tp = 1
|
||||
|
||||
|
||||
def macro_EL(self, line):
|
||||
if self.tp == 3:
|
||||
self.write('</dd>')
|
||||
self.tp = 1
|
||||
self.write('</dl>\n\n')
|
||||
self.tp = 0
|
||||
|
||||
|
||||
def macro_IT(self, line):
|
||||
if self.tp == 3:
|
||||
self.write('</dd>')
|
||||
self.tp = 1
|
||||
self.continueReceived(line)
|
||||
|
||||
|
||||
def text(self, line):
|
||||
"""
|
||||
Handle a line of text without detected token.
|
||||
"""
|
||||
if self.tp == 1:
|
||||
self.write('<dt>')
|
||||
if self.tp == 2:
|
||||
self.write('<dd>')
|
||||
self.paraCheck()
|
||||
|
||||
bits = line.split('\\')
|
||||
self.write(escape(bits[0]))
|
||||
for bit in bits[1:]:
|
||||
if bit[:2] == 'fI':
|
||||
self.write('<em>' + escape(bit[2:]))
|
||||
self.state = 'em'
|
||||
elif bit[:2] == 'fB':
|
||||
self.write('<strong>' + escape(bit[2:]))
|
||||
self.state = 'strong'
|
||||
elif bit[:2] == 'fR':
|
||||
self.write('</%s>' % self.state)
|
||||
self.write(escape(bit[2:]))
|
||||
self.state = 'regular'
|
||||
elif bit[:2] == 'fU':
|
||||
# fU doesn't really exist, but it helps us to manage underlined
|
||||
# text.
|
||||
self.write('<u>' + escape(bit[2:]))
|
||||
self.state = 'u'
|
||||
elif bit[:3] == '(co':
|
||||
self.write('©' + escape(bit[3:]))
|
||||
else:
|
||||
self.write(escape(bit))
|
||||
|
||||
if self.tp == 1:
|
||||
self.write('</dt>')
|
||||
self.tp = 2
|
||||
elif self.tp == 2:
|
||||
self.tp = 3
|
||||
|
||||
|
||||
|
||||
class ProcessingFunctionFactory:
|
||||
|
||||
def generate_lore(self, d, filenameGenerator=None):
|
||||
ext = d.get('ext', '.html')
|
||||
return lambda file,_: ManConverter().convert(open(file),
|
||||
open(os.path.splitext(file)[0]+ext, 'w'))
|
||||
|
||||
|
||||
|
||||
factory = ProcessingFunctionFactory()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
mc = ManConverter().convert(open(sys.argv[1]), sys.stdout)
|
||||
36
Linux/lib/python2.7/site-packages/twisted/lore/numberer.py
Normal file
36
Linux/lib/python2.7/site-packages/twisted/lore/numberer.py
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
# Copyright (c) Twisted Matrix Laboratories.
|
||||
# See LICENSE for details.
|
||||
|
||||
numberSections = None
|
||||
filenum = None
|
||||
|
||||
|
||||
def reset():
|
||||
resetFilenum()
|
||||
setNumberSections(False)
|
||||
|
||||
def resetFilenum():
|
||||
setFilenum(0)
|
||||
|
||||
def setFilenum(arg):
|
||||
global filenum
|
||||
filenum = arg
|
||||
|
||||
def getFilenum():
|
||||
global filenum
|
||||
return filenum
|
||||
|
||||
def getNextFilenum():
|
||||
global filenum
|
||||
filenum += 1
|
||||
return filenum
|
||||
|
||||
def setNumberSections(arg):
|
||||
global numberSections
|
||||
numberSections = arg
|
||||
|
||||
def getNumberSections():
|
||||
global numberSections
|
||||
return numberSections
|
||||
|
||||
reset()
|
||||
120
Linux/lib/python2.7/site-packages/twisted/lore/process.py
Normal file
120
Linux/lib/python2.7/site-packages/twisted/lore/process.py
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
# -*- test-case-name: twisted.lore.test.test_lore -*-
|
||||
# Copyright (c) Twisted Matrix Laboratories.
|
||||
# See LICENSE for details.
|
||||
|
||||
#
|
||||
import sys, os
|
||||
import tree #todo: get rid of this later
|
||||
import indexer
|
||||
|
||||
class NoProcessorError(Exception):
|
||||
pass
|
||||
|
||||
class ProcessingFailure(Exception):
|
||||
pass
|
||||
|
||||
cols = 79
|
||||
|
||||
def dircount(d):
|
||||
return len([1 for el in d.split("/") if el != '.'])
|
||||
|
||||
|
||||
class Walker:
|
||||
|
||||
def __init__(self, df, fext, linkrel):
|
||||
self.df = df
|
||||
self.linkrel = linkrel
|
||||
self.fext = fext
|
||||
self.walked = []
|
||||
self.failures = []
|
||||
|
||||
def walkdir(self, topdir, prefix=''):
|
||||
self.basecount = dircount(topdir)
|
||||
os.path.walk(topdir, self.walk, prefix)
|
||||
|
||||
def walk(self, prefix, d, names):
|
||||
linkrel = prefix + '../' * (dircount(d) - self.basecount)
|
||||
for name in names:
|
||||
fullpath = os.path.join(d, name)
|
||||
fext = os.path.splitext(name)[1]
|
||||
if fext == self.fext:
|
||||
self.walked.append((linkrel, fullpath))
|
||||
|
||||
def generate(self):
|
||||
i = 0
|
||||
indexer.clearEntries()
|
||||
tree.filenum = 0
|
||||
for linkrel, fullpath in self.walked:
|
||||
linkrel = self.linkrel + linkrel
|
||||
i += 1
|
||||
fname = os.path.splitext(fullpath)[0]
|
||||
self.percentdone((float(i) / len(self.walked)), fname)
|
||||
try:
|
||||
self.df(fullpath, linkrel)
|
||||
except ProcessingFailure, e:
|
||||
self.failures.append((fullpath, e))
|
||||
indexer.generateIndex()
|
||||
self.percentdone(1., None)
|
||||
|
||||
def percentdone(self, percent, fname):
|
||||
# override for neater progress bars
|
||||
proglen = 40
|
||||
hashes = int(percent * proglen)
|
||||
spaces = proglen - hashes
|
||||
progstat = "[%s%s] (%s)" %('#' * hashes, ' ' * spaces,fname or "*Done*")
|
||||
progstat += (cols - len(progstat)) * ' '
|
||||
progstat += '\r'
|
||||
sys.stdout.write(progstat)
|
||||
sys.stdout.flush()
|
||||
if fname is None:
|
||||
print
|
||||
|
||||
class PlainReportingWalker(Walker):
|
||||
|
||||
def percentdone(self, percent, fname):
|
||||
if fname:
|
||||
print fname
|
||||
|
||||
class NullReportingWalker(Walker):
|
||||
|
||||
def percentdone(self, percent, fname):
|
||||
pass
|
||||
|
||||
def parallelGenerator(originalFileName, outputExtension):
|
||||
return os.path.splitext(originalFileName)[0]+outputExtension
|
||||
|
||||
def fooAddingGenerator(originalFileName, outputExtension):
|
||||
return os.path.splitext(originalFileName)[0]+"foo"+outputExtension
|
||||
|
||||
def outputdirGenerator(originalFileName, outputExtension, inputdir, outputdir):
|
||||
originalFileName = os.path.abspath(originalFileName)
|
||||
abs_inputdir = os.path.abspath(inputdir)
|
||||
if os.path.commonprefix((originalFileName, abs_inputdir)) != abs_inputdir:
|
||||
raise ValueError("Original file name '" + originalFileName +
|
||||
"' not under input directory '" + abs_inputdir + "'")
|
||||
|
||||
adjustedPath = os.path.join(outputdir, os.path.basename(originalFileName))
|
||||
return tree.getOutputFileName(adjustedPath, outputExtension)
|
||||
|
||||
def getFilenameGenerator(config, outputExt):
|
||||
if config.get('outputdir'):
|
||||
return (lambda originalFileName, outputExtension:
|
||||
outputdirGenerator(originalFileName, outputExtension,
|
||||
os.path.abspath(config.get('inputdir')),
|
||||
os.path.abspath(config.get('outputdir'))))
|
||||
else:
|
||||
return tree.getOutputFileName
|
||||
|
||||
def getProcessor(module, output, config):
|
||||
try:
|
||||
m = getattr(module.factory, 'generate_'+output)
|
||||
except AttributeError:
|
||||
raise NoProcessorError("cannot generate "+output+" output")
|
||||
|
||||
if config.get('ext'):
|
||||
ext = config['ext']
|
||||
else:
|
||||
from default import htmlDefault
|
||||
ext = htmlDefault['ext']
|
||||
|
||||
return m(config, getFilenameGenerator(config, ext))
|
||||
|
|
@ -0,0 +1 @@
|
|||
"lore scripts"
|
||||
155
Linux/lib/python2.7/site-packages/twisted/lore/scripts/lore.py
Normal file
155
Linux/lib/python2.7/site-packages/twisted/lore/scripts/lore.py
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
# Copyright (c) Twisted Matrix Laboratories.
|
||||
# See LICENSE for details.
|
||||
|
||||
import sys
|
||||
|
||||
from zope.interface import Interface, Attribute
|
||||
|
||||
from twisted.lore import process, indexer, numberer, htmlbook
|
||||
|
||||
from twisted.python import usage, reflect
|
||||
from twisted import plugin as plugin
|
||||
|
||||
class IProcessor(Interface):
|
||||
"""
|
||||
"""
|
||||
|
||||
name = Attribute("The user-facing name of this processor")
|
||||
|
||||
moduleName = Attribute(
|
||||
"The fully qualified Python name of the object defining "
|
||||
"this processor. This object (typically a module) should "
|
||||
"have a C{factory} attribute with C{generate_<output>} methods.")
|
||||
|
||||
|
||||
class Options(usage.Options):
|
||||
|
||||
longdesc = "lore converts documentation formats."
|
||||
|
||||
optFlags = [["plain", 'p', "Report filenames without progress bar"],
|
||||
["null", 'n', "Do not report filenames"],
|
||||
["number", 'N', "Add chapter/section numbers to section headings"],
|
||||
]
|
||||
|
||||
optParameters = [
|
||||
["input", "i", 'lore'],
|
||||
["inputext", "e", ".xhtml", "The extension that your Lore input files have"],
|
||||
["docsdir", "d", None],
|
||||
["linkrel", "l", ''],
|
||||
["output", "o", 'html'],
|
||||
["index", "x", None, "The base filename you want to give your index file"],
|
||||
["book", "b", None, "The book file to generate a book from"],
|
||||
["prefixurl", None, "", "The prefix to stick on to relative links; only useful when processing directories"],
|
||||
]
|
||||
|
||||
compData = usage.Completions(
|
||||
extraActions=[usage.CompleteFiles(descr="files", repeat=True)])
|
||||
|
||||
def __init__(self, *args, **kw):
|
||||
usage.Options.__init__(self, *args, **kw)
|
||||
self.config = {}
|
||||
|
||||
def opt_config(self, s):
|
||||
if '=' in s:
|
||||
k, v = s.split('=', 1)
|
||||
self.config[k] = v
|
||||
else:
|
||||
self.config[s] = 1
|
||||
|
||||
def parseArgs(self, *files):
|
||||
self['files'] = files
|
||||
|
||||
|
||||
def getProcessor(input, output, config):
|
||||
plugins = plugin.getPlugins(IProcessor)
|
||||
for plug in plugins:
|
||||
if plug.name == input:
|
||||
module = reflect.namedModule(plug.moduleName)
|
||||
break
|
||||
else:
|
||||
# try treating it as a module name
|
||||
try:
|
||||
module = reflect.namedModule(input)
|
||||
except ImportError:
|
||||
print '%s: no such input: %s' % (sys.argv[0], input)
|
||||
return
|
||||
try:
|
||||
return process.getProcessor(module, output, config)
|
||||
except process.NoProcessorError, e:
|
||||
print "%s: %s" % (sys.argv[0], e)
|
||||
|
||||
|
||||
def getWalker(df, opt):
|
||||
klass = process.Walker
|
||||
if opt['plain']:
|
||||
klass = process.PlainReportingWalker
|
||||
if opt['null']:
|
||||
klass = process.NullReportingWalker
|
||||
return klass(df, opt['inputext'], opt['linkrel'])
|
||||
|
||||
|
||||
def runGivenOptions(opt):
|
||||
"""Do everything but parse the options; useful for testing.
|
||||
Returns a descriptive string if there's an error."""
|
||||
|
||||
book = None
|
||||
if opt['book']:
|
||||
book = htmlbook.Book(opt['book'])
|
||||
|
||||
df = getProcessor(opt['input'], opt['output'], opt.config)
|
||||
if not df:
|
||||
return 'getProcessor() failed'
|
||||
|
||||
walker = getWalker(df, opt)
|
||||
|
||||
if opt['files']:
|
||||
for filename in opt['files']:
|
||||
walker.walked.append(('', filename))
|
||||
elif book:
|
||||
for filename in book.getFiles():
|
||||
walker.walked.append(('', filename))
|
||||
else:
|
||||
walker.walkdir(opt['docsdir'] or '.', opt['prefixurl'])
|
||||
|
||||
if opt['index']:
|
||||
indexFilename = opt['index']
|
||||
elif book:
|
||||
indexFilename = book.getIndexFilename()
|
||||
else:
|
||||
indexFilename = None
|
||||
|
||||
if indexFilename:
|
||||
indexer.setIndexFilename("%s.%s" % (indexFilename, opt['output']))
|
||||
else:
|
||||
indexer.setIndexFilename(None)
|
||||
|
||||
## TODO: get numberSections from book, if any
|
||||
numberer.setNumberSections(opt['number'])
|
||||
|
||||
walker.generate()
|
||||
|
||||
if walker.failures:
|
||||
for (file, errors) in walker.failures:
|
||||
for error in errors:
|
||||
print "%s:%s" % (file, error)
|
||||
return 'Walker failures'
|
||||
|
||||
|
||||
def run():
|
||||
opt = Options()
|
||||
try:
|
||||
opt.parseOptions()
|
||||
except usage.UsageError, errortext:
|
||||
print '%s: %s' % (sys.argv[0], errortext)
|
||||
print '%s: Try --help for usage details.' % sys.argv[0]
|
||||
sys.exit(1)
|
||||
|
||||
result = runGivenOptions(opt)
|
||||
if result:
|
||||
print result
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
run()
|
||||
|
||||
370
Linux/lib/python2.7/site-packages/twisted/lore/slides.py
Normal file
370
Linux/lib/python2.7/site-packages/twisted/lore/slides.py
Normal file
|
|
@ -0,0 +1,370 @@
|
|||
# -*- test-case-name: twisted.lore.test.test_slides -*-
|
||||
# Copyright (c) Twisted Matrix Laboratories.
|
||||
# See LICENSE for details.
|
||||
|
||||
"""
|
||||
Rudimentary slide support for Lore.
|
||||
|
||||
TODO:
|
||||
- Complete mgp output target
|
||||
- syntax highlighting
|
||||
- saner font handling
|
||||
- probably lots more
|
||||
- Add HTML output targets
|
||||
- one slides per page (with navigation links)
|
||||
- all in one page
|
||||
|
||||
Example input file::
|
||||
<html>
|
||||
|
||||
<head><title>Title of talk</title></head>
|
||||
|
||||
<body>
|
||||
<h1>Title of talk</h1>
|
||||
|
||||
<h2>First Slide</h2>
|
||||
|
||||
<ul>
|
||||
<li>Bullet point</li>
|
||||
<li>Look ma, I'm <strong>bold</strong>!</li>
|
||||
<li>... etc ...</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Second Slide</h2>
|
||||
|
||||
<pre class="python">
|
||||
# Sample code sample.
|
||||
print "Hello, World!"
|
||||
</pre>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
"""
|
||||
|
||||
from xml.dom import minidom as dom
|
||||
import os.path, re
|
||||
from cStringIO import StringIO
|
||||
|
||||
from twisted.lore import default
|
||||
from twisted.web import domhelpers
|
||||
# These should be factored out
|
||||
from twisted.lore.latex import BaseLatexSpitter, LatexSpitter, processFile
|
||||
from twisted.lore.latex import getLatexText, HeadingLatexSpitter
|
||||
from twisted.lore.tree import getHeaders, _removeLeadingTrailingBlankLines
|
||||
from twisted.lore.tree import removeH1, fixAPI, fontifyPython
|
||||
from twisted.lore.tree import addPyListings, addHTMLListings, setTitle
|
||||
|
||||
|
||||
hacked_entities = { 'amp': ' &', 'gt': ' >', 'lt': ' <', 'quot': ' "',
|
||||
'copy': ' (c)'}
|
||||
|
||||
entities = { 'amp': '&', 'gt': '>', 'lt': '<', 'quot': '"',
|
||||
'copy': '(c)'}
|
||||
|
||||
|
||||
|
||||
class MagicpointOutput(BaseLatexSpitter):
|
||||
bulletDepth = 0
|
||||
|
||||
def writeNodeData(self, node):
|
||||
buf = StringIO()
|
||||
getLatexText(node, buf.write, entities=hacked_entities)
|
||||
data = buf.getvalue().rstrip().replace('\n', ' ')
|
||||
self.writer(re.sub(' +', ' ', data))
|
||||
|
||||
def visitNode_title(self, node):
|
||||
self.title = domhelpers.getNodeText(node)
|
||||
|
||||
def visitNode_body(self, node):
|
||||
# Adapted from tree.generateToC
|
||||
self.fontStack = [('standard', None)]
|
||||
|
||||
# Title slide
|
||||
self.writer(self.start_h2)
|
||||
self.writer(self.title)
|
||||
self.writer(self.end_h2)
|
||||
|
||||
self.writer('%center\n\n\n\n\n')
|
||||
for authorNode in domhelpers.findElementsWithAttribute(node, 'class', 'author'):
|
||||
getLatexText(authorNode, self.writer, entities=entities)
|
||||
self.writer('\n')
|
||||
|
||||
# Table of contents
|
||||
self.writer(self.start_h2)
|
||||
self.writer(self.title)
|
||||
self.writer(self.end_h2)
|
||||
|
||||
for element in getHeaders(node):
|
||||
level = int(element.tagName[1])-1
|
||||
self.writer(level * '\t')
|
||||
self.writer(domhelpers.getNodeText(element))
|
||||
self.writer('\n')
|
||||
|
||||
self.visitNodeDefault(node)
|
||||
|
||||
def visitNode_div_author(self, node):
|
||||
# Skip this node; it's already been used by visitNode_body
|
||||
pass
|
||||
|
||||
def visitNode_div_pause(self, node):
|
||||
self.writer('%pause\n')
|
||||
|
||||
|
||||
def visitNode_pre(self, node):
|
||||
"""
|
||||
Writes Latex block using the 'typewriter' font when it encounters a
|
||||
I{pre} element.
|
||||
|
||||
@param node: The element to process.
|
||||
@type node: L{xml.dom.minidom.Element}
|
||||
"""
|
||||
# TODO: Syntax highlighting
|
||||
buf = StringIO()
|
||||
getLatexText(node, buf.write, entities=entities)
|
||||
data = buf.getvalue()
|
||||
data = _removeLeadingTrailingBlankLines(data)
|
||||
lines = data.split('\n')
|
||||
self.fontStack.append(('typewriter', 4))
|
||||
self.writer('%' + self.fontName() + '\n')
|
||||
for line in lines:
|
||||
self.writer(' ' + line + '\n')
|
||||
del self.fontStack[-1]
|
||||
self.writer('%' + self.fontName() + '\n')
|
||||
|
||||
|
||||
def visitNode_ul(self, node):
|
||||
if self.bulletDepth > 0:
|
||||
self.writer(self._start_ul)
|
||||
self.bulletDepth += 1
|
||||
self.start_li = self._start_li * self.bulletDepth
|
||||
self.visitNodeDefault(node)
|
||||
self.bulletDepth -= 1
|
||||
self.start_li = self._start_li * self.bulletDepth
|
||||
|
||||
def visitNode_strong(self, node):
|
||||
self.doFont(node, 'bold')
|
||||
|
||||
def visitNode_em(self, node):
|
||||
self.doFont(node, 'italic')
|
||||
|
||||
def visitNode_code(self, node):
|
||||
self.doFont(node, 'typewriter')
|
||||
|
||||
def doFont(self, node, style):
|
||||
self.fontStack.append((style, None))
|
||||
self.writer(' \n%cont, ' + self.fontName() + '\n')
|
||||
self.visitNodeDefault(node)
|
||||
del self.fontStack[-1]
|
||||
self.writer('\n%cont, ' + self.fontName() + '\n')
|
||||
|
||||
def fontName(self):
|
||||
names = [x[0] for x in self.fontStack]
|
||||
if 'typewriter' in names:
|
||||
name = 'typewriter'
|
||||
else:
|
||||
name = ''
|
||||
|
||||
if 'bold' in names:
|
||||
name += 'bold'
|
||||
if 'italic' in names:
|
||||
name += 'italic'
|
||||
|
||||
if name == '':
|
||||
name = 'standard'
|
||||
|
||||
sizes = [x[1] for x in self.fontStack]
|
||||
sizes.reverse()
|
||||
for size in sizes:
|
||||
if size:
|
||||
return 'font "%s", size %d' % (name, size)
|
||||
|
||||
return 'font "%s"' % name
|
||||
|
||||
start_h2 = "%page\n\n"
|
||||
end_h2 = '\n\n\n'
|
||||
|
||||
_start_ul = '\n'
|
||||
|
||||
_start_li = "\t"
|
||||
end_li = "\n"
|
||||
|
||||
|
||||
def convertFile(filename, outputter, template, ext=".mgp"):
|
||||
fout = open(os.path.splitext(filename)[0]+ext, 'w')
|
||||
fout.write(open(template).read())
|
||||
spitter = outputter(fout.write, os.path.dirname(filename), filename)
|
||||
fin = open(filename)
|
||||
processFile(spitter, fin)
|
||||
fin.close()
|
||||
fout.close()
|
||||
|
||||
|
||||
# HTML DOM tree stuff
|
||||
|
||||
def splitIntoSlides(document):
|
||||
body = domhelpers.findNodesNamed(document, 'body')[0]
|
||||
slides = []
|
||||
slide = []
|
||||
title = '(unset)'
|
||||
for child in body.childNodes:
|
||||
if isinstance(child, dom.Element) and child.tagName == 'h2':
|
||||
if slide:
|
||||
slides.append((title, slide))
|
||||
slide = []
|
||||
title = domhelpers.getNodeText(child)
|
||||
else:
|
||||
slide.append(child)
|
||||
slides.append((title, slide))
|
||||
return slides
|
||||
|
||||
def insertPrevNextLinks(slides, filename, ext):
|
||||
for slide in slides:
|
||||
for name, offset in (("previous", -1), ("next", +1)):
|
||||
if (slide.pos > 0 and name == "previous") or \
|
||||
(slide.pos < len(slides)-1 and name == "next"):
|
||||
for node in domhelpers.findElementsWithAttribute(slide.dom, "class", name):
|
||||
if node.tagName == 'a':
|
||||
node.setAttribute('href', '%s-%d%s'
|
||||
% (filename[0], slide.pos+offset, ext))
|
||||
else:
|
||||
text = dom.Text()
|
||||
text.data = slides[slide.pos+offset].title
|
||||
node.appendChild(text)
|
||||
else:
|
||||
for node in domhelpers.findElementsWithAttribute(slide.dom, "class", name):
|
||||
pos = 0
|
||||
for child in node.parentNode.childNodes:
|
||||
if child is node:
|
||||
del node.parentNode.childNodes[pos]
|
||||
break
|
||||
pos += 1
|
||||
|
||||
|
||||
class HTMLSlide:
|
||||
def __init__(self, dom, title, pos):
|
||||
self.dom = dom
|
||||
self.title = title
|
||||
self.pos = pos
|
||||
|
||||
|
||||
def munge(document, template, linkrel, d, fullpath, ext, url, config):
|
||||
# FIXME: This has *way* to much duplicated crap in common with tree.munge
|
||||
#fixRelativeLinks(template, linkrel)
|
||||
removeH1(document)
|
||||
fixAPI(document, url)
|
||||
fontifyPython(document)
|
||||
addPyListings(document, d)
|
||||
addHTMLListings(document, d)
|
||||
#fixLinks(document, ext)
|
||||
#putInToC(template, generateToC(document))
|
||||
template = template.cloneNode(1)
|
||||
|
||||
# Insert the slides into the template
|
||||
slides = []
|
||||
pos = 0
|
||||
for title, slide in splitIntoSlides(document):
|
||||
t = template.cloneNode(1)
|
||||
text = dom.Text()
|
||||
text.data = title
|
||||
setTitle(t, [text])
|
||||
tmplbody = domhelpers.findElementsWithAttribute(t, "class", "body")[0]
|
||||
tmplbody.childNodes = slide
|
||||
tmplbody.setAttribute("class", "content")
|
||||
# FIXME: Next/Prev links
|
||||
# FIXME: Perhaps there should be a "Template" class? (setTitle/setBody
|
||||
# could be methods...)
|
||||
slides.append(HTMLSlide(t, title, pos))
|
||||
pos += 1
|
||||
|
||||
insertPrevNextLinks(slides, os.path.splitext(os.path.basename(fullpath)), ext)
|
||||
|
||||
return slides
|
||||
|
||||
from tree import makeSureDirectoryExists
|
||||
|
||||
def getOutputFileName(originalFileName, outputExtension, index):
|
||||
return os.path.splitext(originalFileName)[0]+'-'+str(index) + outputExtension
|
||||
|
||||
def doFile(filename, linkrel, ext, url, templ, options={}, outfileGenerator=getOutputFileName):
|
||||
from tree import parseFileAndReport
|
||||
doc = parseFileAndReport(filename)
|
||||
slides = munge(doc, templ, linkrel, os.path.dirname(filename), filename, ext, url, options)
|
||||
for slide, index in zip(slides, range(len(slides))):
|
||||
newFilename = outfileGenerator(filename, ext, index)
|
||||
makeSureDirectoryExists(newFilename)
|
||||
f = open(newFilename, 'wb')
|
||||
slide.dom.writexml(f)
|
||||
f.close()
|
||||
|
||||
# Prosper output
|
||||
|
||||
class ProsperSlides(LatexSpitter):
|
||||
firstSlide = 1
|
||||
start_html = '\\documentclass[ps]{prosper}\n'
|
||||
start_body = '\\begin{document}\n'
|
||||
start_div_author = '\\author{'
|
||||
end_div_author = '}'
|
||||
|
||||
def visitNode_h2(self, node):
|
||||
if self.firstSlide:
|
||||
self.firstSlide = 0
|
||||
self.end_body = '\\end{slide}\n\n' + self.end_body
|
||||
else:
|
||||
self.writer('\\end{slide}\n\n')
|
||||
self.writer('\\begin{slide}{')
|
||||
spitter = HeadingLatexSpitter(self.writer, self.currDir, self.filename)
|
||||
spitter.visitNodeDefault(node)
|
||||
self.writer('}')
|
||||
|
||||
def _write_img(self, target):
|
||||
self.writer('\\begin{center}\\includegraphics[%%\nwidth=1.0\n\\textwidth,'
|
||||
'height=1.0\\textheight,\nkeepaspectratio]{%s}\\end{center}\n' % target)
|
||||
|
||||
|
||||
class PagebreakLatex(LatexSpitter):
|
||||
|
||||
everyN = 1
|
||||
currentN = 0
|
||||
seenH2 = 0
|
||||
|
||||
start_html = LatexSpitter.start_html+"\\date{}\n"
|
||||
start_body = '\\begin{document}\n\n'
|
||||
|
||||
def visitNode_h2(self, node):
|
||||
if not self.seenH2:
|
||||
self.currentN = 0
|
||||
self.seenH2 = 1
|
||||
else:
|
||||
self.currentN += 1
|
||||
self.currentN %= self.everyN
|
||||
if not self.currentN:
|
||||
self.writer('\\clearpage\n')
|
||||
level = (int(node.tagName[1])-2)+self.baseLevel
|
||||
self.writer('\n\n\\'+level*'sub'+'section*{')
|
||||
spitter = HeadingLatexSpitter(self.writer, self.currDir, self.filename)
|
||||
spitter.visitNodeDefault(node)
|
||||
self.writer('}\n')
|
||||
|
||||
class TwoPagebreakLatex(PagebreakLatex):
|
||||
|
||||
everyN = 2
|
||||
|
||||
|
||||
class SlidesProcessingFunctionFactory(default.ProcessingFunctionFactory):
|
||||
|
||||
latexSpitters = default.ProcessingFunctionFactory.latexSpitters.copy()
|
||||
latexSpitters['prosper'] = ProsperSlides
|
||||
latexSpitters['page'] = PagebreakLatex
|
||||
latexSpitters['twopage'] = TwoPagebreakLatex
|
||||
|
||||
def getDoFile(self):
|
||||
return doFile
|
||||
|
||||
def generate_mgp(self, d, fileNameGenerator=None):
|
||||
template = d.get('template', 'template.mgp')
|
||||
df = lambda file, linkrel: convertFile(file, MagicpointOutput, template, ext=".mgp")
|
||||
return df
|
||||
|
||||
factory=SlidesProcessingFunctionFactory()
|
||||
24
Linux/lib/python2.7/site-packages/twisted/lore/template.mgp
Normal file
24
Linux/lib/python2.7/site-packages/twisted/lore/template.mgp
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
%%deffont "standard" tfont "Arial.ttf"
|
||||
%%deffont "bold" tfont "Arial_Bold.ttf"
|
||||
%%deffont "italic" tfont "Arial_Italic.ttf"
|
||||
%%deffont "bolditalic" tfont "Arial_Bold_Italic.ttf"
|
||||
%%deffont "typewriter" tfont "Courier_New.ttf"
|
||||
%deffont "standard" xfont "Arial-medium-r"
|
||||
%deffont "bold" xfont "Arial-bold-r"
|
||||
%deffont "italic" xfont "Arial-medium-i"
|
||||
%deffont "bolditalic" xfont "Arial-bold-i"
|
||||
%deffont "typewriter" xfont "andale mono"
|
||||
%%deffont "standard" tfont "tahoma.ttf"
|
||||
%%deffont "thick" tfont "tahomabd.ttf"
|
||||
#%deffont "typewriter" tfont "Andale_Mono.ttf"
|
||||
%default 1 area 90 90, leftfill, size 2, fore "white", back "black", font "bold"
|
||||
%default 2 size 7, vgap 10, prefix " ", center
|
||||
%default 3 size 2, bar "gray70", vgap 10, leftfill
|
||||
%default 4 size 1, fore "white", vgap 30, prefix " ", font "standard"
|
||||
%default 5 size 5
|
||||
%%tab 1 size 5, vgap 40, prefix " ", icon box "green" 50
|
||||
%%tab 2 size 4, vgap 40, prefix " ", icon arc "yellow" 50
|
||||
%%tab 3 size 3, vgap 40, prefix " ", icon delta3 "white" 40
|
||||
%tab 1 size 5, vgap 50, prefix " ", icon box "green" 50
|
||||
%tab 2 size 5, vgap 50, prefix " ", icon arc "yellow" 50
|
||||
%tab 3 size 4, vgap 50, prefix " ", icon delta3 "white" 40
|
||||
|
|
@ -0,0 +1 @@
|
|||
"lore tests"
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
language of programming: <a href="lore_index_test.html#index02">1.3</a><br />
|
||||
programming language: <a href="lore_index_test.html#index01">1.2</a><br />
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
aahz: <a href="lore_index_test2.html#index03">link</a>
|
||||
aahz2: <a href="lore_index_test2.html#index02">link</a>
|
||||
language of programming: <a href="lore_index_test.html#index02">link</a>
|
||||
<a href="lore_index_test2.html#index01">link</a>
|
||||
programming language: <a href="lore_index_test.html#index01">link</a>
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
language of programming: <a href="lore_index_test.html#index02">link</a><br />
|
||||
programming language: <a href="lore_index_test.html#index01">link</a><br />
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>The way of the program</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<h1>The way of the program</h1>
|
||||
|
||||
<p>The first paragraph.</p>
|
||||
|
||||
|
||||
<h2>The Python programming language</h2>
|
||||
<span class="index" value="programming language" />
|
||||
<span class="index" value="language of programming" />
|
||||
|
||||
<p>The second paragraph.</p>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>The second page to index</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<h1>The second page to index</h1>
|
||||
|
||||
<p>The first paragraph of the second page.</p>
|
||||
|
||||
|
||||
<h2>The Jython programming language</h2>
|
||||
<span class="index" value="language of programming" />
|
||||
<span class="index" value="aahz2" />
|
||||
<span class="index" value="aahz" />
|
||||
|
||||
<p>The second paragraph of the second page.</p>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><title>Twisted Documentation: 1. The way of the program</title><link href="resources/stylesheet.css" type="text/css" rel="stylesheet" /></head><body bgcolor="white"><h1 class="title">1. The way of the program</h1><div class="toc"><ol><li><a href="#auto0">The Python programming language</a></li><li><a href="#auto1">Section The Second</a></li><li><a href="#auto2">Section The Third</a></li></ol></div><div class="content"><span></span><p>The first paragraph.</p><h2>1.1 The Python programming language<a name="auto0"></a></h2><a name="index01"></a><a name="index02"></a><p>The second paragraph.</p><h2>1.2 Section The Second<a name="auto1"></a></h2><p>The second section.</p><h2>1.3 Section The Third<a name="auto2"></a></h2><p>The Third section.</p></div><p><a href="theIndexFile.html">Index</a></p></body></html>
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><title>Twisted Documentation: 2. The second page to index</title><link href="resources/stylesheet.css" type="text/css" rel="stylesheet" /></head><body bgcolor="white"><h1 class="title">2. The second page to index</h1><div class="toc"><ol><li><a href="#auto0">The Jython programming language</a></li><li><a href="#auto1">Second Section</a></li><li><a href="#auto2">Third Section of Second Page</a></li></ol></div><div class="content"><span></span><p>The first paragraph of the second page.</p><h2>2.1 The Jython programming language<a name="auto0"></a></h2><a name="index01"></a><a name="index02"></a><a name="index03"></a><p>The second paragraph of the second page.</p><h2>2.2 Second Section<a name="auto1"></a></h2><p>The second section of the second page.</p><h2>2.3 Third Section of Second Page<a name="auto2"></a></h2><p>The Third section.</p></div><p><a href="theIndexFile.html">Index</a></p></body></html>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>My Test Lore Input</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>My Test Lore Input</h1>
|
||||
<p>A Body.</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>My Test Lore Input</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>My Test Lore Input</h1>
|
||||
<p>A Body.</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>My Test Lore Input</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>My Test Lore Input</h1>
|
||||
<p>A Body.</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
|
||||
<head><title>Twisted Documentation: </title></head>
|
||||
<body bgcolor="white">
|
||||
<h1 class="title" />
|
||||
<div class="body" />
|
||||
<span class="index-link">Index</span>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
# Copyright (c) Twisted Matrix Laboratories.
|
||||
# See LICENSE for details.
|
||||
|
||||
"""
|
||||
Tests for L{twisted.lore.docbook}.
|
||||
"""
|
||||
|
||||
from xml.dom.minidom import Element, Text
|
||||
|
||||
from twisted.trial.unittest import TestCase
|
||||
from twisted.lore.docbook import DocbookSpitter
|
||||
|
||||
|
||||
class DocbookSpitterTests(TestCase):
|
||||
"""
|
||||
Tests for L{twisted.lore.docbook.DocbookSpitter}.
|
||||
"""
|
||||
def test_li(self):
|
||||
"""
|
||||
L{DocbookSpitter} wraps any non-I{p} elements found intside any I{li}
|
||||
elements with I{p} elements.
|
||||
"""
|
||||
output = []
|
||||
spitter = DocbookSpitter(output.append)
|
||||
|
||||
li = Element('li')
|
||||
li.appendChild(Element('p'))
|
||||
text = Text()
|
||||
text.data = 'foo bar'
|
||||
li.appendChild(text)
|
||||
|
||||
spitter.visitNode(li)
|
||||
self.assertEqual(
|
||||
''.join(output),
|
||||
'<listitem><para></para><para>foo bar</para></listitem>')
|
||||
|
|
@ -0,0 +1,180 @@
|
|||
# Copyright (c) Twisted Matrix Laboratories.
|
||||
# See LICENSE for details.
|
||||
|
||||
"""
|
||||
Tests for L{twisted.lore.latex}.
|
||||
"""
|
||||
|
||||
import os.path
|
||||
from xml.dom.minidom import Comment, Element, Text
|
||||
|
||||
from twisted.python.filepath import FilePath
|
||||
from twisted.trial.unittest import TestCase
|
||||
from twisted.lore.latex import LatexSpitter, getLatexText
|
||||
|
||||
|
||||
class LatexHelperTests(TestCase):
|
||||
"""
|
||||
Tests for free functions in L{twisted.lore.latex}.
|
||||
"""
|
||||
def test_getLatexText(self):
|
||||
"""
|
||||
L{getLatexText} calls the writer function with all of the text at or
|
||||
beneath the given node. Non-ASCII characters are encoded using
|
||||
UTF-8.
|
||||
"""
|
||||
node = Element('foo')
|
||||
text = Text()
|
||||
text.data = u"foo \N{SNOWMAN}"
|
||||
node.appendChild(text)
|
||||
result = []
|
||||
getLatexText(node, result.append)
|
||||
self.assertEqual(result, [u"foo \N{SNOWMAN}".encode('utf-8')])
|
||||
|
||||
|
||||
|
||||
class LatexSpitterTests(TestCase):
|
||||
"""
|
||||
Tests for L{LatexSpitter}.
|
||||
"""
|
||||
def setUp(self):
|
||||
self.filename = self.mktemp()
|
||||
self.output = []
|
||||
self.spitter = LatexSpitter(self.output.append, filename=self.filename)
|
||||
|
||||
|
||||
def test_head(self):
|
||||
"""
|
||||
L{LatexSpitter.visitNode} writes out author information for each
|
||||
I{link} element with a I{rel} attribute set to I{author}.
|
||||
"""
|
||||
head = Element('head')
|
||||
first = Element('link')
|
||||
first.setAttribute('rel', 'author')
|
||||
first.setAttribute('title', 'alice')
|
||||
second = Element('link')
|
||||
second.setAttribute('rel', 'author')
|
||||
second.setAttribute('href', 'http://example.com/bob')
|
||||
third = Element('link')
|
||||
third.setAttribute('rel', 'author')
|
||||
third.setAttribute('href', 'mailto:carol@example.com')
|
||||
head.appendChild(first)
|
||||
head.appendChild(second)
|
||||
head.appendChild(third)
|
||||
|
||||
self.spitter.visitNode(head)
|
||||
|
||||
self.assertEqual(
|
||||
''.join(self.output),
|
||||
'\\author{alice \\and $<$http://example.com/bob$>$ \\and $<$carol@example.com$>$}')
|
||||
|
||||
|
||||
def test_pre(self):
|
||||
"""
|
||||
L{LatexSpitter.visitNode} emits a verbatim block when it encounters a
|
||||
I{pre} element.
|
||||
"""
|
||||
pre = Element('pre')
|
||||
text = Text()
|
||||
text.data = u"\n\n\nfoo\nbar\n\n\n"
|
||||
pre.appendChild(text)
|
||||
|
||||
self.spitter.visitNode(pre)
|
||||
self.assertEqual(
|
||||
''.join(self.output),
|
||||
'\\begin{verbatim}\nfoo\nbar\n\\end{verbatim}\n')
|
||||
|
||||
|
||||
def test_code(self):
|
||||
"""
|
||||
L{LatexSpitter.visitNode} emits a C{texttt} block when it encounters a
|
||||
I{code} element and inserts optional linebreaks at sensible places in
|
||||
absolute python names.
|
||||
"""
|
||||
code = Element('code')
|
||||
text = Text()
|
||||
text.data = u"print this: twisted.lore.latex"
|
||||
code.appendChild(text)
|
||||
|
||||
self.spitter.visitNode(code)
|
||||
self.assertEqual(
|
||||
''.join(self.output),
|
||||
"\\texttt{print this: twisted.\\linebreak[1]lore.\\"
|
||||
"linebreak[1]latex}")
|
||||
|
||||
|
||||
def test_skipComments(self):
|
||||
"""
|
||||
L{LatexSpitter.visitNode} writes nothing to its output stream for
|
||||
comments.
|
||||
"""
|
||||
self.spitter.visitNode(Comment('foo'))
|
||||
self.assertNotIn('foo', ''.join(self.output))
|
||||
|
||||
|
||||
def test_anchorListing(self):
|
||||
"""
|
||||
L{LatexSpitter.visitNode} emits a verbatim block when it encounters a
|
||||
code listing (represented by an I{a} element with a I{listing} class).
|
||||
"""
|
||||
path = FilePath(self.mktemp())
|
||||
path.setContent('\n\nfoo\nbar\n\n\n')
|
||||
listing = Element('a')
|
||||
listing.setAttribute('class', 'listing')
|
||||
listing.setAttribute('href', path.path)
|
||||
self.spitter.visitNode(listing)
|
||||
self.assertEqual(
|
||||
''.join(self.output),
|
||||
"\\begin{verbatim}\n"
|
||||
"foo\n"
|
||||
"bar\n"
|
||||
"\\end{verbatim}\\parbox[b]{\\linewidth}{\\begin{center} --- "
|
||||
"\\begin{em}temp\\end{em}\\end{center}}")
|
||||
|
||||
|
||||
def test_anchorListingSkipLines(self):
|
||||
"""
|
||||
When passed an I{a} element with a I{listing} class and an I{skipLines}
|
||||
attribute, L{LatexSpitter.visitNode} emits a verbatim block which skips
|
||||
the indicated number of lines from the beginning of the source listing.
|
||||
"""
|
||||
path = FilePath(self.mktemp())
|
||||
path.setContent('foo\nbar\n')
|
||||
listing = Element('a')
|
||||
listing.setAttribute('class', 'listing')
|
||||
listing.setAttribute('skipLines', '1')
|
||||
listing.setAttribute('href', path.path)
|
||||
self.spitter.visitNode(listing)
|
||||
self.assertEqual(
|
||||
''.join(self.output),
|
||||
"\\begin{verbatim}\n"
|
||||
"bar\n"
|
||||
"\\end{verbatim}\\parbox[b]{\\linewidth}{\\begin{center} --- "
|
||||
"\\begin{em}temp\\end{em}\\end{center}}")
|
||||
|
||||
|
||||
def test_anchorRef(self):
|
||||
"""
|
||||
L{LatexSpitter.visitNode} emits a footnote when it encounters an I{a}
|
||||
element with an I{href} attribute with a network scheme.
|
||||
"""
|
||||
listing = Element('a')
|
||||
listing.setAttribute('href', 'http://example.com/foo')
|
||||
self.spitter.visitNode(listing)
|
||||
self.assertEqual(
|
||||
''.join(self.output),
|
||||
"\\footnote{http://example.com/foo}")
|
||||
|
||||
|
||||
def test_anchorName(self):
|
||||
"""
|
||||
When passed an I{a} element with a I{name} attribute,
|
||||
L{LatexSpitter.visitNode} emits a label.
|
||||
"""
|
||||
listing = Element('a')
|
||||
listing.setAttribute('name', 'foo')
|
||||
self.spitter.visitNode(listing)
|
||||
self.assertEqual(
|
||||
''.join(self.output),
|
||||
"\\label{%sHASHfoo}" % (
|
||||
os.path.abspath(self.filename).replace('\\', '/'),))
|
||||
153
Linux/lib/python2.7/site-packages/twisted/lore/test/test_lint.py
Normal file
153
Linux/lib/python2.7/site-packages/twisted/lore/test/test_lint.py
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
# Copyright (c) Twisted Matrix Laboratories.
|
||||
# See LICENSE for details.
|
||||
|
||||
"""
|
||||
Tests for L{twisted.lore.lint}.
|
||||
"""
|
||||
|
||||
import sys
|
||||
from xml.dom import minidom
|
||||
from cStringIO import StringIO
|
||||
|
||||
from twisted.trial.unittest import TestCase
|
||||
from twisted.lore.lint import getDefaultChecker
|
||||
from twisted.lore.process import ProcessingFailure
|
||||
|
||||
|
||||
|
||||
class DeprecationTestCase(TestCase):
|
||||
"""
|
||||
Deprecations in L{twisted.lore.lint}.
|
||||
"""
|
||||
def test_parserErrors(self):
|
||||
"""
|
||||
L{lint.parserErrors} is deprecated.
|
||||
"""
|
||||
from twisted.lore.lint import parserErrors
|
||||
warnings = self.flushWarnings(
|
||||
offendingFunctions=[self.test_parserErrors])
|
||||
self.assertEqual(DeprecationWarning, warnings[0]['category'])
|
||||
self.assertEqual(
|
||||
"twisted.lore.lint.parserErrors was deprecated in Twisted 13.1.0: "
|
||||
"parserErrors is deprecated",
|
||||
warnings[0]['message'])
|
||||
self.assertEqual(1, len(warnings))
|
||||
self.assertEqual(parserErrors, (SyntaxError,))
|
||||
|
||||
|
||||
|
||||
class DefaultTagCheckerTests(TestCase):
|
||||
"""
|
||||
Tests for L{twisted.lore.lint.DefaultTagChecker}.
|
||||
"""
|
||||
def test_quote(self):
|
||||
"""
|
||||
If a non-comment node contains a quote (C{'"'}), the checker returned
|
||||
by L{getDefaultChecker} reports an error and raises
|
||||
L{ProcessingFailure}.
|
||||
"""
|
||||
documentSource = (
|
||||
'<html>'
|
||||
'<head><title>foo</title></head>'
|
||||
'<body><h1>foo</h1><div>"</div></body>'
|
||||
'</html>')
|
||||
document = minidom.parseString(documentSource)
|
||||
filename = self.mktemp()
|
||||
checker = getDefaultChecker()
|
||||
|
||||
output = StringIO()
|
||||
patch = self.patch(sys, 'stdout', output)
|
||||
self.assertRaises(ProcessingFailure, checker.check, document, filename)
|
||||
patch.restore()
|
||||
|
||||
self.assertIn("contains quote", output.getvalue())
|
||||
|
||||
|
||||
def test_quoteComment(self):
|
||||
"""
|
||||
If a comment node contains a quote (C{'"'}), the checker returned by
|
||||
L{getDefaultChecker} does not report an error.
|
||||
"""
|
||||
documentSource = (
|
||||
'<html>'
|
||||
'<head><title>foo</title></head>'
|
||||
'<body><h1>foo</h1><!-- " --></body>'
|
||||
'</html>')
|
||||
document = minidom.parseString(documentSource)
|
||||
filename = self.mktemp()
|
||||
checker = getDefaultChecker()
|
||||
|
||||
output = StringIO()
|
||||
patch = self.patch(sys, 'stdout', output)
|
||||
checker.check(document, filename)
|
||||
patch.restore()
|
||||
|
||||
self.assertEqual(output.getvalue(), "")
|
||||
|
||||
|
||||
def test_aNode(self):
|
||||
"""
|
||||
If there is an <a> tag in the document, the checker returned by
|
||||
L{getDefaultChecker} does not report an error.
|
||||
"""
|
||||
documentSource = (
|
||||
'<html>'
|
||||
'<head><title>foo</title></head>'
|
||||
'<body><h1>foo</h1><a>A link.</a></body>'
|
||||
'</html>')
|
||||
|
||||
self.assertEqual(self._lintCheck(True, documentSource), "")
|
||||
|
||||
|
||||
def test_textMatchesRef(self):
|
||||
"""
|
||||
If an I{a} node has a link with a scheme as its contained text, a
|
||||
warning is emitted if that link does not match the value of the
|
||||
I{href} attribute.
|
||||
"""
|
||||
documentSource = (
|
||||
'<html>'
|
||||
'<head><title>foo</title></head>'
|
||||
'<body><h1>foo</h1>'
|
||||
'<a href="http://bar/baz">%s</a>'
|
||||
'</body>'
|
||||
'</html>')
|
||||
self.assertEqual(
|
||||
self._lintCheck(True, documentSource % ("http://bar/baz",)), "")
|
||||
self.assertIn(
|
||||
"link text does not match href",
|
||||
self._lintCheck(False, documentSource % ("http://bar/quux",)))
|
||||
|
||||
|
||||
def _lintCheck(self, expectSuccess, source):
|
||||
"""
|
||||
Lint the given document source and return the output.
|
||||
|
||||
@param expectSuccess: A flag indicating whether linting is expected
|
||||
to succeed or not.
|
||||
|
||||
@param source: The document source to lint.
|
||||
|
||||
@return: A C{str} of the output of linting.
|
||||
"""
|
||||
document = minidom.parseString(source)
|
||||
filename = self.mktemp()
|
||||
checker = getDefaultChecker()
|
||||
|
||||
output = StringIO()
|
||||
patch = self.patch(sys, 'stdout', output)
|
||||
try:
|
||||
try:
|
||||
checker.check(document, filename)
|
||||
finally:
|
||||
patch.restore()
|
||||
except ProcessingFailure:
|
||||
if expectSuccess:
|
||||
raise
|
||||
else:
|
||||
if not expectSuccess:
|
||||
self.fail(
|
||||
"Expected checker to fail, but it did not. "
|
||||
"Output was: %r" % (output.getvalue(),))
|
||||
|
||||
return output.getvalue()
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
# Copyright (c) Twisted Matrix Laboratories.
|
||||
# See LICENSE for details.
|
||||
|
||||
"""
|
||||
Tests for L{twisted.lore.lmath}.
|
||||
"""
|
||||
|
||||
from xml.dom.minidom import Element, Text
|
||||
|
||||
from twisted.trial.unittest import TestCase
|
||||
from twisted.python.filepath import FilePath
|
||||
from twisted.lore.scripts.lore import IProcessor
|
||||
|
||||
from twisted.plugin import getPlugins
|
||||
|
||||
from twisted.lore.lmath import formulaeToImages
|
||||
|
||||
|
||||
class PluginTests(TestCase):
|
||||
"""
|
||||
Tests for the plugin which lets L{twisted.lore.lmath} be used from the lore
|
||||
command line tool.
|
||||
"""
|
||||
def test_discoverable(self):
|
||||
"""
|
||||
The plugin for L{twisted.lore.lmath} can be discovered by querying for
|
||||
L{IProcessor} plugins.
|
||||
"""
|
||||
plugins = getPlugins(IProcessor)
|
||||
lmath = [p for p in plugins if p.name == "mlore"]
|
||||
self.assertEqual(len(lmath), 1, "Did not find math lore plugin: %r" % (lmath,))
|
||||
|
||||
|
||||
|
||||
class FormulaeTests(TestCase):
|
||||
"""
|
||||
Tests for L{formulaeToImages}.
|
||||
"""
|
||||
def test_insertImages(self):
|
||||
"""
|
||||
L{formulaeToImages} replaces any elements with the I{latexformula}
|
||||
class with I{img} elements which refer to external images generated
|
||||
based on the latex in the original elements.
|
||||
"""
|
||||
parent = Element('div')
|
||||
base = FilePath(self.mktemp())
|
||||
base.makedirs()
|
||||
|
||||
macros = Element('span')
|
||||
macros.setAttribute('class', 'latexmacros')
|
||||
text = Text()
|
||||
text.data = 'foo'
|
||||
macros.appendChild(text)
|
||||
parent.appendChild(macros)
|
||||
|
||||
formula = Element('span')
|
||||
formula.setAttribute('class', 'latexformula')
|
||||
text = Text()
|
||||
text.data = 'bar'
|
||||
formula.appendChild(text)
|
||||
parent.appendChild(formula)
|
||||
|
||||
# Avoid actually executing the commands to generate images from the
|
||||
# latex. It might be nice to have some assertions about what commands
|
||||
# are executed, or perhaps even execute them and make sure an image
|
||||
# file is created, but that is a task for another day.
|
||||
commands = []
|
||||
formulaeToImages(parent, base.path, _system=commands.append)
|
||||
|
||||
self.assertEqual(
|
||||
parent.toxml(),
|
||||
'<div><span><br/><img src="latexformula0.png"/><br/></span></div>')
|
||||
1219
Linux/lib/python2.7/site-packages/twisted/lore/test/test_lore.py
Normal file
1219
Linux/lib/python2.7/site-packages/twisted/lore/test/test_lore.py
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,169 @@
|
|||
# Copyright (c) Twisted Matrix Laboratories.
|
||||
# See LICENSE for details.
|
||||
|
||||
|
||||
"""
|
||||
Tests for L{twisted.lore.man2lore}.
|
||||
"""
|
||||
|
||||
from StringIO import StringIO
|
||||
|
||||
from twisted.trial.unittest import TestCase
|
||||
|
||||
from twisted.lore.man2lore import ManConverter
|
||||
|
||||
|
||||
_TRANSITIONAL_XHTML_DTD = ("""\
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
""")
|
||||
|
||||
|
||||
class ManConverterTestCase(TestCase):
|
||||
"""
|
||||
Tests for L{ManConverter}.
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Build instance variables useful for tests.
|
||||
|
||||
@ivar converter: a L{ManConverter} to be used during tests.
|
||||
"""
|
||||
self.converter = ManConverter()
|
||||
|
||||
|
||||
def assertConvert(self, inputLines, expectedOutput):
|
||||
"""
|
||||
Helper method to check conversion from a man page to a Lore output.
|
||||
|
||||
@param inputLines: lines of the manpages.
|
||||
@type inputLines: C{list}
|
||||
|
||||
@param expectedOutput: expected Lore content.
|
||||
@type expectedOutput: C{str}
|
||||
"""
|
||||
inputFile = StringIO()
|
||||
for line in inputLines:
|
||||
inputFile.write(line + '\n')
|
||||
inputFile.seek(0)
|
||||
outputFile = StringIO()
|
||||
self.converter.convert(inputFile, outputFile)
|
||||
self.assertEqual(
|
||||
outputFile.getvalue(), _TRANSITIONAL_XHTML_DTD + expectedOutput)
|
||||
|
||||
|
||||
def test_convert(self):
|
||||
"""
|
||||
Test convert on a minimal example.
|
||||
"""
|
||||
inputLines = ['.TH BAR "1" "Oct 2007" "" ""', "Foo\n"]
|
||||
output = ("<html><head>\n<title>BAR.1</title></head>\n<body>\n\n"
|
||||
"<h1>BAR.1</h1>\n\n<p>Foo\n\n</p>\n\n</body>\n</html>\n")
|
||||
self.assertConvert(inputLines, output)
|
||||
|
||||
|
||||
def test_TP(self):
|
||||
"""
|
||||
Test C{TP} parsing.
|
||||
"""
|
||||
inputLines = ['.TH BAR "1" "Oct 2007" "" ""',
|
||||
".SH HEADER",
|
||||
".TP",
|
||||
"\\fB-o\\fR, \\fB--option\\fR",
|
||||
"An option"]
|
||||
output = ("<html><head>\n<title>BAR.1</title></head>\n<body>\n\n"
|
||||
"<h1>BAR.1</h1>\n\n<h2>HEADER</h2>\n\n<dl><dt>"
|
||||
"<strong>-o</strong>, <strong>--option</strong>\n</dt>"
|
||||
"<dd>An option\n</dd>\n\n</dl>\n\n</body>\n</html>\n")
|
||||
self.assertConvert(inputLines, output)
|
||||
|
||||
|
||||
def test_TPMultipleOptions(self):
|
||||
"""
|
||||
Try to parse multiple C{TP} fields.
|
||||
"""
|
||||
inputLines = ['.TH BAR "1" "Oct 2007" "" ""',
|
||||
".SH HEADER",
|
||||
".TP",
|
||||
"\\fB-o\\fR, \\fB--option\\fR",
|
||||
"An option",
|
||||
".TP",
|
||||
"\\fB-n\\fR, \\fB--another\\fR",
|
||||
"Another option",
|
||||
]
|
||||
output = ("<html><head>\n<title>BAR.1</title></head>\n<body>\n\n"
|
||||
"<h1>BAR.1</h1>\n\n<h2>HEADER</h2>\n\n<dl><dt>"
|
||||
"<strong>-o</strong>, <strong>--option</strong>\n</dt>"
|
||||
"<dd>An option\n</dd>\n\n<dt>"
|
||||
"<strong>-n</strong>, <strong>--another</strong>\n</dt>"
|
||||
"<dd>Another option\n</dd>\n\n</dl>\n\n</body>\n</html>\n")
|
||||
self.assertConvert(inputLines, output)
|
||||
|
||||
|
||||
def test_TPMultiLineOptions(self):
|
||||
"""
|
||||
Try to parse multiple C{TP} fields, with options text on several lines.
|
||||
"""
|
||||
inputLines = ['.TH BAR "1" "Oct 2007" "" ""',
|
||||
".SH HEADER",
|
||||
".TP",
|
||||
"\\fB-o\\fR, \\fB--option\\fR",
|
||||
"An option",
|
||||
"on two lines",
|
||||
".TP",
|
||||
"\\fB-n\\fR, \\fB--another\\fR",
|
||||
"Another option",
|
||||
"on two lines",
|
||||
]
|
||||
output = ("<html><head>\n<title>BAR.1</title></head>\n<body>\n\n"
|
||||
"<h1>BAR.1</h1>\n\n<h2>HEADER</h2>\n\n<dl><dt>"
|
||||
"<strong>-o</strong>, <strong>--option</strong>\n</dt>"
|
||||
"<dd>An option\non two lines\n</dd>\n\n"
|
||||
"<dt><strong>-n</strong>, <strong>--another</strong>\n</dt>"
|
||||
"<dd>Another option\non two lines\n</dd>\n\n</dl>\n\n"
|
||||
"</body>\n</html>\n")
|
||||
self.assertConvert(inputLines, output)
|
||||
|
||||
|
||||
def test_ITLegacyManagement(self):
|
||||
"""
|
||||
Test management of BL/IT/EL used in some man pages.
|
||||
"""
|
||||
inputLines = ['.TH BAR "1" "Oct 2007" "" ""',
|
||||
".SH HEADER",
|
||||
".BL",
|
||||
".IT An option",
|
||||
"on two lines",
|
||||
".IT",
|
||||
"Another option",
|
||||
"on two lines",
|
||||
".EL"
|
||||
]
|
||||
output = ("<html><head>\n<title>BAR.1</title></head>\n<body>\n\n"
|
||||
"<h1>BAR.1</h1>\n\n<h2>HEADER</h2>\n\n<dl>"
|
||||
"<dt>on two lines\n</dt><dd>Another option\non two lines\n"
|
||||
"</dd></dl>\n\n</body>\n</html>\n")
|
||||
self.assertConvert(inputLines, output)
|
||||
|
||||
|
||||
def test_interactiveCommand(self):
|
||||
"""
|
||||
Test management of interactive command tag.
|
||||
"""
|
||||
inputLines = ['.TH BAR "1" "Oct 2007" "" ""',
|
||||
".SH HEADER",
|
||||
".BL",
|
||||
".IT IC foo AR bar",
|
||||
"option 1",
|
||||
".IT IC egg AR spam OP AR stuff",
|
||||
"option 2",
|
||||
".EL"
|
||||
]
|
||||
output = ("<html><head>\n<title>BAR.1</title></head>\n<body>\n\n"
|
||||
"<h1>BAR.1</h1>\n\n<h2>HEADER</h2>\n\n<dl>"
|
||||
"<dt>foo <u>bar</u></dt><dd>option 1\n</dd><dt>egg "
|
||||
"<u>spam</u> [<u>stuff</u>]</dt><dd>option 2\n</dd></dl>"
|
||||
"\n\n</body>\n</html>\n")
|
||||
self.assertConvert(inputLines, output)
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
# Copyright (c) Twisted Matrix Laboratories.
|
||||
# See LICENSE for details.
|
||||
|
||||
"""
|
||||
Tests for the command-line interface to lore.
|
||||
"""
|
||||
|
||||
from twisted.trial.unittest import TestCase
|
||||
from twisted.scripts.test.test_scripts import ScriptTestsMixin
|
||||
from twisted.python.test.test_shellcomp import ZshScriptTestMixin
|
||||
|
||||
|
||||
|
||||
class ScriptTests(TestCase, ScriptTestsMixin):
|
||||
"""
|
||||
Tests for all one of lore's scripts.
|
||||
"""
|
||||
def test_lore(self):
|
||||
self.scriptTest("lore/lore")
|
||||
|
||||
|
||||
|
||||
class ZshIntegrationTestCase(TestCase, ZshScriptTestMixin):
|
||||
"""
|
||||
Test that zsh completion functions are generated without error
|
||||
"""
|
||||
generateFor = [('lore', 'twisted.lore.scripts.lore.Options')]
|
||||
|
|
@ -0,0 +1,153 @@
|
|||
# Copyright (c) Twisted Matrix Laboratories.
|
||||
# See LICENSE for details.
|
||||
|
||||
"""
|
||||
Tests for L{twisted.lore.slides}.
|
||||
"""
|
||||
|
||||
from xml.dom.minidom import Element, Text
|
||||
|
||||
from twisted.trial.unittest import TestCase
|
||||
from twisted.lore.slides import (
|
||||
HTMLSlide, splitIntoSlides, insertPrevNextLinks, MagicpointOutput)
|
||||
|
||||
|
||||
class SlidesTests(TestCase):
|
||||
"""
|
||||
Tests for functions in L{twisted.lore.slides}.
|
||||
"""
|
||||
def test_splitIntoSlides(self):
|
||||
"""
|
||||
L{splitIntoSlides} accepts a document and returns a list of two-tuples,
|
||||
each element of which contains the title of a slide taken from an I{h2}
|
||||
element and the body of that slide.
|
||||
"""
|
||||
parent = Element('html')
|
||||
body = Element('body')
|
||||
parent.appendChild(body)
|
||||
|
||||
first = Element('h2')
|
||||
text = Text()
|
||||
text.data = 'first slide'
|
||||
first.appendChild(text)
|
||||
body.appendChild(first)
|
||||
body.appendChild(Element('div'))
|
||||
body.appendChild(Element('span'))
|
||||
|
||||
second = Element('h2')
|
||||
text = Text()
|
||||
text.data = 'second slide'
|
||||
second.appendChild(text)
|
||||
body.appendChild(second)
|
||||
body.appendChild(Element('p'))
|
||||
body.appendChild(Element('br'))
|
||||
|
||||
slides = splitIntoSlides(parent)
|
||||
|
||||
self.assertEqual(slides[0][0], 'first slide')
|
||||
firstContent = slides[0][1]
|
||||
self.assertEqual(firstContent[0].tagName, 'div')
|
||||
self.assertEqual(firstContent[1].tagName, 'span')
|
||||
self.assertEqual(len(firstContent), 2)
|
||||
|
||||
self.assertEqual(slides[1][0], 'second slide')
|
||||
secondContent = slides[1][1]
|
||||
self.assertEqual(secondContent[0].tagName, 'p')
|
||||
self.assertEqual(secondContent[1].tagName, 'br')
|
||||
self.assertEqual(len(secondContent), 2)
|
||||
|
||||
self.assertEqual(len(slides), 2)
|
||||
|
||||
|
||||
def test_insertPrevNextText(self):
|
||||
"""
|
||||
L{insertPrevNextLinks} appends a text node with the title of the
|
||||
previous slide to each node with a I{previous} class and the title of
|
||||
the next slide to each node with a I{next} class.
|
||||
"""
|
||||
next = Element('span')
|
||||
next.setAttribute('class', 'next')
|
||||
container = Element('div')
|
||||
container.appendChild(next)
|
||||
slideWithNext = HTMLSlide(container, 'first', 0)
|
||||
|
||||
previous = Element('span')
|
||||
previous.setAttribute('class', 'previous')
|
||||
container = Element('div')
|
||||
container.appendChild(previous)
|
||||
slideWithPrevious = HTMLSlide(container, 'second', 1)
|
||||
|
||||
insertPrevNextLinks(
|
||||
[slideWithNext, slideWithPrevious], None, None)
|
||||
|
||||
self.assertEqual(
|
||||
next.toxml(), '<span class="next">second</span>')
|
||||
self.assertEqual(
|
||||
previous.toxml(), '<span class="previous">first</span>')
|
||||
|
||||
|
||||
|
||||
class MagicpointOutputTests(TestCase):
|
||||
"""
|
||||
Tests for L{lore.slides.MagicpointOutput}.
|
||||
"""
|
||||
def setUp(self):
|
||||
self.filename = self.mktemp()
|
||||
self.output = []
|
||||
self.spitter = MagicpointOutput(self.output.append,
|
||||
filename=self.filename)
|
||||
|
||||
self.parent = Element('html')
|
||||
title = Element('title')
|
||||
text = Text()
|
||||
text.data = "My Title"
|
||||
title.appendChild(text)
|
||||
self.body = Element('body')
|
||||
self.parent.appendChild(title)
|
||||
self.parent.appendChild(self.body)
|
||||
|
||||
|
||||
def test_body(self):
|
||||
"""
|
||||
L{MagicpointOutput.visitNode} emits a verbatim block when it encounters
|
||||
a I{body} element.
|
||||
"""
|
||||
link = Element('link')
|
||||
link.setAttribute('class', 'author')
|
||||
text = Text()
|
||||
text.data = u"John Doe"
|
||||
link.appendChild(text)
|
||||
self.body.appendChild(link)
|
||||
|
||||
head = Element('h2')
|
||||
first = Text()
|
||||
first.data = u'My Header'
|
||||
head.appendChild(first)
|
||||
self.body.appendChild(head)
|
||||
|
||||
self.spitter.visitNode(self.parent)
|
||||
self.assertEqual(
|
||||
''.join(self.output),
|
||||
'%page\n\nMy Title\n\n\n%center\n\n\n\n\nJohn Doe\n%page\n\n'
|
||||
'My Title\n\n\n\tMy Header\nJohn Doe%page\n\nMy Header\n\n\n')
|
||||
|
||||
|
||||
def test_pre(self):
|
||||
"""
|
||||
L{MagicpointOutput.visitNode} emits the 'typewriter' font when it
|
||||
encounters a I{pre} element.
|
||||
"""
|
||||
pre = Element('pre')
|
||||
text = Text()
|
||||
text.data = u"\nfirst line\nsecond line\n\n"
|
||||
pre.appendChild(text)
|
||||
self.body.appendChild(pre)
|
||||
|
||||
self.spitter.visitNode(self.parent)
|
||||
self.assertEqual(
|
||||
''.join(self.output),
|
||||
'%page\n\nMy Title\n\n\n%center\n\n\n\n\n%page\n\nMy Title\n\n\n'
|
||||
'%font "typewriter", size 4\n first line\n second line\n \n'
|
||||
'%font "standard"\n')
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
# Copyright (c) Twisted Matrix Laboratories.
|
||||
# See LICENSE for details.
|
||||
|
||||
"""
|
||||
Tests for L{twisted.lore.texi}.
|
||||
"""
|
||||
|
||||
from xml.dom.minidom import Element, Text
|
||||
|
||||
from twisted.trial.unittest import TestCase
|
||||
from twisted.lore.texi import TexiSpitter
|
||||
|
||||
|
||||
class TexiSpitterTests(TestCase):
|
||||
"""
|
||||
Tests for L{TexiSpitter}.
|
||||
"""
|
||||
def setUp(self):
|
||||
self.filename = self.mktemp()
|
||||
self.output = []
|
||||
self.spitter = TexiSpitter(self.output.append, filename=self.filename)
|
||||
|
||||
|
||||
def test_title(self):
|
||||
"""
|
||||
L{TexiSpitter.visitNode} emits I{@node} and I{@section} blocks when it
|
||||
encounters a I{title} element.
|
||||
"""
|
||||
titleElement = Element('title')
|
||||
text = Text()
|
||||
text.data = u'bar'
|
||||
titleElement.appendChild(text)
|
||||
|
||||
self.spitter.visitNode(titleElement)
|
||||
self.assertEqual(''.join(self.output), '@node bar\n@section bar\n')
|
||||
|
||||
|
||||
def test_titleWithHeader(self):
|
||||
"""
|
||||
L{TexiSpitter.visitNode} emits I{@subsection} and I{@menu} blocks when
|
||||
it encounters a header (h2 or h3) in a I{title} element.
|
||||
"""
|
||||
titleElement = Element('title')
|
||||
text = Text()
|
||||
text.data = u'bar'
|
||||
titleElement.appendChild(text)
|
||||
|
||||
head = Element('h2')
|
||||
first = Text()
|
||||
first.data = u'header1'
|
||||
head.appendChild(first)
|
||||
titleElement.appendChild(head)
|
||||
|
||||
self.spitter.visitNode(titleElement)
|
||||
self.assertEqual(''.join(self.output),
|
||||
'@node bar\n\n@node header1\n\n\n@subsection header1\n\n'
|
||||
'@section bar\n\n@node header1\n\n\n@subsection header1\n\n'
|
||||
'@menu\n* header1::\n@end menu\n')
|
||||
|
||||
|
||||
def test_pre(self):
|
||||
"""
|
||||
L{TexiSpitter.visitNode} emits a verbatim block when it encounters a
|
||||
I{pre} element.
|
||||
"""
|
||||
preElement = Element('pre')
|
||||
text = Text()
|
||||
text.data = u'foo'
|
||||
preElement.appendChild(text)
|
||||
|
||||
self.spitter.visitNode(preElement)
|
||||
self.assertEqual(''.join(self.output),
|
||||
'@verbatim\nfoo\n@end verbatim\n')
|
||||
|
||||
|
||||
def test_code(self):
|
||||
"""
|
||||
L{TexiSpitter.visitNode} emits a C{@code} block when it encounters a
|
||||
I{code} element.
|
||||
"""
|
||||
codeElement = Element('code')
|
||||
text = Text()
|
||||
text.data = u'print'
|
||||
codeElement.appendChild(text)
|
||||
|
||||
self.spitter.visitNode(codeElement)
|
||||
self.assertEqual(''.join(self.output), "@code{print}")
|
||||
|
||||
115
Linux/lib/python2.7/site-packages/twisted/lore/texi.py
Normal file
115
Linux/lib/python2.7/site-packages/twisted/lore/texi.py
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
# -*- test-case-name: twisted.lore.test.test_texi -*-
|
||||
# Copyright (c) Twisted Matrix Laboratories.
|
||||
# See LICENSE for details.
|
||||
|
||||
from cStringIO import StringIO
|
||||
import os, re
|
||||
|
||||
from twisted.web import domhelpers
|
||||
import latex, tree
|
||||
|
||||
spaceRe = re.compile('\s+')
|
||||
|
||||
def texiEscape(text):
|
||||
return spaceRe.sub(text, ' ')
|
||||
|
||||
entities = latex.entities.copy()
|
||||
entities['copy'] = '@copyright{}'
|
||||
|
||||
class TexiSpitter(latex.BaseLatexSpitter):
|
||||
|
||||
baseLevel = 1
|
||||
|
||||
def writeNodeData(self, node):
|
||||
latex.getLatexText(node, self.writer, texiEscape, entities)
|
||||
|
||||
def visitNode_title(self, node):
|
||||
self.writer('@node ')
|
||||
self.visitNodeDefault(node)
|
||||
self.writer('\n')
|
||||
self.writer('@section ')
|
||||
self.visitNodeDefault(node)
|
||||
self.writer('\n')
|
||||
headers = tree.getHeaders(domhelpers.getParents(node)[-1])
|
||||
if not headers:
|
||||
return
|
||||
self.writer('@menu\n')
|
||||
for header in headers:
|
||||
self.writer('* %s::\n' % domhelpers.getNodeText(header))
|
||||
self.writer('@end menu\n')
|
||||
|
||||
|
||||
def visitNode_pre(self, node):
|
||||
"""
|
||||
Writes a I{verbatim} block when it encounters a I{pre} element.
|
||||
|
||||
@param node: The element to process.
|
||||
@type node: L{xml.dom.minidom.Element}
|
||||
"""
|
||||
self.writer('@verbatim\n')
|
||||
buf = StringIO()
|
||||
latex.getLatexText(node, buf.write, entities=entities)
|
||||
self.writer(tree._removeLeadingTrailingBlankLines(buf.getvalue()))
|
||||
self.writer('@end verbatim\n')
|
||||
|
||||
|
||||
def visitNode_code(self, node):
|
||||
fout = StringIO()
|
||||
latex.getLatexText(node, fout.write, texiEscape, entities)
|
||||
self.writer('@code{'+fout.getvalue()+'}')
|
||||
|
||||
def visitNodeHeader(self, node):
|
||||
self.writer('\n\n@node ')
|
||||
self.visitNodeDefault(node)
|
||||
self.writer('\n')
|
||||
level = (int(node.tagName[1])-2)+self.baseLevel
|
||||
self.writer('\n\n@'+level*'sub'+'section ')
|
||||
self.visitNodeDefault(node)
|
||||
self.writer('\n')
|
||||
|
||||
def visitNode_a_listing(self, node):
|
||||
fileName = os.path.join(self.currDir, node.getAttribute('href'))
|
||||
self.writer('@verbatim\n')
|
||||
self.writer(open(fileName).read())
|
||||
self.writer('@end verbatim')
|
||||
# Write a caption for this source listing
|
||||
|
||||
def visitNode_a_href(self, node):
|
||||
self.visitNodeDefault(node)
|
||||
|
||||
def visitNode_a_name(self, node):
|
||||
self.visitNodeDefault(node)
|
||||
|
||||
visitNode_h2 = visitNode_h3 = visitNode_h4 = visitNodeHeader
|
||||
|
||||
start_dl = '@itemize\n'
|
||||
end_dl = '@end itemize\n'
|
||||
start_ul = '@itemize\n'
|
||||
end_ul = '@end itemize\n'
|
||||
|
||||
start_ol = '@enumerate\n'
|
||||
end_ol = '@end enumerate\n'
|
||||
|
||||
start_li = '@item\n'
|
||||
end_li = '\n'
|
||||
|
||||
start_dt = '@item\n'
|
||||
end_dt = ': '
|
||||
end_dd = '\n'
|
||||
|
||||
start_p = '\n\n'
|
||||
|
||||
start_strong = start_em = '@emph{'
|
||||
end_strong = end_em = '}'
|
||||
|
||||
start_q = "``"
|
||||
end_q = "''"
|
||||
|
||||
start_span_footnote = '@footnote{'
|
||||
end_span_footnote = '}'
|
||||
|
||||
start_div_note = '@quotation\n@strong{Note:}'
|
||||
end_div_note = '@end quotation\n'
|
||||
|
||||
start_th = '@strong{'
|
||||
end_th = '}'
|
||||
203
Linux/lib/python2.7/site-packages/twisted/lore/topfiles/NEWS
Normal file
203
Linux/lib/python2.7/site-packages/twisted/lore/topfiles/NEWS
Normal file
|
|
@ -0,0 +1,203 @@
|
|||
Ticket numbers in this file can be looked up by visiting
|
||||
http://twistedmatrix.com/trac/ticket/<number>
|
||||
|
||||
Twisted Lore 14.0.0 (2014-05-08)
|
||||
================================
|
||||
|
||||
Deprecations and Removals
|
||||
-------------------------
|
||||
- twisted.lore is now deprecated in favor of Sphinx. (#6907)
|
||||
|
||||
Other
|
||||
-----
|
||||
- #6998
|
||||
|
||||
|
||||
Twisted Lore 13.2.0 (2013-10-29)
|
||||
================================
|
||||
|
||||
No significant changes have been made for this release.
|
||||
|
||||
Other
|
||||
-----
|
||||
- #6546
|
||||
|
||||
|
||||
Twisted Lore 13.1.0 (2013-06-23)
|
||||
================================
|
||||
|
||||
Deprecations and Removals
|
||||
-------------------------
|
||||
- twisted.lore.lint.parserErrors is deprecated now. (#5386)
|
||||
|
||||
|
||||
Twisted Lore 13.0.0 (2013-03-19)
|
||||
================================
|
||||
|
||||
No significant changes have been made for this release.
|
||||
|
||||
|
||||
Twisted Lore 12.3.0 (2012-12-20)
|
||||
================================
|
||||
|
||||
No significant changes have been made for this release.
|
||||
|
||||
|
||||
Twisted Lore 12.2.0 (2012-08-26)
|
||||
================================
|
||||
|
||||
No significant changes have been made for this release.
|
||||
|
||||
|
||||
Twisted Lore 12.1.0 (2012-06-02)
|
||||
================================
|
||||
|
||||
Bugfixes
|
||||
--------
|
||||
- twisted.plugins.twisted_lore's MathProcessor plugin is now
|
||||
associated with the correct implementation module. (#5326)
|
||||
|
||||
|
||||
Twisted Lore 12.0.0 (2012-02-10)
|
||||
================================
|
||||
|
||||
No significant changes have been made for this release.
|
||||
|
||||
|
||||
Twisted Lore 11.1.0 (2011-11-15)
|
||||
================================
|
||||
|
||||
Bugfixes
|
||||
--------
|
||||
- When run from an unpacked source tarball or a VCS checkout,
|
||||
bin/lore/lore will now use the version of Twisted it is part of.
|
||||
(#3526)
|
||||
|
||||
Deprecations and Removals
|
||||
-------------------------
|
||||
- Removed compareMarkPos and comparePosition from lore.tree,
|
||||
deprecated in Twisted 9.0. (#5127)
|
||||
|
||||
|
||||
Twisted Lore 11.0.0 (2011-04-01)
|
||||
================================
|
||||
|
||||
No significant changes have been made for this release.
|
||||
|
||||
|
||||
Twisted Lore 10.2.0 (2010-11-29)
|
||||
================================
|
||||
|
||||
No significant changes have been made for this release.
|
||||
|
||||
Other
|
||||
-----
|
||||
- #4571
|
||||
|
||||
|
||||
Twisted Lore 10.1.0 (2010-06-27)
|
||||
================================
|
||||
|
||||
No significant changes have been made for this release.
|
||||
|
||||
|
||||
Twisted Lore 10.0.0 (2010-03-01)
|
||||
================================
|
||||
|
||||
Other
|
||||
-----
|
||||
- #4241
|
||||
|
||||
|
||||
Twisted Lore 9.0.0 (2009-11-24)
|
||||
===============================
|
||||
|
||||
Features
|
||||
--------
|
||||
- Python source listings now include line numbers (#3486)
|
||||
|
||||
Fixes
|
||||
-----
|
||||
- Lore now uses minidom instead of Twisted's microdom, which incidentally
|
||||
fixes some Lore bugs such as throwing away certain whitespace
|
||||
(#3560, #414, #3619)
|
||||
- Lore's "lint" command should no longer break on documents with links in them
|
||||
(#4051, #4115)
|
||||
|
||||
Deprecations and Removals
|
||||
-------------------------
|
||||
- Lore no longer uses the ancient "tml" Twisted plugin system (#1911)
|
||||
|
||||
Other
|
||||
-----
|
||||
- #3565, #3246, #3540, #3750, #4050
|
||||
|
||||
|
||||
Lore 8.2.0 (2008-12-16)
|
||||
=======================
|
||||
|
||||
Other
|
||||
-----
|
||||
- #2207, #2514
|
||||
|
||||
|
||||
8.1.0 (2008-05-18)
|
||||
==================
|
||||
|
||||
Fixes
|
||||
-----
|
||||
- The deprecated mktap API is no longer used (#3127)
|
||||
|
||||
|
||||
8.0.0 (2008-03-17)
|
||||
==================
|
||||
|
||||
Fixes
|
||||
-----
|
||||
- Change twisted.lore.tree.setIndexLin so that it removes node with index-link
|
||||
class when the specified index filename is None. (#812)
|
||||
- Fix the conversion of the list of options in man pages to Lore format.
|
||||
(#3017)
|
||||
- Fix conch man pages generation. (#3075)
|
||||
- Fix management of the interactive command tag in man2lore. (#3076)
|
||||
|
||||
Misc
|
||||
----
|
||||
- #2847
|
||||
|
||||
|
||||
0.3.0 (2007-01-06)
|
||||
==================
|
||||
|
||||
Features
|
||||
--------
|
||||
- Many docstrings were added to twisted.lore.tree (#2301)
|
||||
|
||||
Fixes
|
||||
-----
|
||||
- Emitting a span with an index class to latex now works (#2134)
|
||||
|
||||
|
||||
0.2.0 (2006-05-24)
|
||||
==================
|
||||
|
||||
Features
|
||||
--------
|
||||
- Docstring improvements.
|
||||
|
||||
Fixes
|
||||
-----
|
||||
- Embedded Dia support for Latex no longer requires the 'which'
|
||||
command line tool.
|
||||
- Misc: #1142.
|
||||
|
||||
Deprecations
|
||||
------------
|
||||
- The unused, undocumented, untested and severely crashy 'bookify'
|
||||
functionality was removed.
|
||||
|
||||
|
||||
0.1.0
|
||||
=====
|
||||
- Use htmlizer mode that doesn't insert extra span tags, thus making
|
||||
it not mess up in Safari.
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
Twisted Lore 14.0.0
|
||||
|
||||
Twisted Lore depends on Twisted and Twisted Web.
|
||||
1161
Linux/lib/python2.7/site-packages/twisted/lore/tree.py
Normal file
1161
Linux/lib/python2.7/site-packages/twisted/lore/tree.py
Normal file
File diff suppressed because it is too large
Load diff
196
Linux/lib/python2.7/site-packages/twisted/lore/xhtml-lat1.ent
Normal file
196
Linux/lib/python2.7/site-packages/twisted/lore/xhtml-lat1.ent
Normal file
|
|
@ -0,0 +1,196 @@
|
|||
<!-- Portions (C) International Organization for Standardization 1986
|
||||
Permission to copy in any form is granted for use with
|
||||
conforming SGML systems and applications as defined in
|
||||
ISO 8879, provided this notice is included in all copies.
|
||||
-->
|
||||
<!-- Character entity set. Typical invocation:
|
||||
<!ENTITY % HTMLlat1 PUBLIC
|
||||
"-//W3C//ENTITIES Latin 1 for XHTML//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent">
|
||||
%HTMLlat1;
|
||||
-->
|
||||
|
||||
<!ENTITY nbsp " "> <!-- no-break space = non-breaking space,
|
||||
U+00A0 ISOnum -->
|
||||
<!ENTITY iexcl "¡"> <!-- inverted exclamation mark, U+00A1 ISOnum -->
|
||||
<!ENTITY cent "¢"> <!-- cent sign, U+00A2 ISOnum -->
|
||||
<!ENTITY pound "£"> <!-- pound sign, U+00A3 ISOnum -->
|
||||
<!ENTITY curren "¤"> <!-- currency sign, U+00A4 ISOnum -->
|
||||
<!ENTITY yen "¥"> <!-- yen sign = yuan sign, U+00A5 ISOnum -->
|
||||
<!ENTITY brvbar "¦"> <!-- broken bar = broken vertical bar,
|
||||
U+00A6 ISOnum -->
|
||||
<!ENTITY sect "§"> <!-- section sign, U+00A7 ISOnum -->
|
||||
<!ENTITY uml "¨"> <!-- diaeresis = spacing diaeresis,
|
||||
U+00A8 ISOdia -->
|
||||
<!ENTITY copy "©"> <!-- copyright sign, U+00A9 ISOnum -->
|
||||
<!ENTITY ordf "ª"> <!-- feminine ordinal indicator, U+00AA ISOnum -->
|
||||
<!ENTITY laquo "«"> <!-- left-pointing double angle quotation mark
|
||||
= left pointing guillemet, U+00AB ISOnum -->
|
||||
<!ENTITY not "¬"> <!-- not sign = angled dash,
|
||||
U+00AC ISOnum -->
|
||||
<!ENTITY shy "­"> <!-- soft hyphen = discretionary hyphen,
|
||||
U+00AD ISOnum -->
|
||||
<!ENTITY reg "®"> <!-- registered sign = registered trade mark sign,
|
||||
U+00AE ISOnum -->
|
||||
<!ENTITY macr "¯"> <!-- macron = spacing macron = overline
|
||||
= APL overbar, U+00AF ISOdia -->
|
||||
<!ENTITY deg "°"> <!-- degree sign, U+00B0 ISOnum -->
|
||||
<!ENTITY plusmn "±"> <!-- plus-minus sign = plus-or-minus sign,
|
||||
U+00B1 ISOnum -->
|
||||
<!ENTITY sup2 "²"> <!-- superscript two = superscript digit two
|
||||
= squared, U+00B2 ISOnum -->
|
||||
<!ENTITY sup3 "³"> <!-- superscript three = superscript digit three
|
||||
= cubed, U+00B3 ISOnum -->
|
||||
<!ENTITY acute "´"> <!-- acute accent = spacing acute,
|
||||
U+00B4 ISOdia -->
|
||||
<!ENTITY micro "µ"> <!-- micro sign, U+00B5 ISOnum -->
|
||||
<!ENTITY para "¶"> <!-- pilcrow sign = paragraph sign,
|
||||
U+00B6 ISOnum -->
|
||||
<!ENTITY middot "·"> <!-- middle dot = Georgian comma
|
||||
= Greek middle dot, U+00B7 ISOnum -->
|
||||
<!ENTITY cedil "¸"> <!-- cedilla = spacing cedilla, U+00B8 ISOdia -->
|
||||
<!ENTITY sup1 "¹"> <!-- superscript one = superscript digit one,
|
||||
U+00B9 ISOnum -->
|
||||
<!ENTITY ordm "º"> <!-- masculine ordinal indicator,
|
||||
U+00BA ISOnum -->
|
||||
<!ENTITY raquo "»"> <!-- right-pointing double angle quotation mark
|
||||
= right pointing guillemet, U+00BB ISOnum -->
|
||||
<!ENTITY frac14 "¼"> <!-- vulgar fraction one quarter
|
||||
= fraction one quarter, U+00BC ISOnum -->
|
||||
<!ENTITY frac12 "½"> <!-- vulgar fraction one half
|
||||
= fraction one half, U+00BD ISOnum -->
|
||||
<!ENTITY frac34 "¾"> <!-- vulgar fraction three quarters
|
||||
= fraction three quarters, U+00BE ISOnum -->
|
||||
<!ENTITY iquest "¿"> <!-- inverted question mark
|
||||
= turned question mark, U+00BF ISOnum -->
|
||||
<!ENTITY Agrave "À"> <!-- latin capital letter A with grave
|
||||
= latin capital letter A grave,
|
||||
U+00C0 ISOlat1 -->
|
||||
<!ENTITY Aacute "Á"> <!-- latin capital letter A with acute,
|
||||
U+00C1 ISOlat1 -->
|
||||
<!ENTITY Acirc "Â"> <!-- latin capital letter A with circumflex,
|
||||
U+00C2 ISOlat1 -->
|
||||
<!ENTITY Atilde "Ã"> <!-- latin capital letter A with tilde,
|
||||
U+00C3 ISOlat1 -->
|
||||
<!ENTITY Auml "Ä"> <!-- latin capital letter A with diaeresis,
|
||||
U+00C4 ISOlat1 -->
|
||||
<!ENTITY Aring "Å"> <!-- latin capital letter A with ring above
|
||||
= latin capital letter A ring,
|
||||
U+00C5 ISOlat1 -->
|
||||
<!ENTITY AElig "Æ"> <!-- latin capital letter AE
|
||||
= latin capital ligature AE,
|
||||
U+00C6 ISOlat1 -->
|
||||
<!ENTITY Ccedil "Ç"> <!-- latin capital letter C with cedilla,
|
||||
U+00C7 ISOlat1 -->
|
||||
<!ENTITY Egrave "È"> <!-- latin capital letter E with grave,
|
||||
U+00C8 ISOlat1 -->
|
||||
<!ENTITY Eacute "É"> <!-- latin capital letter E with acute,
|
||||
U+00C9 ISOlat1 -->
|
||||
<!ENTITY Ecirc "Ê"> <!-- latin capital letter E with circumflex,
|
||||
U+00CA ISOlat1 -->
|
||||
<!ENTITY Euml "Ë"> <!-- latin capital letter E with diaeresis,
|
||||
U+00CB ISOlat1 -->
|
||||
<!ENTITY Igrave "Ì"> <!-- latin capital letter I with grave,
|
||||
U+00CC ISOlat1 -->
|
||||
<!ENTITY Iacute "Í"> <!-- latin capital letter I with acute,
|
||||
U+00CD ISOlat1 -->
|
||||
<!ENTITY Icirc "Î"> <!-- latin capital letter I with circumflex,
|
||||
U+00CE ISOlat1 -->
|
||||
<!ENTITY Iuml "Ï"> <!-- latin capital letter I with diaeresis,
|
||||
U+00CF ISOlat1 -->
|
||||
<!ENTITY ETH "Ð"> <!-- latin capital letter ETH, U+00D0 ISOlat1 -->
|
||||
<!ENTITY Ntilde "Ñ"> <!-- latin capital letter N with tilde,
|
||||
U+00D1 ISOlat1 -->
|
||||
<!ENTITY Ograve "Ò"> <!-- latin capital letter O with grave,
|
||||
U+00D2 ISOlat1 -->
|
||||
<!ENTITY Oacute "Ó"> <!-- latin capital letter O with acute,
|
||||
U+00D3 ISOlat1 -->
|
||||
<!ENTITY Ocirc "Ô"> <!-- latin capital letter O with circumflex,
|
||||
U+00D4 ISOlat1 -->
|
||||
<!ENTITY Otilde "Õ"> <!-- latin capital letter O with tilde,
|
||||
U+00D5 ISOlat1 -->
|
||||
<!ENTITY Ouml "Ö"> <!-- latin capital letter O with diaeresis,
|
||||
U+00D6 ISOlat1 -->
|
||||
<!ENTITY times "×"> <!-- multiplication sign, U+00D7 ISOnum -->
|
||||
<!ENTITY Oslash "Ø"> <!-- latin capital letter O with stroke
|
||||
= latin capital letter O slash,
|
||||
U+00D8 ISOlat1 -->
|
||||
<!ENTITY Ugrave "Ù"> <!-- latin capital letter U with grave,
|
||||
U+00D9 ISOlat1 -->
|
||||
<!ENTITY Uacute "Ú"> <!-- latin capital letter U with acute,
|
||||
U+00DA ISOlat1 -->
|
||||
<!ENTITY Ucirc "Û"> <!-- latin capital letter U with circumflex,
|
||||
U+00DB ISOlat1 -->
|
||||
<!ENTITY Uuml "Ü"> <!-- latin capital letter U with diaeresis,
|
||||
U+00DC ISOlat1 -->
|
||||
<!ENTITY Yacute "Ý"> <!-- latin capital letter Y with acute,
|
||||
U+00DD ISOlat1 -->
|
||||
<!ENTITY THORN "Þ"> <!-- latin capital letter THORN,
|
||||
U+00DE ISOlat1 -->
|
||||
<!ENTITY szlig "ß"> <!-- latin small letter sharp s = ess-zed,
|
||||
U+00DF ISOlat1 -->
|
||||
<!ENTITY agrave "à"> <!-- latin small letter a with grave
|
||||
= latin small letter a grave,
|
||||
U+00E0 ISOlat1 -->
|
||||
<!ENTITY aacute "á"> <!-- latin small letter a with acute,
|
||||
U+00E1 ISOlat1 -->
|
||||
<!ENTITY acirc "â"> <!-- latin small letter a with circumflex,
|
||||
U+00E2 ISOlat1 -->
|
||||
<!ENTITY atilde "ã"> <!-- latin small letter a with tilde,
|
||||
U+00E3 ISOlat1 -->
|
||||
<!ENTITY auml "ä"> <!-- latin small letter a with diaeresis,
|
||||
U+00E4 ISOlat1 -->
|
||||
<!ENTITY aring "å"> <!-- latin small letter a with ring above
|
||||
= latin small letter a ring,
|
||||
U+00E5 ISOlat1 -->
|
||||
<!ENTITY aelig "æ"> <!-- latin small letter ae
|
||||
= latin small ligature ae, U+00E6 ISOlat1 -->
|
||||
<!ENTITY ccedil "ç"> <!-- latin small letter c with cedilla,
|
||||
U+00E7 ISOlat1 -->
|
||||
<!ENTITY egrave "è"> <!-- latin small letter e with grave,
|
||||
U+00E8 ISOlat1 -->
|
||||
<!ENTITY eacute "é"> <!-- latin small letter e with acute,
|
||||
U+00E9 ISOlat1 -->
|
||||
<!ENTITY ecirc "ê"> <!-- latin small letter e with circumflex,
|
||||
U+00EA ISOlat1 -->
|
||||
<!ENTITY euml "ë"> <!-- latin small letter e with diaeresis,
|
||||
U+00EB ISOlat1 -->
|
||||
<!ENTITY igrave "ì"> <!-- latin small letter i with grave,
|
||||
U+00EC ISOlat1 -->
|
||||
<!ENTITY iacute "í"> <!-- latin small letter i with acute,
|
||||
U+00ED ISOlat1 -->
|
||||
<!ENTITY icirc "î"> <!-- latin small letter i with circumflex,
|
||||
U+00EE ISOlat1 -->
|
||||
<!ENTITY iuml "ï"> <!-- latin small letter i with diaeresis,
|
||||
U+00EF ISOlat1 -->
|
||||
<!ENTITY eth "ð"> <!-- latin small letter eth, U+00F0 ISOlat1 -->
|
||||
<!ENTITY ntilde "ñ"> <!-- latin small letter n with tilde,
|
||||
U+00F1 ISOlat1 -->
|
||||
<!ENTITY ograve "ò"> <!-- latin small letter o with grave,
|
||||
U+00F2 ISOlat1 -->
|
||||
<!ENTITY oacute "ó"> <!-- latin small letter o with acute,
|
||||
U+00F3 ISOlat1 -->
|
||||
<!ENTITY ocirc "ô"> <!-- latin small letter o with circumflex,
|
||||
U+00F4 ISOlat1 -->
|
||||
<!ENTITY otilde "õ"> <!-- latin small letter o with tilde,
|
||||
U+00F5 ISOlat1 -->
|
||||
<!ENTITY ouml "ö"> <!-- latin small letter o with diaeresis,
|
||||
U+00F6 ISOlat1 -->
|
||||
<!ENTITY divide "÷"> <!-- division sign, U+00F7 ISOnum -->
|
||||
<!ENTITY oslash "ø"> <!-- latin small letter o with stroke,
|
||||
= latin small letter o slash,
|
||||
U+00F8 ISOlat1 -->
|
||||
<!ENTITY ugrave "ù"> <!-- latin small letter u with grave,
|
||||
U+00F9 ISOlat1 -->
|
||||
<!ENTITY uacute "ú"> <!-- latin small letter u with acute,
|
||||
U+00FA ISOlat1 -->
|
||||
<!ENTITY ucirc "û"> <!-- latin small letter u with circumflex,
|
||||
U+00FB ISOlat1 -->
|
||||
<!ENTITY uuml "ü"> <!-- latin small letter u with diaeresis,
|
||||
U+00FC ISOlat1 -->
|
||||
<!ENTITY yacute "ý"> <!-- latin small letter y with acute,
|
||||
U+00FD ISOlat1 -->
|
||||
<!ENTITY thorn "þ"> <!-- latin small letter thorn,
|
||||
U+00FE ISOlat1 -->
|
||||
<!ENTITY yuml "ÿ"> <!-- latin small letter y with diaeresis,
|
||||
U+00FF ISOlat1 -->
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
<!-- Special characters for XHTML -->
|
||||
|
||||
<!-- Character entity set. Typical invocation:
|
||||
<!ENTITY % HTMLspecial PUBLIC
|
||||
"-//W3C//ENTITIES Special for XHTML//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent">
|
||||
%HTMLspecial;
|
||||
-->
|
||||
|
||||
<!-- Portions (C) International Organization for Standardization 1986:
|
||||
Permission to copy in any form is granted for use with
|
||||
conforming SGML systems and applications as defined in
|
||||
ISO 8879, provided this notice is included in all copies.
|
||||
-->
|
||||
|
||||
<!-- Relevant ISO entity set is given unless names are newly introduced.
|
||||
New names (i.e., not in ISO 8879 list) do not clash with any
|
||||
existing ISO 8879 entity names. ISO 10646 character numbers
|
||||
are given for each character, in hex. values are decimal
|
||||
conversions of the ISO 10646 values and refer to the document
|
||||
character set. Names are Unicode names.
|
||||
-->
|
||||
|
||||
<!-- C0 Controls and Basic Latin -->
|
||||
<!ENTITY quot """> <!-- quotation mark, U+0022 ISOnum -->
|
||||
<!ENTITY amp "&#38;"> <!-- ampersand, U+0026 ISOnum -->
|
||||
<!ENTITY lt "&#60;"> <!-- less-than sign, U+003C ISOnum -->
|
||||
<!ENTITY gt ">"> <!-- greater-than sign, U+003E ISOnum -->
|
||||
<!ENTITY apos "'"> <!-- apostrophe = APL quote, U+0027 ISOnum -->
|
||||
|
||||
<!-- Latin Extended-A -->
|
||||
<!ENTITY OElig "Œ"> <!-- latin capital ligature OE,
|
||||
U+0152 ISOlat2 -->
|
||||
<!ENTITY oelig "œ"> <!-- latin small ligature oe, U+0153 ISOlat2 -->
|
||||
<!-- ligature is a misnomer, this is a separate character in some languages -->
|
||||
<!ENTITY Scaron "Š"> <!-- latin capital letter S with caron,
|
||||
U+0160 ISOlat2 -->
|
||||
<!ENTITY scaron "š"> <!-- latin small letter s with caron,
|
||||
U+0161 ISOlat2 -->
|
||||
<!ENTITY Yuml "Ÿ"> <!-- latin capital letter Y with diaeresis,
|
||||
U+0178 ISOlat2 -->
|
||||
|
||||
<!-- Spacing Modifier Letters -->
|
||||
<!ENTITY circ "ˆ"> <!-- modifier letter circumflex accent,
|
||||
U+02C6 ISOpub -->
|
||||
<!ENTITY tilde "˜"> <!-- small tilde, U+02DC ISOdia -->
|
||||
|
||||
<!-- General Punctuation -->
|
||||
<!ENTITY ensp " "> <!-- en space, U+2002 ISOpub -->
|
||||
<!ENTITY emsp " "> <!-- em space, U+2003 ISOpub -->
|
||||
<!ENTITY thinsp " "> <!-- thin space, U+2009 ISOpub -->
|
||||
<!ENTITY zwnj "‌"> <!-- zero width non-joiner,
|
||||
U+200C NEW RFC 2070 -->
|
||||
<!ENTITY zwj "‍"> <!-- zero width joiner, U+200D NEW RFC 2070 -->
|
||||
<!ENTITY lrm "‎"> <!-- left-to-right mark, U+200E NEW RFC 2070 -->
|
||||
<!ENTITY rlm "‏"> <!-- right-to-left mark, U+200F NEW RFC 2070 -->
|
||||
<!ENTITY ndash "–"> <!-- en dash, U+2013 ISOpub -->
|
||||
<!ENTITY mdash "—"> <!-- em dash, U+2014 ISOpub -->
|
||||
<!ENTITY lsquo "‘"> <!-- left single quotation mark,
|
||||
U+2018 ISOnum -->
|
||||
<!ENTITY rsquo "’"> <!-- right single quotation mark,
|
||||
U+2019 ISOnum -->
|
||||
<!ENTITY sbquo "‚"> <!-- single low-9 quotation mark, U+201A NEW -->
|
||||
<!ENTITY ldquo "“"> <!-- left double quotation mark,
|
||||
U+201C ISOnum -->
|
||||
<!ENTITY rdquo "”"> <!-- right double quotation mark,
|
||||
U+201D ISOnum -->
|
||||
<!ENTITY bdquo "„"> <!-- double low-9 quotation mark, U+201E NEW -->
|
||||
<!ENTITY dagger "†"> <!-- dagger, U+2020 ISOpub -->
|
||||
<!ENTITY Dagger "‡"> <!-- double dagger, U+2021 ISOpub -->
|
||||
<!ENTITY permil "‰"> <!-- per mille sign, U+2030 ISOtech -->
|
||||
<!ENTITY lsaquo "‹"> <!-- single left-pointing angle quotation mark,
|
||||
U+2039 ISO proposed -->
|
||||
<!-- lsaquo is proposed but not yet ISO standardized -->
|
||||
<!ENTITY rsaquo "›"> <!-- single right-pointing angle quotation mark,
|
||||
U+203A ISO proposed -->
|
||||
<!-- rsaquo is proposed but not yet ISO standardized -->
|
||||
|
||||
<!-- Currency Symbols -->
|
||||
<!ENTITY euro "€"> <!-- euro sign, U+20AC NEW -->
|
||||
237
Linux/lib/python2.7/site-packages/twisted/lore/xhtml-symbol.ent
Normal file
237
Linux/lib/python2.7/site-packages/twisted/lore/xhtml-symbol.ent
Normal file
|
|
@ -0,0 +1,237 @@
|
|||
<!-- Mathematical, Greek and Symbolic characters for XHTML -->
|
||||
|
||||
<!-- Character entity set. Typical invocation:
|
||||
<!ENTITY % HTMLsymbol PUBLIC
|
||||
"-//W3C//ENTITIES Symbols for XHTML//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent">
|
||||
%HTMLsymbol;
|
||||
-->
|
||||
|
||||
<!-- Portions (C) International Organization for Standardization 1986:
|
||||
Permission to copy in any form is granted for use with
|
||||
conforming SGML systems and applications as defined in
|
||||
ISO 8879, provided this notice is included in all copies.
|
||||
-->
|
||||
|
||||
<!-- Relevant ISO entity set is given unless names are newly introduced.
|
||||
New names (i.e., not in ISO 8879 list) do not clash with any
|
||||
existing ISO 8879 entity names. ISO 10646 character numbers
|
||||
are given for each character, in hex. values are decimal
|
||||
conversions of the ISO 10646 values and refer to the document
|
||||
character set. Names are Unicode names.
|
||||
-->
|
||||
|
||||
<!-- Latin Extended-B -->
|
||||
<!ENTITY fnof "ƒ"> <!-- latin small letter f with hook = function
|
||||
= florin, U+0192 ISOtech -->
|
||||
|
||||
<!-- Greek -->
|
||||
<!ENTITY Alpha "Α"> <!-- greek capital letter alpha, U+0391 -->
|
||||
<!ENTITY Beta "Β"> <!-- greek capital letter beta, U+0392 -->
|
||||
<!ENTITY Gamma "Γ"> <!-- greek capital letter gamma,
|
||||
U+0393 ISOgrk3 -->
|
||||
<!ENTITY Delta "Δ"> <!-- greek capital letter delta,
|
||||
U+0394 ISOgrk3 -->
|
||||
<!ENTITY Epsilon "Ε"> <!-- greek capital letter epsilon, U+0395 -->
|
||||
<!ENTITY Zeta "Ζ"> <!-- greek capital letter zeta, U+0396 -->
|
||||
<!ENTITY Eta "Η"> <!-- greek capital letter eta, U+0397 -->
|
||||
<!ENTITY Theta "Θ"> <!-- greek capital letter theta,
|
||||
U+0398 ISOgrk3 -->
|
||||
<!ENTITY Iota "Ι"> <!-- greek capital letter iota, U+0399 -->
|
||||
<!ENTITY Kappa "Κ"> <!-- greek capital letter kappa, U+039A -->
|
||||
<!ENTITY Lambda "Λ"> <!-- greek capital letter lamda,
|
||||
U+039B ISOgrk3 -->
|
||||
<!ENTITY Mu "Μ"> <!-- greek capital letter mu, U+039C -->
|
||||
<!ENTITY Nu "Ν"> <!-- greek capital letter nu, U+039D -->
|
||||
<!ENTITY Xi "Ξ"> <!-- greek capital letter xi, U+039E ISOgrk3 -->
|
||||
<!ENTITY Omicron "Ο"> <!-- greek capital letter omicron, U+039F -->
|
||||
<!ENTITY Pi "Π"> <!-- greek capital letter pi, U+03A0 ISOgrk3 -->
|
||||
<!ENTITY Rho "Ρ"> <!-- greek capital letter rho, U+03A1 -->
|
||||
<!-- there is no Sigmaf, and no U+03A2 character either -->
|
||||
<!ENTITY Sigma "Σ"> <!-- greek capital letter sigma,
|
||||
U+03A3 ISOgrk3 -->
|
||||
<!ENTITY Tau "Τ"> <!-- greek capital letter tau, U+03A4 -->
|
||||
<!ENTITY Upsilon "Υ"> <!-- greek capital letter upsilon,
|
||||
U+03A5 ISOgrk3 -->
|
||||
<!ENTITY Phi "Φ"> <!-- greek capital letter phi,
|
||||
U+03A6 ISOgrk3 -->
|
||||
<!ENTITY Chi "Χ"> <!-- greek capital letter chi, U+03A7 -->
|
||||
<!ENTITY Psi "Ψ"> <!-- greek capital letter psi,
|
||||
U+03A8 ISOgrk3 -->
|
||||
<!ENTITY Omega "Ω"> <!-- greek capital letter omega,
|
||||
U+03A9 ISOgrk3 -->
|
||||
|
||||
<!ENTITY alpha "α"> <!-- greek small letter alpha,
|
||||
U+03B1 ISOgrk3 -->
|
||||
<!ENTITY beta "β"> <!-- greek small letter beta, U+03B2 ISOgrk3 -->
|
||||
<!ENTITY gamma "γ"> <!-- greek small letter gamma,
|
||||
U+03B3 ISOgrk3 -->
|
||||
<!ENTITY delta "δ"> <!-- greek small letter delta,
|
||||
U+03B4 ISOgrk3 -->
|
||||
<!ENTITY epsilon "ε"> <!-- greek small letter epsilon,
|
||||
U+03B5 ISOgrk3 -->
|
||||
<!ENTITY zeta "ζ"> <!-- greek small letter zeta, U+03B6 ISOgrk3 -->
|
||||
<!ENTITY eta "η"> <!-- greek small letter eta, U+03B7 ISOgrk3 -->
|
||||
<!ENTITY theta "θ"> <!-- greek small letter theta,
|
||||
U+03B8 ISOgrk3 -->
|
||||
<!ENTITY iota "ι"> <!-- greek small letter iota, U+03B9 ISOgrk3 -->
|
||||
<!ENTITY kappa "κ"> <!-- greek small letter kappa,
|
||||
U+03BA ISOgrk3 -->
|
||||
<!ENTITY lambda "λ"> <!-- greek small letter lamda,
|
||||
U+03BB ISOgrk3 -->
|
||||
<!ENTITY mu "μ"> <!-- greek small letter mu, U+03BC ISOgrk3 -->
|
||||
<!ENTITY nu "ν"> <!-- greek small letter nu, U+03BD ISOgrk3 -->
|
||||
<!ENTITY xi "ξ"> <!-- greek small letter xi, U+03BE ISOgrk3 -->
|
||||
<!ENTITY omicron "ο"> <!-- greek small letter omicron, U+03BF NEW -->
|
||||
<!ENTITY pi "π"> <!-- greek small letter pi, U+03C0 ISOgrk3 -->
|
||||
<!ENTITY rho "ρ"> <!-- greek small letter rho, U+03C1 ISOgrk3 -->
|
||||
<!ENTITY sigmaf "ς"> <!-- greek small letter final sigma,
|
||||
U+03C2 ISOgrk3 -->
|
||||
<!ENTITY sigma "σ"> <!-- greek small letter sigma,
|
||||
U+03C3 ISOgrk3 -->
|
||||
<!ENTITY tau "τ"> <!-- greek small letter tau, U+03C4 ISOgrk3 -->
|
||||
<!ENTITY upsilon "υ"> <!-- greek small letter upsilon,
|
||||
U+03C5 ISOgrk3 -->
|
||||
<!ENTITY phi "φ"> <!-- greek small letter phi, U+03C6 ISOgrk3 -->
|
||||
<!ENTITY chi "χ"> <!-- greek small letter chi, U+03C7 ISOgrk3 -->
|
||||
<!ENTITY psi "ψ"> <!-- greek small letter psi, U+03C8 ISOgrk3 -->
|
||||
<!ENTITY omega "ω"> <!-- greek small letter omega,
|
||||
U+03C9 ISOgrk3 -->
|
||||
<!ENTITY thetasym "ϑ"> <!-- greek theta symbol,
|
||||
U+03D1 NEW -->
|
||||
<!ENTITY upsih "ϒ"> <!-- greek upsilon with hook symbol,
|
||||
U+03D2 NEW -->
|
||||
<!ENTITY piv "ϖ"> <!-- greek pi symbol, U+03D6 ISOgrk3 -->
|
||||
|
||||
<!-- General Punctuation -->
|
||||
<!ENTITY bull "•"> <!-- bullet = black small circle,
|
||||
U+2022 ISOpub -->
|
||||
<!-- bullet is NOT the same as bullet operator, U+2219 -->
|
||||
<!ENTITY hellip "…"> <!-- horizontal ellipsis = three dot leader,
|
||||
U+2026 ISOpub -->
|
||||
<!ENTITY prime "′"> <!-- prime = minutes = feet, U+2032 ISOtech -->
|
||||
<!ENTITY Prime "″"> <!-- double prime = seconds = inches,
|
||||
U+2033 ISOtech -->
|
||||
<!ENTITY oline "‾"> <!-- overline = spacing overscore,
|
||||
U+203E NEW -->
|
||||
<!ENTITY frasl "⁄"> <!-- fraction slash, U+2044 NEW -->
|
||||
|
||||
<!-- Letterlike Symbols -->
|
||||
<!ENTITY weierp "℘"> <!-- script capital P = power set
|
||||
= Weierstrass p, U+2118 ISOamso -->
|
||||
<!ENTITY image "ℑ"> <!-- black-letter capital I = imaginary part,
|
||||
U+2111 ISOamso -->
|
||||
<!ENTITY real "ℜ"> <!-- black-letter capital R = real part symbol,
|
||||
U+211C ISOamso -->
|
||||
<!ENTITY trade "™"> <!-- trade mark sign, U+2122 ISOnum -->
|
||||
<!ENTITY alefsym "ℵ"> <!-- alef symbol = first transfinite cardinal,
|
||||
U+2135 NEW -->
|
||||
<!-- alef symbol is NOT the same as hebrew letter alef,
|
||||
U+05D0 although the same glyph could be used to depict both characters -->
|
||||
|
||||
<!-- Arrows -->
|
||||
<!ENTITY larr "←"> <!-- leftwards arrow, U+2190 ISOnum -->
|
||||
<!ENTITY uarr "↑"> <!-- upwards arrow, U+2191 ISOnum-->
|
||||
<!ENTITY rarr "→"> <!-- rightwards arrow, U+2192 ISOnum -->
|
||||
<!ENTITY darr "↓"> <!-- downwards arrow, U+2193 ISOnum -->
|
||||
<!ENTITY harr "↔"> <!-- left right arrow, U+2194 ISOamsa -->
|
||||
<!ENTITY crarr "↵"> <!-- downwards arrow with corner leftwards
|
||||
= carriage return, U+21B5 NEW -->
|
||||
<!ENTITY lArr "⇐"> <!-- leftwards double arrow, U+21D0 ISOtech -->
|
||||
<!-- Unicode does not say that lArr is the same as the 'is implied by' arrow
|
||||
but also does not have any other character for that function. So lArr can
|
||||
be used for 'is implied by' as ISOtech suggests -->
|
||||
<!ENTITY uArr "⇑"> <!-- upwards double arrow, U+21D1 ISOamsa -->
|
||||
<!ENTITY rArr "⇒"> <!-- rightwards double arrow,
|
||||
U+21D2 ISOtech -->
|
||||
<!-- Unicode does not say this is the 'implies' character but does not have
|
||||
another character with this function so rArr can be used for 'implies'
|
||||
as ISOtech suggests -->
|
||||
<!ENTITY dArr "⇓"> <!-- downwards double arrow, U+21D3 ISOamsa -->
|
||||
<!ENTITY hArr "⇔"> <!-- left right double arrow,
|
||||
U+21D4 ISOamsa -->
|
||||
|
||||
<!-- Mathematical Operators -->
|
||||
<!ENTITY forall "∀"> <!-- for all, U+2200 ISOtech -->
|
||||
<!ENTITY part "∂"> <!-- partial differential, U+2202 ISOtech -->
|
||||
<!ENTITY exist "∃"> <!-- there exists, U+2203 ISOtech -->
|
||||
<!ENTITY empty "∅"> <!-- empty set = null set, U+2205 ISOamso -->
|
||||
<!ENTITY nabla "∇"> <!-- nabla = backward difference,
|
||||
U+2207 ISOtech -->
|
||||
<!ENTITY isin "∈"> <!-- element of, U+2208 ISOtech -->
|
||||
<!ENTITY notin "∉"> <!-- not an element of, U+2209 ISOtech -->
|
||||
<!ENTITY ni "∋"> <!-- contains as member, U+220B ISOtech -->
|
||||
<!ENTITY prod "∏"> <!-- n-ary product = product sign,
|
||||
U+220F ISOamsb -->
|
||||
<!-- prod is NOT the same character as U+03A0 'greek capital letter pi' though
|
||||
the same glyph might be used for both -->
|
||||
<!ENTITY sum "∑"> <!-- n-ary summation, U+2211 ISOamsb -->
|
||||
<!-- sum is NOT the same character as U+03A3 'greek capital letter sigma'
|
||||
though the same glyph might be used for both -->
|
||||
<!ENTITY minus "−"> <!-- minus sign, U+2212 ISOtech -->
|
||||
<!ENTITY lowast "∗"> <!-- asterisk operator, U+2217 ISOtech -->
|
||||
<!ENTITY radic "√"> <!-- square root = radical sign,
|
||||
U+221A ISOtech -->
|
||||
<!ENTITY prop "∝"> <!-- proportional to, U+221D ISOtech -->
|
||||
<!ENTITY infin "∞"> <!-- infinity, U+221E ISOtech -->
|
||||
<!ENTITY ang "∠"> <!-- angle, U+2220 ISOamso -->
|
||||
<!ENTITY and "∧"> <!-- logical and = wedge, U+2227 ISOtech -->
|
||||
<!ENTITY or "∨"> <!-- logical or = vee, U+2228 ISOtech -->
|
||||
<!ENTITY cap "∩"> <!-- intersection = cap, U+2229 ISOtech -->
|
||||
<!ENTITY cup "∪"> <!-- union = cup, U+222A ISOtech -->
|
||||
<!ENTITY int "∫"> <!-- integral, U+222B ISOtech -->
|
||||
<!ENTITY there4 "∴"> <!-- therefore, U+2234 ISOtech -->
|
||||
<!ENTITY sim "∼"> <!-- tilde operator = varies with = similar to,
|
||||
U+223C ISOtech -->
|
||||
<!-- tilde operator is NOT the same character as the tilde, U+007E,
|
||||
although the same glyph might be used to represent both -->
|
||||
<!ENTITY cong "≅"> <!-- approximately equal to, U+2245 ISOtech -->
|
||||
<!ENTITY asymp "≈"> <!-- almost equal to = asymptotic to,
|
||||
U+2248 ISOamsr -->
|
||||
<!ENTITY ne "≠"> <!-- not equal to, U+2260 ISOtech -->
|
||||
<!ENTITY equiv "≡"> <!-- identical to, U+2261 ISOtech -->
|
||||
<!ENTITY le "≤"> <!-- less-than or equal to, U+2264 ISOtech -->
|
||||
<!ENTITY ge "≥"> <!-- greater-than or equal to,
|
||||
U+2265 ISOtech -->
|
||||
<!ENTITY sub "⊂"> <!-- subset of, U+2282 ISOtech -->
|
||||
<!ENTITY sup "⊃"> <!-- superset of, U+2283 ISOtech -->
|
||||
<!ENTITY nsub "⊄"> <!-- not a subset of, U+2284 ISOamsn -->
|
||||
<!ENTITY sube "⊆"> <!-- subset of or equal to, U+2286 ISOtech -->
|
||||
<!ENTITY supe "⊇"> <!-- superset of or equal to,
|
||||
U+2287 ISOtech -->
|
||||
<!ENTITY oplus "⊕"> <!-- circled plus = direct sum,
|
||||
U+2295 ISOamsb -->
|
||||
<!ENTITY otimes "⊗"> <!-- circled times = vector product,
|
||||
U+2297 ISOamsb -->
|
||||
<!ENTITY perp "⊥"> <!-- up tack = orthogonal to = perpendicular,
|
||||
U+22A5 ISOtech -->
|
||||
<!ENTITY sdot "⋅"> <!-- dot operator, U+22C5 ISOamsb -->
|
||||
<!-- dot operator is NOT the same character as U+00B7 middle dot -->
|
||||
|
||||
<!-- Miscellaneous Technical -->
|
||||
<!ENTITY lceil "⌈"> <!-- left ceiling = APL upstile,
|
||||
U+2308 ISOamsc -->
|
||||
<!ENTITY rceil "⌉"> <!-- right ceiling, U+2309 ISOamsc -->
|
||||
<!ENTITY lfloor "⌊"> <!-- left floor = APL downstile,
|
||||
U+230A ISOamsc -->
|
||||
<!ENTITY rfloor "⌋"> <!-- right floor, U+230B ISOamsc -->
|
||||
<!ENTITY lang "〈"> <!-- left-pointing angle bracket = bra,
|
||||
U+2329 ISOtech -->
|
||||
<!-- lang is NOT the same character as U+003C 'less than sign'
|
||||
or U+2039 'single left-pointing angle quotation mark' -->
|
||||
<!ENTITY rang "〉"> <!-- right-pointing angle bracket = ket,
|
||||
U+232A ISOtech -->
|
||||
<!-- rang is NOT the same character as U+003E 'greater than sign'
|
||||
or U+203A 'single right-pointing angle quotation mark' -->
|
||||
|
||||
<!-- Geometric Shapes -->
|
||||
<!ENTITY loz "◊"> <!-- lozenge, U+25CA ISOpub -->
|
||||
|
||||
<!-- Miscellaneous Symbols -->
|
||||
<!ENTITY spades "♠"> <!-- black spade suit, U+2660 ISOpub -->
|
||||
<!-- black here seems to mean filled as opposed to hollow -->
|
||||
<!ENTITY clubs "♣"> <!-- black club suit = shamrock,
|
||||
U+2663 ISOpub -->
|
||||
<!ENTITY hearts "♥"> <!-- black heart suit = valentine,
|
||||
U+2665 ISOpub -->
|
||||
<!ENTITY diams "♦"> <!-- black diamond suit, U+2666 ISOpub -->
|
||||
978
Linux/lib/python2.7/site-packages/twisted/lore/xhtml1-strict.dtd
Normal file
978
Linux/lib/python2.7/site-packages/twisted/lore/xhtml1-strict.dtd
Normal file
|
|
@ -0,0 +1,978 @@
|
|||
<!--
|
||||
Extensible HTML version 1.0 Strict DTD
|
||||
|
||||
This is the same as HTML 4 Strict except for
|
||||
changes due to the differences between XML and SGML.
|
||||
|
||||
Namespace = http://www.w3.org/1999/xhtml
|
||||
|
||||
For further information, see: http://www.w3.org/TR/xhtml1
|
||||
|
||||
Copyright (c) 1998-2002 W3C (MIT, INRIA, Keio),
|
||||
All Rights Reserved.
|
||||
|
||||
This DTD module is identified by the PUBLIC and SYSTEM identifiers:
|
||||
|
||||
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
|
||||
|
||||
$Revision: 1.1 $
|
||||
$Date: 2002/08/01 13:56:03 $
|
||||
|
||||
-->
|
||||
|
||||
<!--================ Character mnemonic entities =========================-->
|
||||
|
||||
<!ENTITY % HTMLlat1 PUBLIC
|
||||
"-//W3C//ENTITIES Latin 1 for XHTML//EN"
|
||||
"xhtml-lat1.ent">
|
||||
%HTMLlat1;
|
||||
|
||||
<!ENTITY % HTMLsymbol PUBLIC
|
||||
"-//W3C//ENTITIES Symbols for XHTML//EN"
|
||||
"xhtml-symbol.ent">
|
||||
%HTMLsymbol;
|
||||
|
||||
<!ENTITY % HTMLspecial PUBLIC
|
||||
"-//W3C//ENTITIES Special for XHTML//EN"
|
||||
"xhtml-special.ent">
|
||||
%HTMLspecial;
|
||||
|
||||
<!--================== Imported Names ====================================-->
|
||||
|
||||
<!ENTITY % ContentType "CDATA">
|
||||
<!-- media type, as per [RFC2045] -->
|
||||
|
||||
<!ENTITY % ContentTypes "CDATA">
|
||||
<!-- comma-separated list of media types, as per [RFC2045] -->
|
||||
|
||||
<!ENTITY % Charset "CDATA">
|
||||
<!-- a character encoding, as per [RFC2045] -->
|
||||
|
||||
<!ENTITY % Charsets "CDATA">
|
||||
<!-- a space separated list of character encodings, as per [RFC2045] -->
|
||||
|
||||
<!ENTITY % LanguageCode "NMTOKEN">
|
||||
<!-- a language code, as per [RFC3066] -->
|
||||
|
||||
<!ENTITY % Character "CDATA">
|
||||
<!-- a single character, as per section 2.2 of [XML] -->
|
||||
|
||||
<!ENTITY % Number "CDATA">
|
||||
<!-- one or more digits -->
|
||||
|
||||
<!ENTITY % LinkTypes "CDATA">
|
||||
<!-- space-separated list of link types -->
|
||||
|
||||
<!ENTITY % MediaDesc "CDATA">
|
||||
<!-- single or comma-separated list of media descriptors -->
|
||||
|
||||
<!ENTITY % URI "CDATA">
|
||||
<!-- a Uniform Resource Identifier, see [RFC2396] -->
|
||||
|
||||
<!ENTITY % UriList "CDATA">
|
||||
<!-- a space separated list of Uniform Resource Identifiers -->
|
||||
|
||||
<!ENTITY % Datetime "CDATA">
|
||||
<!-- date and time information. ISO date format -->
|
||||
|
||||
<!ENTITY % Script "CDATA">
|
||||
<!-- script expression -->
|
||||
|
||||
<!ENTITY % StyleSheet "CDATA">
|
||||
<!-- style sheet data -->
|
||||
|
||||
<!ENTITY % Text "CDATA">
|
||||
<!-- used for titles etc. -->
|
||||
|
||||
<!ENTITY % Length "CDATA">
|
||||
<!-- nn for pixels or nn% for percentage length -->
|
||||
|
||||
<!ENTITY % MultiLength "CDATA">
|
||||
<!-- pixel, percentage, or relative -->
|
||||
|
||||
<!ENTITY % Pixels "CDATA">
|
||||
<!-- integer representing length in pixels -->
|
||||
|
||||
<!-- these are used for image maps -->
|
||||
|
||||
<!ENTITY % Shape "(rect|circle|poly|default)">
|
||||
|
||||
<!ENTITY % Coords "CDATA">
|
||||
<!-- comma separated list of lengths -->
|
||||
|
||||
<!--=================== Generic Attributes ===============================-->
|
||||
|
||||
<!-- core attributes common to most elements
|
||||
id document-wide unique id
|
||||
class space separated list of classes
|
||||
style associated style info
|
||||
title advisory title/amplification
|
||||
-->
|
||||
<!ENTITY % coreattrs
|
||||
"id ID #IMPLIED
|
||||
class CDATA #IMPLIED
|
||||
style %StyleSheet; #IMPLIED
|
||||
title %Text; #IMPLIED"
|
||||
>
|
||||
|
||||
<!-- internationalization attributes
|
||||
lang language code (backwards compatible)
|
||||
xml:lang language code (as per XML 1.0 spec)
|
||||
dir direction for weak/neutral text
|
||||
-->
|
||||
<!ENTITY % i18n
|
||||
"lang %LanguageCode; #IMPLIED
|
||||
xml:lang %LanguageCode; #IMPLIED
|
||||
dir (ltr|rtl) #IMPLIED"
|
||||
>
|
||||
|
||||
<!-- attributes for common UI events
|
||||
onclick a pointer button was clicked
|
||||
ondblclick a pointer button was double clicked
|
||||
onmousedown a pointer button was pressed down
|
||||
onmouseup a pointer button was released
|
||||
onmousemove a pointer was moved onto the element
|
||||
onmouseout a pointer was moved away from the element
|
||||
onkeypress a key was pressed and released
|
||||
onkeydown a key was pressed down
|
||||
onkeyup a key was released
|
||||
-->
|
||||
<!ENTITY % events
|
||||
"onclick %Script; #IMPLIED
|
||||
ondblclick %Script; #IMPLIED
|
||||
onmousedown %Script; #IMPLIED
|
||||
onmouseup %Script; #IMPLIED
|
||||
onmouseover %Script; #IMPLIED
|
||||
onmousemove %Script; #IMPLIED
|
||||
onmouseout %Script; #IMPLIED
|
||||
onkeypress %Script; #IMPLIED
|
||||
onkeydown %Script; #IMPLIED
|
||||
onkeyup %Script; #IMPLIED"
|
||||
>
|
||||
|
||||
<!-- attributes for elements that can get the focus
|
||||
accesskey accessibility key character
|
||||
tabindex position in tabbing order
|
||||
onfocus the element got the focus
|
||||
onblur the element lost the focus
|
||||
-->
|
||||
<!ENTITY % focus
|
||||
"accesskey %Character; #IMPLIED
|
||||
tabindex %Number; #IMPLIED
|
||||
onfocus %Script; #IMPLIED
|
||||
onblur %Script; #IMPLIED"
|
||||
>
|
||||
|
||||
<!ENTITY % attrs "%coreattrs; %i18n; %events;">
|
||||
|
||||
<!--=================== Text Elements ====================================-->
|
||||
|
||||
<!ENTITY % special.pre
|
||||
"br | span | bdo | map">
|
||||
|
||||
|
||||
<!ENTITY % special
|
||||
"%special.pre; | object | img ">
|
||||
|
||||
<!ENTITY % fontstyle "tt | i | b | big | small ">
|
||||
|
||||
<!ENTITY % phrase "em | strong | dfn | code | q |
|
||||
samp | kbd | var | cite | abbr | acronym | sub | sup ">
|
||||
|
||||
<!ENTITY % inline.forms "input | select | textarea | label | button">
|
||||
|
||||
<!-- these can occur at block or inline level -->
|
||||
<!ENTITY % misc.inline "ins | del | script">
|
||||
|
||||
<!-- these can only occur at block level -->
|
||||
<!ENTITY % misc "noscript | %misc.inline;">
|
||||
|
||||
<!ENTITY % inline "a | %special; | %fontstyle; | %phrase; | %inline.forms;">
|
||||
|
||||
<!-- %Inline; covers inline or "text-level" elements -->
|
||||
<!ENTITY % Inline "(#PCDATA | %inline; | %misc.inline;)*">
|
||||
|
||||
<!--================== Block level elements ==============================-->
|
||||
|
||||
<!ENTITY % heading "h1|h2|h3|h4|h5|h6">
|
||||
<!ENTITY % lists "ul | ol | dl">
|
||||
<!ENTITY % blocktext "pre | hr | blockquote | address">
|
||||
|
||||
<!ENTITY % block
|
||||
"p | %heading; | div | %lists; | %blocktext; | fieldset | table">
|
||||
|
||||
<!ENTITY % Block "(%block; | form | %misc;)*">
|
||||
|
||||
<!-- %Flow; mixes block and inline and is used for list items etc. -->
|
||||
<!ENTITY % Flow "(#PCDATA | %block; | form | %inline; | %misc;)*">
|
||||
|
||||
<!--================== Content models for exclusions =====================-->
|
||||
|
||||
<!-- a elements use %Inline; excluding a -->
|
||||
|
||||
<!ENTITY % a.content
|
||||
"(#PCDATA | %special; | %fontstyle; | %phrase; | %inline.forms; | %misc.inline;)*">
|
||||
|
||||
<!-- pre uses %Inline excluding big, small, sup or sup -->
|
||||
|
||||
<!ENTITY % pre.content
|
||||
"(#PCDATA | a | %fontstyle; | %phrase; | %special.pre; | %misc.inline;
|
||||
| %inline.forms;)*">
|
||||
|
||||
<!-- form uses %Block; excluding form -->
|
||||
|
||||
<!ENTITY % form.content "(%block; | %misc;)*">
|
||||
|
||||
<!-- button uses %Flow; but excludes a, form and form controls -->
|
||||
|
||||
<!ENTITY % button.content
|
||||
"(#PCDATA | p | %heading; | div | %lists; | %blocktext; |
|
||||
table | %special; | %fontstyle; | %phrase; | %misc;)*">
|
||||
|
||||
<!--================ Document Structure ==================================-->
|
||||
|
||||
<!-- the namespace URI designates the document profile -->
|
||||
|
||||
<!ELEMENT html (head, body)>
|
||||
<!ATTLIST html
|
||||
%i18n;
|
||||
id ID #IMPLIED
|
||||
xmlns %URI; #FIXED 'http://www.w3.org/1999/xhtml'
|
||||
>
|
||||
|
||||
<!--================ Document Head =======================================-->
|
||||
|
||||
<!ENTITY % head.misc "(script|style|meta|link|object)*">
|
||||
|
||||
<!-- content model is %head.misc; combined with a single
|
||||
title and an optional base element in any order -->
|
||||
|
||||
<!ELEMENT head (%head.misc;,
|
||||
((title, %head.misc;, (base, %head.misc;)?) |
|
||||
(base, %head.misc;, (title, %head.misc;))))>
|
||||
|
||||
<!ATTLIST head
|
||||
%i18n;
|
||||
id ID #IMPLIED
|
||||
profile %URI; #IMPLIED
|
||||
>
|
||||
|
||||
<!-- The title element is not considered part of the flow of text.
|
||||
It should be displayed, for example as the page header or
|
||||
window title. Exactly one title is required per document.
|
||||
-->
|
||||
<!ELEMENT title (#PCDATA)>
|
||||
<!ATTLIST title
|
||||
%i18n;
|
||||
id ID #IMPLIED
|
||||
>
|
||||
|
||||
<!-- document base URI -->
|
||||
|
||||
<!ELEMENT base EMPTY>
|
||||
<!ATTLIST base
|
||||
href %URI; #REQUIRED
|
||||
id ID #IMPLIED
|
||||
>
|
||||
|
||||
<!-- generic metainformation -->
|
||||
<!ELEMENT meta EMPTY>
|
||||
<!ATTLIST meta
|
||||
%i18n;
|
||||
id ID #IMPLIED
|
||||
http-equiv CDATA #IMPLIED
|
||||
name CDATA #IMPLIED
|
||||
content CDATA #REQUIRED
|
||||
scheme CDATA #IMPLIED
|
||||
>
|
||||
|
||||
<!--
|
||||
Relationship values can be used in principle:
|
||||
|
||||
a) for document specific toolbars/menus when used
|
||||
with the link element in document head e.g.
|
||||
start, contents, previous, next, index, end, help
|
||||
b) to link to a separate style sheet (rel="stylesheet")
|
||||
c) to make a link to a script (rel="script")
|
||||
d) by stylesheets to control how collections of
|
||||
html nodes are rendered into printed documents
|
||||
e) to make a link to a printable version of this document
|
||||
e.g. a PostScript or PDF version (rel="alternate" media="print")
|
||||
-->
|
||||
|
||||
<!ELEMENT link EMPTY>
|
||||
<!ATTLIST link
|
||||
%attrs;
|
||||
charset %Charset; #IMPLIED
|
||||
href %URI; #IMPLIED
|
||||
hreflang %LanguageCode; #IMPLIED
|
||||
type %ContentType; #IMPLIED
|
||||
rel %LinkTypes; #IMPLIED
|
||||
rev %LinkTypes; #IMPLIED
|
||||
media %MediaDesc; #IMPLIED
|
||||
>
|
||||
|
||||
<!-- style info, which may include CDATA sections -->
|
||||
<!ELEMENT style (#PCDATA)>
|
||||
<!ATTLIST style
|
||||
%i18n;
|
||||
id ID #IMPLIED
|
||||
type %ContentType; #REQUIRED
|
||||
media %MediaDesc; #IMPLIED
|
||||
title %Text; #IMPLIED
|
||||
xml:space (preserve) #FIXED 'preserve'
|
||||
>
|
||||
|
||||
<!-- script statements, which may include CDATA sections -->
|
||||
<!ELEMENT script (#PCDATA)>
|
||||
<!ATTLIST script
|
||||
id ID #IMPLIED
|
||||
charset %Charset; #IMPLIED
|
||||
type %ContentType; #REQUIRED
|
||||
src %URI; #IMPLIED
|
||||
defer (defer) #IMPLIED
|
||||
xml:space (preserve) #FIXED 'preserve'
|
||||
>
|
||||
|
||||
<!-- alternate content container for non script-based rendering -->
|
||||
|
||||
<!ELEMENT noscript %Block;>
|
||||
<!ATTLIST noscript
|
||||
%attrs;
|
||||
>
|
||||
|
||||
<!--=================== Document Body ====================================-->
|
||||
|
||||
<!ELEMENT body %Block;>
|
||||
<!ATTLIST body
|
||||
%attrs;
|
||||
onload %Script; #IMPLIED
|
||||
onunload %Script; #IMPLIED
|
||||
>
|
||||
|
||||
<!ELEMENT div %Flow;> <!-- generic language/style container -->
|
||||
<!ATTLIST div
|
||||
%attrs;
|
||||
>
|
||||
|
||||
<!--=================== Paragraphs =======================================-->
|
||||
|
||||
<!ELEMENT p %Inline;>
|
||||
<!ATTLIST p
|
||||
%attrs;
|
||||
>
|
||||
|
||||
<!--=================== Headings =========================================-->
|
||||
|
||||
<!--
|
||||
There are six levels of headings from h1 (the most important)
|
||||
to h6 (the least important).
|
||||
-->
|
||||
|
||||
<!ELEMENT h1 %Inline;>
|
||||
<!ATTLIST h1
|
||||
%attrs;
|
||||
>
|
||||
|
||||
<!ELEMENT h2 %Inline;>
|
||||
<!ATTLIST h2
|
||||
%attrs;
|
||||
>
|
||||
|
||||
<!ELEMENT h3 %Inline;>
|
||||
<!ATTLIST h3
|
||||
%attrs;
|
||||
>
|
||||
|
||||
<!ELEMENT h4 %Inline;>
|
||||
<!ATTLIST h4
|
||||
%attrs;
|
||||
>
|
||||
|
||||
<!ELEMENT h5 %Inline;>
|
||||
<!ATTLIST h5
|
||||
%attrs;
|
||||
>
|
||||
|
||||
<!ELEMENT h6 %Inline;>
|
||||
<!ATTLIST h6
|
||||
%attrs;
|
||||
>
|
||||
|
||||
<!--=================== Lists ============================================-->
|
||||
|
||||
<!-- Unordered list -->
|
||||
|
||||
<!ELEMENT ul (li)+>
|
||||
<!ATTLIST ul
|
||||
%attrs;
|
||||
>
|
||||
|
||||
<!-- Ordered (numbered) list -->
|
||||
|
||||
<!ELEMENT ol (li)+>
|
||||
<!ATTLIST ol
|
||||
%attrs;
|
||||
>
|
||||
|
||||
<!-- list item -->
|
||||
|
||||
<!ELEMENT li %Flow;>
|
||||
<!ATTLIST li
|
||||
%attrs;
|
||||
>
|
||||
|
||||
<!-- definition lists - dt for term, dd for its definition -->
|
||||
|
||||
<!ELEMENT dl (dt|dd)+>
|
||||
<!ATTLIST dl
|
||||
%attrs;
|
||||
>
|
||||
|
||||
<!ELEMENT dt %Inline;>
|
||||
<!ATTLIST dt
|
||||
%attrs;
|
||||
>
|
||||
|
||||
<!ELEMENT dd %Flow;>
|
||||
<!ATTLIST dd
|
||||
%attrs;
|
||||
>
|
||||
|
||||
<!--=================== Address ==========================================-->
|
||||
|
||||
<!-- information on author -->
|
||||
|
||||
<!ELEMENT address %Inline;>
|
||||
<!ATTLIST address
|
||||
%attrs;
|
||||
>
|
||||
|
||||
<!--=================== Horizontal Rule ==================================-->
|
||||
|
||||
<!ELEMENT hr EMPTY>
|
||||
<!ATTLIST hr
|
||||
%attrs;
|
||||
>
|
||||
|
||||
<!--=================== Preformatted Text ================================-->
|
||||
|
||||
<!-- content is %Inline; excluding "img|object|big|small|sub|sup" -->
|
||||
|
||||
<!ELEMENT pre %pre.content;>
|
||||
<!ATTLIST pre
|
||||
%attrs;
|
||||
xml:space (preserve) #FIXED 'preserve'
|
||||
>
|
||||
|
||||
<!--=================== Block-like Quotes ================================-->
|
||||
|
||||
<!ELEMENT blockquote %Block;>
|
||||
<!ATTLIST blockquote
|
||||
%attrs;
|
||||
cite %URI; #IMPLIED
|
||||
>
|
||||
|
||||
<!--=================== Inserted/Deleted Text ============================-->
|
||||
|
||||
<!--
|
||||
ins/del are allowed in block and inline content, but its
|
||||
inappropriate to include block content within an ins element
|
||||
occurring in inline content.
|
||||
-->
|
||||
<!ELEMENT ins %Flow;>
|
||||
<!ATTLIST ins
|
||||
%attrs;
|
||||
cite %URI; #IMPLIED
|
||||
datetime %Datetime; #IMPLIED
|
||||
>
|
||||
|
||||
<!ELEMENT del %Flow;>
|
||||
<!ATTLIST del
|
||||
%attrs;
|
||||
cite %URI; #IMPLIED
|
||||
datetime %Datetime; #IMPLIED
|
||||
>
|
||||
|
||||
<!--================== The Anchor Element ================================-->
|
||||
|
||||
<!-- content is %Inline; except that anchors shouldn't be nested -->
|
||||
|
||||
<!ELEMENT a %a.content;>
|
||||
<!ATTLIST a
|
||||
%attrs;
|
||||
%focus;
|
||||
charset %Charset; #IMPLIED
|
||||
type %ContentType; #IMPLIED
|
||||
name NMTOKEN #IMPLIED
|
||||
href %URI; #IMPLIED
|
||||
hreflang %LanguageCode; #IMPLIED
|
||||
rel %LinkTypes; #IMPLIED
|
||||
rev %LinkTypes; #IMPLIED
|
||||
shape %Shape; "rect"
|
||||
coords %Coords; #IMPLIED
|
||||
>
|
||||
|
||||
<!--===================== Inline Elements ================================-->
|
||||
|
||||
<!ELEMENT span %Inline;> <!-- generic language/style container -->
|
||||
<!ATTLIST span
|
||||
%attrs;
|
||||
>
|
||||
|
||||
<!ELEMENT bdo %Inline;> <!-- I18N BiDi over-ride -->
|
||||
<!ATTLIST bdo
|
||||
%coreattrs;
|
||||
%events;
|
||||
lang %LanguageCode; #IMPLIED
|
||||
xml:lang %LanguageCode; #IMPLIED
|
||||
dir (ltr|rtl) #REQUIRED
|
||||
>
|
||||
|
||||
<!ELEMENT br EMPTY> <!-- forced line break -->
|
||||
<!ATTLIST br
|
||||
%coreattrs;
|
||||
>
|
||||
|
||||
<!ELEMENT em %Inline;> <!-- emphasis -->
|
||||
<!ATTLIST em %attrs;>
|
||||
|
||||
<!ELEMENT strong %Inline;> <!-- strong emphasis -->
|
||||
<!ATTLIST strong %attrs;>
|
||||
|
||||
<!ELEMENT dfn %Inline;> <!-- definitional -->
|
||||
<!ATTLIST dfn %attrs;>
|
||||
|
||||
<!ELEMENT code %Inline;> <!-- program code -->
|
||||
<!ATTLIST code %attrs;>
|
||||
|
||||
<!ELEMENT samp %Inline;> <!-- sample -->
|
||||
<!ATTLIST samp %attrs;>
|
||||
|
||||
<!ELEMENT kbd %Inline;> <!-- something user would type -->
|
||||
<!ATTLIST kbd %attrs;>
|
||||
|
||||
<!ELEMENT var %Inline;> <!-- variable -->
|
||||
<!ATTLIST var %attrs;>
|
||||
|
||||
<!ELEMENT cite %Inline;> <!-- citation -->
|
||||
<!ATTLIST cite %attrs;>
|
||||
|
||||
<!ELEMENT abbr %Inline;> <!-- abbreviation -->
|
||||
<!ATTLIST abbr %attrs;>
|
||||
|
||||
<!ELEMENT acronym %Inline;> <!-- acronym -->
|
||||
<!ATTLIST acronym %attrs;>
|
||||
|
||||
<!ELEMENT q %Inline;> <!-- inlined quote -->
|
||||
<!ATTLIST q
|
||||
%attrs;
|
||||
cite %URI; #IMPLIED
|
||||
>
|
||||
|
||||
<!ELEMENT sub %Inline;> <!-- subscript -->
|
||||
<!ATTLIST sub %attrs;>
|
||||
|
||||
<!ELEMENT sup %Inline;> <!-- superscript -->
|
||||
<!ATTLIST sup %attrs;>
|
||||
|
||||
<!ELEMENT tt %Inline;> <!-- fixed pitch font -->
|
||||
<!ATTLIST tt %attrs;>
|
||||
|
||||
<!ELEMENT i %Inline;> <!-- italic font -->
|
||||
<!ATTLIST i %attrs;>
|
||||
|
||||
<!ELEMENT b %Inline;> <!-- bold font -->
|
||||
<!ATTLIST b %attrs;>
|
||||
|
||||
<!ELEMENT big %Inline;> <!-- bigger font -->
|
||||
<!ATTLIST big %attrs;>
|
||||
|
||||
<!ELEMENT small %Inline;> <!-- smaller font -->
|
||||
<!ATTLIST small %attrs;>
|
||||
|
||||
<!--==================== Object ======================================-->
|
||||
<!--
|
||||
object is used to embed objects as part of HTML pages.
|
||||
param elements should precede other content. Parameters
|
||||
can also be expressed as attribute/value pairs on the
|
||||
object element itself when brevity is desired.
|
||||
-->
|
||||
|
||||
<!ELEMENT object (#PCDATA | param | %block; | form | %inline; | %misc;)*>
|
||||
<!ATTLIST object
|
||||
%attrs;
|
||||
declare (declare) #IMPLIED
|
||||
classid %URI; #IMPLIED
|
||||
codebase %URI; #IMPLIED
|
||||
data %URI; #IMPLIED
|
||||
type %ContentType; #IMPLIED
|
||||
codetype %ContentType; #IMPLIED
|
||||
archive %UriList; #IMPLIED
|
||||
standby %Text; #IMPLIED
|
||||
height %Length; #IMPLIED
|
||||
width %Length; #IMPLIED
|
||||
usemap %URI; #IMPLIED
|
||||
name NMTOKEN #IMPLIED
|
||||
tabindex %Number; #IMPLIED
|
||||
>
|
||||
|
||||
<!--
|
||||
param is used to supply a named property value.
|
||||
In XML it would seem natural to follow RDF and support an
|
||||
abbreviated syntax where the param elements are replaced
|
||||
by attribute value pairs on the object start tag.
|
||||
-->
|
||||
<!ELEMENT param EMPTY>
|
||||
<!ATTLIST param
|
||||
id ID #IMPLIED
|
||||
name CDATA #IMPLIED
|
||||
value CDATA #IMPLIED
|
||||
valuetype (data|ref|object) "data"
|
||||
type %ContentType; #IMPLIED
|
||||
>
|
||||
|
||||
<!--=================== Images ===========================================-->
|
||||
|
||||
<!--
|
||||
To avoid accessibility problems for people who aren't
|
||||
able to see the image, you should provide a text
|
||||
description using the alt and longdesc attributes.
|
||||
In addition, avoid the use of server-side image maps.
|
||||
Note that in this DTD there is no name attribute. That
|
||||
is only available in the transitional and frameset DTD.
|
||||
-->
|
||||
|
||||
<!ELEMENT img EMPTY>
|
||||
<!ATTLIST img
|
||||
%attrs;
|
||||
src %URI; #REQUIRED
|
||||
alt %Text; #REQUIRED
|
||||
longdesc %URI; #IMPLIED
|
||||
height %Length; #IMPLIED
|
||||
width %Length; #IMPLIED
|
||||
usemap %URI; #IMPLIED
|
||||
ismap (ismap) #IMPLIED
|
||||
>
|
||||
|
||||
<!-- usemap points to a map element which may be in this document
|
||||
or an external document, although the latter is not widely supported -->
|
||||
|
||||
<!--================== Client-side image maps ============================-->
|
||||
|
||||
<!-- These can be placed in the same document or grouped in a
|
||||
separate document although this isn't yet widely supported -->
|
||||
|
||||
<!ELEMENT map ((%block; | form | %misc;)+ | area+)>
|
||||
<!ATTLIST map
|
||||
%i18n;
|
||||
%events;
|
||||
id ID #REQUIRED
|
||||
class CDATA #IMPLIED
|
||||
style %StyleSheet; #IMPLIED
|
||||
title %Text; #IMPLIED
|
||||
name NMTOKEN #IMPLIED
|
||||
>
|
||||
|
||||
<!ELEMENT area EMPTY>
|
||||
<!ATTLIST area
|
||||
%attrs;
|
||||
%focus;
|
||||
shape %Shape; "rect"
|
||||
coords %Coords; #IMPLIED
|
||||
href %URI; #IMPLIED
|
||||
nohref (nohref) #IMPLIED
|
||||
alt %Text; #REQUIRED
|
||||
>
|
||||
|
||||
<!--================ Forms ===============================================-->
|
||||
<!ELEMENT form %form.content;> <!-- forms shouldn't be nested -->
|
||||
|
||||
<!ATTLIST form
|
||||
%attrs;
|
||||
action %URI; #REQUIRED
|
||||
method (get|post) "get"
|
||||
enctype %ContentType; "application/x-www-form-urlencoded"
|
||||
onsubmit %Script; #IMPLIED
|
||||
onreset %Script; #IMPLIED
|
||||
accept %ContentTypes; #IMPLIED
|
||||
accept-charset %Charsets; #IMPLIED
|
||||
>
|
||||
|
||||
<!--
|
||||
Each label must not contain more than ONE field
|
||||
Label elements shouldn't be nested.
|
||||
-->
|
||||
<!ELEMENT label %Inline;>
|
||||
<!ATTLIST label
|
||||
%attrs;
|
||||
for IDREF #IMPLIED
|
||||
accesskey %Character; #IMPLIED
|
||||
onfocus %Script; #IMPLIED
|
||||
onblur %Script; #IMPLIED
|
||||
>
|
||||
|
||||
<!ENTITY % InputType
|
||||
"(text | password | checkbox |
|
||||
radio | submit | reset |
|
||||
file | hidden | image | button)"
|
||||
>
|
||||
|
||||
<!-- the name attribute is required for all but submit & reset -->
|
||||
|
||||
<!ELEMENT input EMPTY> <!-- form control -->
|
||||
<!ATTLIST input
|
||||
%attrs;
|
||||
%focus;
|
||||
type %InputType; "text"
|
||||
name CDATA #IMPLIED
|
||||
value CDATA #IMPLIED
|
||||
checked (checked) #IMPLIED
|
||||
disabled (disabled) #IMPLIED
|
||||
readonly (readonly) #IMPLIED
|
||||
size CDATA #IMPLIED
|
||||
maxlength %Number; #IMPLIED
|
||||
src %URI; #IMPLIED
|
||||
alt CDATA #IMPLIED
|
||||
usemap %URI; #IMPLIED
|
||||
onselect %Script; #IMPLIED
|
||||
onchange %Script; #IMPLIED
|
||||
accept %ContentTypes; #IMPLIED
|
||||
>
|
||||
|
||||
<!ELEMENT select (optgroup|option)+> <!-- option selector -->
|
||||
<!ATTLIST select
|
||||
%attrs;
|
||||
name CDATA #IMPLIED
|
||||
size %Number; #IMPLIED
|
||||
multiple (multiple) #IMPLIED
|
||||
disabled (disabled) #IMPLIED
|
||||
tabindex %Number; #IMPLIED
|
||||
onfocus %Script; #IMPLIED
|
||||
onblur %Script; #IMPLIED
|
||||
onchange %Script; #IMPLIED
|
||||
>
|
||||
|
||||
<!ELEMENT optgroup (option)+> <!-- option group -->
|
||||
<!ATTLIST optgroup
|
||||
%attrs;
|
||||
disabled (disabled) #IMPLIED
|
||||
label %Text; #REQUIRED
|
||||
>
|
||||
|
||||
<!ELEMENT option (#PCDATA)> <!-- selectable choice -->
|
||||
<!ATTLIST option
|
||||
%attrs;
|
||||
selected (selected) #IMPLIED
|
||||
disabled (disabled) #IMPLIED
|
||||
label %Text; #IMPLIED
|
||||
value CDATA #IMPLIED
|
||||
>
|
||||
|
||||
<!ELEMENT textarea (#PCDATA)> <!-- multi-line text field -->
|
||||
<!ATTLIST textarea
|
||||
%attrs;
|
||||
%focus;
|
||||
name CDATA #IMPLIED
|
||||
rows %Number; #REQUIRED
|
||||
cols %Number; #REQUIRED
|
||||
disabled (disabled) #IMPLIED
|
||||
readonly (readonly) #IMPLIED
|
||||
onselect %Script; #IMPLIED
|
||||
onchange %Script; #IMPLIED
|
||||
>
|
||||
|
||||
<!--
|
||||
The fieldset element is used to group form fields.
|
||||
Only one legend element should occur in the content
|
||||
and if present should only be preceded by whitespace.
|
||||
-->
|
||||
<!ELEMENT fieldset (#PCDATA | legend | %block; | form | %inline; | %misc;)*>
|
||||
<!ATTLIST fieldset
|
||||
%attrs;
|
||||
>
|
||||
|
||||
<!ELEMENT legend %Inline;> <!-- fieldset label -->
|
||||
<!ATTLIST legend
|
||||
%attrs;
|
||||
accesskey %Character; #IMPLIED
|
||||
>
|
||||
|
||||
<!--
|
||||
Content is %Flow; excluding a, form and form controls
|
||||
-->
|
||||
<!ELEMENT button %button.content;> <!-- push button -->
|
||||
<!ATTLIST button
|
||||
%attrs;
|
||||
%focus;
|
||||
name CDATA #IMPLIED
|
||||
value CDATA #IMPLIED
|
||||
type (button|submit|reset) "submit"
|
||||
disabled (disabled) #IMPLIED
|
||||
>
|
||||
|
||||
<!--======================= Tables =======================================-->
|
||||
|
||||
<!-- Derived from IETF HTML table standard, see [RFC1942] -->
|
||||
|
||||
<!--
|
||||
The border attribute sets the thickness of the frame around the
|
||||
table. The default units are screen pixels.
|
||||
|
||||
The frame attribute specifies which parts of the frame around
|
||||
the table should be rendered. The values are not the same as
|
||||
CALS to avoid a name clash with the valign attribute.
|
||||
-->
|
||||
<!ENTITY % TFrame "(void|above|below|hsides|lhs|rhs|vsides|box|border)">
|
||||
|
||||
<!--
|
||||
The rules attribute defines which rules to draw between cells:
|
||||
|
||||
If rules is absent then assume:
|
||||
"none" if border is absent or border="0" otherwise "all"
|
||||
-->
|
||||
|
||||
<!ENTITY % TRules "(none | groups | rows | cols | all)">
|
||||
|
||||
<!-- horizontal alignment attributes for cell contents
|
||||
|
||||
char alignment char, e.g. char=':'
|
||||
charoff offset for alignment char
|
||||
-->
|
||||
<!ENTITY % cellhalign
|
||||
"align (left|center|right|justify|char) #IMPLIED
|
||||
char %Character; #IMPLIED
|
||||
charoff %Length; #IMPLIED"
|
||||
>
|
||||
|
||||
<!-- vertical alignment attributes for cell contents -->
|
||||
<!ENTITY % cellvalign
|
||||
"valign (top|middle|bottom|baseline) #IMPLIED"
|
||||
>
|
||||
|
||||
<!ELEMENT table
|
||||
(caption?, (col*|colgroup*), thead?, tfoot?, (tbody+|tr+))>
|
||||
<!ELEMENT caption %Inline;>
|
||||
<!ELEMENT thead (tr)+>
|
||||
<!ELEMENT tfoot (tr)+>
|
||||
<!ELEMENT tbody (tr)+>
|
||||
<!ELEMENT colgroup (col)*>
|
||||
<!ELEMENT col EMPTY>
|
||||
<!ELEMENT tr (th|td)+>
|
||||
<!ELEMENT th %Flow;>
|
||||
<!ELEMENT td %Flow;>
|
||||
|
||||
<!ATTLIST table
|
||||
%attrs;
|
||||
summary %Text; #IMPLIED
|
||||
width %Length; #IMPLIED
|
||||
border %Pixels; #IMPLIED
|
||||
frame %TFrame; #IMPLIED
|
||||
rules %TRules; #IMPLIED
|
||||
cellspacing %Length; #IMPLIED
|
||||
cellpadding %Length; #IMPLIED
|
||||
>
|
||||
|
||||
<!ATTLIST caption
|
||||
%attrs;
|
||||
>
|
||||
|
||||
<!--
|
||||
colgroup groups a set of col elements. It allows you to group
|
||||
several semantically related columns together.
|
||||
-->
|
||||
<!ATTLIST colgroup
|
||||
%attrs;
|
||||
span %Number; "1"
|
||||
width %MultiLength; #IMPLIED
|
||||
%cellhalign;
|
||||
%cellvalign;
|
||||
>
|
||||
|
||||
<!--
|
||||
col elements define the alignment properties for cells in
|
||||
one or more columns.
|
||||
|
||||
The width attribute specifies the width of the columns, e.g.
|
||||
|
||||
width=64 width in screen pixels
|
||||
width=0.5* relative width of 0.5
|
||||
|
||||
The span attribute causes the attributes of one
|
||||
col element to apply to more than one column.
|
||||
-->
|
||||
<!ATTLIST col
|
||||
%attrs;
|
||||
span %Number; "1"
|
||||
width %MultiLength; #IMPLIED
|
||||
%cellhalign;
|
||||
%cellvalign;
|
||||
>
|
||||
|
||||
<!--
|
||||
Use thead to duplicate headers when breaking table
|
||||
across page boundaries, or for static headers when
|
||||
tbody sections are rendered in scrolling panel.
|
||||
|
||||
Use tfoot to duplicate footers when breaking table
|
||||
across page boundaries, or for static footers when
|
||||
tbody sections are rendered in scrolling panel.
|
||||
|
||||
Use multiple tbody sections when rules are needed
|
||||
between groups of table rows.
|
||||
-->
|
||||
<!ATTLIST thead
|
||||
%attrs;
|
||||
%cellhalign;
|
||||
%cellvalign;
|
||||
>
|
||||
|
||||
<!ATTLIST tfoot
|
||||
%attrs;
|
||||
%cellhalign;
|
||||
%cellvalign;
|
||||
>
|
||||
|
||||
<!ATTLIST tbody
|
||||
%attrs;
|
||||
%cellhalign;
|
||||
%cellvalign;
|
||||
>
|
||||
|
||||
<!ATTLIST tr
|
||||
%attrs;
|
||||
%cellhalign;
|
||||
%cellvalign;
|
||||
>
|
||||
|
||||
|
||||
<!-- Scope is simpler than headers attribute for common tables -->
|
||||
<!ENTITY % Scope "(row|col|rowgroup|colgroup)">
|
||||
|
||||
<!-- th is for headers, td for data and for cells acting as both -->
|
||||
|
||||
<!ATTLIST th
|
||||
%attrs;
|
||||
abbr %Text; #IMPLIED
|
||||
axis CDATA #IMPLIED
|
||||
headers IDREFS #IMPLIED
|
||||
scope %Scope; #IMPLIED
|
||||
rowspan %Number; "1"
|
||||
colspan %Number; "1"
|
||||
%cellhalign;
|
||||
%cellvalign;
|
||||
>
|
||||
|
||||
<!ATTLIST td
|
||||
%attrs;
|
||||
abbr %Text; #IMPLIED
|
||||
axis CDATA #IMPLIED
|
||||
headers IDREFS #IMPLIED
|
||||
scope %Scope; #IMPLIED
|
||||
rowspan %Number; "1"
|
||||
colspan %Number; "1"
|
||||
%cellhalign;
|
||||
%cellvalign;
|
||||
>
|
||||
|
||||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue