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

Use start= attribute of <ol> to enable numbered lists that start with non-1 digits #66

Open
jywarren opened this issue Mar 1, 2018 · 3 comments

Comments

@jywarren
Copy link
Collaborator

jywarren commented Mar 1, 2018

(ref publiclab/PublicLab.Editor#128)

In GitHub Markdown, there's a nice feature where you can start a list with a non-1 digit and it starts numbering there. As a step in that direction, when parsing Markdown lists, can we not convert to 1,2,3,4 automatically? The megamark parser should be able to read it anyways, so if we take a list like:

3. hi
4. hi
5. hi

...is there any way to preserve that numbering while in rich mode? Perhaps by storing the number in a <li data-numeral="3"> type attribute?

Just by way of example:

  1. hi
  2. hi
  3. hi
@jywarren
Copy link
Collaborator Author

jywarren commented Mar 1, 2018

Aha -- examining GitHub's work, the list starts with <ol start="3"> -- I imagine that's a standard HTML way to do this. Could that work?

@jywarren jywarren changed the title Don't reset numbering of numbered lists on mode change Use start= attribute of <ol> to enable numbered lists that start with non-1 digits Mar 1, 2018
@jywarren
Copy link
Collaborator Author

jywarren commented Mar 1, 2018

This line seems like where we could start:

var olist = '<' + tag + '>';

and correspondingly on converting to Markdown, here we'd have to read the start attribute and offest the numerals shown:

digital = /\d+[.]/.test(chunks.startTag);
chunks.startTag = '';
chunks.selection = chunks.selection.replace(/\n[ ]{4}/g, '\n');
wrapping.unwrap(chunks);

@jywarren
Copy link
Collaborator Author

@bevacqua what do you think of this solution? Not urgent but if you +1 I can open a PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant