Class AsciiDoc
- java.lang.Object
-
- org.forgerock.api.markup.asciidoc.AsciiDoc
-
public final class AsciiDoc extends Object
Root builder for AsciiDoc markup. All operations may be applied at the current linear position within the document being built, such that markup that must appear at the top should be added first.This class is not thread-safe.
-
-
Field Summary
Fields Modifier and Type Field Description static Pattern
INCLUDE_PATTERN
Regex for finding Include-directives, where group 1 contains the path-value.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AsciiDoc
anchor(String id)
Inserts a cross-reference anchor.AsciiDoc
anchor(String id, String xreflabel)
Inserts a cross-reference anchor, with a custom xreflabel.static AsciiDoc
asciiDoc()
Creates a new builder instance.AsciiDoc
blockTitle(String title)
Inserts a block title.AsciiDoc
boldText(String text)
Inserts bold text.AsciiDoc
documentTitle(String title)
Inserts a document title.AsciiDoc
exampleBlock(String content)
Inserts an example-block.AsciiDoc
horizontalRule()
Inserts a horizontal-rule divider.AsciiDoc
include(String... path)
Inserts an include-directive, given a relative path to a file.AsciiDoc
italic(String text)
Inserts italic text.AsciiDoc
link(String anchorId)
Inserts a cross-reference link.AsciiDoc
link(String anchorId, String xreflabel)
Inserts a cross-reference link, with a custom xreflabel.AsciiDoc
listContinuation()
Inserts a list-continuation, for adding complex formatted content to a list.AsciiDoc
listingBlock(String content)
Inserts a listing-block.AsciiDoc
listingBlock(String content, String sourceType)
Inserts a listing-block, with the source-code type (e.g., java, json, etc.) noted for formatting purposes.AsciiDoc
literalBlock(String content)
Inserts a literal-block.AsciiDoc
mono(String text)
Inserts monospaced (e.g., code) text.AsciiDoc
newline()
Inserts a UNIX newline character, where two adjacent newlines will create a new paragraph.static String
normalizeName(String... parts)
Normalizes a name such that it can be used as a unique filename and/or anchor in AsciiDoc.AsciiDoc
passthroughBlock(String content)
Inserts a pass-through-block.AsciiDoc
rawLine(String text)
Inserts raw line (may contain markup), and will insert one newline-characters above and below, if those newlines do not already exist.AsciiDoc
rawParagraph(String text)
Inserts raw paragraph (may contain markup), and will insert two newline-characters above and below, if those newlines do not already exist [ref].AsciiDoc
rawText(String text)
Inserts raw text (may contain markup or only whitespace).AsciiDoc
sectionTitle(String title, int level)
Inserts a section title, at a given level.AsciiDoc
sectionTitle1(String title)
Inserts a section title, level 1.AsciiDoc
sectionTitle2(String title)
Inserts a section title, level 2.AsciiDoc
sectionTitle3(String title)
Inserts a section title, level 3.AsciiDoc
sectionTitle4(String title)
Inserts a section title, level 4.AsciiDoc
sectionTitle5(String title)
Inserts a section title, level 5.AsciiDoc
sidebarBlock(String content)
Inserts a sidebar-block.AsciiDocTable
tableStart()
Starts a table at the current position.void
toFile(Path outputDirPath, String filename)
Saves builder content to a file.String
toString()
Converts builder content to aString
.AsciiDoc
unorderedList1(String content)
Inserts a line for an unordered list, at level 1 indentation.
-
-
-
Field Detail
-
INCLUDE_PATTERN
public static final Pattern INCLUDE_PATTERN
Regex for finding Include-directives, where group 1 contains the path-value.- See Also:
include(String...)
-
-
Method Detail
-
asciiDoc
public static AsciiDoc asciiDoc()
Creates a new builder instance.- Returns:
- builder
-
newline
public AsciiDoc newline()
Inserts a UNIX newline character, where two adjacent newlines will create a new paragraph. As a best-practice, they suggest one-sentence-per-line style.- Returns:
- builder
-
rawText
public AsciiDoc rawText(String text)
Inserts raw text (may contain markup or only whitespace).- Parameters:
text
- Raw text/markup- Returns:
- builder
-
rawLine
public AsciiDoc rawLine(String text)
Inserts raw line (may contain markup), and will insert one newline-characters above and below, if those newlines do not already exist.- Parameters:
text
- Raw text/markup- Returns:
- builder
-
rawParagraph
public AsciiDoc rawParagraph(String text)
Inserts raw paragraph (may contain markup), and will insert two newline-characters above and below, if those newlines do not already exist [ref].- Parameters:
text
- Raw text/markup- Returns:
- builder
-
boldText
public AsciiDoc boldText(String text)
Inserts bold text.- Parameters:
text
- Text to make bold- Returns:
- builder
-
italic
public AsciiDoc italic(String text)
Inserts italic text.- Parameters:
text
- Text to make bold- Returns:
- Doc builder
-
mono
public AsciiDoc mono(String text)
Inserts monospaced (e.g., code) text.- Parameters:
text
- Text to make monospaced- Returns:
- Doc builder
-
documentTitle
public AsciiDoc documentTitle(String title)
Inserts a document title.- Parameters:
title
- Document title- Returns:
- Doc builder
-
blockTitle
public AsciiDoc blockTitle(String title)
Inserts a block title.- Parameters:
title
- Block title- Returns:
- Doc builder
-
sectionTitle
public AsciiDoc sectionTitle(String title, int level)
Inserts a section title, at a given level.- Parameters:
title
- Section titlelevel
- Section level [1-5]- Returns:
- Doc builder
-
sectionTitle1
public AsciiDoc sectionTitle1(String title)
Inserts a section title, level 1.- Parameters:
title
- Section title- Returns:
- Doc builder
-
sectionTitle2
public AsciiDoc sectionTitle2(String title)
Inserts a section title, level 2.- Parameters:
title
- Section title- Returns:
- Doc builder
-
sectionTitle3
public AsciiDoc sectionTitle3(String title)
Inserts a section title, level 3.- Parameters:
title
- Section title- Returns:
- Doc builder
-
sectionTitle4
public AsciiDoc sectionTitle4(String title)
Inserts a section title, level 4.- Parameters:
title
- Section title- Returns:
- Doc builder
-
sectionTitle5
public AsciiDoc sectionTitle5(String title)
Inserts a section title, level 5.- Parameters:
title
- Section title- Returns:
- Doc builder
-
exampleBlock
public AsciiDoc exampleBlock(String content)
Inserts an example-block.- Parameters:
content
- Content- Returns:
- Doc builder
-
listingBlock
public AsciiDoc listingBlock(String content)
Inserts a listing-block.- Parameters:
content
- Content- Returns:
- Doc builder
-
listingBlock
public AsciiDoc listingBlock(String content, String sourceType)
Inserts a listing-block, with the source-code type (e.g., java, json, etc.) noted for formatting purposes.- Parameters:
content
- ContentsourceType
- Type of source-code in the listing- Returns:
- Doc builder
-
literalBlock
public AsciiDoc literalBlock(String content)
Inserts a literal-block.- Parameters:
content
- Content- Returns:
- Doc builder
-
passthroughBlock
public AsciiDoc passthroughBlock(String content)
Inserts a pass-through-block.- Parameters:
content
- Content- Returns:
- Doc builder
-
sidebarBlock
public AsciiDoc sidebarBlock(String content)
Inserts a sidebar-block.- Parameters:
content
- Content- Returns:
- Doc builder
-
anchor
public AsciiDoc anchor(String id)
Inserts a cross-reference anchor.- Parameters:
id
- Anchor ID- Returns:
- Doc builder
-
anchor
public AsciiDoc anchor(String id, String xreflabel)
Inserts a cross-reference anchor, with a custom xreflabel.- Parameters:
id
- Anchor IDxreflabel
- Custom cross-reference link- Returns:
- Doc builder
-
link
public AsciiDoc link(String anchorId)
Inserts a cross-reference link.- Parameters:
anchorId
- Anchor ID- Returns:
- Doc builder
-
link
public AsciiDoc link(String anchorId, String xreflabel)
Inserts a cross-reference link, with a custom xreflabel.- Parameters:
anchorId
- Anchor IDxreflabel
- Custom cross-reference link- Returns:
- Doc builder
-
unorderedList1
public AsciiDoc unorderedList1(String content)
Inserts a line for an unordered list, at level 1 indentation.- Parameters:
content
- Line of content- Returns:
- Doc builder
-
listContinuation
public AsciiDoc listContinuation()
Inserts a list-continuation, for adding complex formatted content to a list.- Returns:
- Doc builder
-
horizontalRule
public AsciiDoc horizontalRule()
Inserts a horizontal-rule divider.- Returns:
- Doc builder
-
tableStart
public AsciiDocTable tableStart()
Starts a table at the current position.- Returns:
- Table builder
-
include
public AsciiDoc include(String... path)
Inserts an include-directive, given a relative path to a file.- Parameters:
path
- Relative path segments- Returns:
- Doc builder
-
toFile
public void toFile(Path outputDirPath, String filename) throws IOException
Saves builder content to a file.- Parameters:
outputDirPath
- Output directoryfilename
- Filename- Throws:
IOException
- When error occurs while saving.
-
toString
public String toString()
Converts builder content to aString
.
-
normalizeName
public static String normalizeName(String... parts)
Normalizes a name such that it can be used as a unique filename and/or anchor in AsciiDoc. Names are converted to lower-case, unsupported characters are collapsed to a single underscore-character, and parts are separated by an underscore.- Parameters:
parts
- Name-parts to normalize- Returns:
- Normalized name
-
-