-
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.
Add support for description lists in parser-doxia-module
* Checkpoint: tested all description lists from docs * Update docs * Update IT Closes #751
- Loading branch information
1 parent
19ddcdc
commit 06e7f1d
Showing
8 changed files
with
390 additions
and
27 deletions.
There are no files selected for viewing
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
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
77 changes: 77 additions & 0 deletions
77
...src/main/java/org/asciidoctor/maven/site/ast/processors/DescriptionListNodeProcessor.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,77 @@ | ||
package org.asciidoctor.maven.site.ast.processors; | ||
|
||
import java.util.List; | ||
|
||
import org.apache.maven.doxia.sink.Sink; | ||
import org.asciidoctor.ast.DescriptionList; | ||
import org.asciidoctor.ast.DescriptionListEntry; | ||
import org.asciidoctor.ast.ListItem; | ||
import org.asciidoctor.ast.StructuralNode; | ||
import org.asciidoctor.maven.site.ast.NodeProcessor; | ||
|
||
/** | ||
* Description list processor. | ||
* | ||
* @author abelsromero | ||
* @since 3.0.0 | ||
*/ | ||
public class DescriptionListNodeProcessor extends AbstractSinkNodeProcessor implements NodeProcessor { | ||
|
||
private ListItemNodeProcessor itemNodeProcessor; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param sink Doxia {@link Sink} | ||
*/ | ||
public DescriptionListNodeProcessor(Sink sink) { | ||
super(sink); | ||
} | ||
|
||
/** | ||
* Inject a {@link ListItemNodeProcessor}. | ||
* | ||
* @param nodeProcessor {@link ListItemNodeProcessor} | ||
*/ | ||
public void setItemNodeProcessor(ListItemNodeProcessor nodeProcessor) { | ||
this.itemNodeProcessor = nodeProcessor; | ||
} | ||
|
||
@Override | ||
public boolean applies(StructuralNode node) { | ||
return "dlist".equals(node.getNodeName()); | ||
} | ||
|
||
@Override | ||
public boolean isTerminal(StructuralNode node) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void process(StructuralNode node) { | ||
|
||
final List<DescriptionListEntry> items = ((DescriptionList) node).getItems(); | ||
final Sink sink = getSink(); | ||
|
||
if (!items.isEmpty()) { | ||
sink.definitionList(); | ||
for (DescriptionListEntry item : items) { | ||
// About the model, see https://asciidoctor.zulipchat.com/#narrow/stream/279642-users/topic/.E2.9C.94.20Description.20List.20AST.20structure/near/419353063 | ||
final ListItem term = item.getTerms().get(0); | ||
sink.definedTerm(); | ||
sink.rawText(term.getText()); | ||
sink.definedTerm_(); | ||
|
||
final ListItem description = item.getDescription(); | ||
sink.definition(); | ||
if (description.getBlocks().isEmpty()) { | ||
sink.rawText(description.getText()); | ||
} else { | ||
itemNodeProcessor.process(description); | ||
} | ||
sink.definition_(); | ||
} | ||
sink.definitionList_(); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.