forked from asciidoctor/asciidoctor-maven-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request asciidoctor#185 from mojavelinux/issue-183
resolves asciidoctor#183 upgrade to AsciidoctorJ 1.5.3.2 and JRuby 1.7.23
- Loading branch information
Showing
6 changed files
with
121 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
132 changes: 66 additions & 66 deletions
132
src/test/java/org/asciidoctor/maven/test/processors/UriIncludeProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,66 @@ | ||
package org.asciidoctor.maven.test.processors; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
import java.util.Map; | ||
|
||
import org.asciidoctor.ast.DocumentRuby; | ||
import org.asciidoctor.extension.IncludeProcessor; | ||
import org.asciidoctor.extension.PreprocessorReader; | ||
|
||
public class UriIncludeProcessor extends IncludeProcessor { | ||
|
||
public UriIncludeProcessor(Map<String, Object> config) { | ||
super(config); | ||
System.out.println(this.getClass().getSimpleName() + "(" | ||
+ this.getClass().getSuperclass().getSimpleName() + ") initialized"); | ||
} | ||
|
||
@Override | ||
public boolean handles(String target) { | ||
return target.startsWith("http://") || target.startsWith("https://"); | ||
} | ||
|
||
@Override | ||
public void process(DocumentRuby document, PreprocessorReader reader, String target, | ||
Map<String, Object> attributes) { | ||
|
||
System.out.println("Processing "+ this.getClass().getSimpleName()); | ||
|
||
StringBuilder content = readContent(target); | ||
reader.push_include(content.toString(), target, target, 1, attributes); | ||
|
||
} | ||
|
||
private StringBuilder readContent(String target) { | ||
|
||
StringBuilder content = new StringBuilder(); | ||
|
||
try { | ||
|
||
URL url = new URL(target); | ||
InputStream openStream = url.openStream(); | ||
|
||
BufferedReader bufferedReader = new BufferedReader( | ||
new InputStreamReader(openStream)); | ||
|
||
String line = null; | ||
while ((line = bufferedReader.readLine()) != null) { | ||
content.append(line); | ||
} | ||
|
||
bufferedReader.close(); | ||
|
||
} catch (MalformedURLException e) { | ||
throw new IllegalArgumentException(e); | ||
} catch (IOException e) { | ||
throw new IllegalArgumentException(e); | ||
} | ||
return content; | ||
} | ||
|
||
} | ||
package org.asciidoctor.maven.test.processors; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
import java.util.Map; | ||
|
||
import org.asciidoctor.ast.DocumentRuby; | ||
import org.asciidoctor.extension.IncludeProcessor; | ||
import org.asciidoctor.extension.PreprocessorReader; | ||
|
||
public class UriIncludeProcessor extends IncludeProcessor { | ||
|
||
public UriIncludeProcessor(Map<String, Object> config) { | ||
super(config); | ||
System.out.println(this.getClass().getSimpleName() + "(" | ||
+ this.getClass().getSuperclass().getSimpleName() + ") initialized"); | ||
} | ||
|
||
@Override | ||
public boolean handles(String target) { | ||
return target.startsWith("http://") || target.startsWith("https://"); | ||
} | ||
|
||
@Override | ||
public void process(DocumentRuby document, PreprocessorReader reader, String target, | ||
Map<String, Object> attributes) { | ||
|
||
System.out.println("Processing "+ this.getClass().getSimpleName()); | ||
|
||
StringBuilder content = readContent(target); | ||
reader.push_include(content.toString(), target, target, 1, attributes); | ||
|
||
} | ||
|
||
private StringBuilder readContent(String target) { | ||
|
||
StringBuilder content = new StringBuilder(); | ||
|
||
try { | ||
|
||
URL url = new URL(target); | ||
InputStream openStream = url.openStream(); | ||
|
||
BufferedReader bufferedReader = new BufferedReader( | ||
new InputStreamReader(openStream)); | ||
|
||
String line = null; | ||
while ((line = bufferedReader.readLine()) != null) { | ||
content.append(line + "\n"); | ||
} | ||
|
||
bufferedReader.close(); | ||
|
||
} catch (MalformedURLException e) { | ||
throw new IllegalArgumentException(e); | ||
} catch (IOException e) { | ||
throw new IllegalArgumentException(e); | ||
} | ||
return content; | ||
} | ||
|
||
} |