Record indented data structures and output them in various formats

Download .zip Download .tar.gz View on GitHub

Usage

Paragraph paragraph = new Paragraph();
paragraph.append("How to bake a cake");
paragraph.indent();
paragraph.append("Preheat oven");
paragraph.append("Mix ingredients");
paragraph.indent();
paragraph.append("eggs");
paragraph.append("flour");
paragraph.append("sugar");
paragraph.append("butter");
paragraph.append("milk");
paragraph.append("vanilla");
paragraph.unindent();
paragraph.append("Pour batter into greased pan");
paragraph.append("Bake");
paragraph.unindent();

Output in various formats

HTML List

new HtmlListFormatter().format(paragraph);

<ul>
    <li>How to bake a cake
        <ul>
            <li>Preheat oven</li>
            <li>Mix ingredients
                <ul>
                    <li>eggs</li>
                    <li>flour</li>
                    <li>sugar</li>
                    <li>butter</li>
                    <li>milk</li>
                    <li>vanilla</li>
               </ul>
            </li>
            <li>Pour batter into greased pan</li>
            <li>Bake</li>
        </ul>
    </li>
</ul>

Tabbed

new TabbedFormatter().format(paragraph);

How to bake a cake
\tPreheat oven
\tMix ingredients
\t\teggs
\t\tflour
\t\tsugar
\t\tbutter
\t\tmilk
\t\tvanilla
\tPour batter into greased pan
\tBake