Pillar annotations for Latex

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

Pillar annotations for Latex

Ben Coman
The Pillar documentation [1] says...
    "An annotated paragraph starts a line with @@ followed by either
todo or note. For example,
        @@note this is a note annotation.
    generates
         Note: this is a note annotation.
    And,
        @@todo this is a todo annotation
    generates a todo annotation that is not visible in the output."

However this does not work when rendering to LaTex.
    * The notes do not start with "Note:"
    * The todos are visible

This seemed to be handled by...
    PRMarkdownWriter>>visitAnnotatedParagraph: anAnnotatedParagraph
        "Pier seams to lack consistensy here ..."      
        needsABreak ifTrue: [ canvas addInvisibleSeparator ].

        anAnnotatedParagraph annotation asLowercase = 'todo'
            ifTrue: [ ^ self visitCommentedLine: anAnnotatedParagraph ].

        self nest: [ :brush |  
            brush
                name: ''
                with: [ :nestedStream |
                    self writeRawDuring: [
                        nestedStream << 'Note: '.
                        nestedStream << anAnnotatedParagraph text
trimBoth ] ] ].          
        needsABreak := true.

but that there is no equivalent PRLaTexWriter>>visitAnnotatedParagraph:
and the following is used by default...
    PRVisitor>>visitAnnotatedParagraph: aDocument
        self visitParagraph: aDocument


In seeking to fix this for LaTex I found...
* /needsABreak/ is an ivar of PRMarkdown and I guess not applicable to LaTex
* #nest: and the /nest/ ivar it references belong to PRMarkdown, and I'm
not sure of their purpose.

So I cut those out, which left the following...
    PRLaTexWriter>>visitAnnotatedParagraph
        anAnnotatedParagraph annotation asLowercase = 'todo'
            ifTrue: [ ^ self visitCommentedLine: anAnnotatedParagraph ].

        self writeRawDuring: [
            nestedStream << 'Note: '.
            nestedStream << anAnnotatedParagraph text trimBoth ].

...which works well enough for the usage I see so far in
PharoLaserGameTutorial. [2]

Now is there any important function missing, or is there a better way to
do this?
I also want add an annotation type, which I'll describe in a following post.

cheers -ben

[1] https://github.com/pillar-markup/pillar-documentation
[2] https://github.com/bencoman/PharoLaserGameTutorial
_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: [Pharo-users] Pillar annotations for Latex

Damien Cassou
Hi Ben,

On Thu, May 22, 2014 at 6:09 PM, Ben Coman <[hidden email]> wrote:
> Now is there any important function missing, or is there a better way to do
> this?

thank you for your contribution.

I would try to generate this instead:

    \begin{note}
      foo bar baz
    \end{note}

This environment is meant for this. To output the \begin and \end parts, use

    canvas environment

(look at the senders of #environment in the PRLaTeXWriter class for examples)

To output the text, you can just write

   super visitAnnotatedParagraph: aParagraph


> I also want add an annotation type, which I'll describe in a following post.


I should we should think a bit how these should be handled. In the
meantime, you can just hack around :-). And please add unit tests.

--
Damien Cassou
http://damiencassou.seasidehosting.st

"Success is the ability to go from one failure to another without
losing enthusiasm."
Winston Churchill
_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki