-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added: tables, liusting, figure, partial example. Missing appendix
# Conflicts: # asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/NodesSinker.java # asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/processors/ListingNodeProcessor.java # asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/processors/TableNodeProcessor.java
- Loading branch information
1 parent
912de34
commit 24e2365
Showing
8 changed files
with
133 additions
and
18 deletions.
There are no files selected for viewing
Empty file.
59 changes: 59 additions & 0 deletions
59
...dule/src/main/java/org/asciidoctor/maven/site/parser/processors/ExampleNodeProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package org.asciidoctor.maven.site.parser.processors; | ||
|
||
import org.apache.maven.doxia.sink.Sink; | ||
import org.asciidoctor.ast.StructuralNode; | ||
import org.asciidoctor.maven.site.parser.NodeProcessor; | ||
|
||
import javax.swing.text.html.HTML.Attribute; | ||
import java.nio.file.FileSystems; | ||
|
||
import static javax.swing.text.html.HTML.Attribute.ALT; | ||
import static org.asciidoctor.maven.commons.StringUtils.isBlank; | ||
import static org.asciidoctor.maven.commons.StringUtils.isNotBlank; | ||
|
||
/** | ||
* Inline images are processed as paragraphs. | ||
* | ||
* @author abelsromero | ||
* @since 3.0.0 | ||
*/ | ||
public class ExampleNodeProcessor extends AbstractSinkNodeProcessor implements NodeProcessor { | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param sink Doxia {@link Sink} | ||
*/ | ||
public ExampleNodeProcessor(Sink sink) { | ||
super(sink); | ||
} | ||
|
||
@Override | ||
public boolean applies(StructuralNode node) { | ||
return "example".equals(node.getNodeName()); | ||
} | ||
|
||
@Override | ||
public void process(StructuralNode node) { | ||
// Add caption as a div (same as Asciidoctor): | ||
// - For consistency | ||
// - Using `figureCaption` requires wrapping the image in <figure> which adds indentation | ||
final Sink sink = getSink(); | ||
// sink.division(); | ||
final String title = TitleExtractor.getText(node); | ||
if (isNotBlank(title)) { | ||
sink.division(SinkAttributes.of(Attribute.STYLE, Styles.CAPTION)); | ||
sink.text(title); | ||
sink.division_(); | ||
} | ||
// sink.division_(); | ||
} | ||
|
||
private String formatPath(String imagesdir, String target) { | ||
if (imagesdir.endsWith("/") || imagesdir.endsWith("\\")) { | ||
return imagesdir + target; | ||
} else { | ||
return imagesdir + FileSystems.getDefault().getSeparator() + target; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...xia-module/src/main/java/org/asciidoctor/maven/site/parser/processors/SinkAttributes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.asciidoctor.maven.site.parser.processors; | ||
|
||
import javax.swing.text.html.HTML.Attribute; | ||
|
||
import org.apache.maven.doxia.sink.SinkEventAttributes; | ||
import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet; | ||
|
||
class SinkAttributes { | ||
|
||
static SinkEventAttributes of(Attribute name, String value) { | ||
final var attributes = new SinkEventAttributeSet(); | ||
attributes.addAttribute(name, value); | ||
return attributes; | ||
} | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
...arser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/processors/Styles.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.asciidoctor.maven.site.parser.processors; | ||
|
||
class Styles { | ||
|
||
public static final String CAPTION = "color: #7a2518; margin-bottom: .25em;"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...xia-module/src/main/java/org/asciidoctor/maven/site/parser/processors/TitleExtractor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.asciidoctor.maven.site.parser.processors; | ||
|
||
import org.asciidoctor.ast.StructuralNode; | ||
|
||
import static org.asciidoctor.maven.commons.StringUtils.isBlank; | ||
|
||
class TitleExtractor { | ||
|
||
static String getText(StructuralNode node) { | ||
// Caption is returned when a title is set in: | ||
// - Listings | ||
// - Image blocks | ||
final String caption = node.getCaption(); | ||
return isBlank(caption) ? node.getTitle() : caption + node.getTitle(); | ||
} | ||
|
||
} |