-
-
Notifications
You must be signed in to change notification settings - Fork 254
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
Support Pandoc fancy-lists #2418
Comments
While it is an interesting idea, it is not likely something I would use. Pydown Extensions is not meant to be a one-stop shop for all Python Markdown extensions, so I am often very selective about what I add. Generally, if I am to maintain an extension, it is usually one I am interested in personally using as well. In short, I need to be invested in the extension for me to take on supporting it. Let me sit on this and think about it. It is possible already to wrap blocks in a div with a special class that can use CSS to target them and change the style, but I do get that you want a more convenient approach. I would just need to decide if this is something I'm willing to get behind and take on long term maintenance of. @gir-bot add P: maybe |
I'm exploring the possibility via prototype, but I am not sure if I'm all in yet. One thing to note, this behaves very Pandoc-like currently in that:
Here is the prototype: https://gist.github.com/facelessuser/a6613237425b78e843c32268ef464e2e |
Linking another recent discussion: #2454. |
Updated prototype to drop I also updated the prototype to follow the Pandoc rule of requiring uppercase, single letter list markers to need at least two spaces after the marker. I would rather keep this rule (which I am sure was added for some reason) and possibly relax it in the future if sufficient testing deemed it unnecessary. |
Also fixed some bugs |
I should note that |
This is what I'm thinking so far. By default, FancyList would extend list formats such that All other formats are probably not supported syntactically in many editors. It's possible not everyone wants such behavior, and might actually control this automatically with CSS when lists are nested, but that's okay. I think additional list formats would be opt-in. You could enable one or all of them if you desire. Someone using MkDocs might do this to enable all formats; decimal cannot be toggled and is always enabled. markdown_extensions:
- pymdownx.fancylists:
addtional_ordered_styles:
- alpha
- roman
- generic |
Okay, I ended up leaving all the list types enabled by default. Instead, people can opt out of certain list formats. I have PR with testing available here: #2455 |
Okay, I think I may be at a point where I am ready to stop fiddling. There are two inherient conflicts that exist when both alphabetically ordered and Roman numeral ordered lists are enabled. Alphabetical lists cannot start/restart a list with This issue also exists in Pandoc, but mitigation is fairly straight forward. We relax the Roman numerals a little and the use can use things like
<ol start="10" type="i">
<li>item 10</li>
<li>item 11</li>
</ol> Alphabetical lists don't have such clean mitigation, but if you have the HTML Block extension enabled, you can work around the
<ol start="9" type="a">
<li>item i</li>
<li>item j</li>
</ol> While maybe not as clean as the the Roman numeral case, it works fine and this case won't likely occur all that often. Pandoc has the same issue, but I don't know if they have a workaround. Some may assume you can do the following while using
You get something more like this, which is not desirable: <ol start="9" type="i">
<ol type="i">
<li>item i</li>
</ol>
<ol start="10" type="a">
<li>item j</li>
</ol>
</ol> |
I think I'm now open to people willing to test the PR and give feedback: #2455. |
Apparently, I implemented |
|
Okay, I added a more targeted workaround to handle alpha vs Roman numeral conflicts. While the HTML Block approach seemed to work at first glance, more complex cases showed that the parser was confused a bit while trying to process child list items from inside an already existing ordered list element. So now, if you have both alphabetic and Roman numeral lists enabled together, and you have to restart a list with a value that is ambiguous, such as
Of course, if you only have alphabetic or Roman enabled, there are no conflicts. I believe all corner cases and mitigations have finally been solved. |
I've added an |
I'm having trouble with styling different list styles because of that reason. Using a parenthesis instead of a dot in lower-alpha lists also affect upper-alpha. .md-typeset ol[type="a"] li::marker {
content: counter(list-item, lower-alpha) ") ";
} Would I assume it would look something like: .md-typeset ol[style="list-style-type: lower-alpha;"] li::marker {
content: counter(list-item, lower-alpha) ") ";
} In that case, wouldn't be easier to inject a class and then use it in CSS? |
Yes, this occurs because only Firefox supports case-sensitive attribute selectors
No, all it does is this. <ol style="list-style-type: lower-roman;" type="i">
<li>Item i</li>
</ol> It works for ensuring the browser renders the lists with the default style for such lists, even when there is other CSS trying to set it to something else. Browsers understand the case sensitivity of the
The above is easier for the average user as no additional CSS is required from them. I can add an option to inject classes if that is what you desire. Your case is more of a niche case. Most people aren't trying to change the default styling for a list type, but I could certainly facilitate it due to the lack of useful selectors currently in browsers. If I do, I would simply add a class on the |
I've also added an option to inject CSS classes. That should satisfy everyone. Those who just want the lists to work can inject styles if they aren't working. Those who want fine control over the lists can inject classes. |
Sorry for my phrasing. I meant it would help to solve the issue of selecting each type of list, making it easier to override CSS.
I haven't thought of the idea of browsers not rendering lists correctly.
Thanks! In my particular case, it helps a lot! 😄 |
I probably phrased this poorly, but as an example, what i mean is like with Mkdocs Material which has preset styles for tiers of lists. A user enabling this plugin just wants them to do what they think they should. As you've seen, just applying CSS to override can be difficult. So inject styles fixes the issue completely. Injecting styles doesn't fix the problem of CSS targeting for more advance styling, but injecting classes does. |
Will prodce: <ol class="fancylists-decimal;" start="3" type="1">
<li>List item number</li>
<li>List item number
<ol class="fancylists-lower-alpha;" type="a">
<li>List item letter</li>
<li>List item letter
<ol class="fancylists-lower-roman;" type="i">
<li>List item roman</li>
<li>List item roma</li>
</ol>
</li>
</ol>
</li>
</ol> |
I opened a PR that removes the semicolon: #2464 |
Description
Benefits
This would allow using roman numerals and alphabets for ordered list bullets, without having to specify
type
orlist-style-type
, which is quite common for nested lists.Solution Idea
Another extension to parse additional bullet types besides numbers.
The text was updated successfully, but these errors were encountered: