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

Feature request: allow changing default options #453

Closed
kylebarbour opened this issue Sep 19, 2017 · 8 comments
Closed

Feature request: allow changing default options #453

kylebarbour opened this issue Sep 19, 2017 · 8 comments
Assignees

Comments

@kylebarbour
Copy link

@kylebarbour kylebarbour commented Sep 19, 2017

A common mechanism for configuring alternate default options in Unix environments is a dotfile, e.g. .bashrc or .vimrc. It would be really helpful to be able to set default options in .kramdown. It could use the same syntax as the already-existing {::options ... /} syntax:

$ cat .kramdown
 auto_ids="false"
 footnote_nr="5"
$

Currently I solve this problem by aliasing kramdown to include my default settings, but I think this would be more elegant.

Thanks for considering!

@gettalong gettalong self-assigned this Sep 20, 2017
@gettalong
Copy link
Owner

@gettalong gettalong commented Sep 20, 2017

Thanks for this idea - this makes sense and can easily be implemented for the kramdown binary.

As for the details:

  • The configuration file should probably live under the XDG configuration directory, normally ~/.config/, so the file name would probably be ~/.config/kramdown. As for macOS ~/Library/Preferences/kramdown would probably the right location? (just guessing here since I'm not using macOS). As for Windows: any pointers?

  • For the file format I can imagine using either YAML (as done with the kramdown tests) or the {::options .../} syntax - what do you think would be easier for most users?

Loading

@kylebarbour
Copy link
Author

@kylebarbour kylebarbour commented Sep 21, 2017

I think ~/.config/kramdown makes sense. I wish I could offer any thoughts regarding Windows or MacOS - I use Linux myself.

I think both YAML and the native {::options ../} syntax are equally intelligible. I like YAML myself and think it's pretty straightforward but don't have much of a preference either way. I think people will be able to follow either.

Thanks very much!

Loading

@gettalong
Copy link
Owner

@gettalong gettalong commented Sep 22, 2017

Two Linux users - it's the year of the Linux desktop! 😉

The {::options /} syntax actually uses YAML for value parsing (as does the kramdown binary).

Maybe the easiest thing would be allowing to specify the binary options like on the command line, e.g.

$ cat ~/.config/kramdown
--auto-ids false --footnote-nr 5

This would imply no learning curve whatsoever - what do you think?

Loading

@kylebarbour
Copy link
Author

@kylebarbour kylebarbour commented Sep 22, 2017

Haha, we're finally taking over! :)

I think that's reasonable - your call. I haven't seen that style in config files but I don't think there's anything wrong with it. Personally I like

auto-ids: false
footnote-nr: 5

which is pretty common YAML notation, but I think any of your suggestions is equally comprehensible.

Loading

@gettalong
Copy link
Owner

@gettalong gettalong commented Oct 26, 2017

I will go with your suggested YAML approach - will be in the next release.

Loading

@kylebarbour
Copy link
Author

@kylebarbour kylebarbour commented Dec 2, 2017

I'm having trouble using this in the new release. After hacking on it for a while, I think the issue may be that loading $XDG_CONFIG_HOME/kramdownrc generates options as strings and not symbols. In other words, running kramdown --smart-quotes "apos,apos,quot,quot" file.md works fine and on internal inspection the options hash contains {:smart_quotes=>["apos", "apos", "quot", "quot"]}, but when smart-quotes: "apos,apos,quot,quot" is in ~/.config/kramdownrc the options aren't run and the options hash contains {"smart-quotes"=>"apos,apos,quot,quot"}.

Any thoughts?

Loading

@gettalong
Copy link
Owner

@gettalong gettalong commented Dec 2, 2017

You need to use the option name, not the command line switch used for the option name, i.e. smart_quote instead of smart-quote.

Loading

@kylebarbour
Copy link
Author

@kylebarbour kylebarbour commented Dec 2, 2017

Aaaaaaah, thanks!

Loading

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

Successfully merging a pull request may close this issue.

None yet
2 participants