Blank or empty X-expression? #38

Closed
opened 10 years ago by basus · 1 comments
basus commented 10 years ago (Migrated from github.com)

I'm following the decoding example from the third Pollen tutorial to define handlers on the root tag. In particular, I'm trying to automatically insert paragraph tags, but not insert <br/> tags for single-line breaks. In order to do that, I'm using the following code, trying to reuse the functions in decode.rkt:

◊(define (mk-para elements)
   (detect-paragraphs elements
                      #:tag 'p
                      #:linebreak-proc (lambda (x) (detect-linebreaks x #:insert '()))))

◊(define (root . elements)
   (make-txexpr 'root null
                (decode-elements elements
                                 #:txexpr-elements-proc mk-para
                                 #:string-proc (compose smart-quotes smart-dashes))))

The main difference from the code in decode.rkt is that I'm trying to use '() as the tag to insert in place of a line-break instead of '(br). However, this causes a contract violation because '() is not a valid X-expression. Perhaps there should be some notion of a blank or empty X-expression that does not translated to anything?

I'm following the decoding example from the third Pollen tutorial to define handlers on the `root` tag. In particular, I'm trying to automatically insert paragraph tags, but _not_ insert `<br/>` tags for single-line breaks. In order to do that, I'm using the following code, trying to reuse the functions in `decode.rkt`: ``` ◊(define (mk-para elements) (detect-paragraphs elements #:tag 'p #:linebreak-proc (lambda (x) (detect-linebreaks x #:insert '())))) ◊(define (root . elements) (make-txexpr 'root null (decode-elements elements #:txexpr-elements-proc mk-para #:string-proc (compose smart-quotes smart-dashes)))) ``` The main difference from the code in `decode.rkt` is that I'm trying to use `'()` as the tag to insert in place of a line-break instead of `'(br)`. However, this causes a contract violation because `'()` is not a valid X-expression. Perhaps there should be some notion of a blank or empty X-expression that does not translated to anything?
basus commented 10 years ago (Migrated from github.com)

Actually, looking at the X-expression docs I realize that the empty string "" is essentially a blank X-expression.

Actually, looking at the [X-expression docs](http://pkg-build.racket-lang.org/doc/xml/index.html#%28def._%28%28lib._xml%2Fprivate%2Fxexpr-core..rkt%29._xexpr~3f%29%29) I realize that the empty string `""` is essentially a blank X-expression.
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: mbutterick/pollen#38
Loading…
There is no content yet.