Anchor and UserAnchor nodes can contain children

The impetus for this change was to help make the MarkupConverter code
more robust. However, it's also possible that an Anchor can contain
styled text. For example, in markdown someone might write a link that
contains some <strong> text:

```markdown
[this link is so **good**](https://example.com)
```

This setup will now allow that. Unknown if UserAnchor can ever contain
any text that isn't just the user's name, but it's easy to deal with
and makes the typing much easier.
This commit is contained in:
Edward Loveall 2021-08-08 14:34:40 -04:00
commit 31f7d6956c
No known key found for this signature in database
GPG key ID: 789A4AE983AC8901
6 changed files with 19 additions and 18 deletions

View file

@ -126,7 +126,7 @@ describe MarkupConverter do
result.should eq([
Text.new("I am a "),
Anchor.new(text: "Link", href: "https://example.com"),
Anchor.new(children: [Text.new("Link")] of Child, href: "https://example.com"),
])
end
@ -160,7 +160,7 @@ describe MarkupConverter do
result.should eq([
Text.new("Hi "),
UserAnchor.new(text: "Dr Nick", userId: "abc123"),
UserAnchor.new(children: [Text.new("Dr Nick")] of Child, userId: "abc123"),
Text.new("!"),
])
end

View file

@ -190,7 +190,10 @@ describe ParagraphConverter do
Image.new(src: "image.png", originalWidth: 1000, originalHeight: 600),
FigureCaption.new(children: [
Text.new("Image by "),
Anchor.new(href: "https://unsplash.com/@someuser", text: "someuser"),
Anchor.new(
children: [Text.new("someuser")] of Child,
href: "https://unsplash.com/@someuser"
),
] of Child),
] of Child),
]