Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asciidoctor.loadFile(file, options) doesn't generate complete document. #434

Closed
axelschoener opened this issue Feb 25, 2016 · 2 comments
Closed
Assignees
Labels
Milestone

Comments

@axelschoener
Copy link

loadFile doesn't generate complete document, only first paragraph will be processed.
Reading from string (line based reading of a file done before) does work.

The project is maven based and is using version 1.5.4 of asciidoctorj.

// Example of reading via loadFile
Map<String,Object> attributes = new HashMap<String, Object>();
attributes.put("stylesdir", "adocs/css");
attributes.put("stylesheet", "asciidoctor.css");
Map<String, Object> options = new HashMap<String, Object>();
options.put("attributes", attributes);
options.put("in_place", true);
options.put("header", true);
options.put("footer", true);
options.put("safe", 0);

Document document = asciidoctor.loadFile(file, options);

// Example for asciidoctor.load:
Map<String,Object> attributes = new HashMap<String, Object>();
attributes.put("stylesdir", "adocs/css");
attributes.put("stylesheet", "asciidoctor.css");
Map<String, Object> options = new HashMap<String, Object>();
options.put("attributes", attributes);
options.put("in_place", true);
options.put("header", true);
options.put("footer", true);
options.put("safe", 0);

String lines = "";
String tmpString = "";
if (file.canRead())
{
System.out.println("File: " + file + " is readable");
try {
FileReader fileReader = new FileReader(file);
BufferedReader bufferedReader = new BufferedReader(fileReader);
while( (tmpString = bufferedReader.readLine()) != null )
{
lines = lines + "\n" + tmpString;
}
bufferedReader.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Document document = asciidoctor.load(lines, options);
System.out.println("content: " + document.convert());

@robertpanzer
Copy link
Member

Thank you, Alex!
That's a bad one!
The problem is here: https://github.com/asciidoctor/asciidoctorj/blob/master/asciidoctorj-core/src/main/java/org/asciidoctor/internal/JRubyAsciidoctor.java#L601

Instead of calling asciidoctorModule.load(String, RubyHash) it should call asciidoctorModule.loadFile(String, RubyHash).

I'll prepare a fix for it.

Cheers
Robert

@robertpanzer robertpanzer added this to the v1.5.5 milestone Feb 25, 2016
@robertpanzer robertpanzer self-assigned this Feb 25, 2016
robertpanzer added a commit that referenced this issue Feb 27, 2016
Fixes #434. Make Asciidoctor.loadFile invoke Asciidoctor::load_file i…
@mojavelinux
Copy link
Member

👍

abelsromero pushed a commit to abelsromero/asciidoctorj that referenced this issue Dec 14, 2016
…load_file instead of Asciidoctor::load which basically renders only the file name.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants