def __init__(self, document): nodes.NodeVisitor.__init__(self, document) self.settings = document.settings self.header = [] self.body = [] self.context = [] self.stylesheet_path = utils.get_stylesheet_reference( self.settings, os.path.join(os.getcwd(), 'dummy')) if self.stylesheet_path: self.settings.record_dependencies.add(self.stylesheet_path) # This ugly hack will be cleaned up when refactoring the # stylesheet mess. self.settings.stylesheet = self.settings.user_stylesheet self.settings.stylesheet_path = self.settings.user_stylesheet_path self.user_stylesheet_path = utils.get_stylesheet_reference( self.settings, os.path.join(os.getcwd(), 'dummy')) if self.user_stylesheet_path: self.settings.record_dependencies.add(self.user_stylesheet_path) lang = self.settings.language_code or '' if lang.startswith('de'): self.double_quote_replacment = "{\\dq}" elif lang.startswith('it'): self.double_quote_replacment = r'{\char`\"}' else: self.double_quote_replacment = None self.write_header()
def __init__(self, document): nodes.NodeVisitor.__init__(self, document) self.settings = document.settings self.header = [] self.body = [] self.context = [] self.stylesheet_path = utils.get_stylesheet_reference( self.settings, os.path.join(os.getcwd(), 'dummy')) if self.stylesheet_path: self.settings.record_dependencies.add(self.stylesheet_path) # This ugly hack will be cleaned up when refactoring the # stylesheet mess. self.settings.stylesheet = self.settings.user_stylesheet self.settings.stylesheet_path = self.settings.user_stylesheet_path self.user_stylesheet_path = utils.get_stylesheet_reference( self.settings, os.path.join(os.getcwd(), 'dummy')) if self.user_stylesheet_path: self.settings.record_dependencies.add(self.user_stylesheet_path) lang = self.settings.language_code or '' if lang.startswith('de'): self.double_quote_replacment = "{\\dq}" elif lang.startswith('it'): self.double_quote_replacment = r'{\char`\"}' else: self.double_quote_replacment = None self.write_header()
def apply(self): if ( self.document.settings._stylesheet_required and utils.get_stylesheet_reference(self.document.settings) is None): self.document.reporter.warning( 'No stylesheet path or URI given. Use the --stylesheet ' 'or --stylesheet-path option to specify the location of ' 'default.css (in the tools/stylesheets/ directory of the ' 'Docutils distribution).')
def apply(self): if ( self.document.settings._stylesheet_required and utils.get_stylesheet_reference(self.document.settings) is None): self.document.reporter.warning( 'No stylesheet path or URI given. Use the --stylesheet ' 'or --stylesheet-path option to specify the location of ' 'default.css (in the tools/stylesheets/ directory of the ' 'Docutils distribution).')
def __init__(self, document): nodes.NodeVisitor.__init__(self, document) self.settings = document.settings self.header = [] self.body = [] self.context = [] self.stylesheet_path = utils.get_stylesheet_reference( self.settings, os.path.join(os.getcwd(), 'dummy')) if self.stylesheet_path: self.settings.record_dependencies.add(self.stylesheet_path) # This ugly hack will be cleaned up when refactoring the # stylesheet mess. self.settings.stylesheet = self.settings.user_stylesheet self.settings.stylesheet_path = self.settings.user_stylesheet_path self.user_stylesheet_path = utils.get_stylesheet_reference( self.settings, os.path.join(os.getcwd(), 'dummy')) if self.user_stylesheet_path: self.settings.record_dependencies.add(self.user_stylesheet_path) self.write_header()
def __init__(self, document): nodes.NodeVisitor.__init__(self, document) self.settings = document.settings self.header = [] self.body = [] self.context = [] self.stylesheet_path = utils.get_stylesheet_reference( self.settings, os.path.join(os.getcwd(), 'dummy')) if self.stylesheet_path: self.settings.record_dependencies.add(self.stylesheet_path) # This ugly hack will be cleaned up when refactoring the # stylesheet mess. self.settings.stylesheet = self.settings.user_stylesheet self.settings.stylesheet_path = self.settings.user_stylesheet_path self.user_stylesheet_path = utils.get_stylesheet_reference( self.settings, os.path.join(os.getcwd(), 'dummy')) if self.user_stylesheet_path: self.settings.record_dependencies.add(self.user_stylesheet_path) self.write_header()
def write(self, document, destination): self.document = document self.language = docutils.languages.get_language( document.settings.language_code) self.destination = destination index_file_path = destination.destination_path index_file_name = os.path.basename(index_file_path) (index_file, extension) = os.path.splitext(index_file_name) if document.settings.chunk_dir_name: page_files_dir = document.settings.chunk_dir_name else: page_files_dir = index_file chunk_files_path = os.path.join( os.path.dirname(index_file_path) , page_files_dir ) output_stylesheet = None if document.settings.embed_stylesheet: document.settings.dont_copy_stylesheet = 1 if not document.settings.dont_copy_stylesheet: stylesheet_path = utils.get_stylesheet_reference(document.settings) if stylesheet_path: output_stylesheet = os.path.basename(stylesheet_path) document.settings.stylesheet = '%s/%s' % ( page_files_dir, output_stylesheet ) document.settings.stylesheet_path = None (index_text, pages) = self.translate(document, index_file, page_files_dir, extension) if len(pages) > 0 and not os.path.exists(chunk_files_path): os.mkdir(chunk_files_path) if output_stylesheet: shutil.copy( stylesheet_path , os.path.join(chunk_files_path, output_stylesheet) ) destination.write(index_text) for c in pages.keys(): chunk_file = self.make_chunk_output( destination , os.path.join(chunk_files_path,c + extension) ) chunk_file.write(pages[c])
def write(self, document, destination): self.document = document self.language = docutils.languages.get_language( document.settings.language_code) self.destination = destination index_file_path = destination.destination_path index_file_name = os.path.basename(index_file_path) (index_file, extension) = os.path.splitext(index_file_name) if document.settings.chunk_dir_name: page_files_dir = document.settings.chunk_dir_name else: page_files_dir = index_file chunk_files_path = os.path.join( os.path.dirname(index_file_path) , page_files_dir ) output_stylesheet = None if document.settings.embed_stylesheet: document.settings.dont_copy_stylesheet = 1 if not document.settings.dont_copy_stylesheet: stylesheet_path = utils.get_stylesheet_reference(document.settings) if stylesheet_path: output_stylesheet = os.path.basename(stylesheet_path) document.settings.stylesheet = '%s/%s' % ( page_files_dir, output_stylesheet ) document.settings.stylesheet_path = None (index_text, pages) = self.translate(document, index_file, page_files_dir, extension) if len(pages) > 0 and not os.path.exists(chunk_files_path): os.mkdir(chunk_files_path) if output_stylesheet: shutil.copy( stylesheet_path , os.path.join(chunk_files_path, output_stylesheet) ) destination.write(index_text) for c in pages.keys(): chunk_file = self.make_chunk_output( destination , os.path.join(chunk_files_path,c + extension) ) chunk_file.write(pages[c])
def __init__(self, document): nodes.NodeVisitor.__init__(self, document) self.settings = settings = document.settings lcode = settings.language_code self.language = languages.get_language(lcode) self.meta = [self.content_type % settings.output_encoding, self.generator % docutils.__version__] self.head_prefix = [] self.html_prolog = [] if settings.xml_declaration: self.head_prefix.append(self.xml_declaration % settings.output_encoding) # encoding not interpolated: self.html_prolog.append(self.xml_declaration) #self.head_prefix.extend([self.doctype, # self.head_prefix_template % (lcode, lcode)]) self.html_prolog.append(self.doctype) self.head = [] #self.meta[:] #stylesheet = utils.get_stylesheet_reference(settings) stylesheet= None self.stylesheet = [] if stylesheet: if settings.embed_stylesheet: stylesheet = utils.get_stylesheet_reference( settings, os.path.join(os.getcwd(), 'dummy')) settings.record_dependencies.add(stylesheet) stylesheet_text = open(stylesheet).read() self.stylesheet = [self.embedded_stylesheet % stylesheet_text] else: self.stylesheet = [self.stylesheet_link % self.encode(stylesheet)] self.body_prefix = ['</head>\n<body>\n'] # document title, subtitle display self.body_pre_docinfo = [] # author, date, etc. self.docinfo = [] self.body = [] self.fragment = [] self.body_suffix = ['</body>\n</html>\n'] self.section_level = 0 self.initial_header_level = int(settings.initial_header_level) # A heterogenous stack used in conjunction with the tree traversal. # Make sure that the pops correspond to the pushes: self.context = [] self.topic_classes = [] self.colspecs = [] self.compact_p = 1 self.compact_simple = None self.compact_field_list = None self.in_docinfo = None self.in_sidebar = None self.title = [] self.subtitle = [] self.header = [] self.footer = [] self.html_head = [self.content_type] # charset not interpolated self.html_title = [] self.html_subtitle = [] self.html_body = [] self.in_document_title = 0 self.in_mailto = 0 self.author_in_authors = None