-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #934 from robertpanzer/fix-931-setLevel
Fixes #931. Add method StructuralNode.setLevel()
- Loading branch information
Showing
6 changed files
with
82 additions
and
1 deletion.
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
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
31 changes: 31 additions & 0 deletions
31
asciidoctorj-core/src/test/java/org/asciidoctor/converter/LevelConverter.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,31 @@ | ||
package org.asciidoctor.converter; | ||
|
||
import org.asciidoctor.ast.ContentNode; | ||
import org.asciidoctor.ast.Document; | ||
import org.asciidoctor.ast.Section; | ||
|
||
import java.util.Map; | ||
|
||
public class LevelConverter extends StringConverter { | ||
|
||
public LevelConverter(String backend, Map<String, Object> opts) { // <2> | ||
super(backend, opts); | ||
} | ||
|
||
@Override | ||
public String convert( | ||
ContentNode node, String transform, Map<Object, Object> o) { | ||
|
||
if (node instanceof Document) { | ||
Document document = (Document) node; | ||
return document.getContent().toString(); | ||
} else if (node instanceof Section) { | ||
Section section = (Section) node; | ||
return new StringBuilder() | ||
.append("== ").append(section.getLevel()).append(" ").append(section.getTitle()).append(" ==") | ||
.toString(); | ||
} | ||
return null; | ||
} | ||
|
||
} |
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