From 3c082b00ac38260bbed847ff39d3d1307edc3c89 Mon Sep 17 00:00:00 2001
From: piergiuseppe la cava
Date: Thu, 29 Dec 2016 19:51:50 +0100
Subject: [PATCH 1/9] Add Table supports as BlockEmitter and Plugin. Add test
case and chage pom.xml version
---
.../org/markdown4j/TableBlockEmitter.java | 50 +++++++++++++++++++
.../markdown4j/TestMardown4jProcessor.java | 24 +++++++++
src/test/resources/table.txt | 12 +++++
src/test/resources/tableAsPlugin.txt | 5 ++
4 files changed, 91 insertions(+)
create mode 100644 src/main/java/org/markdown4j/TableBlockEmitter.java
create mode 100644 src/test/java/org/markdown4j/TestMardown4jProcessor.java
create mode 100644 src/test/resources/table.txt
create mode 100644 src/test/resources/tableAsPlugin.txt
diff --git a/src/main/java/org/markdown4j/TableBlockEmitter.java b/src/main/java/org/markdown4j/TableBlockEmitter.java
new file mode 100644
index 0000000..9f0d6cc
--- /dev/null
+++ b/src/main/java/org/markdown4j/TableBlockEmitter.java
@@ -0,0 +1,50 @@
+package org.markdown4j;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.github.rjeschke.txtmark.BlockEmitter;
+
+public class TableBlockEmitter implements BlockEmitter{
+
+ @Override
+ public void emitBlock(StringBuilder out, List lines, String meta) {
+ Map alignment = new HashMap();
+ StringBuilder myst = new StringBuilder();
+ myst.append("");
+ boolean first = true;
+ for (String string : lines) {
+ myst.append("");
+ String[] split = string.split("\\|");
+ Integer count = 0;
+ for (String string2 : split) {
+ if(string2.isEmpty()) continue;
+ count ++;
+ if(string2.trim().matches("\\:.*\\:")){
+ alignment.put(count, "center"); continue;
+ }else if(string2.trim().matches(".*\\:")){
+ alignment.put(count, "right"); continue;
+ }else if(string2.trim().matches("\\:.*")){
+ alignment.put(count, "left"); continue;
+ }
+ myst.append(first?"| ":" | ");
+ myst.append(string2);
+ myst.append(first?"":" | ");
+
+ }
+ myst.append("
");
+ first = false;
+ }
+ myst.append("
");
+ String string = myst.toString();
+ Set keySet = alignment.keySet();
+ for (Integer integer : keySet) {
+ string = string.replaceAll("calm=\""+integer+"\"", "style=\"text-align:"+alignment.get(integer)+"\"");
+ }
+ out.append(string);
+
+ }
+
+}
diff --git a/src/test/java/org/markdown4j/TestMardown4jProcessor.java b/src/test/java/org/markdown4j/TestMardown4jProcessor.java
new file mode 100644
index 0000000..5b07e94
--- /dev/null
+++ b/src/test/java/org/markdown4j/TestMardown4jProcessor.java
@@ -0,0 +1,24 @@
+package org.markdown4j;
+
+import java.io.FileReader;
+import java.io.IOException;
+import java.net.URL;
+
+import org.junit.Test;
+
+import com.github.rjeschke.txtmark.test.MarkupFileTester;
+
+public class TestMardown4jProcessor {
+
+ @Test
+ public void test() throws IOException {
+ Markdown4jProcessor markdown4jProcessor = new Markdown4jProcessor();
+ markdown4jProcessor = markdown4jProcessor.registerPlugins(new TablePlugin());
+ URL fileUrl = MarkupFileTester.class.getResource( "/table.txt" );
+ FileReader file = new FileReader( fileUrl.getFile() );
+ String process = markdown4jProcessor.process(file);
+ System.out.println(process);
+
+ }
+
+}
diff --git a/src/test/resources/table.txt b/src/test/resources/table.txt
new file mode 100644
index 0000000..25e12b6
--- /dev/null
+++ b/src/test/resources/table.txt
@@ -0,0 +1,12 @@
+# Test Table as Plugin
+%%% table
+| HEADER 1 | HEADER 2 | HEADER 3 |
+| :--- | :---: | ---: |
+|content 1 | content 2|content 3 |
+%%%
+
+#Test Table as native TABLE type
+| HEADER 1 | HEADER 2 | HEADER 3 |
+| :--- | :---: | ---: |
+|content 1 | content 2|content 3 |
+
diff --git a/src/test/resources/tableAsPlugin.txt b/src/test/resources/tableAsPlugin.txt
new file mode 100644
index 0000000..7b60436
--- /dev/null
+++ b/src/test/resources/tableAsPlugin.txt
@@ -0,0 +1,5 @@
+%%% table
+| HEADER 1 | HEADER 2 | HEADER 3 |
+| :--- | :---: | ---: |
+|content 1 | content 2|content 3 |
+%%%
From 68ae1449f46675a5cc217819ffc5648f4b49a220 Mon Sep 17 00:00:00 2001
From: piergiuseppe la cava
Date: Thu, 29 Dec 2016 19:59:21 +0100
Subject: [PATCH 2/9] Add Table supports as BlockEmitter and Plugin. Add test
case and chage pom.xml version
---
pom.xml | 2 +-
.../github/rjeschke/txtmark/BlockType.java | 4 +-
.../rjeschke/txtmark/Configuration.java | 16 ++++-
.../com/github/rjeschke/txtmark/Emitter.java | 58 ++++++++++++++++++-
.../com/github/rjeschke/txtmark/Line.java | 8 ++-
.../com/github/rjeschke/txtmark/LineType.java | 4 +-
.../github/rjeschke/txtmark/Processor.java | 22 ++++++-
.../org/markdown4j/Markdown4jProcessor.java | 2 +-
.../org/markdown4j/TableBlockEmitter.java | 4 ++
src/main/java/org/markdown4j/TablePlugin.java | 30 ++--------
.../markdown4j/TestMardown4jProcessor.java | 25 +++++++-
src/test/resources/table.txt | 8 ---
12 files changed, 137 insertions(+), 46 deletions(-)
diff --git a/pom.xml b/pom.xml
index 7b33bf5..eab507d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@
org.commonjava.googlecode.markdown4j
markdown4j
- 2.2-cj-1.2-SNAPSHOT
+ 2.2-plc-1.3-SNAPSHOT
scm:git:http://jdcasey@github.com/jdcasey/markdown4j.git
diff --git a/src/main/java/com/github/rjeschke/txtmark/BlockType.java b/src/main/java/com/github/rjeschke/txtmark/BlockType.java
index 03227b1..5603eb3 100644
--- a/src/main/java/com/github/rjeschke/txtmark/BlockType.java
+++ b/src/main/java/com/github/rjeschke/txtmark/BlockType.java
@@ -45,5 +45,7 @@ enum BlockType
/** A XML block. */
XML,
/** A plugin block. */
- PLUGIN
+ PLUGIN,
+ /** A TABLE block. */
+ TABLE
}
diff --git a/src/main/java/com/github/rjeschke/txtmark/Configuration.java b/src/main/java/com/github/rjeschke/txtmark/Configuration.java
index 6991ef4..82047b9 100644
--- a/src/main/java/com/github/rjeschke/txtmark/Configuration.java
+++ b/src/main/java/com/github/rjeschke/txtmark/Configuration.java
@@ -35,6 +35,8 @@ public class Configuration
final Decorator decorator;
final BlockEmitter codeBlockEmitter;
+
+ final BlockEmitter tableBlockEmitter;
final boolean forceExtendedProfile;
@@ -82,15 +84,17 @@ public class Configuration
* @param safeMode
* @param encoding
* @param decorator
+ * @param tableBlockEmitter
*/
Configuration( final boolean safeMode, final String encoding, final Decorator decorator, final BlockEmitter codeBlockEmitter,
- final boolean forceExtendedProfile, final boolean convertNewline2Br, final SpanEmitter specialLinkEmitter,
+ final BlockEmitter tableBlockEmitter, final boolean forceExtendedProfile, final boolean convertNewline2Br, final SpanEmitter specialLinkEmitter,
final List plugins )
{
this.safeMode = safeMode;
this.encoding = encoding;
this.decorator = decorator;
this.codeBlockEmitter = codeBlockEmitter;
+ this.tableBlockEmitter = tableBlockEmitter;
this.convertNewline2Br = convertNewline2Br;
this.forceExtendedProfile = forceExtendedProfile;
this.specialLinkEmitter = specialLinkEmitter;
@@ -126,6 +130,8 @@ public static class Builder
private Decorator decorator = new DefaultDecorator();
private BlockEmitter codeBlockEmitter = null;
+
+ private BlockEmitter tableBlockEmitter = null;
private SpanEmitter specialLinkEmitter = null;
@@ -281,7 +287,7 @@ public Builder registerPlugins( final Plugin... plugins )
*/
public Configuration build()
{
- return new Configuration( this.safeMode, this.encoding, this.decorator, this.codeBlockEmitter, this.forceExtendedProfile,
+ return new Configuration( this.safeMode, this.encoding, this.decorator, this.codeBlockEmitter,this.tableBlockEmitter, this.forceExtendedProfile,
this.convertNewline2Br, this.specialLinkEmitter, this.plugins );
}
@@ -289,5 +295,11 @@ public Decorator getDecorator()
{
return decorator;
}
+
+
+ public Builder setTableBlockEmitter(BlockEmitter tableBlockEmitter) {
+ this.tableBlockEmitter = tableBlockEmitter;
+ return this;
+ }
}
}
diff --git a/src/main/java/com/github/rjeschke/txtmark/Emitter.java b/src/main/java/com/github/rjeschke/txtmark/Emitter.java
index ccfe6bd..2d680e2 100644
--- a/src/main/java/com/github/rjeschke/txtmark/Emitter.java
+++ b/src/main/java/com/github/rjeschke/txtmark/Emitter.java
@@ -18,6 +18,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
+import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -193,6 +194,9 @@ private void emitLines(final StringBuilder out, final Block block)
case FENCED_CODE:
this.emitCodeLines(out, block.lines, block.meta, false);
break;
+ case TABLE:
+ this.emitTableLines(out, block.lines, block.meta);
+ break;
case PLUGIN:
this.emitPluginLines(out, block.lines, block.meta);
break;
@@ -208,7 +212,59 @@ private void emitLines(final StringBuilder out, final Block block)
}
}
- /**
+ private void emitTableLines(StringBuilder out, Line lines, String meta) {
+// Map alignment = new HashMap();
+// StringBuilder myst = new StringBuilder();
+// myst.append("");
+// boolean first = true;
+// do{
+// String lineValue = lines.value;
+// myst.append("");
+// String[] split = lineValue.split("\\|");
+// Integer count = 0;
+// for (String string2 : split) {
+// if(string2.isEmpty()) continue;
+// count ++;
+// if(string2.trim().matches("\\:.*\\:")){
+// alignment.put(count, "center"); continue;
+// }else if(string2.trim().matches(".*\\:")){
+// alignment.put(count, "right"); continue;
+// }else if(string2.trim().matches("\\:.*")){
+// alignment.put(count, "left"); continue;
+// }
+// myst.append(first?"| ":" | ");
+// myst.append(string2);
+// myst.append(first?"":" | ");
+//
+// }
+// myst.append("
");
+// first = false;
+// lines = lines.next;
+// }while(lines != null && lines.value != null && !lines.value.isEmpty());
+// myst.append("
");
+// String string = myst.toString();
+// Set keySet = alignment.keySet();
+// for (Integer integer : keySet) {
+// string = string.replaceAll("calm=\""+integer+"\"", "style=\"text-align:"+alignment.get(integer)+"\"");
+// }
+// out.append(string);
+ Line line = lines;
+ if(this.config.codeBlockEmitter != null)
+ {
+ final ArrayList list = new ArrayList<>();
+ while(line != null)
+ {
+ if(line.isEmpty)
+ list.add("");
+ else
+ list.add(line.value);
+ line = line.next;
+ }
+ this.config.tableBlockEmitter.emitBlock(out, list, meta);
+ }
+ }
+
+ /**
* Finds the position of the given Token in the given String.
*
* @param in
diff --git a/src/main/java/com/github/rjeschke/txtmark/Line.java b/src/main/java/com/github/rjeschke/txtmark/Line.java
index 7d41c13..9c5913b 100644
--- a/src/main/java/com/github/rjeschke/txtmark/Line.java
+++ b/src/main/java/com/github/rjeschke/txtmark/Line.java
@@ -260,6 +260,9 @@ public LineType getLineType(boolean extendedMode)
if(this.value.charAt(this.leading) == '>')
return LineType.BQUOTE;
+
+ if(this.value.contains("|"))
+ return LineType.TABLE;
if(extendedMode)
{
@@ -272,10 +275,11 @@ public LineType getLineType(boolean extendedMode)
return LineType.FENCED_CODE;
if(this.countCharsStart('%') >= 3)
- return LineType.PLUGIN;
+ return LineType.PLUGIN;
+
}
}
-
+
if(this.value.length() - this.leading - this.trailing > 2
&& (this.value.charAt(this.leading) == '*' || this.value.charAt(this.leading) == '-' || this.value
.charAt(this.leading) == '_')
diff --git a/src/main/java/com/github/rjeschke/txtmark/LineType.java b/src/main/java/com/github/rjeschke/txtmark/LineType.java
index 481b261..26bdffc 100644
--- a/src/main/java/com/github/rjeschke/txtmark/LineType.java
+++ b/src/main/java/com/github/rjeschke/txtmark/LineType.java
@@ -41,5 +41,7 @@ enum LineType
/** Fenced code block start/end */
FENCED_CODE,
/** plugin block */
- PLUGIN
+ PLUGIN,
+ /** table block */
+ TABLE
}
diff --git a/src/main/java/com/github/rjeschke/txtmark/Processor.java b/src/main/java/com/github/rjeschke/txtmark/Processor.java
index 5382ba9..1573bb4 100644
--- a/src/main/java/com/github/rjeschke/txtmark/Processor.java
+++ b/src/main/java/com/github/rjeschke/txtmark/Processor.java
@@ -888,7 +888,7 @@ private void recurse( final Block root, final boolean listMode )
{
break;
}
- if ( this.useExtensions && ( t == LineType.CODE || t == LineType.FENCED_CODE || t == LineType.PLUGIN ) )
+ if ( this.useExtensions && ( t == LineType.CODE || t == LineType.FENCED_CODE || t == LineType.PLUGIN || t == LineType.TABLE ) )
{
break;
}
@@ -1012,6 +1012,26 @@ private void recurse( final Block root, final boolean listMode )
}
block.removeSurroundingEmptyLines();
break;
+ case TABLE:
+ while ( line != null )
+ {
+ if ( line.getLineType( this.useExtensions ) == LineType.TABLE )
+ {
+ line = line.next;
+ }else{
+ break;
+ }
+
+ }
+ if ( line != null )
+ {
+ line = line.next;
+ }
+ block = root.split( line != null ? line.previous : root.lineTail );
+ block.type = BlockType.TABLE;
+ block.meta = "table";
+ block.removeSurroundingEmptyLines();
+ break;
case HEADLINE:
case HEADLINE1:
case HEADLINE2:
diff --git a/src/main/java/org/markdown4j/Markdown4jProcessor.java b/src/main/java/org/markdown4j/Markdown4jProcessor.java
index 5b3d082..49c830c 100644
--- a/src/main/java/org/markdown4j/Markdown4jProcessor.java
+++ b/src/main/java/org/markdown4j/Markdown4jProcessor.java
@@ -21,7 +21,7 @@ public Markdown4jProcessor() {
private Builder builder() {
decorator = new ExtDecorator();
- return Configuration.builder().forceExtentedProfile().registerPlugins(new YumlPlugin(), new WebSequencePlugin(), new IncludePlugin()).convertNewline2Br().setDecorator(decorator).setCodeBlockEmitter(new CodeBlockEmitter());
+ return Configuration.builder().forceExtentedProfile().registerPlugins(new YumlPlugin(), new WebSequencePlugin(), new IncludePlugin()).convertNewline2Br().setDecorator(decorator).setCodeBlockEmitter(new CodeBlockEmitter()).setTableBlockEmitter(new TableBlockEmitter());
}
public Markdown4jProcessor registerPlugins(Plugin ... plugins) {
builder.registerPlugins(plugins);
diff --git a/src/main/java/org/markdown4j/TableBlockEmitter.java b/src/main/java/org/markdown4j/TableBlockEmitter.java
index 9f0d6cc..5a6e26e 100644
--- a/src/main/java/org/markdown4j/TableBlockEmitter.java
+++ b/src/main/java/org/markdown4j/TableBlockEmitter.java
@@ -7,6 +7,10 @@
import com.github.rjeschke.txtmark.BlockEmitter;
+/**
+ * @author https://github.com/piergiuseppe82
+ *
+ */
public class TableBlockEmitter implements BlockEmitter{
@Override
diff --git a/src/main/java/org/markdown4j/TablePlugin.java b/src/main/java/org/markdown4j/TablePlugin.java
index bfd2fe2..53b09bb 100644
--- a/src/main/java/org/markdown4j/TablePlugin.java
+++ b/src/main/java/org/markdown4j/TablePlugin.java
@@ -2,40 +2,20 @@
import java.util.List;
import java.util.Map;
-import java.util.regex.Pattern;
+
+import com.github.rjeschke.txtmark.BlockEmitter;
public class TablePlugin extends Plugin {
public TablePlugin() {
super("table");
}
-
- private int findSeparatorLine(int beginIndex, List lines) {
- for(int i = beginIndex;i lines,
Map params) {
- StringBuffer sb2;
- String lparams;
- int ioh = findSeparatorLine(0, lines);
- String headerLine;
- String footerLine;
- if(ioh != -1) {
- headerLine = lines.get(ioh);
- int iof = findSeparatorLine(ioh, lines);
- if(iof != -1) {
- footerLine = lines.get(iof);
- }
- }
-
+ BlockEmitter blockemitter = new TableBlockEmitter();
+ blockemitter.emitBlock(out, lines, null);
}
}
diff --git a/src/test/java/org/markdown4j/TestMardown4jProcessor.java b/src/test/java/org/markdown4j/TestMardown4jProcessor.java
index 5b07e94..f9c9175 100644
--- a/src/test/java/org/markdown4j/TestMardown4jProcessor.java
+++ b/src/test/java/org/markdown4j/TestMardown4jProcessor.java
@@ -4,21 +4,40 @@
import java.io.IOException;
import java.net.URL;
+import junit.framework.Assert;
+
import org.junit.Test;
import com.github.rjeschke.txtmark.test.MarkupFileTester;
-
+/**
+ * @author https://github.com/piergiuseppe82
+ *
+ */
public class TestMardown4jProcessor {
+ private static final String expected =
+ "| HEADER 1 | HEADER 2 | HEADER 3 |
|---|
|
| content 1 | content 2 | content 3 |
";
+
@Test
- public void test() throws IOException {
+ public void testTable() throws IOException {
Markdown4jProcessor markdown4jProcessor = new Markdown4jProcessor();
- markdown4jProcessor = markdown4jProcessor.registerPlugins(new TablePlugin());
URL fileUrl = MarkupFileTester.class.getResource( "/table.txt" );
FileReader file = new FileReader( fileUrl.getFile() );
String process = markdown4jProcessor.process(file);
System.out.println(process);
+ Assert.assertEquals(expected, process);
}
+
+ @Test
+ public void testTableAsPlugin() throws IOException {
+ Markdown4jProcessor markdown4jProcessor = new Markdown4jProcessor();
+ markdown4jProcessor = markdown4jProcessor.registerPlugins(new TablePlugin());
+ URL fileUrl = MarkupFileTester.class.getResource( "/tableAsPlugin.txt" );
+ FileReader file = new FileReader( fileUrl.getFile() );
+ String process = markdown4jProcessor.process(file);
+ System.out.println(process);
+ Assert.assertEquals(expected, process);
+ }
}
diff --git a/src/test/resources/table.txt b/src/test/resources/table.txt
index 25e12b6..b8e72e9 100644
--- a/src/test/resources/table.txt
+++ b/src/test/resources/table.txt
@@ -1,11 +1,3 @@
-# Test Table as Plugin
-%%% table
-| HEADER 1 | HEADER 2 | HEADER 3 |
-| :--- | :---: | ---: |
-|content 1 | content 2|content 3 |
-%%%
-
-#Test Table as native TABLE type
| HEADER 1 | HEADER 2 | HEADER 3 |
| :--- | :---: | ---: |
|content 1 | content 2|content 3 |
From 42e485ffff28d8f10d6c9a0f5cb30bbb7293b102 Mon Sep 17 00:00:00 2001
From: piergiuseppe la cava
Date: Thu, 29 Dec 2016 20:05:53 +0100
Subject: [PATCH 3/9] Source Code Clean
---
.../com/github/rjeschke/txtmark/Emitter.java | 35 -------------------
1 file changed, 35 deletions(-)
diff --git a/src/main/java/com/github/rjeschke/txtmark/Emitter.java b/src/main/java/com/github/rjeschke/txtmark/Emitter.java
index 2d680e2..8c582a2 100644
--- a/src/main/java/com/github/rjeschke/txtmark/Emitter.java
+++ b/src/main/java/com/github/rjeschke/txtmark/Emitter.java
@@ -213,41 +213,6 @@ private void emitLines(final StringBuilder out, final Block block)
}
private void emitTableLines(StringBuilder out, Line lines, String meta) {
-// Map alignment = new HashMap();
-// StringBuilder myst = new StringBuilder();
-// myst.append("");
-// boolean first = true;
-// do{
-// String lineValue = lines.value;
-// myst.append("");
-// String[] split = lineValue.split("\\|");
-// Integer count = 0;
-// for (String string2 : split) {
-// if(string2.isEmpty()) continue;
-// count ++;
-// if(string2.trim().matches("\\:.*\\:")){
-// alignment.put(count, "center"); continue;
-// }else if(string2.trim().matches(".*\\:")){
-// alignment.put(count, "right"); continue;
-// }else if(string2.trim().matches("\\:.*")){
-// alignment.put(count, "left"); continue;
-// }
-// myst.append(first?"| ":" | ");
-// myst.append(string2);
-// myst.append(first?"":" | ");
-//
-// }
-// myst.append("
");
-// first = false;
-// lines = lines.next;
-// }while(lines != null && lines.value != null && !lines.value.isEmpty());
-// myst.append("
");
-// String string = myst.toString();
-// Set keySet = alignment.keySet();
-// for (Integer integer : keySet) {
-// string = string.replaceAll("calm=\""+integer+"\"", "style=\"text-align:"+alignment.get(integer)+"\"");
-// }
-// out.append(string);
Line line = lines;
if(this.config.codeBlockEmitter != null)
{
From a57887253848197e7b4697a814641b03be62e1e9 Mon Sep 17 00:00:00 2001
From: piergiuseppe la cava
Date: Sun, 1 Jan 2017 17:44:04 +0100
Subject: [PATCH 4/9] Add Java Properties files Highlight Plugin. Code
rendering modified: now test if exist a plugin associated then call it.
Eexcute standard code rendering if not exist. Pom file personalized
---
pom.xml | 8 +-
.../github/rjeschke/txtmark/Decorator.java | 111 ++++++++++++++++++
.../rjeschke/txtmark/DefaultDecorator.java | 41 ++++++-
.../com/github/rjeschke/txtmark/Emitter.java | 12 +-
.../github/rjeschke/txtmark/Processor.java | 16 ++-
.../org/markdown4j/PropertiesCodePlugin.java | 35 ++++++
.../org/markdown4j/TableBlockEmitter.java | 4 +-
.../markdown4j/TestMardown4jProcessor.java | 12 +-
src/test/resources/propertiesPlugin.txt | 8 ++
9 files changed, 236 insertions(+), 11 deletions(-)
create mode 100644 src/main/java/org/markdown4j/PropertiesCodePlugin.java
create mode 100644 src/test/resources/propertiesPlugin.txt
diff --git a/pom.xml b/pom.xml
index eab507d..7c91d31 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,12 +8,12 @@
org.commonjava.googlecode.markdown4j
markdown4j
- 2.2-plc-1.3-SNAPSHOT
+ 2.2-plc-1.4-SNAPSHOT
- scm:git:http://jdcasey@github.com/jdcasey/markdown4j.git
- scm:git:git@github.com:jdcasey/markdown4j.git
- http://github.com/jdcasey/markdown4j
+ scm:git:https://github.com/piergiuseppe82/markdown4j.git
+ scm:git:git@github.com:piergiuseppe82/markdown4j.git
+ http://github.com/piergiuseppe82/markdown4j
diff --git a/src/main/java/com/github/rjeschke/txtmark/Decorator.java b/src/main/java/com/github/rjeschke/txtmark/Decorator.java
index d090b92..e5a433f 100644
--- a/src/main/java/com/github/rjeschke/txtmark/Decorator.java
+++ b/src/main/java/com/github/rjeschke/txtmark/Decorator.java
@@ -467,4 +467,115 @@ public interface Decorator
* The StringBuilder to write to.
*/
public void openImage(final StringBuilder out);
+
+ /**
+ * Called when new Html rendering started.
+ *
+ *
+ * Note: Don't close the HTML tag!
+ *
+ *
+ * Default implementation is:
+ *
+ *
+ *
+ * out.append("<html>");
+ *
+ *
+ * @param out
+ * The StringBuilder to write to.
+ */
+ public void openHtml(StringBuilder out);
+
+ /**
+ * Called when new Html rendering started and after HTML tag.
+ *
+ *
+ * Note: Don't close the HTML tag!
+ *
+ *
+ * Default implementation is:
+ *
+ *
+ *
+ * out.append("<head>");
+ *
+ *
+ * @param out
+ * The StringBuilder to write to.
+ */
+ public void openHtmlHeaders(StringBuilder out);
+
+
+ /**
+ * Called when new Html rendering started and write default internal style beetwen html headers tag.
+ *
+ * @param out
+ * The StringBuilder to write to.
+ */
+ public void writeDefaultInternalStyle(StringBuilder out);
+
+ /**
+ * Called when new Html rendering started and before Body tag.
+ *
+ *
+ * Note: Don't open the HTML tag!
+ *
+ *
+ * Default implementation is:
+ *
+ *
+ *
+ * out.append("</head>");
+ *
+ *
+ * @param out
+ * The StringBuilder to write to.
+ */
+ public void closeHtmlHeaders(StringBuilder out);
+
+ /**
+ * Called when new Html rendering started and before process html's block.
+ *
+ * Default implementation is:
+ *
+ *
+ *
+ * out.append("<body>");
+ *
+ *
+ * @param out
+ * The StringBuilder to write to.
+ */
+ public void openBody(StringBuilder out);
+
+ /**
+ * Called after process html's block.
+ *
+ * Default implementation is:
+ *
+ *
+ *
+ * out.append("</body>");
+ *
+ *
+ * @param out
+ * The StringBuilder to write to.
+ */
+ public void closeBody(StringBuilder out);
+
+ /**
+ * Called when all blocks is processed and before return html document.
+ *
+ * Default implementation is:
+ *
+ *
+ *
+ * out.append("</html>");
+ *
+ *
+ * @param out
+ * The StringBuilder to write to.
+ */
+ public void closeHtml(StringBuilder out);
}
diff --git a/src/main/java/com/github/rjeschke/txtmark/DefaultDecorator.java b/src/main/java/com/github/rjeschke/txtmark/DefaultDecorator.java
index 006199d..14ffa31 100644
--- a/src/main/java/com/github/rjeschke/txtmark/DefaultDecorator.java
+++ b/src/main/java/com/github/rjeschke/txtmark/DefaultDecorator.java
@@ -38,7 +38,9 @@
*/
public class DefaultDecorator implements Decorator
{
- /** Constructor. */
+ private static final String DEFAULT_INTERNAL_STYLE = "";
+
+ /** Constructor. */
public DefaultDecorator()
{
// empty
@@ -241,4 +243,41 @@ public void openImage(StringBuilder out)
{
out.append("
\n");
+
+ }
+
+ @Override
+ public void openHtmlHeaders(StringBuilder out) {
+ out.append("\n");
+
+ }
+
+ @Override
+ public void writeDefaultInternalStyle(StringBuilder out) {
+ out.append(DEFAULT_INTERNAL_STYLE+"\n");
+ }
+
+ @Override
+ public void closeHtmlHeaders(StringBuilder out) {
+ out.append("\n");
+ }
+
+ @Override
+ public void openBody(StringBuilder out) {
+ out.append("\n");
+ }
+
+ @Override
+ public void closeBody(StringBuilder out) {
+ out.append("\n");
+ }
+
+ @Override
+ public void closeHtml(StringBuilder out) {
+ out.append("