diff --git a/byexample/modules/markdown.py b/byexample/modules/markdown.py index 57bdad8b..dd9e2a0f 100644 --- a/byexample/modules/markdown.py +++ b/byexample/modules/markdown.py @@ -1,11 +1,11 @@ from __future__ import unicode_literals import re -from byexample.finder import ExampleFinder +from byexample.finder import ExampleFinder, ZoneFinder stability = 'stable' -class FencedMatchFinder(ExampleFinder): - target = 'markdown-fenced-code' +class FencedMatchFinder: #(ExampleFinder): + #target = 'markdown-fenced-code' specific = False def example_regex(self): @@ -47,3 +47,28 @@ def get_language_of(self, options, match, where): def spurious_endings(self): endings = ExampleFinder.spurious_endings(self) return endings - {'```', '~~~'} + +class MarkdownFencedCodeFinder(ZoneFinder): + target = {'.md'} + + def zone_regex(self): + return re.compile(r''' + # Begin with a markdown fenced-code marker or a html comment marker + ^[ ]* + (?: + (?P```(?:``)*(?=[^`])) # fenced-code marker (backticks) + | (?:) # otherwise, we must match the close of the html comment + ) + [ ]*$\n? + ''', re.MULTILINE | re.VERBOSE) +