?? __init__.py
字號:
def depart_footer(self, node): start = self.context.pop() footer = (['\n\\begin{center}\small\n'] + self.body[start:] + ['\n\\end{center}\n']) self.body_suffix[:0] = footer del self.body[start:] def visit_footnote(self, node): if self.use_latex_footnotes: num,text = node.astext().split(None,1) num = self.encode(num.strip()) self.body.append('\\footnotetext['+num+']') self.body.append('{') else: self.body.append('\\begin{figure}[b]') for id in node['ids']: self.body.append('\\hypertarget{%s}' % id) def depart_footnote(self, node): if self.use_latex_footnotes: self.body.append('}\n') else: self.body.append('\\end{figure}\n') def visit_footnote_reference(self, node): if self.use_latex_footnotes: self.body.append("\\footnotemark["+self.encode(node.astext())+"]") raise nodes.SkipNode href = '' if node.has_key('refid'): href = node['refid'] elif node.has_key('refname'): href = self.document.nameids[node['refname']] format = self.settings.footnote_references if format == 'brackets': suffix = '[' self.context.append(']') elif format == 'superscript': suffix = '\\raisebox{.5em}[0em]{\\scriptsize' self.context.append('}') else: # shouldn't happen raise AssertionError('Illegal footnote reference format.') self.body.append('%s\\hyperlink{%s}{' % (suffix,href)) def depart_footnote_reference(self, node): if self.use_latex_footnotes: return self.body.append('}%s' % self.context.pop()) # footnote/citation label def label_delim(self, node, bracket, superscript): if isinstance(node.parent, nodes.footnote): if self.use_latex_footnotes: raise nodes.SkipNode if self.settings.footnote_references == 'brackets': self.body.append(bracket) else: self.body.append(superscript) else: assert isinstance(node.parent, nodes.citation) if not self._use_latex_citations: self.body.append(bracket) def visit_label(self, node): self.label_delim(node, '[', '$^{') def depart_label(self, node): self.label_delim(node, ']', '}$') # elements generated by the framework e.g. section numbers. def visit_generated(self, node): pass def depart_generated(self, node): pass def visit_header(self, node): self.context.append(len(self.body)) def depart_header(self, node): start = self.context.pop() self.body_prefix.append('\n\\verb|begin_header|\n') self.body_prefix.extend(self.body[start:]) self.body_prefix.append('\n\\verb|end_header|\n') del self.body[start:] def visit_hint(self, node): self.visit_admonition(node, 'hint') def depart_hint(self, node): self.depart_admonition() def visit_image(self, node): attrs = node.attributes # Add image URI to dependency list, assuming that it's # referring to a local file. self.settings.record_dependencies.add(attrs['uri']) pre = [] # in reverse order post = [] include_graphics_options = "" inline = isinstance(node.parent, nodes.TextElement) if attrs.has_key('scale'): # Could also be done with ``scale`` option to # ``\includegraphics``; doing it this way for consistency. pre.append('\\scalebox{%f}{' % (attrs['scale'] / 100.0,)) post.append('}') if attrs.has_key('width'): include_graphics_options = '[width=%s]' % attrs['width'] if attrs.has_key('align'): align_prepost = { # By default latex aligns the top of an image. (1, 'top'): ('', ''), (1, 'middle'): ('\\raisebox{-0.5\\height}{', '}'), (1, 'bottom'): ('\\raisebox{-\\height}{', '}'), (0, 'center'): ('{\\hfill', '\\hfill}'), # These 2 don't exactly do the right thing. The image should # be floated alongside the paragraph. See # http://www.w3.org/TR/html4/struct/objects.html#adef-align-IMG (0, 'left'): ('{', '\\hfill}'), (0, 'right'): ('{\\hfill', '}'),} try: pre.append(align_prepost[inline, attrs['align']][0]) post.append(align_prepost[inline, attrs['align']][1]) except KeyError: pass # XXX complain here? if not inline: pre.append('\n') post.append('\n') pre.reverse() self.body.extend( pre ) self.body.append( '\\includegraphics%s{%s}' % ( include_graphics_options, attrs['uri'] ) ) self.body.extend( post ) def depart_image(self, node): pass def visit_important(self, node): self.visit_admonition(node, 'important') def depart_important(self, node): self.depart_admonition() def visit_interpreted(self, node): # @@@ Incomplete, pending a proper implementation on the # Parser/Reader end. self.visit_literal(node) def depart_interpreted(self, node): self.depart_literal(node) def visit_legend(self, node): self.body.append('{\\small ') def depart_legend(self, node): self.body.append('}') def visit_line(self, node): self.body.append('\item[] ') def depart_line(self, node): self.body.append('\n') def visit_line_block(self, node): if isinstance(node.parent, nodes.line_block): self.body.append('\\item[] \n' '\\begin{lineblock}{\\lineblockindentation}\n') else: self.body.append('\n\\begin{lineblock}{0em}\n') def depart_line_block(self, node): self.body.append('\\end{lineblock}\n') def visit_list_item(self, node): # Append "{}" in case the next character is "[", which would break # LaTeX's list environment (no numbering and the "[" is not printed). self.body.append('\\item {} ') def depart_list_item(self, node): self.body.append('\n') def visit_literal(self, node): self.literal = 1 self.body.append('\\texttt{') def depart_literal(self, node): self.body.append('}') self.literal = 0 def visit_literal_block(self, node): """ Render a literal-block. Literal blocks are used for "::"-prefixed literal-indented blocks of text, where the inline markup is not recognized, but are also the product of the parsed-literal directive, where the markup is respected. """ # In both cases, we want to use a typewriter/monospaced typeface. # For "real" literal-blocks, we can use \verbatim, while for all # the others we must use \mbox. # # We can distinguish between the two kinds by the number of # siblings the compose this node: if it is composed by a # single element, it's surely is either a real one, otherwise # it's a parsed-literal that does not contain any markup. # if (self.settings.use_verbatim_when_possible and (len(node) == 1) # in case of a parsed-literal containing just a "**bold**" word: and isinstance(node[0], nodes.Text)): self.verbatim = 1 self.body.append('\\begin{quote}\\begin{verbatim}\n') else: self.literal_block = 1 self.insert_none_breaking_blanks = 1 if self.active_table.is_open(): self.body.append('\n{\\ttfamily \\raggedright \\noindent\n') else: # no quote inside tables, to avoid vertical sppace between # table border and literal block. # BUG: fails if normal text preceeds the literal block. self.body.append('\\begin{quote}') self.body.append('{\\ttfamily \\raggedright \\noindent\n') # * obey..: is from julien and never worked for me (grubert). # self.body.append('{\\obeylines\\obeyspaces\\ttfamily\n') def depart_literal_block(self, node): if self.verbatim: self.body.append('\n\\end{verbatim}\\end{quote}\n') self.verbatim = 0 else: if self.active_table.is_open(): self.body.append('\n}\n') else: self.body.append('\n') self.body.append('}\\end{quote}\n') self.insert_none_breaking_blanks = 0 self.literal_block = 0 # obey end: self.body.append('}\n') def visit_meta(self, node): self.body.append('[visit_meta]\n') # BUG maybe set keywords for pdf ##self.head.append(self.starttag(node, 'meta', **node.attributes)) def depart_meta(self, node): self.body.append('[depart_meta]\n') def visit_note(self, node): self.visit_admonition(node, 'note') def depart_note(self, node): self.depart_admonition() def visit_option(self, node): if self.context[-1]: # this is not the first option self.body.append(', ') def depart_option(self, node): # flag tha the first option is done. self.context[-1] += 1 def visit_option_argument(self, node): """The delimiter betweeen an option and its argument.""" self.body.append(node.get('delimiter', ' ')) def depart_option_argument(self, node): pass def visit_option_group(self, node): if self.use_optionlist_for_option_list: self.body.append('\\item [') else: if len(node.astext()) > 14: self.body.append('\\multicolumn{2}{l}{') self.context.append('} \\\\\n ') else: self.context.append('') self.body.append('\\texttt{') # flag for first option self.context.append(0) def depart_option_group(self, node): self.context.pop() # the flag if self.use_optionlist_for_option_list: self.body.append('] ') else: self.body.append('}') self.body.append(self.context.pop()) def visit_option_list(self, node): self.body.append('% [option list]\n') if self.use_optionlist_for_option_list: self.body.append('\\begin{optionlist}{3cm}\n') else: self.body.append('\\begin{center}\n') # BUG: use admwidth or make it relative to textwidth ? self.body.append('\\begin{tabularx}{.9\\linewidth}{lX}\n') def depart_option_list(self, node): if self.use_optionlist_for_option_list: self.body.append('\\end{optionlist}\n') else: self.body.append('\\end{tabularx}\n') self.body.append('\\end{center}\n') def visit_option_list_item(self, node): pass def depart_option_list_item(self, node): if not self.use_optionlist_for_option_list: self.body.append('\\\\\n') def visit_option_string(self, node): ##self.body.append(self.starttag(node, 'span', '', CLASS='option')) pass def depart_option_string(self, node): ##self.body.append('</span>') pass def visit_organization(self, node): self.visit_docinfo_item(node, 'organization') def depart_organization(self, node): self.depart_docinfo_item(node) def visit_paragraph(self, node): index = node.parent.index(node) if not ('contents' in self.topic_classes or (isinstance(node.parent, nodes.compound) and index > 0 and not isinstance(node.parent[index - 1], nodes.paragraph) and not isinstance(node.parent[index - 1], nodes.compound))): self.body.append('\n') def depart_paragraph(self, node): self.body.append('\n') def visit_problematic(self, node): self.body.append('{\\color{red}\\bfseries{}') def depart_problematic(self, node): self.body.append('}') def visit_raw(s
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -