How to use the creoleparser.elements function in Creoleparser

To help you get started, we’ve selected a few Creoleparser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sfu-fas / coursys / courselib / markup.py View on Github external
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)
github sfu-fas / coursys / pages / models.py View on Github external
if self.offering:
            nb_macros = {
                     'duedate': duedate_macro,
                     'duedatetime': duedatetime_macro,
                     'pagelist': pagelist_macro,
                     'activitylink': activitylink_macro,
                     }
        else:
            nb_macros = None
        CreoleBase = creoleparser.creole11_base(non_bodied_macros=nb_macros, add_heading_ids='h-')

        class CreoleDialect(CreoleBase):
            codeblock = CodeBlock()
            abbracronym = AbbrAcronym()
            htmlentity = HTMLEntity()
            strikethrough = creoleparser.elements.InlineElement('del','--')
            
            def __init__(self):
                self.custom_elements = [self.abbracronym, self.strikethrough]
                super(CreoleDialect,self).__init__()
                
            @property
            def inline_elements(self):
                inline = super(CreoleDialect, self).inline_elements
                inline.append(self.abbracronym)
                inline.append(self.strikethrough)
                inline.append(self.htmlentity)
                return inline

            @property
            def block_elements(self):
                blocks = super(CreoleDialect, self).block_elements