All Downloads are FREE. Search and download functionalities are using the official Maven repository.

aQute.lib.markdown.MarkdownFormatter Maven / Gradle / Ivy

There is a newer version: 7.1.0
Show newest version
package aQute.lib.markdown;

import java.util.Formatter;

public class MarkdownFormatter {

	private Formatter f;

	public MarkdownFormatter(Appendable out) {
		f = new Formatter(out);
	}

	public MarkdownFormatter format(String format, Object... args) {
		f = f.format(format, args);
		return this;
	}

	public MarkdownFormatter h1(String format, Object... args) {
		f = f.format("# " + format + " #%n", args);
		return this;
	}

	public MarkdownFormatter h2(String format, Object... args) {
		f = f.format("## " + format + " ##%n", args);
		return this;
	}

	public MarkdownFormatter h3(String format, Object... args) {
		f = f.format("### " + format + " ###%n", args);
		return this;
	}

	public MarkdownFormatter list(String format, Object... args) {
		f = f.format("+ " + format + "%n", args);
		return this;
	}

	@Override
	public String toString() {
		return f.toString();
	}

	public MarkdownFormatter code(String format, Object... args) {
		f = f.format("\t" + format + "%n", args);
		return this;
	}

	public MarkdownFormatter inlineCode(String format, Object... args) {
		f = f.format("`" + format + "`", args);
		return this;
	}

	public MarkdownFormatter endP() {
		f = f.format("%n%n");
		return this;
	}

	public MarkdownFormatter flush() {
		f.flush();
		return this;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy