Overriding the characters for beginning and ending smart quotes #138

Closed
opened 8 years ago by saadatm · 4 comments
saadatm commented 8 years ago (Migrated from github.com)

I am playing with Pollen for making a book in Urdu, which is a right-to-left (RTL) language.

When using Pollen's smart-quotes function, the quotes (obviously) come off wrong, because for Urdu (or for other RTL languages), their order should be opposite to what works with American English (i.e. should be the beginning quote and should be the ending one).

So I was wondering if some setup values for quotes could be introduced, which the users can then override for specifying the characters for single/double beginning/ending quotes. Besides RTL languages, these could also be useful for a variety of other quote combinations.

I am playing with Pollen for making a book in Urdu, which is a right-to-left (RTL) language. When using Pollen's `smart-quotes` function, the quotes (obviously) come off wrong, because for Urdu (or for other RTL languages), their order should be opposite to what works with American English (i.e. `”` should be the beginning quote and `“` should be the ending one). So I was wondering if some [setup values](http://docs.racket-lang.org/pollen/Setup.html) for quotes could be introduced, which the users can then override for specifying the characters for single/double beginning/ending quotes. Besides RTL languages, these could also be useful for a [variety of other quote combinations](https://en.wikipedia.org/wiki/Quotation_mark#Summary_table).
mbutterick commented 8 years ago (Migrated from github.com)

Certainly it would be easy to update smart-quotes to accept optional arguments that let you set the replacements. Would that suffice?

(I try to mint new setup values sparingly. They’re necessary for situations where a value needs to be used in multiple, difficult-to-reach places in the code. But smart-quotes, by contrast, is used directly in a decoder, so it seems simpler to just change its interface.)

Certainly it would be easy to update `smart-quotes` to accept optional arguments that let you set the replacements. Would that suffice? (I try to mint new setup values sparingly. They’re necessary for situations where a value needs to be used in multiple, difficult-to-reach places in the code. But `smart-quotes`, by contrast, is used directly in a decoder, so it seems simpler to just change its interface.)
saadatm commented 8 years ago (Migrated from github.com)

(I try to mint new setup values sparingly. They’re necessary for situations where a value needs to be used in multiple, difficult-to-reach places in the code. But smart-quotes, by contrast, is used directly in a decoder, so it seems simpler to just change its interface.)

Makes sense. Changing the interface of smart-quotes to accept optional arguments can work too, yes.

However, being a Racket newbie, here's a follow-up question: how can I pass arguments to smart-quotes (or any other function) while building a txexpr like below?

(txexpr 'root empty (decode-elements elements
    #:txexpr-elements-proc decode-paragraphs
    #:string-proc (compose1 smart-quotes smart-dashes)))

Would I have to do something like this?

(txexpr 'root empty (decode-elements elements
    #:txexpr-elements-proc decode-paragraphs
    #:string-proc (compose1 my-smart-quotes smart-dashes)))

(define (my-smart-quotes x)
    (smart-quotes x #:beginning-quote "”" #:ending-quote "“"))
> (I try to mint new setup values sparingly. They’re necessary for situations where a value needs to be used in multiple, difficult-to-reach places in the code. But smart-quotes, by contrast, is used directly in a decoder, so it seems simpler to just change its interface.) Makes sense. Changing the interface of `smart-quotes` to accept optional arguments can work too, yes. However, being a Racket newbie, here's a follow-up question: how can I pass arguments to `smart-quotes` (or any other function) while building a `txexpr` like below? ``` (txexpr 'root empty (decode-elements elements #:txexpr-elements-proc decode-paragraphs #:string-proc (compose1 smart-quotes smart-dashes))) ``` Would I have to do something like this? ``` (txexpr 'root empty (decode-elements elements #:txexpr-elements-proc decode-paragraphs #:string-proc (compose1 my-smart-quotes smart-dashes))) (define (my-smart-quotes x) (smart-quotes x #:beginning-quote "”" #:ending-quote "“")) ```
mbutterick commented 8 years ago (Migrated from github.com)

Yes, exactly — make a helper function that sets the extra arguments.

Yes, exactly — make a helper function that sets the extra arguments.
saadatm commented 8 years ago (Migrated from github.com)

All right. Thanks. :-)

All right. Thanks. :-)
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#138
Loading…
There is no content yet.