diff --git a/docs/getting_started.rst b/docs/getting_started.rst index add77c17..09840e8a 100644 --- a/docs/getting_started.rst +++ b/docs/getting_started.rst @@ -172,17 +172,6 @@ Markdown posts should follow this pattern:: This is the content of my super blog post. -Your third option is to write raw html (by ending your file in ``.html``):: - - - - - - -

- This is the content of my super blog post. -

- Note that, aside from the title, none of this metadata is mandatory: if the date is not specified, Pelican will rely on the file's "mtime" timestamp, and the category can be determined by the directory in which the file resides. For diff --git a/docs/settings.rst b/docs/settings.rst index f8ccb8f7..79878755 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -60,9 +60,9 @@ Setting name (default value) What doe here or a single string representing one locale. When providing a list, all the locales will be tried until one works. -`MARKUP` (``('rst', 'md', 'html')``) A list of available markup languages you want +`MARKUP` (``('rst', 'md')``) A list of available markup languages you want to use. For the moment, the only available values - are `rst`, `md` and `html`. + are `rst` and `md`. `MD_EXTENSIONS` (``['codehilite','extra']``) A list of the extensions that the Markdown processor will use. Refer to the extensions chapter in the Python-Markdown documentation for a complete list of diff --git a/pelican/readers.py b/pelican/readers.py index b5a3ba31..42995688 100644 --- a/pelican/readers.py +++ b/pelican/readers.py @@ -147,30 +147,19 @@ class MarkdownReader(Reader): class HtmlReader(Reader): file_extensions = ['html', 'htm'] - # re.DOTALL and .*? (minimal match of an arbitrary number of characters) - # allow multi-line metadata to be matched correctly - _re = re.compile('<\!--([^\:]*):(.*?)-->', re.DOTALL) + _re = re.compile('\<\!\-\-\#\s?[A-z0-9_-]*\s?\:s?[A-z0-9\s_-]*\s?\-\-\>') def read(self, filename): - """Parse content and metadata of (x)HTML files. + """Parse content and metadata of (x)HTML files""" + with open(filename) as content: + metadata = {'title': 'unnamed'} + for i in self._re.findall(content): + key = i.split(':')[0][5:].strip() + value = i.split(':')[-1][:-3].strip() + name = key.lower() + metadata[name] = self.process_metadata(name, value) - Matches for metadata tags in the form - Activated when you add 'html' to your MARKUP settings variable - - """ - content = open(filename) - metadata = {'title': 'unnamed'} - for comment in self._re.findall(content): - key = comment[0].strip().lower() - value = comment[1].strip() - - # remove identation from multi-line metadata - value = re.sub('[ \t]+', ' ', value) - value = re.sub(' ?\n ?', '\n', value) - - metadata[key] = self.process_metadata(key, value) - - return content, metadata + return content, metadata _EXTENSIONS = {} diff --git a/pelican/settings.py b/pelican/settings.py index 4d297332..610d0733 100644 --- a/pelican/settings.py +++ b/pelican/settings.py @@ -21,7 +21,7 @@ _DEFAULT_CONFIG = {'PATH': '.', 'PAGE_EXCLUDES': (), 'THEME': DEFAULT_THEME, 'OUTPUT_PATH': 'output/', - 'MARKUP': ('rst', 'md', 'html'), + 'MARKUP': ('rst', 'md'), 'STATIC_PATHS': ['images', ], 'THEME_STATIC_PATHS': ['static', ], 'FEED_ATOM': 'feeds/all.atom.xml', diff --git a/tests/content/article_with_html_metadata.html b/tests/content/article_with_html_metadata.html deleted file mode 100644 index 89ef4789..00000000 --- a/tests/content/article_with_html_metadata.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - -

This is an article in html with metadata

-

It features very interesting insights.

diff --git a/tests/test_generators.py b/tests/test_generators.py index 0907cc37..8caa7213 100644 --- a/tests/test_generators.py +++ b/tests/test_generators.py @@ -74,8 +74,7 @@ class TestArticlesGenerator(unittest.TestCase): [u'This is an article with category !', 'published', 'yeah', 'article'], [u'This is an article without category !', 'published', 'Default', 'article'], [u'This is an article without category !', 'published', 'TestCategory', 'article'], - [u'This is a super article !', 'published', 'yeah', 'article'], - [u'A great html article with metadata', 'published', u'yeah', 'article'] + [u'This is a super article !', 'published', 'yeah', 'article'] ] self.assertItemsEqual(articles_expected, articles) diff --git a/tests/test_readers.py b/tests/test_readers.py index a9c06861..406027c1 100644 --- a/tests/test_readers.py +++ b/tests/test_readers.py @@ -109,24 +109,3 @@ class MdReaderTest(unittest.TestCase): '

Level2

' self.assertEqual(content, expected) - - -class HtmlReaderTest(unittest.TestCase): - - def test_article_with_metadata(self): - reader = readers.HtmlReader({}) - content, metadata = reader.read(_filename('article_with_html_metadata.html')) - expected = { - 'category': 'yeah', - 'author': u'Alexis Métaireau', - 'title': 'A great html article with metadata', - 'summary': u'Multi-line metadata should be'\ - u' supported\nas well as inline'\ - u' markup.', - 'date': datetime.datetime(2010, 12, 2, 10, 14), - 'tags': ['foo', 'bar', 'foobar'], - 'custom_field': 'http://notmyidea.org', - } - - for key, value in expected.items(): - self.assertEquals(value, metadata[key], key)