Added import markdown from URL funtionality
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -104,7 +104,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<confluence.version>6.9.0</confluence.version>
|
<confluence.version>6.9.0</confluence.version>
|
||||||
<confluence.data.version>6.9.0</confluence.data.version>
|
<confluence.data.version>6.9.0</confluence.data.version>
|
||||||
<amps.version>6.2.11</amps.version>
|
<amps.version>6.3.0</amps.version>
|
||||||
<plugin.testrunner.version>1.1</plugin.testrunner.version>
|
<plugin.testrunner.version>1.1</plugin.testrunner.version>
|
||||||
<atlassian.spring.scanner.version>2.1.7</atlassian.spring.scanner.version>
|
<atlassian.spring.scanner.version>2.1.7</atlassian.spring.scanner.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ import com.vladsch.flexmark.html.HtmlRenderer;
|
|||||||
import com.vladsch.flexmark.parser.Parser;
|
import com.vladsch.flexmark.parser.Parser;
|
||||||
import com.vladsch.flexmark.util.options.MutableDataSet;
|
import com.vladsch.flexmark.util.options.MutableDataSet;
|
||||||
|
|
||||||
|
import java.net.*;
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
//@Scanned
|
//@Scanned
|
||||||
public class MarkdownMacro extends BaseMacro implements Macro
|
public class MarkdownMacro extends BaseMacro implements Macro
|
||||||
@@ -106,8 +108,25 @@ public class MarkdownMacro extends BaseMacro implements Macro
|
|||||||
Parser parser = Parser.builder(options).build();
|
Parser parser = Parser.builder(options).build();
|
||||||
HtmlRenderer renderer = HtmlRenderer.builder(options).build();
|
HtmlRenderer renderer = HtmlRenderer.builder(options).build();
|
||||||
|
|
||||||
Node document = parser.parse(bodyContent);
|
String toParse = bodyContent;
|
||||||
String html = renderer.render(document ) + highlightjs; // "<p>This is <em>Sparta</em></p>\n"
|
if (parameters.get("URL") != null) {
|
||||||
|
try {
|
||||||
|
String urlParam = parameters.get("URL");
|
||||||
|
URL importFrom = new URL(urlParam);
|
||||||
|
BufferedReader in = new BufferedReader(
|
||||||
|
new InputStreamReader(importFrom.openStream())
|
||||||
|
);
|
||||||
|
String inputLine;
|
||||||
|
toParse = "";
|
||||||
|
while ((inputLine = in.readLine()) != null) {
|
||||||
|
toParse = toParse + "\n" + inputLine;
|
||||||
|
}
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
catch (IOException e) {}
|
||||||
|
}
|
||||||
|
Node document = parser.parse(toParse);
|
||||||
|
String html = renderer.render(document) + highlightjs;
|
||||||
return html;
|
return html;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
documentation-url="https://spec.commonmark.org/0.28/">
|
documentation-url="https://spec.commonmark.org/0.28/">
|
||||||
<category name="formatting"/>
|
<category name="formatting"/>
|
||||||
<parameters>
|
<parameters>
|
||||||
|
<parameter name="URL" type="string" />
|
||||||
</parameters>
|
</parameters>
|
||||||
</xhtml-macro>
|
</xhtml-macro>
|
||||||
<macro name="markdown"
|
<macro name="markdown"
|
||||||
|
|||||||
Reference in New Issue
Block a user