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 2024/01/05 17:35:18 UTC
(maven-doxia) branch feature/support-heading-level6 created (now 708c4de8)
This is an automated email from the ASF dual-hosted git repository.
kwin pushed a change to branch feature/support-heading-level6
in repository https://gitbox.apache.org/repos/asf/maven-doxia.git
at 708c4de8 [DOXIA-695] Support heading level 6
This branch includes the following new commits:
new 708c4de8 [DOXIA-695] Support heading level 6
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(maven-doxia) 01/01: [DOXIA-695] Support heading level 6
Posted by kw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
kwin pushed a commit to branch feature/support-heading-level6
in repository https://gitbox.apache.org/repos/asf/maven-doxia.git
commit 708c4de89b391d407bb2253407bafa1db243ecd2
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Fri Jan 5 18:35:12 2024 +0100
[DOXIA-695] Support heading level 6
---
.../org/apache/maven/doxia/index/IndexEntry.java | 6 +--
.../org/apache/maven/doxia/markup/HtmlMarkup.java | 3 ++
.../maven/doxia/parser/Xhtml5BaseParser.java | 14 ++----
.../apache/maven/doxia/sink/impl/AbstractSink.java | 20 ++++++++
.../apache/maven/doxia/module/xdoc/XdocParser.java | 10 +---
.../apache/maven/doxia/module/xdoc/XdocSink.java | 18 +++++---
.../java/org/apache/maven/doxia/sink/Sink.java | 54 ++++++++++++++++++++--
7 files changed, 93 insertions(+), 32 deletions(-)
diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/index/IndexEntry.java b/doxia-core/src/main/java/org/apache/maven/doxia/index/IndexEntry.java
index 178e403c..f85fe519 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/index/IndexEntry.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/index/IndexEntry.java
@@ -70,7 +70,7 @@ public class IndexEntry {
SECTION_3(Sink.SECTION_LEVEL_3),
SECTION_4(Sink.SECTION_LEVEL_4),
SECTION_5(Sink.SECTION_LEVEL_5),
- SECTION_6(),
+ SECTION_6(Sink.SECTION_LEVEL_6),
DEFINED_TERM(),
FIGURE(),
TABLE();
@@ -86,9 +86,9 @@ public class IndexEntry {
}
static Type fromSectionLevel(int level) {
- if (level < Sink.SECTION_LEVEL_1 || level > Sink.SECTION_LEVEL_5) {
+ if (level < Sink.SECTION_LEVEL_1 || level > Sink.SECTION_LEVEL_6) {
throw new IllegalArgumentException("Level must be between " + Sink.SECTION_LEVEL_1 + " and "
- + Sink.SECTION_LEVEL_5 + " but is " + level);
+ + Sink.SECTION_LEVEL_6 + " but is " + level);
}
return Arrays.stream(Type.values())
.filter(t -> level == t.sectionLevel)
diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/markup/HtmlMarkup.java b/doxia-core/src/main/java/org/apache/maven/doxia/markup/HtmlMarkup.java
index c46ed090..28ccd818 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/markup/HtmlMarkup.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/markup/HtmlMarkup.java
@@ -321,6 +321,9 @@ public interface HtmlMarkup extends XmlMarkup {
/** HTML5 tag for <code>h5</code>. */
Tag H5 = Tag.H5;
+ /** HTML5 tag for <code>h6</code>. */
+ Tag H6 = Tag.H6;
+
/** HTML5 tag for <code>head</code>. */
Tag HEAD = Tag.HEAD;
diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/parser/Xhtml5BaseParser.java b/doxia-core/src/main/java/org/apache/maven/doxia/parser/Xhtml5BaseParser.java
index 24d6c7f8..edeccc49 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/parser/Xhtml5BaseParser.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/parser/Xhtml5BaseParser.java
@@ -209,6 +209,8 @@ public class Xhtml5BaseParser extends AbstractXmlParser implements HtmlMarkup {
handleHeadingStart(sink, Sink.SECTION_LEVEL_4, attribs);
} else if (parser.getName().equals(HtmlMarkup.H5.toString())) {
handleHeadingStart(sink, Sink.SECTION_LEVEL_5, attribs);
+ } else if (parser.getName().equals(HtmlMarkup.H6.toString())) {
+ handleHeadingStart(sink, Sink.SECTION_LEVEL_6, attribs);
} else if (parser.getName().equals(HtmlMarkup.HEADER.toString())) {
sink.header(attribs);
} else if (parser.getName().equals(HtmlMarkup.MAIN.toString())) {
@@ -709,16 +711,8 @@ public class Xhtml5BaseParser extends AbstractXmlParser implements HtmlMarkup {
while (this.headingLevel < newLevel) {
this.headingLevel++;
- if (headingLevel == Sink.SECTION_LEVEL_5) {
- sink.section5();
- } else if (headingLevel == Sink.SECTION_LEVEL_4) {
- sink.section4();
- } else if (headingLevel == Sink.SECTION_LEVEL_3) {
- sink.section3();
- } else if (headingLevel == Sink.SECTION_LEVEL_2) {
- sink.section2();
- } else if (headingLevel == Sink.SECTION_LEVEL_1) {
- sink.section1();
+ if (headingLevel >= Sink.SECTION_LEVEL_1 && headingLevel <= Sink.SECTION_LEVEL_6) {
+ sink.section(headingLevel, null);
}
}
}
diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/AbstractSink.java b/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/AbstractSink.java
index a4d81cbd..35184c32 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/AbstractSink.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/AbstractSink.java
@@ -185,6 +185,26 @@ public abstract class AbstractSink implements Sink, Markup {
sectionTitle_(5);
}
+ @Override
+ public final void section6() {
+ section(6, null);
+ }
+
+ @Override
+ public final void section6_() {
+ section_(6);
+ }
+
+ @Override
+ public final void sectionTitle6() {
+ sectionTitle(6, null);
+ }
+
+ @Override
+ public final void sectionTitle6_() {
+ sectionTitle_(6);
+ }
+
@Override
public final void header() {
header(null);
diff --git a/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java b/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
index b826b123..8cc9a068 100644
--- a/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
+++ b/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
@@ -266,14 +266,8 @@ public class XdocParser extends Xhtml5BaseParser implements XdocMarkup {
*/
private void closeOpenSections(int newLevel, Sink sink) {
while (getSectionLevel() >= newLevel) {
- if (getSectionLevel() == Sink.SECTION_LEVEL_5) {
- sink.section5_();
- } else if (getSectionLevel() == Sink.SECTION_LEVEL_4) {
- sink.section4_();
- } else if (getSectionLevel() == Sink.SECTION_LEVEL_3) {
- sink.section3_();
- } else if (getSectionLevel() == Sink.SECTION_LEVEL_2) {
- sink.section2_();
+ if (getSectionLevel() > Sink.SECTION_LEVEL_1) {
+ sink.section_(getSectionLevel());
}
setSectionLevel(getSectionLevel() - 1);
diff --git a/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java b/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java
index e84ef1fc..f4e55b96 100644
--- a/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java
+++ b/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java
@@ -286,9 +286,10 @@ public class XdocSink extends Xhtml5BaseSink implements XdocMarkup {
* {@inheritDoc}
*
* Starts a section title.
- * @see javax.swing.text.html.HTML.Tag#H3
- * @see javax.swing.text.html.HTML.Tag#H4
- * @see javax.swing.text.html.HTML.Tag#H5
+ * @see #H3
+ * @see #H4
+ * @see #H5
+ * @see #H6
*/
protected void onSectionTitle(int depth, SinkEventAttributes attributes) {
MutableAttributeSet atts = SinkUtils.filterAttributes(attributes, SinkUtils.SINK_SECTION_ATTRIBUTES);
@@ -299,6 +300,8 @@ public class XdocSink extends Xhtml5BaseSink implements XdocMarkup {
writeStartTag(H4, atts);
} else if (depth == SECTION_LEVEL_5) {
writeStartTag(H5, atts);
+ } else if (depth == SECTION_LEVEL_6) {
+ writeStartTag(H6, atts);
}
}
@@ -306,9 +309,10 @@ public class XdocSink extends Xhtml5BaseSink implements XdocMarkup {
* {@inheritDoc}
*
* Ends a section title.
- * @see javax.swing.text.html.HTML.Tag#H3
- * @see javax.swing.text.html.HTML.Tag#H4
- * @see javax.swing.text.html.HTML.Tag#H5
+ * @see #H3
+ * @see #H4
+ * @see #H5
+ * @see #H6
*/
protected void onSectionTitle_(int depth) {
if (depth == SECTION_LEVEL_1 || depth == SECTION_LEVEL_2) {
@@ -319,6 +323,8 @@ public class XdocSink extends Xhtml5BaseSink implements XdocMarkup {
writeEndTag(H4);
} else if (depth == SECTION_LEVEL_5) {
writeEndTag(H5);
+ } else if (depth == SECTION_LEVEL_6) {
+ writeEndTag(H6);
}
}
diff --git a/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/Sink.java b/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/Sink.java
index 6e981cf1..f7d73952 100644
--- a/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/Sink.java
+++ b/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/Sink.java
@@ -114,6 +114,13 @@ public interface Sink extends AutoCloseable {
*/
int SECTION_LEVEL_5 = 5;
+ /**
+ * A level 6 section.
+ * @see #section(int,SinkEventAttributes)
+ * @since 2.0.0
+ */
+ int SECTION_LEVEL_6 = 6;
+
/**
* Center alignment for table cells.
* @see #tableRows(int[], boolean)
@@ -503,7 +510,7 @@ public interface Sink extends AutoCloseable {
/**
* Starts a 5th heading element which contains the topic of the section.
- * This has to be contained within a {@link #section4()} element.
+ * This has to be contained within a {@link #section5()} element.
* <p>
* Shortcut for {@link #section(int, SinkEventAttributes)} with first argument being {@code 5} and second argument being {@code null}.
*
@@ -528,9 +535,46 @@ public interface Sink extends AutoCloseable {
/**
* Ends a 5th title heading element. Shortcut for {@link #sectionTitle_(int)} with argument being {@code 5}.
+ * @since 2.0.0
*/
void sectionTitle5_();
+ /**
+ * Starts a 6th heading element which contains the topic of the section.
+ * This has to be contained within a {@link #section6()} element.
+ * <p>
+ * Shortcut for {@link #section(int, SinkEventAttributes)} with first argument being {@code 6} and second argument being {@code null}.
+ *
+ * @see #section(int,SinkEventAttributes)
+ * @since 2.0.0
+ */
+ void section6();
+
+ /**
+ * Ends a 6th heading element. Shortcut for {@link #section_(int)} with argument being {@code 6}.
+ *
+ * @since 2.0.0
+ */
+ void section6_();
+
+ /**
+ * Starts a 6th title heading element. This element is optional, but if it exists,
+ * it has to be contained, and be the first element, within a {@link #section5()} element.
+ * <p>
+ * Shortcut for {@link #sectionTitle(int, SinkEventAttributes)} with first argument being {@code 6} and second argument being {@code null}.
+ *
+ * @see #sectionTitle(int,SinkEventAttributes)
+ * @since 2.0.0
+ */
+ void sectionTitle6();
+
+ /**
+ * Ends a 6th title heading element. Shortcut for {@link #sectionTitle_(int)} with argument being {@code 6}.
+ *
+ * @since 2.0.0
+ */
+ void sectionTitle6_();
+
/**
* Start a new section at the given level.
*
@@ -541,7 +585,7 @@ public interface Sink extends AutoCloseable {
* Supported attributes are the {@link SinkEventAttributes base attributes}.
* </p>
*
- * @param level the section level.
+ * @param level the section level (must be a value between {@value #SECTION_LEVEL_1} and {@value #SECTION_LEVEL_6}).
* @param attributes A set of {@link SinkEventAttributes}, may be <code>null</code>.
* @since 1.1
*/
@@ -550,7 +594,7 @@ public interface Sink extends AutoCloseable {
/**
* Ends a section at the given level.
*
- * @param level the section level.
+ * @param level the section level (must be a value between {@value #SECTION_LEVEL_1} and {@value #SECTION_LEVEL_6}).
* @since 1.1
*/
void section_(int level);
@@ -576,7 +620,7 @@ public interface Sink extends AutoCloseable {
* {@link SinkEventAttributes#ALIGN ALIGN}.
* </p>
*
- * @param level the section title level.
+ * @param level the section title level (must be a value between {@value #SECTION_LEVEL_1} and {@value #SECTION_LEVEL_6}).
* @param attributes A set of {@link SinkEventAttributes}, may be <code>null</code>.
* @since 1.1
*/
@@ -585,7 +629,7 @@ public interface Sink extends AutoCloseable {
/**
* Ends a section title at the given level.
*
- * @param level the section title level.
+ * @param level the section title level (must be a value between {@value #SECTION_LEVEL_1} and {@value #SECTION_LEVEL_6}).
* @since 1.1
*/
void sectionTitle_(int level);