Merge
This commit is contained in:
11
simplewiki/mdx_camelcase.py
Normal file → Executable file
11
simplewiki/mdx_camelcase.py
Normal file → Executable file
@@ -67,6 +67,13 @@ Dependencies:
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
import markdown
|
import markdown
|
||||||
|
try:
|
||||||
|
# Markdown 2.1.0 changed from 2.0.3. We try importing the new version first,
|
||||||
|
# but import the 2.0.3 version if it fails
|
||||||
|
from markdown.util import etree
|
||||||
|
except:
|
||||||
|
from markdown import etree
|
||||||
|
|
||||||
|
|
||||||
class CamelCaseExtension(markdown.Extension):
|
class CamelCaseExtension(markdown.Extension):
|
||||||
def __init__(self, configs):
|
def __init__(self, configs):
|
||||||
@@ -95,14 +102,14 @@ class CamelCaseExtension(markdown.Extension):
|
|||||||
class CamelCaseLinks(markdown.inlinepatterns.Pattern):
|
class CamelCaseLinks(markdown.inlinepatterns.Pattern):
|
||||||
def handleMatch(self, m) :
|
def handleMatch(self, m) :
|
||||||
if m.group('escape') == '\\':
|
if m.group('escape') == '\\':
|
||||||
a = markdown.etree.Element('a')#doc.createTextNode(m.group('camelcase'))
|
a = etree.Element('a')#doc.createTextNode(m.group('camelcase'))
|
||||||
else :
|
else :
|
||||||
url = m.group('camelcase')
|
url = m.group('camelcase')
|
||||||
#'%s%s%s'% (self.md.wiki_config['base_url'][0], \
|
#'%s%s%s'% (self.md.wiki_config['base_url'][0], \
|
||||||
#m.group('camelcase'), \
|
#m.group('camelcase'), \
|
||||||
#self.md.wiki_config['end_url'][0])
|
#self.md.wiki_config['end_url'][0])
|
||||||
label = m.group('camelcase').replace('_', ' ')
|
label = m.group('camelcase').replace('_', ' ')
|
||||||
a = markdown.etree.Element('a')
|
a = etree.Element('a')
|
||||||
a.set('href', url)
|
a.set('href', url)
|
||||||
a.text = label
|
a.text = label
|
||||||
a.set('class', 'wikilink')
|
a.set('class', 'wikilink')
|
||||||
|
|||||||
14
simplewiki/mdx_circuit.py
Normal file → Executable file
14
simplewiki/mdx_circuit.py
Normal file → Executable file
@@ -7,12 +7,16 @@ circuit:name becomes the circuit.
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
import simplewiki.settings as settings
|
import simplewiki.settings as settings
|
||||||
import markdown
|
|
||||||
from markdown import etree_loader
|
|
||||||
|
|
||||||
from djangomako.shortcuts import render_to_response, render_to_string
|
from djangomako.shortcuts import render_to_response, render_to_string
|
||||||
|
|
||||||
ElementTree=etree_loader.importETree()
|
import markdown
|
||||||
|
try:
|
||||||
|
# Markdown 2.1.0 changed from 2.0.3. We try importing the new version first,
|
||||||
|
# but import the 2.0.3 version if it fails
|
||||||
|
from markdown.util import etree
|
||||||
|
except:
|
||||||
|
from markdown import etree
|
||||||
|
|
||||||
class CircuitExtension(markdown.Extension):
|
class CircuitExtension(markdown.Extension):
|
||||||
def __init__(self, configs):
|
def __init__(self, configs):
|
||||||
@@ -32,9 +36,9 @@ class CircuitLink(markdown.inlinepatterns.Pattern):
|
|||||||
def handleMatch(self, m):
|
def handleMatch(self, m):
|
||||||
name = m.group('name')
|
name = m.group('name')
|
||||||
if not name.isalnum():
|
if not name.isalnum():
|
||||||
return ElementTree.fromstring("<div>Circuit name must be alphanumeric</div>")
|
return etree.fromstring("<div>Circuit name must be alphanumeric</div>")
|
||||||
|
|
||||||
return ElementTree.fromstring(render_to_string('show_circuit.html', {'name':name}))
|
return etree.fromstring(render_to_string('show_circuit.html', {'name':name}))
|
||||||
|
|
||||||
|
|
||||||
def makeExtension(configs=None) :
|
def makeExtension(configs=None) :
|
||||||
|
|||||||
10
simplewiki/mdx_image.py
Normal file → Executable file
10
simplewiki/mdx_image.py
Normal file → Executable file
@@ -16,7 +16,15 @@ Requires Python-Markdown 1.6+
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
import simplewiki.settings as settings
|
import simplewiki.settings as settings
|
||||||
|
|
||||||
import markdown
|
import markdown
|
||||||
|
try:
|
||||||
|
# Markdown 2.1.0 changed from 2.0.3. We try importing the new version first,
|
||||||
|
# but import the 2.0.3 version if it fails
|
||||||
|
from markdown.util import etree
|
||||||
|
except:
|
||||||
|
from markdown import etree
|
||||||
|
|
||||||
|
|
||||||
class ImageExtension(markdown.Extension):
|
class ImageExtension(markdown.Extension):
|
||||||
def __init__(self, configs):
|
def __init__(self, configs):
|
||||||
@@ -35,7 +43,7 @@ class ImageExtension(markdown.Extension):
|
|||||||
|
|
||||||
class ImageLink(markdown.inlinepatterns.Pattern):
|
class ImageLink(markdown.inlinepatterns.Pattern):
|
||||||
def handleMatch(self, m):
|
def handleMatch(self, m):
|
||||||
img = markdown.etree.Element('img')
|
img = etree.Element('img')
|
||||||
proto = m.group('proto') or "http://"
|
proto = m.group('proto') or "http://"
|
||||||
domain = m.group('domain')
|
domain = m.group('domain')
|
||||||
path = m.group('path')
|
path = m.group('path')
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
# Source: https://github.com/mayoff/python-markdown-mathjax
|
# Source: https://github.com/mayoff/python-markdown-mathjax
|
||||||
|
|
||||||
import markdown
|
import markdown
|
||||||
|
try:
|
||||||
|
# Markdown 2.1.0 changed from 2.0.3. We try importing the new version first,
|
||||||
|
# but import the 2.0.3 version if it fails
|
||||||
|
from markdown.util import etree, AtomicString
|
||||||
|
except:
|
||||||
|
from markdown import etree, AtomicString
|
||||||
|
|
||||||
class MathJaxPattern(markdown.inlinepatterns.Pattern):
|
class MathJaxPattern(markdown.inlinepatterns.Pattern):
|
||||||
|
|
||||||
@@ -8,7 +14,9 @@ class MathJaxPattern(markdown.inlinepatterns.Pattern):
|
|||||||
markdown.inlinepatterns.Pattern.__init__(self, r'(?<!\\)(\$\$?)(.+?)\2')
|
markdown.inlinepatterns.Pattern.__init__(self, r'(?<!\\)(\$\$?)(.+?)\2')
|
||||||
|
|
||||||
def handleMatch(self, m):
|
def handleMatch(self, m):
|
||||||
return markdown.AtomicString(m.group(2) + m.group(3) + m.group(2))
|
el = etree.Element('span')
|
||||||
|
el.text = AtomicString(m.group(2) + m.group(3) + m.group(2))
|
||||||
|
return el
|
||||||
|
|
||||||
class MathJaxExtension(markdown.Extension):
|
class MathJaxExtension(markdown.Extension):
|
||||||
def extendMarkdown(self, md, md_globals):
|
def extendMarkdown(self, md, md_globals):
|
||||||
|
|||||||
17
simplewiki/mdx_video.py
Normal file → Executable file
17
simplewiki/mdx_video.py
Normal file → Executable file
@@ -128,6 +128,13 @@ u'<p><object data="http://www.gametrailers.com/remote_wrap.php?mid=58079" height
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import markdown
|
import markdown
|
||||||
|
try:
|
||||||
|
# Markdown 2.1.0 changed from 2.0.3. We try importing the new version first,
|
||||||
|
# but import the 2.0.3 version if it fails
|
||||||
|
from markdown.util import etree
|
||||||
|
except:
|
||||||
|
from markdown import etree
|
||||||
|
|
||||||
|
|
||||||
version = "0.1.6"
|
version = "0.1.6"
|
||||||
|
|
||||||
@@ -229,7 +236,7 @@ class Yahoo(markdown.inlinepatterns.Pattern):
|
|||||||
width = self.ext.config['yahoo_width'][0]
|
width = self.ext.config['yahoo_width'][0]
|
||||||
height = self.ext.config['yahoo_height'][0]
|
height = self.ext.config['yahoo_height'][0]
|
||||||
obj = flash_object(url, width, height)
|
obj = flash_object(url, width, height)
|
||||||
param = markdown.etree.Element('param')
|
param = etree.Element('param')
|
||||||
param.set('name', 'flashVars')
|
param.set('name', 'flashVars')
|
||||||
param.set('value', "id=%s&vid=%s" % (m.group('yahooid'),
|
param.set('value', "id=%s&vid=%s" % (m.group('yahooid'),
|
||||||
m.group('yahoovid')))
|
m.group('yahoovid')))
|
||||||
@@ -244,20 +251,20 @@ class Youtube(markdown.inlinepatterns.Pattern):
|
|||||||
return flash_object(url, width, height)
|
return flash_object(url, width, height)
|
||||||
|
|
||||||
def flash_object(url, width, height):
|
def flash_object(url, width, height):
|
||||||
obj = markdown.etree.Element('object')
|
obj = etree.Element('object')
|
||||||
obj.set('type', 'application/x-shockwave-flash')
|
obj.set('type', 'application/x-shockwave-flash')
|
||||||
obj.set('width', width)
|
obj.set('width', width)
|
||||||
obj.set('height', height)
|
obj.set('height', height)
|
||||||
obj.set('data', url)
|
obj.set('data', url)
|
||||||
param = markdown.etree.Element('param')
|
param = etree.Element('param')
|
||||||
param.set('name', 'movie')
|
param.set('name', 'movie')
|
||||||
param.set('value', url)
|
param.set('value', url)
|
||||||
obj.append(param)
|
obj.append(param)
|
||||||
param = markdown.etree.Element('param')
|
param = etree.Element('param')
|
||||||
param.set('name', 'allowFullScreen')
|
param.set('name', 'allowFullScreen')
|
||||||
param.set('value', 'true')
|
param.set('value', 'true')
|
||||||
obj.append(param)
|
obj.append(param)
|
||||||
#param = markdown.etree.Element('param')
|
#param = etree.Element('param')
|
||||||
#param.set('name', 'allowScriptAccess')
|
#param.set('name', 'allowScriptAccess')
|
||||||
#param.set('value', 'sameDomain')
|
#param.set('value', 'sameDomain')
|
||||||
#obj.append(param)
|
#obj.append(param)
|
||||||
|
|||||||
Reference in New Issue
Block a user