Added import markdown from URL funtionality
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -104,7 +104,7 @@
|
||||
<properties>
|
||||
<confluence.version>6.9.0</confluence.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>
|
||||
<atlassian.spring.scanner.version>2.1.7</atlassian.spring.scanner.version>
|
||||
</properties>
|
||||
|
||||
@@ -40,6 +40,8 @@ import com.vladsch.flexmark.html.HtmlRenderer;
|
||||
import com.vladsch.flexmark.parser.Parser;
|
||||
import com.vladsch.flexmark.util.options.MutableDataSet;
|
||||
|
||||
import java.net.*;
|
||||
import java.io.*;
|
||||
|
||||
//@Scanned
|
||||
public class MarkdownMacro extends BaseMacro implements Macro
|
||||
@@ -106,8 +108,25 @@ public class MarkdownMacro extends BaseMacro implements Macro
|
||||
Parser parser = Parser.builder(options).build();
|
||||
HtmlRenderer renderer = HtmlRenderer.builder(options).build();
|
||||
|
||||
Node document = parser.parse(bodyContent);
|
||||
String html = renderer.render(document ) + highlightjs; // "<p>This is <em>Sparta</em></p>\n"
|
||||
String toParse = bodyContent;
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
documentation-url="https://spec.commonmark.org/0.28/">
|
||||
<category name="formatting"/>
|
||||
<parameters>
|
||||
<parameter name="URL" type="string" />
|
||||
</parameters>
|
||||
</xhtml-macro>
|
||||
<macro name="markdown"
|
||||
|
||||
Reference in New Issue
Block a user