Best Python code snippet using autotest_python
highlight.py
Source:highlight.py
...12 if not _TEMPLATE:13 _TEMPLATE = Template(14 '<span style="color: {color|htmltag};">{token|html}</span>')15 meta_left, meta_right = SplitMeta(meta)16 token_re = MakeTokenRegex(meta_left, meta_right)17 tokens = token_re.split(template_str)18 html = []19 for i, token in enumerate(tokens):20 # By the definition of re.split, even tokens are literal strings, and odd21 # tokens are directives.22 if i % 2 == 0:23 html.append(cgi.escape(token))24 else:25 # Because of the regex, the token should be at least 2 characters long26 c = token[1]27 if c == '#':28 token_type = COMMENT29 elif c == '.':30 token_type = DIRECTIVE...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!