Added import markdown from URL funtionality

This commit is contained in:
unknown
2018-08-06 19:25:49 -05:00
parent fae6196f14
commit e3fa72d307
3 changed files with 24 additions and 4 deletions

View File

@@ -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>

View File

@@ -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
@@ -105,9 +107,26 @@ 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;
} }

View File

@@ -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"