Skip to content

Commit 1c23d6c

Browse files
authored
Merge pull request #5485 from Textualize/textual-markup
Textual markup
2 parents a05cffa + a91d8cc commit 1c23d6c

File tree

94 files changed

+4918
-1771
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+4918
-1771
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ jobs:
4949
if: ${{ matrix.python-version == '3.8' }}
5050
- name: Upload snapshot report
5151
if: always()
52-
uses: actions/upload-artifact@v3
52+
uses: actions/upload-artifact@v4
5353
with:
54-
name: snapshot-report-textual
54+
name: snapshot_report_textual
5555
path: snapshot_report.html
56+
overwrite: true

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2424
- Added App.ALLOW_SELECT for a global switch to disable text selection https://github.com/Textualize/textual/pull/5409
2525
- Added `DOMNode.query_ancestor` https://github.com/Textualize/textual/pull/5409
2626
- Added selection to Log widget https://github.com/Textualize/textual/pull/5467
27+
- Added `text-wrap` and `text-overflow` CSS values https://github.com/Textualize/textual/pull/5485
28+
- Added Textual markup to replace Rich markup https://github.com/Textualize/textual/pull/5485
29+
- Added `Content.from_markup` https://github.com/Textualize/textual/pull/5485
2730

2831
### Fixed
2932

docs/api/content.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: "textual.content"
3+
---
4+
5+
::: textual.content

docs/api/style.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: "textual.style"
3+
---
4+
5+
::: textual.style
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from textual.app import App, ComposeResult
2+
from textual.widgets import Static
3+
4+
TEXT1 = """\
5+
Hello, [bold $text on $primary]World[/]!
6+
7+
[@click=app.notify('Hello, World!')]Click me[/]
8+
"""
9+
10+
TEXT2 = """\
11+
Markup will [bold]not[/bold] be displayed.
12+
13+
Tags will be left in the output.
14+
15+
"""
16+
17+
18+
class ContentApp(App):
19+
CSS = """
20+
Screen {
21+
Static {
22+
height: 1fr;
23+
}
24+
#text1 { background: $primary-muted; }
25+
#text2 { background: $error-muted; }
26+
}
27+
"""
28+
29+
def compose(self) -> ComposeResult:
30+
yield Static(TEXT1, id="text1")
31+
yield Static(TEXT2, id="text2", markup=False) # (1)!
32+
33+
34+
if __name__ == "__main__":
35+
app = ContentApp()
36+
app.run()
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from textual._markup_playground import MarkupPlayground
2+
3+
if __name__ == "__main__":
4+
app = MarkupPlayground()
5+
app.run()
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from rich.syntax import Syntax
2+
3+
from textual.app import App, ComposeResult, RenderResult
4+
from textual.reactive import reactive
5+
from textual.widget import Widget
6+
7+
8+
class CodeView(Widget):
9+
"""Widget to display Python code."""
10+
11+
DEFAULT_CSS = """
12+
CodeView { height: auto; }
13+
"""
14+
15+
code = reactive("")
16+
17+
def render(self) -> RenderResult:
18+
# Syntax is a Rich renderable that displays syntax highlighted code
19+
syntax = Syntax(self.code, "python", line_numbers=True, indent_guides=True)
20+
return syntax
21+
22+
23+
class CodeApp(App):
24+
"""App to demonstrate Rich renderables in Textual."""
25+
26+
def compose(self) -> ComposeResult:
27+
with open(__file__) as self_file:
28+
code = self_file.read()
29+
code_view = CodeView()
30+
code_view.code = code
31+
yield code_view
32+
33+
34+
if __name__ == "__main__":
35+
app = CodeApp()
36+
app.run()

docs/examples/styles/border_sub_title_align_all.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def compose(self):
3939
"had to fill up",
4040
"lbl4",
4141
"", # (4)!
42-
"[link=https://textual.textualize.io]Left[/]", # (5)!
42+
"[link='https://textual.textualize.io']Left[/]", # (5)!
4343
)
4444
yield make_label_container( # (6)!
4545
"nine labels", "lbl5", "Title", "Subtitle"

docs/examples/styles/link_background.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class LinkBackgroundApp(App):
77

88
def compose(self):
99
yield Label(
10-
"Visit the [link=https://textualize.io]Textualize[/link] website.",
10+
"Visit the [link='https://textualize.io']Textualize[/link] website.",
1111
id="lbl1", # (1)!
1212
)
1313
yield Label(

docs/examples/styles/link_background_hover.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class LinkHoverBackgroundApp(App):
77

88
def compose(self):
99
yield Label(
10-
"Visit the [link=https://textualize.io]Textualize[/link] website.",
10+
"Visit the [link='https://textualize.io']Textualize[/link] website.",
1111
id="lbl1", # (1)!
1212
)
1313
yield Label(

0 commit comments

Comments
 (0)