Skip to content

Commit

Permalink
Add overline, underoverline and all text decoration options
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgio committed Aug 26, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent c187e30 commit c77d99e
Showing 4 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -59,7 +59,10 @@ class TextTransformData(
enum class Decoration : RenderRepresentable {
NONE,
UNDERLINE,
OVERLINE,
UNDEROVERLINE,
STRIKETHROUGH,
ALL,
;

override fun <T> accept(visitor: RenderRepresentableVisitor<T>): T = visitor.visit(this)
Original file line number Diff line number Diff line change
@@ -81,6 +81,8 @@ class CssRepresentableVisitor : RenderRepresentableVisitor<String> {
override fun visit(decoration: TextTransformData.Decoration) =
when (decoration) {
TextTransformData.Decoration.STRIKETHROUGH -> "line-through"
TextTransformData.Decoration.UNDEROVERLINE -> "underline overline"
TextTransformData.Decoration.ALL -> "underline overline line-through"
else -> decoration.kebabCaseName
}

13 changes: 11 additions & 2 deletions core/src/test/kotlin/eu/iamgio/quarkdown/HtmlNodeRendererTest.kt
Original file line number Diff line number Diff line change
@@ -726,7 +726,7 @@ class HtmlNodeRendererTest {
TextTransformData(
size = TextTransformData.Size.LARGE,
style = TextTransformData.Style.ITALIC,
decoration = TextTransformData.Decoration.UNDERLINE,
decoration = TextTransformData.Decoration.STRIKETHROUGH,
),
listOf(Text("Foo")),
).render(),
@@ -738,7 +738,7 @@ class HtmlNodeRendererTest {
TextTransformData(
size = TextTransformData.Size.TINY,
weight = TextTransformData.Weight.BOLD,
decoration = TextTransformData.Decoration.STRIKETHROUGH,
decoration = TextTransformData.Decoration.UNDEROVERLINE,
variant = TextTransformData.Variant.SMALL_CAPS,
),
listOf(Emphasis(listOf(Text("Foo"))), Text("bar")),
@@ -750,10 +750,19 @@ class HtmlNodeRendererTest {
TextTransform(
TextTransformData(
weight = TextTransformData.Weight.BOLD,
decoration = TextTransformData.Decoration.ALL,
color = Color(255, 0, 0),
),
listOf(Text("Foo")),
).render(),
)

assertEquals(
out.next(),
TextTransform(
TextTransformData(),
listOf(Text("Foo")),
).render(),
)
}
}
12 changes: 9 additions & 3 deletions core/src/test/resources/rendering/quarkdown/texttransform.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<span class="size-large" style="font-style: italic; text-decoration: underline;">
<span class="size-large" style="font-style: italic; text-decoration: line-through;">
Foo
</span>

---

<span class="size-tiny" style="font-weight: bold; font-variant: small-caps; text-decoration: line-through;">
<span class="size-tiny" style="font-weight: bold; font-variant: small-caps; text-decoration: underline overline;">
<em>
Foo
</em>
@@ -13,6 +13,12 @@

---

<span style="font-weight: bold; color: rgba(255, 0, 0, 1.0);">
<span style="font-weight: bold; text-decoration: underline overline line-through; color: rgba(255, 0, 0, 1.0);">
Foo
</span>

---

<span>
Foo
</span>

0 comments on commit c77d99e

Please sign in to comment.