Alex,
That attribute syntax is some old legacy code which existed in
Python-Markdown before I came to the project. It is completely
undocumented but remains (semi) supported because some people have old
documents that still use it. I don't believe we have any tests of the
feature.
In any event, I think you will find our new Attribute List Extension
[1] more useful (see the code here[2]). It handles both headers and
other attributes and uses a syntax shared by multiple markdown
implementations. It will officially be available in the next release
(currently at 2.1.0-alpha [3]) of Python-Markdown.
As a side note, I should mention that the Attribute List Extension
does not auto-generate IDs on headers. The HeaderID Extension [4]
still exists (in version 2.1) for that purpose and will only
auto-generate IDs. Defining your own IDs is left to the Attribute List
Extension. Additionally, the HeaderID Extension is specifically
designed to work in conjunction with Attribute Lists and won't have
the problems you're seeing with the old style attributes.
I should also mention that as PHP Markdown Extra (which our "extra" is
emulating) does not auto-generate IDs, HeaderID is no longer part of
Extra; however, Attribute Lists are so you can define your own IDs.
[1]:
https://github.com/waylan/Python-Markdown/blob/master/docs/extensions/attr_list.md
[2]:
https://github.com/waylan/Python-Markdown/blob/master/markdown/extensions/attr_list.py
[3]: https://github.com/waylan/Python-Markdown/downloads
[4]:
https://github.com/waylan/Python-Markdown/blob/master/docs/extensions/header_id.md
On Thu, Sep 22, 2011 at 9:01 AM, Alexandre Leray
<newsletters at alexandreleray.com> wrote:> Hi,
>
> I'm using the header id extension from markdown extra and in my
perception
> it gets wrong when I use attributes on headers, for instance:
>
>>>> md = markdown.Markdown(['extra'])
>>>> md.convert('# My header {@class=red}')
> ? ?u'<h1 class="red"
id="my_header_classred_1">My header </h1>'
>
> I would have expected:
>
> ? ?u'<h1 class="red" id="my_header">My header
</h1>'
>
> An other example:
>
>>>> markdown.markdown("# Test {@style=position: absolute; top:
100px; left:
>>>> 455px; width: 300px; height: 250px;}
>>>>
{@about=http://video.constantvzw.org/Ellentriek8/softsensor_pure_d.ogv}",
>>>> ['headerid'])
> ? ?u'<h1
>
about="http://video.constantvzw.org/Ellentriek8/softsensor_pure_d.ogv"
>
id="test_styleposition_absolute_top_100px_left_455px_width_300px_height_250px_abouthttpvideoconstantvzworgellentriek8softsensor_pure_dogv"
> style="position: absolute; top: 100px; left: 455px; width: 300px;
height:
> 250px;">Test </h1>
>
> Instead, I'd like:
>
> ? ?u'<h1
>
about="http://video.constantvzw.org/Ellentriek8/softsensor_pure_d.ogv"
> id="test" style="position: absolute; top: 100px; left:
455px; width: 300px;
> height: 250px;">Test </h1>
>
> What do you think? Should it be fixed by stripping {@...} chunks in
> _create_id function?
>
> Thanks,
>
> -- Alex
> _______________________________________________
> Markdown-Discuss mailing list
> Markdown-Discuss at six.pairlist.net
> http://six.pairlist.net/mailman/listinfo/markdown-discuss
>
--
----
\X/ /-\ `/ |_ /-\ |\|
Waylan Limberg