Beispiel #1
0
 def format_content(cls, path, content, convert=True, existing_data=None):
     ext = os.path.splitext(path)[1]
     convert_to_markdown = ext == ".md" and convert is not False
     content = utils.clean_html(content, convert_to_markdown=convert_to_markdown)
     # Preserve any existing frontmatter.
     if existing_data:
         if formats.Format.has_front_matter(existing_data):
             content = formats.Format.update(existing_data, body=content)
     return content
Beispiel #2
0
 def format_content(cls, path, content, convert=True, existing_data=None):
     ext = os.path.splitext(path)[1]
     convert_to_markdown = ext == '.md' and convert is not False
     content = utils.clean_html(content,
                                convert_to_markdown=convert_to_markdown)
     # Preserve any existing frontmatter.
     if existing_data:
         if formats.Format.has_front_matter(existing_data):
             content = formats.Format.update(existing_data, body=content)
     return content
Beispiel #3
0
 def format_content(cls, path, content, convert=True, existing_data=None):
     ext = os.path.splitext(path)[1]
     convert_to_markdown = ext == '.md' and convert is not False
     content = utils.clean_html(
         content, convert_to_markdown=convert_to_markdown)
     # Preserve any existing frontmatter, return new content.
     if existing_data:
         if doc_front_matter.BOUNDARY_REGEX.search(existing_data):
             front_matter, old_content = doc_front_matter.DocumentFrontMatter.split_front_matter(
                 existing_data)
             return document_format.DocumentFormat.format_doc(front_matter, content)
     return content
Beispiel #4
0
 def format_content(cls, path, content, convert=True, existing_data=None):
     ext = os.path.splitext(path)[1]
     convert_to_markdown = ext == '.md' and convert is not False
     content = utils.clean_html(
         content, convert_to_markdown=convert_to_markdown)
     # Preserve any existing frontmatter.
     if existing_data:
         if doc_front_matter.BOUNDARY_REGEX.search(existing_data):
             front_matter, content = doc_front_matter.DocumentFrontMatter.split_front_matter(
                 existing_data)
             return document_format.DocumentFormat.format_doc(front_matter, content)
     return content
Beispiel #5
0
 def _parse_item(self, item):
     item_id = item.pop('id')
     ext = 'md' if self.config.markdown else 'html'
     basename = '{}.{}'.format(item_id, ext)
     body = item.pop('content').encode('utf-8')
     fields = item
     # Formatted like: 2011-05-20T11:45:23-07:00
     published = fields['published'][:-6]
     published_dt = datetime.datetime.strptime(published, '%Y-%m-%dT%H:%M:%S')
     fields['$date'] = published_dt
     if 'title' in fields:
         fields['$title'] = fields.pop('title')
     if self.config.markdown:
         body = utils.clean_html(body, convert_to_markdown=True)
     return fields, body, basename
Beispiel #6
0
 def _parse_item(self, item):
     item_id = item.pop('id')
     ext = 'md' if self.config.markdown else 'html'
     basename = '{}.{}'.format(item_id, ext)
     body = item.pop('content').encode('utf-8')
     fields = item
     # Formatted like: 2011-05-20T11:45:23-07:00
     published = fields['published'][:-6]
     published_dt = datetime.datetime.strptime(published, '%Y-%m-%dT%H:%M:%S')
     fields['$date'] = published_dt
     if 'title' in fields:
         fields['$title'] = fields.pop('title')
     if self.config.markdown:
         body = utils.clean_html(body, convert_to_markdown=True)
     return fields, body, basename