diff --git a/src/main/java/com/github/rjeschke/txtmark/Block.java b/src/main/java/com/github/rjeschke/txtmark/Block.java index 01bd969..ab3819b 100644 --- a/src/main/java/com/github/rjeschke/txtmark/Block.java +++ b/src/main/java/com/github/rjeschke/txtmark/Block.java @@ -36,7 +36,7 @@ class Block public String id = null; /** Block meta information */ public String meta = ""; - + /** Constructor. */ public Block() { diff --git a/src/main/java/com/github/rjeschke/txtmark/Configuration.java b/src/main/java/com/github/rjeschke/txtmark/Configuration.java index 2359e96..3acfdee 100644 --- a/src/main/java/com/github/rjeschke/txtmark/Configuration.java +++ b/src/main/java/com/github/rjeschke/txtmark/Configuration.java @@ -101,7 +101,7 @@ public class Configuration private Decorator decorator = new DefaultDecorator(); private BlockEmitter codeBlockEmitter = null; private SpanEmitter specialLinkEmitter = null; - + /** * Constructor. * @@ -206,7 +206,8 @@ public class Configuration /** * Sets the emitter for special link spans ([[ ... ]]). * - * @param emitter The emitter. + * @param emitter + * The emitter. * @return This builder. * @since 0.7 */ @@ -215,7 +216,7 @@ public class Configuration this.specialLinkEmitter = emitter; return this; } - + /** * Builds a configuration instance. * diff --git a/src/main/java/com/github/rjeschke/txtmark/Decorator.java b/src/main/java/com/github/rjeschke/txtmark/Decorator.java index a5d6fe0..c29b05d 100644 --- a/src/main/java/com/github/rjeschke/txtmark/Decorator.java +++ b/src/main/java/com/github/rjeschke/txtmark/Decorator.java @@ -25,20 +25,32 @@ public interface Decorator /** * Called when a paragraph is opened. * - *
Default implementation is:
- *out.append("<p>");
+ * + * Default implementation is: + *
* - * @param out The StringBuilder to write to. + *
+ * out.append("<p>");
+ *
+ *
+ * @param out
+ * The StringBuilder to write to.
*/
public void openParagraph(final StringBuilder out);
-
+
/**
* Called when a paragraph is closed.
*
- * Default implementation is:
- *out.append("</p>\n");
+ * + * Default implementation is: + *
* - * @param out The StringBuilder to write to. + *
+ * out.append("</p>\n");
+ *
+ *
+ * @param out
+ * The StringBuilder to write to.
*/
public void closeParagraph(final StringBuilder out);
@@ -46,236 +58,380 @@ public interface Decorator
* Called when a blockquote is opened.
*
* Default implementation is:
- * out.append("<blockquote>");
*
- * @param out The StringBuilder to write to.
+ *
+ * out.append("<blockquote>");
+ *
+ *
+ * @param out
+ * The StringBuilder to write to.
*/
public void openBlockquote(final StringBuilder out);
-
+
/**
* Called when a blockquote is closed.
*
- * Default implementation is:
- *out.append("</blockquote>\n");
+ * + * Default implementation is: + *
* - * @param out The StringBuilder to write to. + *
+ * out.append("</blockquote>\n");
+ *
+ *
+ * @param out
+ * The StringBuilder to write to.
*/
public void closeBlockquote(final StringBuilder out);
-
+
/**
* Called when a code block is opened.
*
- * Default implementation is:
- *out.append("<pre><code>");
+ * + * Default implementation is: + *
* - * @param out The StringBuilder to write to. + *
+ * out.append("<pre><code>");
+ *
+ *
+ * @param out
+ * The StringBuilder to write to.
*/
public void openCodeBlock(final StringBuilder out);
-
+
/**
* Called when a code block is closed.
*
- * Default implementation is:
- *out.append("</code></pre>\n");
+ * + * Default implementation is: + *
* - * @param out The StringBuilder to write to. + *
+ * out.append("</code></pre>\n");
+ *
+ *
+ * @param out
+ * The StringBuilder to write to.
*/
public void closeCodeBlock(final StringBuilder out);
-
+
/**
* Called when a code span is opened.
*
- * Default implementation is:
- *out.append("<code>");
+ * + * Default implementation is: + *
* - * @param out The StringBuilder to write to. + *
+ * out.append("<code>");
+ *
+ *
+ * @param out
+ * The StringBuilder to write to.
*/
public void openCodeSpan(final StringBuilder out);
/**
* Called when a code span is closed.
*
- * Default implementation is:
- *out.append("</code>");
+ * + * Default implementation is: + *
* - * @param out The StringBuilder to write to. + *
+ * out.append("</code>");
+ *
+ *
+ * @param out
+ * The StringBuilder to write to.
*/
public void closeCodeSpan(final StringBuilder out);
-
+
/**
* Called when a headline is opened.
*
- * Note: Don't close the HTML tag!
- *Default implementation is:
- * out.append("<h");
- * out.append(level);
+ * + * Note: Don't close the HTML tag! + *
+ *+ * Default implementation is: + *
* - * @param out The StringBuilder to write to. + *
+ * out.append("<h");
+ * out.append(level);
+ *
+ *
+ * @param out
+ * The StringBuilder to write to.
*/
public void openHeadline(final StringBuilder out, int level);
-
+
/**
* Called when a headline is closed.
*
- * Default implementation is:
- * out.append("</h");
- * out.append(level);
- * out.append(">\n");
+ * + * Default implementation is: + *
* - * @param out The StringBuilder to write to. + *
+ * out.append("</h");
+ * out.append(level);
+ * out.append(">\n");
+ *
+ *
+ * @param out
+ * The StringBuilder to write to.
*/
public void closeHeadline(final StringBuilder out, int level);
/**
* Called when a strong span is opened.
*
- * Default implementation is:
- *out.append("<strong>");
+ * + * Default implementation is: + *
* - * @param out The StringBuilder to write to. + *
+ * out.append("<strong>");
+ *
+ *
+ * @param out
+ * The StringBuilder to write to.
*/
public void openStrong(final StringBuilder out);
/**
* Called when a strong span is closed.
*
- * Default implementation is:
- *out.append("</strong>");
+ * + * Default implementation is: + *
* - * @param out The StringBuilder to write to. + *
+ * out.append("</strong>");
+ *
+ *
+ * @param out
+ * The StringBuilder to write to.
*/
public void closeStrong(final StringBuilder out);
-
+
/**
* Called when an emphasis span is opened.
*
- * Default implementation is:
- *out.append("<em>");
+ * + * Default implementation is: + *
* - * @param out The StringBuilder to write to. + *
+ * out.append("<em>");
+ *
+ *
+ * @param out
+ * The StringBuilder to write to.
*/
public void openEmphasis(final StringBuilder out);
-
+
/**
* Called when an emphasis span is closed.
*
- * Default implementation is:
- *out.append("</em>");
+ * + * Default implementation is: + *
* - * @param out The StringBuilder to write to. + *
+ * out.append("</em>");
+ *
+ *
+ * @param out
+ * The StringBuilder to write to.
*/
public void closeEmphasis(final StringBuilder out);
/**
* Called when a superscript span is opened.
*
- * Default implementation is:
- *out.append("<sup>");
+ * + * Default implementation is: + *
* - * @param out The StringBuilder to write to. + *
+ * out.append("<sup>");
+ *
+ *
+ * @param out
+ * The StringBuilder to write to.
*/
public void openSuper(final StringBuilder out);
/**
* Called when a superscript span is closed.
*
- * Default implementation is:
- *out.append("</sup>");
+ * + * Default implementation is: + *
* - * @param out The StringBuilder to write to. + *
+ * out.append("</sup>");
+ *
+ *
+ * @param out
+ * The StringBuilder to write to.
*/
public void closeSuper(final StringBuilder out);
/**
* Called when an ordered list is opened.
*
- * Default implementation is:
- *out.append("<ol>\n");
+ * + * Default implementation is: + *
* - * @param out The StringBuilder to write to. + *
+ * out.append("<ol>\n");
+ *
+ *
+ * @param out
+ * The StringBuilder to write to.
*/
public void openOrderedList(final StringBuilder out);
-
+
/**
* Called when an ordered list is closed.
*
- * Default implementation is:
- *out.append("</ol>\n");
+ * + * Default implementation is: + *
* - * @param out The StringBuilder to write to. + *
+ * out.append("</ol>\n");
+ *
+ *
+ * @param out
+ * The StringBuilder to write to.
*/
public void closeOrderedList(final StringBuilder out);
/**
* Called when an unordered list is opened.
*
- * Default implementation is:
- *out.append("<ul>\n");
+ * + * Default implementation is: + *
* - * @param out The StringBuilder to write to. + *
+ * out.append("<ul>\n");
+ *
+ *
+ * @param out
+ * The StringBuilder to write to.
*/
public void openUnorderedList(final StringBuilder out);
-
+
/**
* Called when an unordered list is closed.
*
- * Default implementation is:
- *out.append("</ul>\n");
+ * + * Default implementation is: + *
* - * @param out The StringBuilder to write to. + *
+ * out.append("</ul>\n");
+ *
+ *
+ * @param out
+ * The StringBuilder to write to.
*/
public void closeUnorderedList(final StringBuilder out);
-
+
/**
* Called when a list item is opened.
*
- * Note: Don't close the HTML tag!
- *Default implementation is:
- *out.append("<li");
+ * + * Note: Don't close the HTML tag! + *
+ *+ * Default implementation is: + *
* - * @param out The StringBuilder to write to. + *
+ * out.append("<li");
+ *
+ *
+ * @param out
+ * The StringBuilder to write to.
*/
public void openListItem(final StringBuilder out);
-
+
/**
* Called when a list item is closed.
*
- * Default implementation is:
- *out.append("</li>\n");
+ * + * Default implementation is: + *
* - * @param out The StringBuilder to write to. + *
+ * out.append("</li>\n");
+ *
+ *
+ * @param out
+ * The StringBuilder to write to.
*/
public void closeListItem(final StringBuilder out);
-
+
/**
* Called when a horizontal ruler is encountered.
*
- * Default implementation is:
- *out.append("<hr />\n");
+ * + * Default implementation is: + *
* - * @param out The StringBuilder to write to. + *
+ * out.append("<hr />\n");
+ *
+ *
+ * @param out
+ * The StringBuilder to write to.
*/
public void horizontalRuler(final StringBuilder out);
-
+
/**
* Called when a link is opened.
*
- * Note: Don't close the HTML tag!
- *Default implementation is:
- *out.append("<a");
+ * + * Note: Don't close the HTML tag! + *
+ *+ * Default implementation is: + *
* - * @param out The StringBuilder to write to. + *
+ * out.append("<a");
+ *
+ *
+ * @param out
+ * The StringBuilder to write to.
*/
public void openLink(final StringBuilder out);
-
+
/**
* Called when an image is opened.
*
- * Note: Don't close the HTML tag!
- *Default implementation is:
- *out.append("<img");
+ * + * Note: Don't close the HTML tag! + *
+ *+ * Default implementation is: + *
* - * @param out The StringBuilder to write to. + *
+ * out.append("<img");
+ *
+ *
+ * @param out
+ * The StringBuilder to write to.
*/
public void openImage(final StringBuilder out);
}
diff --git a/src/main/java/com/github/rjeschke/txtmark/Emitter.java b/src/main/java/com/github/rjeschke/txtmark/Emitter.java
index 7b86bbd..27cc581 100644
--- a/src/main/java/com/github/rjeschke/txtmark/Emitter.java
+++ b/src/main/java/com/github/rjeschke/txtmark/Emitter.java
@@ -31,7 +31,7 @@ class Emitter
private final Configuration config;
/** Extension flag. */
public boolean useExtensions = false;
-
+
/** Constructor. */
public Emitter(final Configuration config)
{
@@ -42,8 +42,10 @@ class Emitter
/**
* Adds a LinkRef to this set of LinkRefs.
*
- * @param key The key/id.
- * @param linkRef The LinkRef.
+ * @param key
+ * The key/id.
+ * @param linkRef
+ * The LinkRef.
*/
public void addLinkRef(final String key, final LinkRef linkRef)
{
@@ -53,8 +55,10 @@ class Emitter
/**
* Transforms the given block recursively into HTML.
*
- * @param out The StringBuilder to write to.
- * @param root The Block to process.
+ * @param out
+ * The StringBuilder to write to.
+ * @param root
+ * The Block to process.
*/
public void emit(final StringBuilder out, final Block root)
{
@@ -156,8 +160,10 @@ class Emitter
/**
* Transforms lines into HTML.
*
- * @param out The StringBuilder to write to.
- * @param block The Block to process.
+ * @param out
+ * The StringBuilder to write to.
+ * @param block
+ * The Block to process.
*/
private void emitLines(final StringBuilder out, final Block block)
{
@@ -181,9 +187,12 @@ class Emitter
/**
* Finds the position of the given Token in the given String.
*
- * @param in The String to search on.
- * @param start The starting character position.
- * @param token The token to find.
+ * @param in
+ * The String to search on.
+ * @param start
+ * The starting character position.
+ * @param token
+ * The token to find.
* @return The position of the token or -1 if none could be found.
*/
private int findToken(final String in, int start, MarkToken token)
@@ -201,10 +210,14 @@ class Emitter
/**
* Checks if there is a valid markdown link definition.
*
- * @param out The StringBuilder containing the generated output.
- * @param in Input String.
- * @param start Starting position.
- * @param token Either LINK or IMAGE.
+ * @param out
+ * The StringBuilder containing the generated output.
+ * @param in
+ * Input String.
+ * @param start
+ * Starting position.
+ * @param token
+ * Either LINK or IMAGE.
* @return The new position or -1 if there is no valid markdown link.
*/
private int checkLink(final StringBuilder out, final String in, int start, MarkToken token)
@@ -212,7 +225,7 @@ class Emitter
boolean isAbbrev = false;
int pos = start + (token == MarkToken.LINK ? 1 : 2);
final StringBuilder temp = new StringBuilder();
-
+
temp.setLength(0);
pos = Utils.readMdLinkId(temp, in, pos);
if(pos < start)
@@ -355,12 +368,15 @@ class Emitter
}
/**
- * Check if there is a valid HTML tag here.
- * This method also transforms auto links and mailto auto links.
+ * Check if there is a valid HTML tag here. This method also transforms auto
+ * links and mailto auto links.
*
- * @param out The StringBuilder to write to.
- * @param in Input String.
- * @param start Starting position.
+ * @param out
+ * The StringBuilder to write to.
+ * @param in
+ * Input String.
+ * @param start
+ * Starting position.
* @return The new position or -1 if nothing valid has been found.
*/
private int checkHtml(final StringBuilder out, final String in, int start)
@@ -386,7 +402,7 @@ class Emitter
return pos;
}
}
-
+
// Check for mailto auto link
temp.setLength(0);
pos = Utils.readUntil(temp, in, start + 1, '@', ' ', '>', '\n');
@@ -406,23 +422,26 @@ class Emitter
return pos;
}
}
-
+
// Check for inline html
if(start + 2 < in.length())
{
temp.setLength(0);
return Utils.readXML(out, in, start, this.config.safeMode);
- }
-
+ }
+
return -1;
}
-
+
/**
* Check if this is a valid XML/HTML entity.
*
- * @param out The StringBuilder to write to.
- * @param in Input String.
- * @param start Starting position
+ * @param out
+ * The StringBuilder to write to.
+ * @param in
+ * Input String.
+ * @param start
+ * Starting position
* @return The new position or -1 if this entity in invalid.
*/
private static int checkEntity(final StringBuilder out, final String in, int start)
@@ -465,18 +484,24 @@ class Emitter
out.append(';');
return HTML.isEntity(out.toString()) ? pos : -1;
}
-
+
return pos;
}
-
+
/**
- * Recursively scans through the given line, taking care of any markdown stuff.
+ * Recursively scans through the given line, taking care of any markdown
+ * stuff.
*
- * @param out The StringBuilder to write to.
- * @param in Input String.
- * @param start Start position.
- * @param token The matching Token (for e.g. '*')
- * @return The position of the matching Token or -1 if token was NONE or no Token could be found.
+ * @param out
+ * The StringBuilder to write to.
+ * @param in
+ * Input String.
+ * @param start
+ * Start position.
+ * @param token
+ * The matching Token (for e.g. '*')
+ * @return The position of the matching Token or -1 if token was NONE or no
+ * Token could be found.
*/
private int recursiveEmitLine(final StringBuilder out, final String in, int start, MarkToken token)
{
@@ -485,7 +510,9 @@ class Emitter
while(pos < in.length())
{
final MarkToken mt = this.getToken(in, pos);
- if(token != MarkToken.NONE && (mt == token || token == MarkToken.EM_STAR && mt == MarkToken.STRONG_STAR || token == MarkToken.EM_UNDERSCORE && mt == MarkToken.STRONG_UNDERSCORE))
+ if(token != MarkToken.NONE
+ && (mt == token || token == MarkToken.EM_STAR && mt == MarkToken.STRONG_STAR || token == MarkToken.EM_UNDERSCORE
+ && mt == MarkToken.STRONG_UNDERSCORE))
return pos;
switch(mt)
@@ -666,14 +693,16 @@ class Emitter
/**
* Check if there is any markdown Token.
*
- * @param in Input String.
- * @param pos Starting position.
+ * @param in
+ * Input String.
+ * @param pos
+ * Starting position.
* @return The Token.
*/
private MarkToken getToken(final String in, final int pos)
{
final char c0 = pos > 0 ? in.charAt(pos - 1) : ' ';
- final char c = in.charAt(pos);
+ final char c = in.charAt(pos);
final char c1 = pos + 1 < in.length() ? in.charAt(pos + 1) : ' ';
final char c2 = pos + 2 < in.length() ? in.charAt(pos + 2) : ' ';
final char c3 = pos + 3 < in.length() ? in.charAt(pos + 3) : ' ';
@@ -785,8 +814,10 @@ class Emitter
/**
* Writes a set of markdown lines into the StringBuilder.
*
- * @param out The StringBuilder to write to.
- * @param lines The lines to write.
+ * @param out
+ * The StringBuilder to write to.
+ * @param lines
+ * The lines to write.
*/
private void emitMarkedLines(final StringBuilder out, final Line lines)
{
@@ -811,8 +842,10 @@ class Emitter
/**
* Writes a set of raw lines into the StringBuilder.
*
- * @param out The StringBuilder to write to.
- * @param lines The lines to write.
+ * @param out
+ * The StringBuilder to write to.
+ * @param lines
+ * The lines to write.
*/
private void emitRawLines(final StringBuilder out, final Line lines)
{
@@ -869,9 +902,12 @@ class Emitter
/**
* Writes a code block into the StringBuilder.
*
- * @param out The StringBuilder to write to.
- * @param lines The lines to write.
- * @param meta Meta information.
+ * @param out
+ * The StringBuilder to write to.
+ * @param lines
+ * The lines to write.
+ * @param meta
+ * Meta information.
*/
private void emitCodeLines(final StringBuilder out, final Line lines, final String meta, final boolean removeIndent)
{
diff --git a/src/main/java/com/github/rjeschke/txtmark/LinkRef.java b/src/main/java/com/github/rjeschke/txtmark/LinkRef.java
index 5c702c8..aea77b6 100644
--- a/src/main/java/com/github/rjeschke/txtmark/LinkRef.java
+++ b/src/main/java/com/github/rjeschke/txtmark/LinkRef.java
@@ -32,8 +32,10 @@ class LinkRef
/**
* Constructor.
*
- * @param link The link.
- * @param title The title (may be null).
+ * @param link
+ * The link.
+ * @param title
+ * The title (may be null).
*/
public LinkRef(final String link, final String title, final boolean isAbbrev)
{
diff --git a/src/main/java/com/github/rjeschke/txtmark/Processor.java b/src/main/java/com/github/rjeschke/txtmark/Processor.java
index 56a9c8d..64fb34b 100644
--- a/src/main/java/com/github/rjeschke/txtmark/Processor.java
+++ b/src/main/java/com/github/rjeschke/txtmark/Processor.java
@@ -269,7 +269,8 @@ public class Processor
* if an IO error occurs
* @see Configuration#DEFAULT
*/
- public final static String process(final File file, final Decorator decorator, final boolean safeMode) throws IOException
+ public final static String process(final File file, final Decorator decorator, final boolean safeMode)
+ throws IOException
{
return process(file, Configuration.builder().setDecorator(decorator).setSafeMode(safeMode).build());
}
@@ -305,7 +306,8 @@ public class Processor
* if an IO error occurs
* @see Configuration#DEFAULT
*/
- public final static String process(final File file, final String encoding, final boolean safeMode) throws IOException
+ public final static String process(final File file, final String encoding, final boolean safeMode)
+ throws IOException
{
return process(file, Configuration.builder().setEncoding(encoding).setSafeMode(safeMode).build());
}
@@ -324,7 +326,8 @@ public class Processor
* if an IO error occurs
* @see Configuration#DEFAULT
*/
- public final static String process(final File file, final String encoding, final Decorator decorator) throws IOException
+ public final static String process(final File file, final String encoding, final Decorator decorator)
+ throws IOException
{
return process(file, Configuration.builder().setEncoding(encoding).setDecorator(decorator).build());
}
@@ -869,7 +872,8 @@ public class Processor
{
if(line.getLineType(this.useExtensions) == LineType.FENCED_CODE)
break;
- // TODO ... is this really necessary? Maybe add a special flag?
+ // TODO ... is this really necessary? Maybe add a special
+ // flag?
line = line.next;
}
if(line != null)
diff --git a/src/main/java/com/github/rjeschke/txtmark/Run.java b/src/main/java/com/github/rjeschke/txtmark/Run.java
index 63f2ce6..0724273 100644
--- a/src/main/java/com/github/rjeschke/txtmark/Run.java
+++ b/src/main/java/com/github/rjeschke/txtmark/Run.java
@@ -24,30 +24,41 @@ import java.io.InputStreamReader;
/**
* Simple class for processing markdown files on the command line.
*
- * Usage:
- *java -cp txtmark.jar txtmark.Run filename [header_footer_file]
- *
+ * + * Usage: + *
* - *The header_footer_file is an optional UTF-8 encoded file containing
- * a header and a footer to output around the generated HTML code.
+ * java -cp txtmark.jar txtmark.Run filename [header_footer_file]
+ *
+ *
*
- * Example:
+ *
+ * The header_footer_file is an optional UTF-8 encoded file
+ * containing a header and a footer to output around the generated HTML code.
+ *
<?xml version="1.0" encoding="UTF-8"?>
- *<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- * "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- *<html xmlns="http://www.w3.org/1999/xhtml">
- *<head>
- *<title>markdown</title>
- *<link type="text/css" href="style.css" rel="stylesheet"/>
- *<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
- *</head>
- *<body>
- *<!-- the following line separates header from footer -->
- *<!-- ### -->
- *</body>
- *</html>
- *
+ * + * Example: + *
+ * + *
+ * <?xml version="1.0" encoding="UTF-8"?>
+ * <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ * "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+ * <html xmlns="http://www.w3.org/1999/xhtml">
+ * <head>
+ * <title>markdown</title>
+ * <link type="text/css" href="style.css" rel="stylesheet"/>
+ * <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
+ * </head>
+ * <body>
+ * <!-- the following line separates header from footer -->
+ * <!-- ### -->
+ * </body>
+ * </html>
+ *
+ *
*
* @author René Jeschke ` and trims spaces.
*
- * @param fenceLine Fenced code block starting line
+ * @param fenceLine
+ * Fenced code block starting line
* @return Rest of the line after trimming and backtick removal
* @since 0.7
*/