How to use makeExtension method in Kiwi

Best Python code snippet using Kiwi_python

render.py

Source:render.py Github

copy

Full Screen

1from html import escape2from locale import strxfrm3from os import linesep4from typing import Callable, Match, Sequence, Tuple, Union, no_type_check5from markdown import Markdown6from markdown.extensions import Extension7from markdown.extensions.abbr import makeExtension as abbr8from markdown.extensions.admonition import makeExtension as admonition9from markdown.extensions.attr_list import makeExtension as attr_list10from markdown.extensions.codehilite import makeExtension as codehilite11from markdown.extensions.def_list import makeExtension as def_list12from markdown.extensions.fenced_code import makeExtension as fenced_code13from markdown.extensions.footnotes import makeExtension as footnotes14from markdown.extensions.md_in_html import makeExtension as md_in_html15from markdown.extensions.nl2br import makeExtension as nl2br16from markdown.extensions.sane_lists import makeExtension as sane_lists17from markdown.extensions.smarty import makeExtension as smarty18from markdown.extensions.tables import makeExtension as tables19from markdown.extensions.toc import makeExtension as toc20from markdown.extensions.wikilinks import makeExtension as wikilinks21from markdown.inlinepatterns import InlineProcessor22from pygments.formatters.html import HtmlFormatter23from pygments.styles import get_all_styles, get_style_by_name24_CODEHL_CLASS = "codehilite"25class _B4HtmlProcessor(InlineProcessor):26 """27 The builtin html processors store & restore `<...>`28 But does not check if `<...>` is valid html29 This processor tries to escape invalid html30 before the builtin ones31 """32 PRIORITY = 9133 def __init__(self) -> None:34 super().__init__(pattern="<([^>]*)>")35 @no_type_check36 def handleMatch(37 self, m: Match[str], data: str38 ) -> Union[Tuple[str, int, int], Tuple[None, None, None]]:39 maybe_html = m.group(1)40 chars = {*maybe_html}41 if maybe_html.endswith("/") or "<" in chars or chars > {"=", '"'}:42 return None, None, None43 else:44 escaped = escape(data)45 return escaped, m.start(0), m.end(0)46class _UserExts(Extension):47 def extendMarkdown(self, md: Markdown) -> None:48 md.inlinePatterns.register(49 _B4HtmlProcessor(),50 name=_B4HtmlProcessor.__qualname__,51 priority=_B4HtmlProcessor.PRIORITY,52 )53@no_type_check54def _extensions(style: str) -> Sequence[Extension]:55 return (56 abbr(),57 admonition(),58 attr_list(),59 codehilite(css_class=f"{_CODEHL_CLASS} {style}"),60 def_list(),61 fenced_code(),62 footnotes(),63 md_in_html(),64 nl2br(),65 sane_lists(),66 smarty(),67 tables(),68 toc(),69 wikilinks(),70 _UserExts(),71 )72def css() -> str:73 lines = (74 f".{_CODEHL_CLASS}.{name} {line}"75 for name in get_all_styles()76 for line in HtmlFormatter(style=get_style_by_name(name))77 .get_style_defs()78 .splitlines()79 )80 css = linesep.join(sorted(lines, key=strxfrm))81 return css82def render(style: str) -> Callable[[str], str]:83 _markdown = Markdown(extensions=_extensions(style))84 def render(md: str) -> str:85 return _markdown.convert(md)...

Full Screen

Full Screen

setup.py

Source:setup.py Github

copy

Full Screen

...47 print("~~",cpath)48 elif os.path.isdir(path):49 cleanc(path)50# generate an Extension object from its dotted name51def makeExtension(extName):52 extPath = extName.replace(".", os.path.sep)+".pyx"53 folder=extName.split(".")[0]54 files=[extPath]55 56 files.append('splikes/randomkit.c')57 return Extension(58 extName,59 files,60 include_dirs = [numpy.get_include(), ".", "%s/" % folder], # adding the '.' to include_dirs is CRUCIAL!!61 extra_compile_args = ["-O3", ],62 extra_link_args = ['-g'],63 )64# get the list of extensions65extNames = scandir("plasticnet")66#cleanc("plasticnet")67# and build up the set of Extension objects68extensions = [makeExtension(name) for name in extNames]69# finally, we can pass all this to distutils70setup(71 name="plasticnet",72 version=get_version('plasticnet'),73 description="Plasticity in Rate-Based Neurons",74 author="Brian Blais",75 packages=["plasticnet", "plasticnet.neurons", "plasticnet.connections", "plasticnet.monitors"],76 ext_modules=extensions,77 cmdclass = {'build_ext': build_ext},78)79# get the list of extensions80extNames = scandir("splikes")81#cleanc("splikes")82# and build up the set of Extension objects83extensions = [makeExtension(name) for name in extNames]84# finally, we can pass all this to distutils85setup(86 name="splikes",87 version=get_version('splikes'),88 description="Plasticity in Spike-Based Neurons",89 author="Brian Blais",90 packages=["splikes", "splikes.neurons", "splikes.connections", "splikes.monitors"],91 ext_modules=extensions,92 cmdclass = {'build_ext': build_ext},...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Kiwi automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful