use markdown import and content type only when available
This commit is contained in:
parent
8c09a0e73d
commit
a13784e93e
1 changed files with 8 additions and 3 deletions
9
util.py
9
util.py
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2012 Helmut Merz helmutm@cy55.de
|
# Copyright (c) 2017 Helmut Merz helmutm@cy55.de
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -31,7 +31,10 @@ from zope.app.renderer.interfaces import ISource, IHTMLRenderer
|
||||||
from zope.app.renderer import SourceFactory
|
from zope.app.renderer import SourceFactory
|
||||||
from zope.schema import vocabulary
|
from zope.schema import vocabulary
|
||||||
from zope import thread
|
from zope import thread
|
||||||
|
try:
|
||||||
import markdown
|
import markdown
|
||||||
|
except ImportError:
|
||||||
|
markdown = None
|
||||||
|
|
||||||
import cybertools
|
import cybertools
|
||||||
from loops.browser.util import html_quote
|
from loops.browser.util import html_quote
|
||||||
|
@ -40,7 +43,6 @@ _ = MessageFactory('loops')
|
||||||
|
|
||||||
|
|
||||||
renderingFactories = {
|
renderingFactories = {
|
||||||
'text/markdown': 'loops.util.markdown',
|
|
||||||
'text/plain': 'zope.source.plaintext',
|
'text/plain': 'zope.source.plaintext',
|
||||||
'text/stx': 'zope.source.stx',
|
'text/stx': 'zope.source.stx',
|
||||||
'text/structured': 'zope.source.stx',
|
'text/structured': 'zope.source.stx',
|
||||||
|
@ -48,6 +50,9 @@ renderingFactories = {
|
||||||
'text/restructured': 'zope.source.rest',
|
'text/restructured': 'zope.source.rest',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if markdown:
|
||||||
|
renderingFactories['text/markdown'] = 'loops.util.markdown'
|
||||||
|
|
||||||
class IMarkdownSource(ISource):
|
class IMarkdownSource(ISource):
|
||||||
"""Marker interface for a restructured text source. Note that an
|
"""Marker interface for a restructured text source. Note that an
|
||||||
implementation of this interface should always derive from unicode or
|
implementation of this interface should always derive from unicode or
|
||||||
|
|
Loading…
Add table
Reference in a new issue