From 5902f86332949b4a29d69ed293e646dde142d618 Mon Sep 17 00:00:00 2001 From: vicky Date: Wed, 16 Mar 2022 14:57:42 +0100 Subject: [PATCH] changed http_characters to pp.commons.url and structural_elements to pp.CaselessLiteral and ^ to | --- src/bootstraparse/modules/syntax.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/bootstraparse/modules/syntax.py b/src/bootstraparse/modules/syntax.py index b0a535e..20f111a 100644 --- a/src/bootstraparse/modules/syntax.py +++ b/src/bootstraparse/modules/syntax.py @@ -169,7 +169,7 @@ value = (quotes + pp.Word(pp.alphanums + r'.') + pp.match_previous_literal(quote pp.common.fnumber)("value") assignation = pp.Group(pp.common.identifier('var_name') + '=' + value('var_value'))("assignation") text = pp.OneOrMore(pp.Word(pp.alphanums))('text').add_parse_action(of_type(TextToken)) -http_characters = pp.Word(pp.alphanums + r'=+-_\/\\.:;!?%#@&*()[]{}~` ') # Todo : Check common.url that can match any common url structure # noqa E501 # pylint: disable=line-too-long +http_characters = pp.Word(pp.common.url) # Composite elements var = '[' + pp.delimitedList(assignation ^ value)("list_vars").set_name("list_vars") + ']' @@ -180,8 +180,12 @@ image_element = ('@{' + pp.common.identifier('image_name') + '}')("image_element alias_element = ('@[' + pp.common.identifier('alias_name') + ']')("alias_element") expression = pp.Word(pp.alphanums + r'=+-_\'",;:!<> ') html_insert = '{' + expression('html_insert') + '}' -structural_elements = \ - (pp.Word('div') ^ pp.Word('article') ^ pp.Word('aside') ^ pp.Word('section'))('structural_element') # TODO : Fixit: Word is "make a word with any of the characters in the string" whereas Literal is "make a word with a specific string" # noqa E501 (line too long) +structural_elements = ( + pp.CaselessLiteral('div') | + pp.CaselessLiteral('article') | + pp.CaselessLiteral('aside') | + pp.CaselessLiteral('section') +)('structural_element') # Optional elements