MCPcopy Index your code
hub / github.com/pywebio/PyWebIO / put_code

Function put_code

pywebio/output.py:482–505  ·  view source on GitHub ↗

Output code block :param str content: code string :param str language: language of code :param int rows: The max lines of code can be displayed, no limit by default. The scroll bar will be displayed when the content exceeds. :param int scope, position: Those arguments have the

(content: str, language: str = '', rows: int = None, scope: str = None,
             position: int = OutputPosition.BOTTOM)

Source from the content-addressed store, hash-verified

480
481
482def put_code(content: str, language: str = '', rows: int = None, scope: str = None,
483 position: int = OutputPosition.BOTTOM) -> Output:
484 """
485 Output code block
486
487 :param str content: code string
488 :param str language: language of code
489 :param int rows: The max lines of code can be displayed, no limit by default. The scroll bar will be displayed when the content exceeds.
490 :param int scope, position: Those arguments have the same meaning as for `put_text()`
491 """
492 if not isinstance(content, str):
493 content = str(content)
494
495 # For fenced code blocks, escaping the backtick need to use more backticks
496 backticks = '```'
497 while backticks in content:
498 backticks += '`'
499
500 code = "%s%s\n%s\n%s" % (backticks, language, content, backticks)
501 out = put_markdown(code, scope=scope, position=position)
502 if rows is not None:
503 max_height = rows * 19 + 32 # 32 is the code css padding
504 out.style("max-height: %spx" % max_height)
505 return out
506
507
508def _left_strip_multiple_line_string_literal(s):

Callers 7

basic_outputFunction · 0.85
basic_inputFunction · 0.85
mainFunction · 0.85
output_widgetsFunction · 0.85
code_blockFunction · 0.85
mainFunction · 0.85
handle_codeFunction · 0.85

Calls 2

put_markdownFunction · 0.85
styleMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…