Skip to content

Commit

Permalink
fix: render urls in table (charmbracelet#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
brianstrauch authored Aug 22, 2023
1 parent 49e7da3 commit b8953ce
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
9 changes: 7 additions & 2 deletions ansi/elements.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,13 @@ func (tr *ANSIRenderer) NewElement(node ast.Node, source []byte) Element {
s := ""
n := node.FirstChild()
for n != nil {
s += string(n.Text(source))
// s += string(n.LinkData.Destination)
switch t := n.(type) {
case *ast.AutoLink:
s += string(t.Label(source))
default:
s += string(n.Text(source))
}

n = n.NextSibling()
}

Expand Down
8 changes: 4 additions & 4 deletions styles/examples/table.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
| Label | Value |
| ------ | ----- |
| First | foo |
| Second | bar |
| Label | Value | URL |
| ------ | ----- | ---------------- |
| First | foo | https://charm.sh |
| Second | bar | https://charm.sh |
8 changes: 4 additions & 4 deletions testdata/table.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

LABEL | VALUE
---------+--------
First | foo
Second | bar
LABEL | VALUE | URL
---------+-------+-------------------
First | foo | https://charm.sh
Second | bar | https://charm.sh

0 comments on commit b8953ce

Please sign in to comment.