You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kw...@apache.org on 2023/09/21 13:30:16 UTC

[maven-doxia] branch master updated: [DOXIA-706] Support SinkEventAttributes in Sink.text(...) (#175)

This is an automated email from the ASF dual-hosted git repository.

kwin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-doxia.git


The following commit(s) were added to refs/heads/master by this push:
     new 240f2b7f [DOXIA-706] Support SinkEventAttributes in Sink.text(...) (#175)
240f2b7f is described below

commit 240f2b7ffe00c29446f6f6006327ff9394e02043
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Thu Sep 21 15:30:10 2023 +0200

    [DOXIA-706] Support SinkEventAttributes in Sink.text(...) (#175)
---
 .../org/apache/maven/doxia/sink/impl/Xhtml5BaseSink.java  |  6 ++++++
 .../apache/maven/doxia/sink/impl/Xhtml5BaseSinkTest.java  | 15 +++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSink.java b/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSink.java
index eca97681..ffbab90b 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSink.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSink.java
@@ -1799,7 +1799,13 @@ public class Xhtml5BaseSink extends AbstractXmlSink implements HtmlMarkup {
     /** {@inheritDoc} */
     @Override
     public void text(String text, SinkEventAttributes attributes) {
+        if (attributes != null) {
+            inline(attributes);
+        }
         text(text);
+        if (attributes != null) {
+            inline_();
+        }
     }
 
     /** {@inheritDoc} */
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSinkTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSinkTest.java
index 0d0bf606..43b6af06 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSinkTest.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSinkTest.java
@@ -26,6 +26,7 @@ import java.io.Writer;
 import org.apache.maven.doxia.markup.Markup;
 import org.apache.maven.doxia.sink.Sink;
 import org.apache.maven.doxia.sink.SinkEventAttributes;
+import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet.Semantics;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
@@ -1045,6 +1046,20 @@ public class Xhtml5BaseSinkTest {
         assertEquals("a text &amp; &#xc6;", writer.toString());
     }
 
+    /**
+     * Test of text method, of class Xhtml5BaseSink.
+     */
+    @Test
+    public void testTextWithAttributes() {
+        String text = "text";
+
+        try (Xhtml5BaseSink sink = new Xhtml5BaseSink(writer)) {
+            sink.text(text, Semantics.STRONG);
+        }
+
+        assertEquals("<strong>text</strong>", writer.toString());
+    }
+
     /**
      * Test of rawText method, of class Xhtml5BaseSink.
      */