Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _build(self,mo,element_store, environ):
try:
abbr, title = mo.group(1).split(":", 1)
except ValueError:
abbr = mo.group(1)
title = None
return creoleparser.core.bldr.tag.__getattr__('abbr')(
creoleparser.core.fragmentize(abbr,
self.child_elements,
element_store, environ), title=title)
def _build(self, mo, element_store, environ):
try:
abbr, title = mo.group(1).split(":", 1)
except ValueError:
abbr = mo.group(1)
title = None
return creoleparser.core.bldr.tag.__getattr__('abbr')(
creoleparser.core.fragmentize(abbr,
self.child_elements,
element_store, environ), title=title)
def _build(self,mo,element_store, environ):
try:
abbr, title = mo.group(1).split(":", 1)
except ValueError:
abbr = mo.group(1)
title = None
return creoleparser.core.bldr.tag.__getattr__('abbr')(
creoleparser.core.fragmentize(abbr,
self.child_elements,
element_store, environ), title=title)
# http://www.wikicreole.org/wiki/AbbreviationAndAcronyms
def __init__(self):
super(AbbrAcronym,self).__init__('abbr', ['^','^'])
def _build(self,mo,element_store, environ):
try:
abbr, title = mo.group(1).split(":", 1)
except ValueError:
abbr = mo.group(1)
title = None
return creoleparser.core.bldr.tag.__getattr__('abbr')(
creoleparser.core.fragmentize(abbr,
self.child_elements,
element_store, environ), title=title)
class HTMLEntity(creoleparser.elements.InlineElement):
# Allows HTML elements to be passed through
def __init__(self):
super(HTMLEntity, self).__init__('span', ['&',';'])
self.regexp = re.compile(self.re_string())
def re_string(self):
return '&([A-Za-z]\w{1,24}|#\d{2,7}|#[Xx][0-9a-zA-Z]{2,6});'
def _build(self,mo,element_store, environ):
content = mo.group(1)
return creoleparser.core.bldr.tag.__getattr__('span')(Markup('&' + content + ';'))
class CodeBlock(creoleparser.elements.BlockElement):
"""
A block of code that gets syntax-highlited
if commit:
instance.save()
return instance
return _MarkupContentMixin
# custom creoleparser Parser class
from genshi.core import Markup
brushre = r"[\w\-#]+"
class AbbrAcronym(creoleparser.elements.InlineElement):
# handles a subset of the abbreviation/acronym extension
# http://www.wikicreole.org/wiki/AbbreviationAndAcronyms
def __init__(self):
super(AbbrAcronym, self).__init__('abbr', ['^', '^'])
def _build(self, mo, element_store, environ):
try:
abbr, title = mo.group(1).split(":", 1)
except ValueError:
abbr = mo.group(1)
title = None
return creoleparser.core.bldr.tag.__getattr__('abbr')(
creoleparser.core.fragmentize(abbr,
self.child_elements,
element_store, environ), title=title)
def __init__(self):
super(AbbrAcronym, self).__init__('abbr', ['^', '^'])
def _build(self, mo, element_store, environ):
try:
abbr, title = mo.group(1).split(":", 1)
except ValueError:
abbr = mo.group(1)
title = None
return creoleparser.core.bldr.tag.__getattr__('abbr')(
creoleparser.core.fragmentize(abbr,
self.child_elements,
element_store, environ), title=title)
class HTMLEntity(creoleparser.elements.InlineElement):
# Allows HTML elements to be passed through
def __init__(self):
super(HTMLEntity, self).__init__('span', ['&', ';'])
self.regexp = re.compile(self.re_string())
def re_string(self):
return '&([A-Za-z]\w{1,24}|#\d{2,7}|#[Xx][0-9a-zA-Z]{2,6});'
def _build(self, mo, element_store, environ):
content = mo.group(1)
return creoleparser.core.bldr.tag.__getattr__('span')(Markup('&' + content + ';'))
class CodeBlock(creoleparser.elements.BlockElement):
"""
A block of code that gets syntax-highlited
defaults = {}
class Meta:
unique_together = (('offering', 'person'), )
# custom creoleparser Parser class:
import genshi
from brush_map import brush_code
from genshi.core import Markup
brushre = r"[\w\-#]+"
brush_class_re = re.compile(r'brush:\s+(' + brushre + ')')
class AbbrAcronym(creoleparser.elements.InlineElement):
# handles a subset of the abbreviation/acronym extension
# http://www.wikicreole.org/wiki/AbbreviationAndAcronyms
def __init__(self):
super(AbbrAcronym,self).__init__('abbr', ['^','^'])
def _build(self,mo,element_store, environ):
try:
abbr, title = mo.group(1).split(":", 1)
except ValueError:
abbr = mo.group(1)
title = None
return creoleparser.core.bldr.tag.__getattr__('abbr')(
creoleparser.core.fragmentize(abbr,
self.child_elements,
element_store, environ), title=title)
def _build(self, mo, element_store, environ):
try:
abbr, title = mo.group(1).split(":", 1)
except ValueError:
abbr = mo.group(1)
title = None
return creoleparser.core.bldr.tag.__getattr__('abbr')(
creoleparser.core.fragmentize(abbr,
self.child_elements,
element_store, environ), title=title)
def _pagelist(offering, pageversion, macro, environ, prefix=None):
# all pages [with the given prefix] for this offering
if prefix:
pages = Page.objects.filter(offering=offering, label__startswith=prefix)
else:
pages = Page.objects.filter(offering=offering)
# ... except this page (if known)
if pageversion:
pages = pages.exclude(id=pageversion.page_id)
elements = []
for p in pages:
link = creoleparser.core.bldr.tag.__getattr__('a')(p.current_version().title or p.label, href=p.label)
li = creoleparser.core.bldr.tag.__getattr__('li')(link)
elements.append(li)
return creoleparser.core.bldr.tag.__getattr__('ul')(elements, **{'class': 'filelist'})
def _activitylink(offering, macro, environ, *act_name):
act = _find_activity(offering, macro['arg_string'])
attrs = {}
if isinstance(act, Activity):
text = act.name
attrs['href'] = act.get_absolute_url()
else:
# error
text = act
attrs['class'] = 'empty'
return creoleparser.core.bldr.tag.__getattr__('a')(text, **attrs)