Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Biblatex option #1

Closed
twsh opened this issue May 23, 2015 · 13 comments
Closed

Biblatex option #1

twsh opened this issue May 23, 2015 · 13 comments

Comments

@twsh
Copy link

twsh commented May 23, 2015

I would like to use pandoc's --biblatex option. I though that the following 'style.yaml' file would do it:

########################################################################
#                     Base - parent of all styles                      #
########################################################################

Base:
    all:
        metadata:
            bibliography: /Users/thomas/Library/texmf/bibtex/bib/bibliography.bib
    latex:
        preflight:
            - run: tmp_out.py
        postflight:
            - run: latexmk.py
            - run: open_pdf.py
        cleanup:
            - run: tmp_back.py
            - run: rmlatex.py

########################################################################
#                               Paper                                #
########################################################################

Paper:
    parent:
        - Base
    all:
        metadata:
            numbersections: true
    latex:
        metadata:
            biblatex: true
        template: default.latex

But when I do $ panzer --output foo.tex foo.txt it's clear that the biblatex option hasn't been called: my cite keys haven't turned to citations commands, and biblatex hasn't been called. I do get numbered sections, so it's not that panzer doesn't see my files or anything like that.

By the way, doing this works fine: $panzer --biblatex --output foo.tex foo.txt. Have I failed to set something up right in my style file?

@msprev
Copy link
Owner

msprev commented May 23, 2015

Currently, the only way to do this currently is to pass --biblatex on the command line as you do.

panzer does not allow arbitrary pandoc command line options to set via metadata. I have been thinking of implementing this, but haven't thought of a good metadata syntax to express it. There are some use cases, like the one you mention, --smart, and --standalone.

Over time pandoc has moved some command-line only options to permit them to be set via metadata (e.g. --bibliography can be set via setting the bibliography field). I do not know if there are plans to move any more options to make them settable via metadata. If this happened in pandoc, it would solve the problem.

@msprev
Copy link
Owner

msprev commented May 23, 2015

I've figured out a way to do this. I will implement it. All command line options, with the exception of reader and writer, will be settable via a metadata field. I'll push the changes once the feature is implemented.

@twsh
Copy link
Author

twsh commented May 23, 2015

That's great. I think panzer is going to be a lot more convenient than my current setup with make files.

On 23 May 2015, at 04:33, Mark Sprevak notifications@github.com wrote:

I've figured out a way to do this. I will implement it. All command line options, with the exception of reader and writer, will be settable via a metadata field. I'll push the changes once the feature is implemented.


Reply to this email directly or view it on GitHub.

@msprev
Copy link
Owner

msprev commented May 23, 2015

It's now implemented in the latest commit. I've added a new style definition field, commandline; documentation here: https://github.com/msprev/panzer#setting-pandoc-command-line-options. This allows one to set arbitrary pandoc command line options in metadata. Thanks for prompting me to do this.

Your new style definition should be:

Paper:
    parent:
        - Base
    all:
        metadata:
            numbersections: true
    latex:
        commandline:
            biblatex: true
        template: default.latex

Let me know if there are any problems.

@msprev msprev closed this as completed May 23, 2015
@twsh
Copy link
Author

twsh commented May 23, 2015

It's working for me. Thanks!

On 23 May 2015, at 17:19, Mark Sprevak notifications@github.com wrote:

It's now implemented in the latest commit. I've added a new style definition field, commandline; documentation here: https://github.com/msprev/panzer#setting-pandoc-command-line-options. This allows one to set arbitrary pandoc command line options in metadata. Thanks for prompting me to do this.

Your new style definition should be:

Paper:
parent:
- Base
all:
metadata:
numbersections: true
latex:
commandline:
biblatex: true
template: default.latex

Let me know if there are any problems.


Reply to this email directly or view it on GitHub.

@twsh
Copy link
Author

twsh commented May 24, 2015

For some reason I haven't been able to figure out yet, adding commandline: smart to my styles doesn't work. I see this in the terminal:

----- style definitions -----
global:
 Base  Paper      
----- document style -----
style:
 Paper
full hierarchy:
 Base, Paper
writer:
 docx
----- run list -----
 empty
----- pandoc -----
running pandoc with options:
 --smart

So the option is being passed, and adding it explicitly to the call to panzer works fine. My style.yaml looks like this:

Paper:
    parent:
        - Base
    all:
        metadata:
            numbersections: true
    docx:
        commandline:
            smart: true
    latex:
        commandline:
            biblatex: true
        template: default.latex

The same thing happens with HTML(5).

@twsh
Copy link
Author

twsh commented May 24, 2015

I've noticed something else: LaTeX output should be 'smart' by default, but now it is as if the --no-tex-ligatures option had been set. Adding --smart to the call to panzer fixes it.

@msprev
Copy link
Owner

msprev commented May 24, 2015

Can you describe the issue more accurately? I don't follow.

commandline: smart is not a valid construct. To set --smart you need

commandline:
    smart: true

pandoc's LaTeX writer is not 'smart' by default; you need to explicitly pass --smart on the command line if you want -- to be an en-dash etc. Currently, with your style definition, you are only passing --smart when the docx writer is selected.

I don't follow the comment on --no-tex-ligatures. This option would only be passed to pandoc if you explicitly require it. Can you give an minimal working example where panzer and pandoc latex output differs on same options?

@twsh
Copy link
Author

twsh commented May 24, 2015

Sorry, 'commandline: smart' was a typo; I have been doing correctly as in the style file in the above post. Here's an MWE for the problem.

This is the 'styles.yaml':

Base:
    docx:
        commandline:
            smart: true
    html:
        commandline:
            smart: true

This is a markdown file:

---
style: Base
...

'Hello world'

That should set the --smart option for the docx and html writers, and do nothing else, right?

I run the following commands and get three files where the quotes aren't 'smart':

  • $ panzer -o mwe.docx mwe.md
  • $ panzer -o mwe.html mwe.md
  • $ panzer -o mwe.tex mwe.md

These with Pandoc do give me 'smart' quotes:

  • $ pandoc --smart -o mwe.docx mwe.md
  • $ pandoc --smart -o mwe.html mwe.md
  • $ pandoc -o mwe.tex mwe.md

The interesting thing with LaTeX is the default would be smart, and --no-tex-ligatures would have to be called to suppress it. (I know it's a bit more complicated than that because there are two issues i.e. ligatures and quotes and they come apart with the LaTeX writer.) The output I get from my latex panzer call is identical to what I get from:

  • $ pandoc --no-tex-ligatures -o mwe.tex mwe.md

@msprev
Copy link
Owner

msprev commented May 25, 2015

I've worked out what is going on. The current implementation only sets pandoc writer options. --smart is a reader option, so it isn't being set. Serves me right for trying to implement a major change in one day. I need to rethink the implementation so that it will set the reader options. I've re-opened this issue. I have some ideas on how to implement it. However, for the moment, you need to pass options like --smart as a command line arguments to panzer. Writer options like --bibtex still work ok with commandline.

The latex writer issue is an interesting edge case. It is an instance when a pandoc reader option (--smart) is set by pandoc conditional on the writer (latex). panzer does not currently pick up on this as panzer works like a filter -- it gets pandoc to produce an ast, which is passed to the appropriate writer (i.e. like pandoc - -t json | pandoc -f json -t latex). My view is that this should always be equivalent to pandoc - -t latex; the writer shouldn't be affecting the reader. But this is case where that doesn't happen. I can add a tweak to reproduce this behaviour: automatically invoke --smart for the reader if the latex writer is selected. I'll check the pandoc documentation for similar cases too.

@msprev msprev reopened this May 25, 2015
msprev pushed a commit that referenced this issue May 29, 2015
@msprev
Copy link
Owner

msprev commented May 29, 2015

Both issues -- setting reader options and automatically setting --smart for latex writer -- fixed in latest commit. Let me know if there are any problems.

@msprev msprev closed this as completed May 29, 2015
@twsh
Copy link
Author

twsh commented May 30, 2015

It's working for me now. Thanks for a great tool.

On 29 May 2015, at 04:59, Mark Sprevak notifications@github.com wrote:

Both issues -- setting reader options and automatically setting --smart for latex writer -- fixed in latest commit. Let me know if there are any problems.


Reply to this email directly or view it on GitHub.

@msprev
Copy link
Owner

msprev commented May 30, 2015 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants