def pre_rendering(self): """ Inserts an nroff header into the buffer """ # Construct the RFC header and footer PaginatedTextRfcWriter.pre_rendering(self) # Insert a timestamp+version comment self.write_nroff(self.comment_header % ( xml2rfc.__version__, time.strftime('%Y-%m-%dT%H:%M:%SZ', datetime.datetime.utcnow().utctimetuple()) ) ) self._lb() # Insert the standard nroff settings self.buf.extend(NroffRfcWriter.settings_header) # Insert the RFC header and footer information self.write_nroff('.ds LH ' + self.left_header) self.write_nroff('.ds CH ' + self.center_header) self.write_nroff('.ds RH ' + self.right_header) self.write_nroff('.ds LF ' + self.left_footer) self.write_nroff('.ds CF ' + self.center_footer) self.write_nroff('.ds RF FORMFEED[Page %]')
def __init__(self, xmlrfc, width=72, quiet=False, verbose=False, date=datetime.date.today()): PaginatedTextRfcWriter.__init__(self, xmlrfc, width=width, \ quiet=quiet, verbose=verbose, date=date) self.curr_indent = 0 # Used like a state machine to control # whether or not we print a .in command self.wrapper.width = self.width self.wrapper.break_on_hyphens = True
def __init__(self, xmlrfc, width=72, quiet=None, options=default_options, date=datetime.date.today()): if not quiet is None: options.quiet = quiet PaginatedTextRfcWriter.__init__(self, xmlrfc, width=width, options=options, date=date) self.curr_indent = 0 # Used like a state machine to control # whether or not we print a .in command self.wrapper.width = self.width self.wrapper.break_on_hyphens = True
def write_ref_element(self, *args, **kwargs): begin = len(self.buf) PaginatedTextRfcWriter.write_ref_element(self, *args, **kwargs) end = len(self.buf) nr = len([ l for l in self.buf[begin:end] if l and l[0] in nroff_linestart_meta ]) self._set_break_hint(end - begin - nr, 'raw', begin)
def write_raw(self, text, indent=3, align='left', blanklines=0, \ delimiter=None, leading_blankline=True, source_line=None): # Wrap in a no fill block first = len(self.buf) self._indent(0) self.write_nroff('.nf') begin = len(self.buf) PaginatedTextRfcWriter.write_raw(self, text, indent=indent, align=align, blanklines=blanklines, delimiter=delimiter, leading_blankline=leading_blankline, source_line=source_line) for i in range(begin, len(self.buf)): if self.buf[i] and self.buf[i][0] in nroff_linestart_meta: self.buf[i] = nroff_escape_linestart(self.buf[i]) self.write_nroff('.fi') self._indent(indent) # Move the paging hint to the first command self.break_hints[first] = self.break_hints[begin] del self.break_hints[begin]
def write_list(self, *args, **kwargs): save_in_list = self.in_list self.in_list = True PaginatedTextRfcWriter.write_list(self, *args, **kwargs) self.in_list = save_in_list
def write_ref_element(self, *args, **kwargs): begin = len(self.buf) PaginatedTextRfcWriter.write_ref_element(self, *args, **kwargs) end = len(self.buf) nr = len([ l for l in self.buf[begin:end] if l and l[0] in nroff_linestart_meta]) self._set_break_hint(end - begin - nr, 'raw', begin)