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

dispatch PANDOC_OPTIONS base on input extensions #3492

Closed
ickc opened this issue Dec 30, 2020 · 6 comments · Fixed by #3501
Closed

dispatch PANDOC_OPTIONS base on input extensions #3492

ickc opened this issue Dec 30, 2020 · 6 comments · Fixed by #3501
Assignees

Comments

@ickc
Copy link
Contributor

ickc commented Dec 30, 2020

Summary

Currently, COMPILERS only has a key pandoc, and PANDOC_OPTIONS is set for all the extensions specified there. The proposed feature simply suggests to have configurable dispatch logic to allow multiple extensions calling pandoc with a different set of PANDOC_OPTIONS.

Example use case

My personal use for this would be to convert one of my site currently using .md and .markdown to mean a different target format. Both will be converted to HTML, but one of them is slideshow, another is normal "article"/post.

Another possible use case is, if one want to specify markdown extensions in pandoc, say -t markdown+...-..., then COMPILERS['pandoc'] = ['.rst', '.md'] won't work with PANDOC_OPTIONS = ['-t', 'markdown+...-...'] because that would be wrong input format for .rst.

Suggested implementation

Probably the natural way is to promote

PANDOC_OPTIONS: Union[list, Dict[str, list]]

where the keys are those in COMPILERS['pandoc'].

If it makes sense I can send a PR doing that. It seems that it only requires changes in https://github.com/getnikola/nikola/blob/master/nikola/plugins/compile/pandoc.py#L52-L56, is it true?

@Kwpolska
Copy link
Member

Please implement this. No changes other than pandoc.py should be necessary.

@ickc
Copy link
Contributor Author

ickc commented Jan 12, 2021

There's one thing I don't understand and missed last time I looked:

self.config_dependencies = [str(site.config['PANDOC_OPTIONS'])]

What's this self.config_dependencies doing here? Turning it into a string is strange here. Is it just for something like logging?

@Kwpolska
Copy link
Member

self.config_dependencies is used to figure out if a post needs updating due to config changes. PANDOC_OPTIONS should be placed there — maybe doing it directly (without str) would work. It’s easy to test: if it doesn’t work, you’d (a) get an exception, (b) fail to get a rebuild when you change PANDOC_OPTIONS, (c) get a rebuild when you didn’t change anything (run nikola build twice+ in a row to test).

@ickc ickc changed the title dispatch PANDOC_OPTIONS on different conditions dispatch PANDOC_OPTIONS base on input extensions Jan 12, 2021
@ickc
Copy link
Contributor Author

ickc commented Jan 12, 2021

I'll leave that alone then as it is working well in the PR. (Good to know it is watching changes from conf.py though I find that sometimes changes in conf.py is not propagated when using nikola auto.)

@Kwpolska
Copy link
Member

changes in conf.py is not propagated when using nikola auto.

This could be a bug — please report it (we will need specific details about what you’re changing, in what cases does it work, and if it happens with nikola build; $EDITOR conf.py; nikola build)

@ickc
Copy link
Contributor Author

ickc commented Jan 13, 2021

I'll watch out for that in the future. Thanks.

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

Successfully merging a pull request may close this issue.

2 participants