Merge pull request #48 from pfultz2/master

Transform files with other endings besides .md
This commit is contained in:
Eric Holscher 2016-06-28 12:50:22 -07:00 committed by GitHub
commit e81b0a0de1
4 changed files with 60 additions and 3 deletions

View file

@ -26,6 +26,7 @@ class AutoStructify(transforms.Transform):
'enable_eval_rst': True,
'enable_math': True,
'enable_inline_math': True,
'commonmark_suffixes': ['.md'],
'url_resolver': lambda x: x,
}
@ -313,10 +314,7 @@ class AutoStructify(transforms.Transform):
def apply(self):
"""Apply the transformation by configuration."""
# only transform markdowns
source = self.document['source']
if not source.endswith('.md'):
return
self.reporter = self.document.reporter
self.reporter.info('AutoStructify: %s' % source)
@ -328,6 +326,11 @@ class AutoStructify(transforms.Transform):
except:
self.reporter.warning('recommonmark_config not setted,'
' proceed default setting')
# only transform markdowns
if not source.endswith(tuple(config['commonmark_suffixes'])):
return
self.url_resolver = config['url_resolver']
assert callable(self.url_resolver)

View file

@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
from recommonmark.parser import CommonMarkParser
from recommonmark.transform import AutoStructify
templates_path = ['_templates']
source_suffix = '.markdown'
source_parsers = { '.markdown': CommonMarkParser }
master_doc = 'index'
project = u'sphinxproj'
copyright = u'2015, rtfd'
author = u'rtfd'
version = '0.1'
release = '0.1'
language = None
exclude_patterns = ['_build']
highlight_language = 'python'
pygments_style = 'sphinx'
todo_include_todos = False
html_theme = 'alabaster'
html_static_path = ['_static']
htmlhelp_basename = 'sphinxproj'
def setup(app):
app.add_config_value('recommonmark_config', {
'enable_eval_rst': True,
'commonmark_suffixes': ['.markdown', '.hpp'],
}, True)
app.add_transform(AutoStructify)

View file

@ -0,0 +1,15 @@
Header
======
A paragraph
```eval_rst
+-----+------+
| abc | data |
+=====+======+
| a | 1 |
+-----+------+
```
Another paragraph

View file

@ -46,3 +46,12 @@ class IndentedCodeTests(SphinxIntegrationTests):
'_build/text/index.html',
'<div class="highlight">'
)
class CustomExtensionTests(SphinxIntegrationTests):
def test_integration(self):
self._run_test(
'sphinx_custom_md',
'_build/text/index.html',
'</table>'
)