Removed URL parameter and updated MarkdownMacro.java to get URL from bodyContent.

This commit is contained in:
unknown
2018-08-08 16:06:31 -05:00
parent e3fa72d307
commit 8a4b73b7bd
3 changed files with 16 additions and 15 deletions

View File

@@ -90,6 +90,8 @@
<configuration> <configuration>
<productVersion>${confluence.version}</productVersion> <productVersion>${confluence.version}</productVersion>
<productDataVersion>${confluence.data.version}</productDataVersion> <productDataVersion>${confluence.data.version}</productDataVersion>
<enableQuickReload>true</enableQuickReload>
<enableFastdev>false</enableFastdev>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>

View File

@@ -105,14 +105,13 @@ public class MarkdownMacro extends BaseMacro implements Macro
" });\n" + " });\n" +
"</script>"; "</script>";
if (bodyContent != null) {
Parser parser = Parser.builder(options).build(); Parser parser = Parser.builder(options).build();
HtmlRenderer renderer = HtmlRenderer.builder(options).build(); HtmlRenderer renderer = HtmlRenderer.builder(options).build();
String toParse = bodyContent; String toParse = "";
if (parameters.get("URL") != null) {
try { try {
String urlParam = parameters.get("URL"); URL importFrom = new URL(bodyContent);
URL importFrom = new URL(urlParam);
BufferedReader in = new BufferedReader( BufferedReader in = new BufferedReader(
new InputStreamReader(importFrom.openStream()) new InputStreamReader(importFrom.openStream())
); );
@@ -124,10 +123,13 @@ public class MarkdownMacro extends BaseMacro implements Macro
in.close(); in.close();
} }
catch (IOException e) {} catch (IOException e) {}
}
Node document = parser.parse(toParse); Node document = parser.parse(toParse);
String html = renderer.render(document) + highlightjs; String html = renderer.render(document) + highlightjs;
return html; return html;
}else {
return "";
}
} }

View File

@@ -14,10 +14,7 @@
icon="/download/resources/com.atlassian.plugins.confluence.markdown.confluence-markdown-macro/images/pluginIcon.png" icon="/download/resources/com.atlassian.plugins.confluence.markdown.confluence-markdown-macro/images/pluginIcon.png"
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>
</xhtml-macro>
<macro name="markdown" <macro name="markdown"
class="com.atlassian.plugins.confluence.markdown.MarkdownMacro" class="com.atlassian.plugins.confluence.markdown.MarkdownMacro"
key="markdown.wiki" key="markdown.wiki"