我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用pygments.lexer.include()。
def gen_elixir_sigil_rules(): states = {} states['strings'] = [ (r'(%[A-Ba-z])?"""(?:.|\n)*?"""', String.Doc), (r"'''(?:.|\n)*?'''", String.Doc), (r'"', String.Double, 'dqs'), (r"'.*'", String.Single), (r'(?<!\w)\?(\\(x\d{1,2}|\h{1,2}(?!\h)\b|0[0-7]{0,2}(?![0-7])\b|' r'[^x0MC])|(\\[MC]-)+\w|[^\s\\])', String.Other) ] for lbrace, rbrace, name, in ('\\{', '\\}', 'cb'), \ ('\\[', '\\]', 'sb'), \ ('\\(', '\\)', 'pa'), \ ('\\<', '\\>', 'lt'): states['strings'] += [ (r'%[a-z]' + lbrace, String.Double, name + 'intp'), (r'%[A-Z]' + lbrace, String.Double, name + 'no-intp') ] states[name +'intp'] = [ (r'' + rbrace + '[a-z]*', String.Double, "#pop"), include('enddoublestr') ] states[name +'no-intp'] = [ (r'.*' + rbrace + '[a-z]*', String.Double , "#pop") ] return states