def extendMarkdown(self, md, md_globals): def handle_match_inline(m): node = etree.Element('script') node.set('type', 'math/tex') node.text = AtomicString(m.group(3)) return node def handle_match(m): node = etree.Element('script') node.set('type', 'math/tex; mode=display') if '\\begin' in m.group(2): node.text = AtomicString(m.group(2) + m.group(4) + m.group(5)) else: node.text = AtomicString(m.group(3)) return node inlinemathpatterns = ( # Inline math with `$...$` Pattern(r'(?<!\\|\$)(\$)([^\$]+)(\$)'), # Inline math with `\(...\)` Pattern(r'(?<!\\)(\\\()(.+?)(\\\))') ) mathpatterns = ( # Display style math with `$$...$$` Pattern(r'(?<!\\)(\$\$)([^\$]+)(\$\$)'), # Display style math with `\[...\]` Pattern(r'(?<!\\)(\\\[)(.+?)(\\\])'), Pattern(r'(?<!\\)(\\begin{([a-z]+?\*?)})(.+?)(\\end{\3})') ) for i, pattern in enumerate(inlinemathpatterns): pattern.handleMatch = handle_match_inline md.inlinePatterns.add('math-inline-%d' % i, pattern, '<escape') for i, pattern in enumerate(mathpatterns): pattern.handleMatch = handle_match md.inlinePatterns.add('math-%d' % i, pattern, '<escape')
def __init__(self, markdown_instance=None, **kwargs): MooseMarkdownCommon.__init__(self, **kwargs) regex = r'^!chart\s+(?P<template>{})(?:$|\s+)(?P<settings>.*)'.format(self.TEMPLATE) Pattern.__init__(self, regex, markdown_instance) self._csv = dict() # CSV DataFrame cache self._count = 0 self._status = None
def __init__(self, pattern, md): """Initialize.""" Pattern.__init__(self, pattern, md) if not util.MD3: self.md = md self.get_hl_settings = False
def __init__(self, pattern, wrap, script, md): """Initialize.""" self.script = script self.wrap = wrap[0] + '%s' + wrap[1] Pattern.__init__(self, pattern) self.markdown = md
def __init__ (self, start_end=None, groups=None): if start_end is not None: self.start_end = start_end if groups is not None: self.groups = groups pattern = r'(?<!\\)(%s)(.+?)(?<!\\)(%s)' % (self.start_end) Pattern.__init__(self, pattern)
def __init__(self, markdown_instance=None, **kwargs): MooseMarkdownCommon.__init__(self, **kwargs) Pattern.__init__(self, self.RE, markdown_instance) # The root/repo settings self._repo = kwargs.pop('repo') self._branch = kwargs.pop('branch')
def __init__(self, pattern, md, user, repo, provider, labels): """Initialize.""" self.user = user self.repo = repo self.labels = labels self.provider = provider if provider in PROVIDER_INFO else '' Pattern.__init__(self, pattern, md)
def __init__(self, markdown_instance=None, **kwargs): MooseCommonExtension.__init__(self, **kwargs) Pattern.__init__(self, self.RE, markdown_instance) # Valid settings for MOOSE specific documentation features # All other markdown 'attributes' will be treated as HTML # style settings for the figure tag. self._settings = {'caption': None}
def __init__(self, markdown_instance=None, **kwargs): MooseMarkdownCommon.__init__(self, **kwargs) regex = r'^!chart\s+(?P<template>{})(?:$|\s+)(?P<settings>.*)'.format( self.TEMPLATE) Pattern.__init__(self, regex, markdown_instance) self._csv = dict() # CSV DataFrame cache self._count = 0 self._status = None
def __init__(self, markdown_instance=None, **kwargs): MooseCommonExtension.__init__(self, **kwargs) Pattern.__init__(self, self.RE, markdown_instance) # Valid settings for MOOSE specific documentation features # All other markdown 'attributes' will be treated as HTML # style settings for the figure tag. self._settings = {"caption": None}
def __init__(self, regex, markdown_instance=None, syntax=None, **kwargs): MooseMarkdownCommon.__init__(self, **kwargs) Pattern.__init__(self, regex, markdown_instance) self._syntax = syntax # Error if the syntax was not supplied if not isinstance(self._syntax, dict): LOG.error("A dictionary of MooseApplicationSyntax objects must be supplied.")
def __init__(self, markdown_instance=None, **kwargs): MooseCommonExtension.__init__(self, **kwargs) Pattern.__init__(self, self.RE, markdown_instance) # Load the yaml data containing package information self.package = MooseDocs.yaml_load("packages.yml") # The default settings self._settings = {'arch': None, 'return': None}
def __init__(self, root=None, **kwargs): MooseCommonExtension.__init__(self) Pattern.__init__(self, self.RE, **kwargs) self._root = os.path.join(root, 'docs/media') # Valid settings for MOOS specific documentation features # All other markdown 'attributes' will be treated as HTML # style settings self._settings = {'caption': None}
def __init__(self, root=None, **kwargs): MooseCommonExtension.__init__(self) Pattern.__init__(self, self.RE, **kwargs) self._root = os.path.join(root, 'docs/media') # Valid settings for MOOS specific documentation features # All other markdown 'attributes' will be treated as HTML # style settings self._settings = {'caption' : None}
def __init__(self, markdown_instance=None, **kwargs): MooseCommonExtension.__init__(self, **kwargs) Pattern.__init__(self, self.RE, markdown_instance) # Load the yaml data containing package information self.package = MooseDocs.yaml_load("packages.yml") # The default settings self._settings = {'arch' : None, 'return' : None}
def __init__(self, pattern, md): self.emoji_index = {} self._append_to_index(emoji1_db) self._append_to_index(c2c_waypoints) self._append_to_index(c2c_activities) self.md = md Pattern.__init__(self, pattern)
def __init__(self, pattern, config): """Initialize.""" # Generic setup self.generic = config.get('generic', False) wrap = config.get('tex_inline_wrap', ["\\(", "\\)"]) self.wrap = wrap[0] + '%s' + wrap[1] # Default setup self.preview = config.get('preview', True) Pattern.__init__(self, pattern)
def __init__(self, pattern, index, generator, remove_var_sel, alt, title, options, md): """Initialize.""" self._set_index(index) self.markdown = md self.unicode_alt = alt in UNICODE_ALT self.encoded_alt = alt == UNICODE_ENTITY self.remove_var_sel = remove_var_sel self.title = title if title in VALID_TITLE else NO_TITLE self.generator = generator self.options = options Pattern.__init__(self, pattern)
def __init__(self, regex, markdown_instance=None, yaml=None, syntax=None, **kwargs): MooseCommonExtension.__init__(self, **kwargs) Pattern.__init__(self, regex, markdown_instance) self._yaml = yaml self._syntax = syntax # Error if the YAML was not supplied if not isinstance(self._yaml, utils.MooseYaml): log.error("The MooseYaml object must be supplied to constructor of MooseObjectClassDescription.") # Error if the syntax was not supplied if not isinstance(self._syntax, dict): log.error("A dictionary of MooseApplicationSyntax objects must be supplied.")
def __init__(self, pattern, config, md): """Initialize.""" title = config['title'] alt = config['alt'] self._set_index(config["emoji_index"]) self.markdown = md self.unicode_alt = alt in UNICODE_ALT self.encoded_alt = alt == UNICODE_ENTITY self.remove_var_sel = config['remove_variation_selector'] self.title = title if title in VALID_TITLE else NO_TITLE self.generator = config['emoji_generator'] self.options = config['options'] Pattern.__init__(self, pattern)
def __init__(self, media_dir=None, root=None, **kwargs): MooseCommonExtension.__init__(self) Pattern.__init__(self, self.RE, **kwargs) self._root = os.path.join(root, media_dir) # The default settings self._settings = { 'alt': None, 'caption': None, 'width': None, 'height': None, 'float': None, 'align': 'left' }
def __init__(self, pattern, markdown_instance=None, repo=None, **kwargs): MooseCommonExtension.__init__(self, **kwargs) Pattern.__init__(self, pattern, markdown_instance) # The root/repo settings self._repo = repo # The default settings self._settings['strip_header'] = True self._settings['repo_link'] = True self._settings['label'] = True self._settings['language'] = 'text' self._settings['strip-extra-newlines'] = False self._settings['prefix'] = '' self._settings['suffix'] = '' self._settings['indent'] = 0
def __init__(self, pattern, md, user, repo, provider, labels, external=False): """Initialize.""" self.user = user self.repo = repo self.labels = labels self.provider = provider self.external = external Pattern.__init__(self, pattern, md)
def extendMarkdown(self, md, md_globals): def _wrap_node(node, preview_text, wrapper_tag): if not self.getConfig('add_preview'): return node preview = etree.Element('span', {'class': 'MathJax_Preview'}) preview.text = AtomicString(preview_text) wrapper = etree.Element(wrapper_tag) wrapper.extend([preview, node]) return wrapper def handle_match_inline(m): node = etree.Element('script') node.set('type', self._get_content_type()) node.text = AtomicString(m.group(3)) return _wrap_node(node, ''.join(m.group(2, 3, 4)), 'span') def handle_match(m): node = etree.Element('script') node.set('type', '%s; mode=display' % self._get_content_type()) if '\\begin' in m.group(2): node.text = AtomicString(''.join(m.group(2, 4, 5))) return _wrap_node(node, ''.join(m.group(1, 2, 4, 5, 6)), 'div') else: node.text = AtomicString(m.group(3)) return _wrap_node(node, ''.join(m.group(2, 3, 4)), 'div') inlinemathpatterns = ( Pattern(r'(?<!\\|\$)(\$)([^\$]+)(\$)'), # $...$ Pattern(r'(?<!\\)(\\\()(.+?)(\\\))') # \(...\) ) mathpatterns = ( Pattern(r'(?<!\\)(\$\$)([^\$]+)(\$\$)'), # $$...$$ Pattern(r'(?<!\\)(\\\[)(.+?)(\\\])'), # \[...\] Pattern(r'(?<!\\)(\\begin{([a-z]+?\*?)})(.+?)(\\end{\3})') ) if not self.getConfig('enable_dollar_delimiter'): inlinemathpatterns = inlinemathpatterns[1:] if self.getConfig('use_asciimath'): mathpatterns = mathpatterns[:-1] # \begin...\end is TeX only for i, pattern in enumerate(mathpatterns): pattern.handleMatch = handle_match md.inlinePatterns.add('math-%d' % i, pattern, '<escape') for i, pattern in enumerate(inlinemathpatterns): pattern.handleMatch = handle_match_inline md.inlinePatterns.add('math-inline-%d' % i, pattern, '<escape') if self.getConfig('enable_dollar_delimiter'): md.ESCAPED_CHARS.append('$')
def __init__(self, regex, config, language=None): Pattern.__init__(self, regex) #super(Pattern, self).__init__(regex) # This fails # Set the language self._language = language # The root directory self._config = config # The default settings self._settings = {'strip_header':True, 'repo_link':True, 'label':True, 'overflow-y':'scroll', 'max-height':'500px', 'strip-extra-newlines':False}
def extendMarkdown(self, md, md_globals): def _wrap_node(node, preview_text, wrapper_tag): if not self.getConfig("add_preview"): return node preview = etree.Element("span", {"class": "MathJax_Preview"}) preview.text = AtomicString(preview_text) wrapper = etree.Element(wrapper_tag) wrapper.extend([preview, node]) return wrapper def handle_match_inline(m): node = etree.Element("script") node.set("type", self._get_content_type()) node.text = AtomicString(m.group(3)) return _wrap_node(node, "".join(m.group(2, 3, 4)), "span") def handle_match(m): node = etree.Element("script") node.set("type", "%s; mode=display" % self._get_content_type()) if "\\begin" in m.group(2): node.text = AtomicString("".join(m.group(2, 4, 5))) return _wrap_node(node, "".join(m.group(1, 2, 4, 5, 6)), "div") else: node.text = AtomicString(m.group(3)) return _wrap_node(node, "".join(m.group(2, 3, 4)), "div") inlinemathpatterns = ( Pattern(r"(?<!\\|\$)(\$)([^\$]+)(\$)"), # $...$ Pattern(r"(?<!\\)(\\\()(.+?)(\\\))"), # \(...\) ) mathpatterns = ( Pattern(r"(?<!\\)(\$\$)([^\$]+)(\$\$)"), # $$...$$ Pattern(r"(?<!\\)(\\\[)(.+?)(\\\])"), # \[...\] Pattern(r"(?<!\\)(\\begin{([a-z]+?\*?)})(.+?)(\\end{\3})"), ) if not self.getConfig("enable_dollar_delimiter"): inlinemathpatterns = inlinemathpatterns[1:] for i, pattern in enumerate(mathpatterns): pattern.handleMatch = handle_match md.inlinePatterns.add("math-%d" % i, pattern, "<escape") for i, pattern in enumerate(inlinemathpatterns): pattern.handleMatch = handle_match_inline md.inlinePatterns.add("math-inline-%d" % i, pattern, "<escape") if self.getConfig("enable_dollar_delimiter"): md.ESCAPED_CHARS.append("$")
def __init__(self, regex, yaml=None, syntax=None, **kwargs): MooseCommonExtension.__init__(self) Pattern.__init__(self, regex, **kwargs) self._yaml = yaml self._syntax = syntax # Error if the YAML was not supplied if not isinstance(self._yaml, utils.MooseYaml): log.error( "The MooseYaml object must be supplied to constructor of MooseObjectClassDescription." ) # Error if the syntax was not supplied if not isinstance(self._syntax, dict): log.error( "A dictionary of MooseApplicationSyntax objects must be supplied." )
def __init__(self, pattern, markdown_instance=None, repo=None, **kwargs): MooseCommonExtension.__init__(self, **kwargs) Pattern.__init__(self, pattern, markdown_instance) # The root/repo settings self._repo = repo # The default settings self._settings = {'strip_header' : True, 'repo_link' : True, 'label' : True, 'method' : True, 'language' : 'text', 'block' : True, 'strip-extra-newlines': False} # Applying overflow/max-height CSS to <div> and <code> causes multiple scroll bars # do not let code float, the div will do this for us self._invalid_css = { 'div' : ['overflow-y', 'overflow-x', 'max-height'], 'code' : ['float'] }
def __init__(self, pattern, language=None, repo=None, root=None, **kwargs): Pattern.__init__(self, pattern, **kwargs) # Set the language self._language = language # The root/repo settings self._root = root self._repo = repo # The default settings self._settings = { 'strip_header': True, 'repo_link': True, 'label': True, 'method': True, 'block': True, 'overflow-y': 'scroll', 'max-height': '500px', 'strip-extra-newlines': False }
def __init__(self, pattern, language=None, repo=None, root=None, **kwargs): Pattern.__init__(self, pattern, **kwargs) # Set the language self._language = language # The root/repo settings self._root = root self._repo = repo # The default settings self._settings = { 'strip_header': True, 'repo_link': True, 'label': True, 'method': True, 'block': True, 'strip-extra-newlines': False } # Applying overflow/max-height CSS to <div> and <code> causes multiple scroll bars self._invalid_css = {'div': ['overflow-y', 'overflow-x', 'max-height']}
def __init__(self, pattern, md): """Initialize.""" Pattern.__init__(self, pattern) self.markdown = md
def __init__(self, markdown_instance=None, **kwargs): MooseMarkdownCommon.__init__(self, **kwargs) Pattern.__init__(self, self.RE, markdown_instance) # Load the yaml data containing package information self.package = MooseDocs.yaml_load(kwargs.pop('package_file'))
def __init__(self): Pattern.__init__(self, r'(>{2})(?P<comment_id>\d+)')
def __init__(self): Pattern.__init__(self, r'(%{2})(?P<contents>.+?)\2')
def __init__(self, markdown_instance=None, **kwargs): MooseMarkdownCommon.__init__(self, **kwargs) Pattern.__init__(self, self.RE, markdown_instance)
def __init__(self, pattern, configs): Pattern.__init__(self, pattern)
def __init__(self, pattern, markdown_instance=None, oembed_consumer=None): Pattern.__init__(self, pattern, markdown_instance) self.consumer = oembed_consumer
def __init__(self, regex, markdown_instance=None, syntax=None, **kwargs): MooseMarkdownCommon.__init__(self, **kwargs) Pattern.__init__(self, regex, markdown_instance) self._syntax = syntax self.__cache = dict()
def __init__(self, markdown_instance=None, syntax=None, **kwargs): MooseMarkdownCommon.__init__(self, **kwargs) Pattern.__init__(self, self.RE, markdown_instance) self._syntax = syntax self._install = kwargs.get('install')
def __init__(self): Pattern.__init__(self, ur'(?P<url>(?P<proto>\w+)://(?:[\w\.\-%\:]*\@)?(?P<host>[\w\.\-%]+)(?::(?P<port>\d+))?(?P<path>(?:/[^\s\?\u0002\u0003]*)*)(?P<qs>\?[^#\s\u0002\u0003]*)?(?:#(?P<hash>\S+))?)')
def __init__(self, pattern): """Intialize.""" Pattern.__init__(self, pattern)
def __init__(self): Pattern.__init__(self, '')
def __init__(self, **kwargs): MooseCommonExtension.__init__(self) Pattern.__init__(self, self.RE, **kwargs) # We have a strict width set that can not be disturbed self._invalid_css = {'div': ['width']}
def __init__(self): Pattern.__init__(self, r'(?P<word>\S{81,})')
def __init__(self, pattern, configs): """Initialize the pattern.""" Pattern.__init__(self, pattern)
def __init__(self): Pattern.__init__(self, r'(?<!\w)\@(?P<u>[a-zA-Z0-9\-]+)')
def __init__(self, *args, **kwargs): #pylint: disable=unused-argument Pattern.__init__(self, self.RE, *args)
def __init__(self): Pattern.__init__(self, ur'(?<!\w|\/)\u0005?#(?P<p>[a-zA-Z]+)(?:[/.](?P<c>\d+))?')
def __init__(self, pattern, tag, attrs): Pattern.__init__(self, pattern) self.tag = tag self.attrs = attrs
def __init__(self): Pattern.__init__(self, ur'(?<![-\w]|/)\u0005?(?<=\()?/(?P<c>\d+)(?=[.,;:?!)]|(?:\s|$))')