Skip to content

Commit

Permalink
strange typing fix
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Jan 29, 2020
1 parent c278c7a commit 37c511f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 65 deletions.
28 changes: 14 additions & 14 deletions rich/box.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def get_bottom(self, widths: Iterable[int]) -> str:
return "".join(parts)


ASCII = Box(
ASCII: Box = Box(
"""\
+--+
| ||
Expand All @@ -155,7 +155,7 @@ def get_bottom(self, widths: Iterable[int]) -> str:
"""
)

SQUARE = Box(
SQUARE: Box = Box(
"""\
┌─┬┐
│ ││
Expand All @@ -169,7 +169,7 @@ def get_bottom(self, widths: Iterable[int]) -> str:
)


MINIMAL = Box(
MINIMAL: Box = Box(
"""\
Expand All @@ -183,7 +183,7 @@ def get_bottom(self, widths: Iterable[int]) -> str:
)


MINIMAL_HEAVY_HEAD = Box(
MINIMAL_HEAVY_HEAD: Box = Box(
"""\
Expand All @@ -196,7 +196,7 @@ def get_bottom(self, widths: Iterable[int]) -> str:
"""
)

MINIMAL_DOUBLE_HEAD = Box(
MINIMAL_DOUBLE_HEAD: Box = Box(
"""\
Expand All @@ -210,7 +210,7 @@ def get_bottom(self, widths: Iterable[int]) -> str:
)


SIMPLE = Box(
SIMPLE: Box = Box(
"""\
Expand All @@ -224,7 +224,7 @@ def get_bottom(self, widths: Iterable[int]) -> str:
)


SIMPLE_HEAVY = Box(
SIMPLE_HEAVY: Box = Box(
"""\
Expand All @@ -238,7 +238,7 @@ def get_bottom(self, widths: Iterable[int]) -> str:
)


HORIZONTALS = Box(
HORIZONTALS: Box = Box(
"""\
────
Expand All @@ -251,7 +251,7 @@ def get_bottom(self, widths: Iterable[int]) -> str:
"""
)

ROUNDED = Box(
ROUNDED: Box = Box(
"""\
╭─┬╮
│ ││
Expand All @@ -264,7 +264,7 @@ def get_bottom(self, widths: Iterable[int]) -> str:
"""
)

HEAVY = Box(
HEAVY: Box = Box(
"""\
┏━┳┓
┃ ┃┃
Expand All @@ -277,7 +277,7 @@ def get_bottom(self, widths: Iterable[int]) -> str:
"""
)

HEAVY_EDGE = Box(
HEAVY_EDGE: Box = Box(
"""\
┏━┯┓
┃ │┃
Expand All @@ -290,7 +290,7 @@ def get_bottom(self, widths: Iterable[int]) -> str:
"""
)

HEAVY_HEAD = Box(
HEAVY_HEAD: Box = Box(
"""\
┏━┳┓
┃ ┃┃
Expand All @@ -303,7 +303,7 @@ def get_bottom(self, widths: Iterable[int]) -> str:
"""
)

DOUBLE = Box(
DOUBLE: Box = Box(
"""\
╔═╦╗
║ ║║
Expand All @@ -316,7 +316,7 @@ def get_bottom(self, widths: Iterable[int]) -> str:
"""
)

DOUBLE_EDGE = Box(
DOUBLE_EDGE: Box = Box(
"""\
╔═╤╗
║ │║
Expand Down
63 changes: 12 additions & 51 deletions rich/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def __console__(self, console: Console, options: ConsoleOptions) -> RenderResult
inlines = self.inlines
new_line = False
for current, entering in nodes:
# print(current, current.literal)
print(current, current.literal)
node_type = current.t
if node_type in ("html_inline", "html_block", "text"):
context.on_text(current.literal)
Expand Down Expand Up @@ -431,62 +431,23 @@ def __console__(self, console: Console, options: ConsoleOptions) -> RenderResult
if __name__ == "__main__": # pragma: no cover

markup = """
An h1 header
============
Paragraphs are separated by a blank line.
2nd paragraph. *Italic*, **bold**, and `monospace`. Itemized lists look like:
* this one
* that one
* the other one
Note that --- not considering the asterisk --- the actual text content starts at 4-columns in.
> Block quotes are
> written like so.
>
> They can span multiple paragraphs,
> if you like.
Use 3 dashes for an em-dash. Use 2 dashes for ranges (ex., "it's all in chapters 12--14"). Three dots ... will be converted to an ellipsis. Unicode is supported. ☺
An h2 header
------------
```python
@classmethod
def adjust_line_length(
cls, line: List[Segment], length: int, style: Style = None
) -> List[Segment]:
line_length = sum(len(text) for text, _style in line)
if line_length < length:
return line[:] + [Segment(" " * (length - line_length), style)]
elif line_length > length:
line_length = 0
new_line: List[Segment] = []
append = new_line.append
for segment in line:
segment_length = len(segment.text)
if line_length + segment_length < length:
append(segment)
line_length += segment_length
else:
text, style = segment
append(Segment(text[: length - line_length], style))
break
return new_line
return line
```
An h1 header
============
| Syntax | Description |
| --- | ----------- |
| Header | Title |
| Paragraph | Text |
"""

import commonmark

print(commonmark.commonmark(markup))

from .console import Console

console = Console(record=True, width=90)
console = Console(record=True)
# print(console.size)

# markup = "<foo>"
Expand Down

0 comments on commit 37c511f

Please sign in to comment.