Preprocessor behaviour

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Preprocessor behaviour

asotobu
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.

Reply | Threaded
Open this post in threaded view
|

Re: Preprocessor behaviour

mojavelinux
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.

-Dan


On Fri, Feb 28, 2014 at 6:09 PM, asotobu [via Asciidoctor :: Discussion] <[hidden email]> wrote:
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.




If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Preprocessor-behaviour-tp1563.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Reply | Threaded
Open this post in threaded view
|

Re: Preprocessor behaviour

asotobu
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

.

Reply | Threaded
Open this post in threaded view
|

Re: Preprocessor behaviour

mojavelinux
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?

-Dan


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:

<html>
 <head></head>
 <body>
  <div class="paragraph"> 
   <p>sample Alex</p> 
  </div>
 </body>
</html>


Substitution occurs, but the title is not rendered with tag

.


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Preprocessor-behaviour-tp1563p1565.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML




--
Reply | Threaded
Open this post in threaded view
|

Re: Preprocessor behaviour

asotobu
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:
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?

-Dan


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:

<html>
 <head></head>
 <body>
  <div class="paragraph"> 
   <p>sample Alex</p> 
  </div>
 </body>
</html>


Substitution occurs, but the title is not rendered with tag

.


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Preprocessor-behaviour-tp1563p1565.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML




--



If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Preprocessor-behaviour-tp1563p1566.html
To unsubscribe from Preprocessor behaviour, click here.
NAML


--
Enviat amb Gmail Mobile
Reply | Threaded
Open this post in threaded view
|

Re: Preprocessor behaviour

asotobu
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.