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

Convert compiletime syntax configuration settings to runtime flags #124

Closed
binki opened this issue Jul 12, 2015 · 2 comments
Closed

Convert compiletime syntax configuration settings to runtime flags #124

binki opened this issue Jul 12, 2015 · 2 comments
Assignees

Comments

@binki
Copy link
Contributor

binki commented Jul 12, 2015

To make discount more usable as a shared tool and library, I think it would be better if all syntax variations could be configured at runtime. If the tool needs to be used to process different types of markdown on the same system, it should be possible to access all of the different syntax variations through the tool as long as it is compiled with support for that. For example, if I run ./configure.sh --with-fenced-code, I should be able to opt out of fences with markdown -f -fencedcode rather than having to compile a different binary with ./configure.sh.

For reference, this is my conclusion when considering gentoo bug #554520.

This would help a lot with the case where discount is installed system-wide and used by multiple different applications or scripts for different purposes. I suspect that some applications might even want to be able to use different options or allow the user to enable/disable them at runtime, but there are quite a few options that remain compiletime.

It looks like there are 23 flags right now, so with the max at 31 there should be enough for all of the ./configure.sh options (6: dldiscout, dlextra, idanchor, githubtags, fencedcode, urlencodedanchor leaves flag values 30 and 31 open). If you’d be willing to accept a patch with this change, I think I could manage to write one, just let me know. I would drop all of the the relevant flags from ./configure.sh and expose them only as flags. Unfortunately, this would be a breaking change for anyone who has used ./configure.sh to customize discount before, but I think trying to keep compatibility would be unnecessarily dirty.

@Orc
Copy link
Owner

Orc commented Jul 12, 2015

I have absolutely no objection to pulling configure-time options out and making them into flags. If you want to make a patch that runtimifies everything, I will happily accept it and merge it into the mainline code. (note that USER_FLAGS masks out the upper 4 bits; I don't think I use them for anything right now, so it's not a problem to make USER_FLAGS 0x3FFFFFFF)

@Orc Orc self-assigned this Jul 12, 2015
binki added a commit to binki/discount that referenced this issue Jul 12, 2015
Instead of specifying `./configure.sh --with-dl=both`, specify
`-fdlextra` or `MKD_DLEXTRA` at runtime.
binki added a commit to binki/discount that referenced this issue Jul 13, 2015
This change is more invasive and difficult for me as not all existing
preprocessor directives directly translate to `if () {}`.

Instead of passing `--with-fenced-code` to `configure.sh`, now use
`MKD_FENCEDCODE` or `-ffencedcode`.

The output of `markdown -VV` will now display `FENCEDCODE` if the
feature is enabled and `!FENCEDCODE` if it is disabled rather than
displaying `FENCED-CODE` if the feature is enabled.
binki added a commit to binki/discount that referenced this issue Jul 13, 2015
Now specify flag `-fidanchor` or `MKD_IDANCHOR` instead of
`./configure.sh --with-id-anchor`. In `markdown -VV` displays as
`IDANCHOR` or `!IDANCHOR` rather than `ID-ANCHOR`.
binki added a commit to binki/discount that referenced this issue Jul 13, 2015
Instead of `./configure.sh --with-github-tags`, specify `-fgithubtags`
or `MKD_GITHUBTAGS`. Shows up in `markdown -VV` as `GITHUBTAGS`
instead of `GITHUB-TAGS` now.
binki added a commit to binki/discount that referenced this issue Jul 13, 2015
Instead of `./configure.sh --with-urlencoded-anchor`, now use
`-furlencodedanchor` or `MKD_URLENCODEDANCHOR`.
binki added a commit to binki/discount that referenced this issue Jul 13, 2015
Instead of specifying `./configure.sh --with-dl=both`, specify
`-fdlextra` or `MKD_DLEXTRA` at runtime.
binki added a commit to binki/discount that referenced this issue Jul 13, 2015
This change is more invasive and difficult for me as not all existing
preprocessor directives directly translate to `if () {}`.

Instead of passing `--with-fenced-code` to `configure.sh`, now use
`MKD_FENCEDCODE` or `-ffencedcode`.

The output of `markdown -VV` will now display `FENCEDCODE` if the
feature is enabled and `!FENCEDCODE` if it is disabled rather than
displaying `FENCED-CODE` if the feature is enabled.
binki added a commit to binki/discount that referenced this issue Jul 13, 2015
Now specify flag `-fidanchor` or `MKD_IDANCHOR` instead of
`./configure.sh --with-id-anchor`. In `markdown -VV` displays as
`IDANCHOR` or `!IDANCHOR` rather than `ID-ANCHOR`.
binki added a commit to binki/discount that referenced this issue Jul 13, 2015
Instead of `./configure.sh --with-github-tags`, specify `-fgithubtags`
or `MKD_GITHUBTAGS`. Shows up in `markdown -VV` as `GITHUBTAGS`
instead of `GITHUB-TAGS` now.
binki added a commit to binki/discount that referenced this issue Jul 13, 2015
Instead of `./configure.sh --with-urlencoded-anchor`, now use
`-furlencodedanchor` or `MKD_URLENCODEDANCHOR`.
Orc pushed a commit that referenced this issue Jul 13, 2015
#124: Convert much compiletime configuration to runtime flags
@Orc
Copy link
Owner

Orc commented Jul 14, 2015

No need to leave this open because binki fixed the wagon for me! Thanks!

@Orc Orc closed this as completed Jul 14, 2015
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