Lines Matching refs:block

42 different type of block. Extensions may add/replace/remove BlockProcessors
58 """ Build the default block parser used by Markdown. """
74 """ Base class for block processors.
79 whether the current block should be processed by this processor. If the
116 def test(self, parent, block):
117 """ Test for block type. Must be overridden by subclasses.
120 on each to determine if the given block of text is of that type. This
122 testing is left to the needs of that particular block type. It could
123 be as simple as ``block.startswith(some_string)`` or a complex regular
124 expression. As the block type may be different depending on the parent
125 of the block (i.e. inside a list), the parent etree element is also
130 * ``parent``: A etree element which will be the parent of the block.
131 * ``block``: A block of text from the source which has been split at
139 When the parser determines the appropriate type of a block, the parser
141 should parse the individual lines of the block and append them to
155 * ``parent``: A etree element which is the parent of the current block.
179 def test(self, parent, block):
180 return block.startswith(' '*self.tab_length) and \
189 block = blocks.pop(0)
190 level, sibling = self.get_level(parent, block)
191 block = self.looseDetab(block, level)
201 self.parser.parseBlocks(parent[-1], [block])
203 # The parent is already a li. Just parse the child block.
204 self.parser.parseBlocks(parent, [block])
207 self.parser.parseBlocks(sibling, [block])
210 # Assume the last child li is the parent of this block.
219 self.parser.parseChunk(sibling[-1], block)
221 self.create_item(sibling, block)
224 def create_item(self, parent, block):
225 """ Create a new li and parse the block with it as the parent. """
227 self.parser.parseBlocks(li, [block])
229 def get_level(self, parent, block):
232 m = self.INDENT_RE.match(block)
252 # we have a code block. So we stop here.
260 def test(self, parent, block):
261 return block.startswith(' '*self.tab_length)
265 block = blocks.pop(0)
269 # The previous block was a code block. As blank lines do not start
270 # new code blocks, append this block to the previous, adding back
273 block, theRest = self.detab(block)
274 code.text = util.AtomicString('%s\n%s\n' % (code.text, block.rstrip()))
279 block, theRest = self.detab(block)
280 code.text = util.AtomicString('%s\n' % block.rstrip())
282 # This block contained unindented line(s) after the first indented
283 # line. Insert these lines as the first block of the master blocks
292 def test(self, parent, block):
293 return bool(self.RE.search(block))
296 block = blocks.pop(0)
297 m = self.RE.search(block)
299 before = block[:m.start()] # Lines before blockquote
303 block = '\n'.join([self.clean(line) for line in
304 block[m.start():].split('\n')])
307 # Previous block was a blockquote so set that as this blocks parent
312 # Recursively parse block with blockquote as parent.
315 self.parser.parseChunk(quote, block)
346 def test(self, parent, block):
347 return bool(self.RE.match(block))
350 # Check fr multiple items in one block.
355 # Previous block was a list item, so set that as parent
375 # parse first block differently as it gets wrapped in a p.
396 # Loop through items in block, recursively parsing each with the
408 def get_items(self, block):
409 """ Break a block into list items. """
411 for line in block.split('\n'):
445 # Detect a header at start of any line in block
448 def test(self, parent, block):
449 return bool(self.RE.search(block))
452 block = blocks.pop(0)
453 m = self.RE.search(block)
455 before = block[:m.start()] # All lines before header
456 after = block[m.end():] # All lines after header
458 # As the header was not the first line of the block and the
460 # recursively parse this lines as a block.
466 # Insert remaining lines as first block for future parsing.
470 logger.warn("We've got a problem header: %r" % block)
476 # Detect Setext-style header. Must be first 2 lines of block.
479 def test(self, parent, block):
480 return bool(self.RE.match(block))
500 # Detect hr on any line of a block.
503 def test(self, parent, block):
504 m = self.SEARCH_RE.search(block)
507 # Then check if we are at end of block or if next char is a newline.
508 if m and (m.end() == len(block) or block[m.end()] == '\n'):
515 block = blocks.pop(0)
516 # Check for lines in block before hr.
517 prelines = block[:self.match.start()].rstrip('\n')
523 # check for lines in block after hr.
524 postlines = block[self.match.end():].lstrip('\n')
534 def test(self, parent, block):
535 return not block or block.startswith('\n')
538 block = blocks.pop(0)
540 if block:
545 theRest = block[1:]
551 # Last block is a codeblock. Append to preserve whitespace.
558 def test(self, parent, block):
562 block = blocks.pop(0)
563 if block.strip():
564 # Not a blank block. Add to parent, otherwise throw it away.
578 sibling.tail = '%s\n%s' % (sibling.tail, block)
580 sibling.tail = '\n%s' % block
584 parent.text = '%s\n%s' % (parent.text, block)
586 parent.text = block.lstrip()
590 p.text = block.lstrip()