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

Avoid Markdown 2.6 deprecations #1638

Merged
merged 1 commit into from Nov 30, 2015

Conversation

kernc
Copy link
Contributor

@kernc kernc commented Feb 23, 2015

The MD_EXTENSIONS documentation in docs/settings.rst hasn't been touched, so it still shows the old value.

'css_class':'highlight'
}
self._md = Markdown(extensions=self.extensions,
extension_configs=extension_configs)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this will surprise too many unweary users. If they want some other css_class, they will have had something else in MD_EXTENSIONS anyway.

@ingwinlu
Copy link
Contributor

Hey,

gonna pile on this: wasn't headerid part of extra before it now got deprecated? I don't think we run tests on that currently, but the behaviour of markdownreader will change through an update (i.e. header ids will not be available anymore)

About the config thing, Can we not just blindly overwrite or correct settings? Would be better to use our deprecation functions somehow and warn the user that we are changing his settings to the now correct ones.

@ingwinlu
Copy link
Contributor

Apparently I was wrong and extra never included headerid

@kernc
Copy link
Contributor Author

kernc commented Feb 25, 2015

What about a code like this:

settings.py

'MD_EXTENSIONS': [
    'codehilite-INTERNAL-ONLY',  # something that would never have been entered by a user
    'markdown.extensions.extra'
],

readers.py

if 'codehilite-INTERNAL-ONLY' in self.extensions:
    ... # correct the plugin name
    ... # set the default css_class setting as above

I wouldn't know how to use the deprecation machinery here, nor how it applies.

@avaris
Copy link
Member

avaris commented Feb 25, 2015

It's probably better to expose extension_configs as a setting since any string extension has to be configured with that. It'll also make setting YAML meta easier:

'MD_EXTENSIONS': [
    'markdown.extensions.codehilite'
    'markdown.extensions.extra'
],
'MD_EXTENSION_CONFIGS' : {'markdown.extensions.codehilite' : {'css_class': 'highlight' }},

and the user defined config will .update the default one, so people can do:

MD_EXTENSION_CONFIGS = {'markdown.extensions.meta': {'yaml': True}}

to turn on YAML processing.

Besides that, settings.py has to correct old MD_EXTENSIONS settings defined by the user (and also warn them) to the new one. If correcting becomes too tricky, we can just warn that the syntax is changed and fall back to default values.

@kernc
Copy link
Contributor Author

kernc commented Feb 27, 2015

~~So then when Markdown decides to break its API with 3.0, wrap everything once again to provide backwards compatibility? I'm against it. The MD_EXTENSIONS interface is clear: If you need special config parameters, you can instantiate the plugin class directly as you want it.~~Ok, that could work.

@@ -39,184 +39,186 @@ Here is a list of settings for Pelican:
Basic settings
==============

=============================================================================== =====================================================================
Setting name (followed by default value, if any) What does it do?
=============================================================================== =====================================================================
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

git diff --ignore-space-change shows the true changes here.

@kernc kernc force-pushed the markdown2.6-deprecations branch 2 times, most recently from ae9880f to 499014a Compare February 28, 2015 03:50
@kernc
Copy link
Contributor Author

kernc commented Feb 28, 2015

How about now? 😅

@justinmayer
Copy link
Member

@avaris: Thoughts on @kernc's latest?

@avaris
Copy link
Member

avaris commented May 2, 2015

@justinmayer Ah, sorry, I somehow missed the last commit.

@kernc Looks mostly OK. Use of eval is a bit troublesome. I can see why it was used but still it would be best to avoid.

EDIT: On second look, that eval won't even work. Consider the old (corrected) default markdown.extensions.codehilite(css_class=highlight): It'd try to do eval('dict(css_class=highlight)') which should result in NameError for highlight.

@ingwinlu
Copy link
Contributor

ingwinlu commented May 3, 2015

Am I the only one who is against introducing setting deprectiation in readers.py?

@ingwinlu
Copy link
Contributor

@kernc any update on this? Can you move the depreciation into the appropriate section?

@justinmayer might want to tag this to keep track of it for soonish release

@justinmayer justinmayer added this to the 3.7 milestone Aug 19, 2015
@justinmayer
Copy link
Member

@ingwinlu: Tagged. Thanks!

@kernc kernc force-pushed the markdown2.6-deprecations branch 3 times, most recently from bfd31b8 to c08866e Compare August 19, 2015 22:09
@kernc
Copy link
Contributor Author

kernc commented Aug 19, 2015

Have considered both @avaris' and @ingwinlu's recommendations. Particularly the provided link was really helpful to a project novice like myself. That dict eval-ing is kind of hackish, but good enough and should work in all practical cases, I think.

@ingwinlu
Copy link
Contributor

hey @kernc good to see you are still on board with this.

some food for thought:

  • can we reduce the configs and replace them with a single dict? we can iterate over that dict's keys to get the names identifying the extensions
  • can we somehow get the eval out? either replace it with a regex or abort when the config is not correct and let users handle it manually

there also appears quite some ws in this commit, is that really necessary (in the doc)?

@kernc
Copy link
Contributor Author

kernc commented Aug 24, 2015

@ingwinlu I agree with your considerations, will implement asap.

Re table whitespace: the default value string should get pretty long. Should I put the default value in the right-hand column instead?

@justinmayer
Copy link
Member

@kernc: I think putting the default value in the right-hand column for this particular setting might indeed make sense, obviating the need to adjust the spacing for the entire table.

@justinmayer
Copy link
Member

Hi @kernc. Just following up on this PR. Any chance you might be able to get it ready for merge as noted above?

@kernc kernc force-pushed the markdown2.6-deprecations branch 2 times, most recently from 95d1617 to 2b18a3f Compare November 8, 2015 22:29
@kernc
Copy link
Contributor Author

kernc commented Nov 8, 2015

@justinmayer sorry, thanks. 😳

@ingwinlu How would I "reduce the configs and replace them with a single dict"? Isn't that exactly the opposite of what @avaris recommended?

I also did (almost) drop the eval? Is it better now or is it still unsafe?

kernc added a commit to kernc/pelican that referenced this pull request Nov 15, 2015
@@ -50,7 +50,8 @@ Take a look at the Markdown reader::
def read(self, source_path):
"""Parse content and metadata of markdown files"""
text = pelican_open(source_path)
md = Markdown(extensions = ['meta', 'codehilite'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs to be updated as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching that. 😅

kernc added a commit to kernc/pelican that referenced this pull request Nov 15, 2015
@avaris
Copy link
Member

avaris commented Nov 15, 2015

Why are we hard-quitting after a misconfiguration that doesn't have any major effect? I seriously disagree with that. It should be treated same as any other misconfiguration: ignore and fall back to default with a warning.

kernc added a commit to kernc/pelican that referenced this pull request Nov 15, 2015
kernc added a commit to kernc/pelican that referenced this pull request Nov 15, 2015
kernc added a commit to kernc/pelican that referenced this pull request Nov 15, 2015
@kernc
Copy link
Contributor Author

kernc commented Nov 15, 2015

That's exactly why I asked, thanks.

logger.warning('The format of the MD_EXTENSIONS setting has '
'changed. It should now be a dict mapping '
'fully-qualified extension names to their '
'configurations. Falling back to the default')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing tailing '.'

@ingwinlu
Copy link
Contributor

other than the comments in the code, this looks good to me now.

if you want to get rid of coveralls warning you might need to add a test for the warning issued when md_extensions is still a list. see other tests that look for logged messages.

atodorov pushed a commit to atodorov/pelican that referenced this pull request Nov 29, 2015
kernc added a commit to kernc/pelican that referenced this pull request Nov 29, 2015
@kernc
Copy link
Contributor Author

kernc commented Nov 29, 2015

You're a nitpicker, aren't you. 😛
Got rid of it, thanks.

@ingwinlu
Copy link
Contributor

I would love not have to have to correct you.

Squash is still missing, after that we are good to go @justinmayer

@justinmayer
Copy link
Member

@kernc: As Winlu suggested, would you be so kind as to squash your commits? Many thanks for patiently working with us to get this ready for merge. (^_^)

@kernc
Copy link
Contributor Author

kernc commented Nov 30, 2015

Oh, no problem at all.

* Make MD_EXTENSIONS setting a dict and add tests for this change;
* Short extension names ('extra', 'meta') are deprecated
  https://pythonhosted.org/Markdown/release-2.6.html#shortened-extension-names-deprecated
* Extension config as part of extension name is deprecated
  https://pythonhosted.org/Markdown/release-2.6.html#extension-configuration-as-part-of-extension-name-deprecated
@justinmayer
Copy link
Member

Sincere thanks to @kernc, @ingwinlu, and @avaris for your work on this. Bravo! 🎉

justinmayer added a commit that referenced this pull request Nov 30, 2015
@justinmayer justinmayer merged commit 959f96f into getpelican:master Nov 30, 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

Successfully merging this pull request may close these issues.

None yet

4 participants