panda.doc.markdown.IncludePlugin Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of panda-core Show documentation
Show all versions of panda-core Show documentation
Panda Core is the core module of Panda Framework, it contains commonly used utility classes similar to apache-commons.
package panda.doc.markdown;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.List;
import java.util.Map;
import panda.io.Streams;
public class IncludePlugin extends Plugin {
public IncludePlugin() {
super("include");
}
@Override
public void emit(final StringBuilder out, final List lines, final Map params) {
String src = params.get("src");
try {
String content2 = getContent(src);
if (content2 != null) {
out.append(content2);
}
}
catch (Exception e) {
throw new RuntimeException("Error while rendering " + this.getClass().getName(), e);
}
}
private String getContent(String src) throws IOException, URISyntaxException {
URL url = new URL(new URL("file:"), src);
return Streams.toString(url);
}
}