markdown_documentation.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. from nicegui import ui
  2. from ..documentation_tools import text_demo
  3. def main_demo() -> None:
  4. ui.markdown('''This is **Markdown**.''')
  5. def more() -> None:
  6. @text_demo('Markdown with indentation', '''
  7. Common indentation is automatically stripped from the beginning of each line.
  8. So you can indent markdown elements, and they will still be rendered correctly.
  9. ''')
  10. def markdown_with_indentation():
  11. ui.markdown('''
  12. ### Example
  13. This line is not indented.
  14. This block is indented.
  15. Thus it is rendered as source code.
  16. This is normal text again.
  17. ''')
  18. @text_demo('Markdown with code blocks', '''
  19. You can use code blocks to show code examples.
  20. If you specify the language after the opening triple backticks, the code will be syntax highlighted.
  21. See [the Pygments website](https://pygments.org/languages/) for a list of supported languages.
  22. ''')
  23. def markdown_with_code_blocks():
  24. ui.markdown('''
  25. ```python
  26. from nicegui import ui
  27. ui.label('Hello World!')
  28. ui.run(dark=True)
  29. ```
  30. ''')