msprev / panzer

pandoc + styles
BSD 3-Clause "New" or "Revised" License
160 stars 13 forks source link

I can't override style settings from the document's YAML block #17

Closed Utsira closed 9 years ago

Utsira commented 9 years ago

Hello, I'm trying to override some of my style settings from the markdown document's YAML data block, but it's not working. Here is my style.yaml (this all works as it should):

Letter:
    parent:
        - Base
  #  all:
      #  metadata:

    latex:
        template: myletter.tex
        metadata:
            fontsize: 12pt
            geometry: margin=1in
            mainfont: Minion Pro
            # opening: false
            fromaddress: |
                    | my street
                    | my town
                    | my postcode
                    | my email
            toaddress:  |
                    | Department
                    | University
                    | City
            closing: Yours sincerely
            signature: my name

I am trying to override latex: metadata: toaddress

I have tried various things in the document's YAML block eg:


---
style: Letter

metadata:
    - toaddress: person I'm writing to
...

and also:


---
style: Letter

latex:
    metadata:
        - toaddress: person I'm writing to
...

Both of them with and without the hyphens. But every time it just gets processed with the settings from the styles.yaml file. What am I doing wrong?

Thanks.

Utsira commented 9 years ago

As an experiment, I tried defining a style in the YAML block which inherits from the letter style:

---
style: Letter2
styledef:
    Letter2:
        parent:
            - Letter
        latex:
            metadata:
                toaddress: |
                        | addressee name

This works. But according to the documentation I can just override the setting I want can't I?

Style settings can be overridden by adding the appropriate field outside a style definition in the document’s metadata block

msprev commented 9 years ago

Have you tried:

---
style: Letter
toaddress: person I'm writing to
...

Let me know if this doesn't work.

More complex overriding behaviour (e.g. having sensitivity to which writer is being used) requires a styledef and explicit inheritance as you describe.

Utsira commented 9 years ago

Wow that works! I thought I'd tried every combination. Thanks for solving this, and thank you for creating Panzer. I've been using the Pandown plugin for Sublime Text 3 which has a similar functionality (storing Pandoc args in a file, JSON in pandown's case), but Panzer is a lot more elegant I think with named styles, inheritance, and the option to use the YAML header (particularly in a case like this, where the addressee is specific to the letter), and keeps things platform independent (in case I move away from Sublime Text 3).

msprev commented 9 years ago

Thanks! I'm glad that you like it! It's always a good idea to be editor neutral!