From: Jean-Philippe F. <co...@jp...> - 2011-06-25 18:46:33
|
Waylan Limberg a écrit le 2011-06-23 18:39 : > 1) Remove HeaderID ext and reimplement those features in the attr_list > extension. However, as they're header specific, that doesn't feel > right to me. For me, it's not really inappropriate to have options related to a subset of attributes in the attr_list extension. I imagine options for ids, classes... Example (non-existent options only for this example): ~~~~~~~~~~~~~~~ extensions=['attr_list(forceid=True, overrideClasses=False, optionalColon=False)'] ~~~~~~~~~~~~~~~ > 2) Remove duplicate id defining code and use the HeaderID ext only for > defining level and autogenerating ids on headers. > 3) Patch the HeaderID extension to work with setext headers and have > two separate extensions which accomplish the same thing - one which > works only with headers (and only sets ids) and the other which works > with any element (and sets any attribute). Seems redundant and > potentially confusing. I think the same code should be use to autogenerate ids on headers, regardless of the extension. For now, toc and headerid don't output the same result. toc: ~~~~~~~~~~~~~~~ text = """ # L'intéressant titre """ print markdown.markdown(text, extensions=['toc']) ~~~~~~~~~~~~~~~ will output: ~~~~~~~~~~~~~~~ <h1 id="linteressant-titre">L'intéressant titre</h1> ~~~~~~~~~~~~~~~ headerid: ~~~~~~~~~~~~~~~ text = """ # L'intéressant titre """ print markdown.markdown(text, extensions=['headerid']) ~~~~~~~~~~~~~~~ will output: ~~~~~~~~~~~~~~~ <h1 id="lint+ressant_titre">L'intéressant titre</h1> ~~~~~~~~~~~~~~~ Using to the same algorithm would ensure uniformity and reduce code duplication. Between toc and headerid, toc algorithm is more interesting since its transliteration is more advanced (e.g., "intéressant" becomes "interessant" instead of "int+ressant"). > 4) Do nothing and tell people to use the attr_list extension moving > forward for defining ids. IMHO: 1) using extensions=['extra'] should be sufficient to have full Markdown Extra support (without using other extensions), and a Markdown Extra document should be converted in HTML the same way whatever the implementation used (PHP, Python...). For now, we must use `extensions=['extra', 'headerid(forceid=False)']` to emulate correctly Markdown Extra, otherwise extra code (forced ids) is added that should not be added. 2) when using extensions=['extra'], extra elements that are not part of the Markdown Extra description should not be accessible, otherwise we open the door to a set of Markdown Extra documents not converted the same way according to the implementation used. > I'm leaning toward #2 myself. But is also occurs to me that the TOC > extension also autogenerates ids when not defined (in a slightly > different manner). Perhaps we should provide some general code > specifically for autogenerating ids on headers. I think so, but I don't know if it should be as an extension or not. Regards, Jean-Philippe |