Markdown metadata rendering as list of unicode strings
mbrookes opened this issue ยท 11 comments
According to this:
https://pythonhosted.org/Markdown/extensions/meta_data.html
That is the expected behavior. This library uses the above mentioned module to parse Markdown. So this is the correct expected behavior. Basically you can have the same meta tag repeat more than once, and they show up as items in the list.
Okay, thanks. I'll try to figure out how to filter it in the page.
Rather than open another issue, could I ask a quick question here? Is it possible to access the currently selected tag in the index.html
template for blogging.posts_by_tag
? I'd like to be able to display the tag in the page title / breadcrumbs... Thanks!
@mbrookes
If i understand your question right, you want to access the tag that was chosen in the posts_by_tag
view. This is possible using the plugin
framework. The following plugin will insert the tag into the meta
variable available in each page, and can be accessed as meta.selected_tag
.
# myplugin.py
from flask_blogging import signals
def set_tag_in_meta(app, engine, posts, meta, tag, count, page):
meta["selected_tag"] = tag
def register(app):
signals.posts_by_tag_processed.connect(set_tag_in_meta)
You can hook the plugin by setting the BLOGGING_PLUGINS
config variable as shown here:
http://flask-blogging.readthedocs.io/en/latest/#extending-using-the-plugin-framework
Fantastic, thanks! Goes to show the power of the plugin framework. Still, I think this should really be a standard feature. ๐
Agree this should be a standard feature. Happy to take a PR. ๐
Ok, I'll see if I can wrap my head around the code base. I'm new to Python & Flask, and all that entails, but (mostly!) enjoying it. ๐
No worries. I will try to add that to the next release. It is a small fix and I can take a look at it as well.
Thanks!
Just circling back to say that now 0.9.2 is working (tag-cloud plugin aside), I was able to test that, and it's exactly what I needed, thanks! I had been using {{posts[0].tags[0] | title }}
as a stop-gap, but meta.tag
is much cleaner.