예제 #1
0
def explain(text, edge_size):

    error_template = get_template('error.html')

    if edge_size > 0:
        text = find_jquery_selector(text, edge_size)

    if is_selector(text):
        explanations = css_explain(text)
        examples = generate_examples(text)
        explanation = css_render(explanations, examples)
    else:
        explanation = error_template.render(Context({'text': text, 'type': 'CSS selector'}))

    return explanation
예제 #2
0
def explain(text, edge_size):

    error_template = get_template('error.html')

    if edge_size > 0:
        text = find_jquery_selector(text, edge_size)

    if is_selector(text):
        explanations = css_explain(text)
        examples = generate_examples(text)
        explanation = css_render(explanations, examples)
    else:
        explanation = error_template.render(
            Context({
                'text': text,
                'type': 'CSS selector'
            }))

    return explanation
예제 #3
0
 def test_if_no_quotes_return_string(self):
     s = find_jquery_selector('   word   ', 3)
     self.assertEqual(s, 'word')
예제 #4
0
 def test_choose_closest_quotes_from_inside(self):
     s = find_jquery_selector('     "\'word\'"     ', 8)
     self.assertEqual(s, 'word')
예제 #5
0
 def test_choose_closest_quotes_from_outside(self):
     s = find_jquery_selector('     "\'word\'"     ', 3)
     self.assertEqual(s, "'word'")
예제 #6
0
 def test_string_in_double_quotes(self):
     s = find_jquery_selector('     "word"     ', 7)
     self.assertEqual(s, 'word')
예제 #7
0
 def test_find_jquery_selector_offset_to_right(self):
     s = find_jquery_selector("       'word' ", 5)
     self.assertEqual(s, 'word')
예제 #8
0
 def test_find_external_string(self):
     s = find_jquery_selector("     'word'     ", 7)
     self.assertEqual(s, 'word')
예제 #9
0
 def test_if_no_quotes_return_string(self):
     s = find_jquery_selector('   word   ', 3)
     self.assertEqual(s, 'word')
예제 #10
0
 def test_choose_closest_quotes_from_inside(self):
     s = find_jquery_selector('     "\'word\'"     ', 8)
     self.assertEqual(s, 'word')
예제 #11
0
 def test_choose_closest_quotes_from_outside(self):
     s = find_jquery_selector('     "\'word\'"     ', 3)
     self.assertEqual(s, "'word'")
예제 #12
0
 def test_string_in_double_quotes(self):
     s = find_jquery_selector('     "word"     ', 7)
     self.assertEqual(s, 'word')
예제 #13
0
 def test_find_jquery_selector_offset_to_right(self):
     s = find_jquery_selector("       'word' ", 5)
     self.assertEqual(s, 'word')
예제 #14
0
 def test_find_external_string(self):
     s = find_jquery_selector("     'word'     ", 7)
     self.assertEqual(s, 'word')