Hello,
I have just implemented a preprocessor example which does a substitution of an attribute: The document looks like: = Document Title sample {content} And the preprocessor is: @Override public PreprocessorReader process(Document document,PreprocessorReader reader) { document.getAttributes().put("content", "Alex"); return reader; } Note that I am not advanced the reader so there is no modification. But the converted document doesn't contain the title of the document. Is it the desired behaviour? Thanks. |
Administrator
|
Alex, This assignment should work. When I test it with a preprocessor written in Ruby it works. Therefore, I think somewhere along the line the reference to the original attributes object is being severed. I also added a test to extensions_test.rb to verify that an attribute assignment in a preprocessor takes hold.
On Fri, Feb 28, 2014 at 6:09 PM, asotobu [via Asciidoctor :: Discussion] <[hidden email]> wrote: Hello, -- Dan Allen | http://google.com/profiles/dan.j.allen |
Hi Dan, yes the assignment work, but title is not rendered. Look the generated document:
<html> <head></head> <body> <div class="paragraph"> <p>sample Alex</p> </div> </body> </html> Substitution occurs, but the title is not rendered with tag . |
Administrator
|
Aha! I missed what you were saying wasn't working. I tried it from the Ruby side and I do see a title, so perhaps we're still getting dropped data somehow. Perhaps create a test for this in AsciidoctorJ and we can debug it? On Sat, Mar 1, 2014 at 2:10 AM, asotobu [via Asciidoctor :: Discussion] <[hidden email]> wrote: Hi Dan, yes the assignment work, but title is not rendered. Look the generated document: -- Dan Allen | http://google.com/profiles/dan.j.allen |
Well I think I had not explained correctly more than you miss something. There is already a unit test on master branch in tests about extensions. Ok if it is not the desired behaviour I will debug too
El dissabte, 1 març de 2014, mojavelinux [via Asciidoctor :: Discussion] <[hidden email]> va escriure:
-- Enviat amb Gmail Mobile |
Look what I have found, I have written next preprocessor test:
System.out.println(reader.lines()); assertThat(reader.isNextLineEmpty(), is(false)); reader.advance(); assertThat(reader.isNextLineEmpty(), is(true)); And the output of the sysout was: ["= Document Title", "", "", "== Section A", "", "*Section A* paragraph."] Si it seems that the first call of isNextLineEmpty should return true. But in fact it returns false. If initially the pointer of content is at (-1) position then yes nextLine will be false and when I call advance (which in fat will move pointer to position 0) then the behaviour is correct. |
Free forum by Nabble | Edit this page |