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

fix toc with special characters - finally #2052

Merged
merged 1 commit into from
Nov 5, 2019

Conversation

tessus
Copy link
Collaborator

@tessus tessus commented Nov 1, 2019

subject says it all

@tessus tessus added bug It's a bug mobile All mobile platforms desktop All desktop platforms labels Nov 1, 2019
@laurent22
Copy link
Owner

I think that's indeed the right solution. Just to be sure, please could you check that it works with Russian and Chinese text headings too? Even better would be to have test units for this, but another time.

@tessus
Copy link
Collaborator Author

tessus commented Nov 1, 2019

Yep, will do. But after a 4h Skype session with a friend in Europe and 2 bottles of red wine I will postpone this task to tomorrow. ;-)

@tessus
Copy link
Collaborator Author

tessus commented Nov 2, 2019

works with Russian and Chinese text headings too?

Yes, it does. Added Japanese (which included a few Chinese characters) and Russion headings and it works like a charm.

@tessus tessus requested a review from laurent22 November 2, 2019 15:44
@tessus
Copy link
Collaborator Author

tessus commented Nov 4, 2019

@laurent22 can we merge this now?

@laurent22
Copy link
Owner

Perfect, thanks for checking @tessus, it's good to merge then.

@laurent22 laurent22 merged commit 83c3c02 into laurent22:master Nov 5, 2019
@tessus tessus deleted the fix/toc-slugify branch November 6, 2019 00:07
@tessus
Copy link
Collaborator Author

tessus commented Nov 6, 2019

@laurent22 here's the test code I used locally. Maybe you can use it for your test cases:

const uslug = require('uslug')

const md = require('markdown-it')({
	  html: true,
	  linkify: true
}).use(require('markdown-it-anchor'), { slugify: s => uslug(s), })
  .use(require('markdown-it-toc-done-right'), { listType: 'ul', slugify: s => uslug(s) })

const str = '[toc]\n\n# 日本語のテキスト\n\nText<br><br><br><br><br><br><br><br><br>\n\n# Немного текста на русском\n\nText<br><br><br><br><br><br><br><br><br>\n\n# heading (special)\n\nText<br><br><br><br><br><br><br><br><br>\n\n# another @ char\n\nText<br><br><br><br><br><br><br><br><br>\n\n# a lot of special characters !@#$%^&*\n\nText<br><br><br><br><br><br><br><br><br>\n\n# test !\n\nText<br><br><br><br><br><br><br><br><br>\n\n# test %\n\nText<br><br><br><br><br><br><br><br><br>\n\n---\n<br><br><br><br><br><br><br><br><br>\n<br><br><br><br><br><br><br><br><br>\n<br><br><br><br><br><br><br><br><br>\n<br><br><br><br><br><br><br><br><br>\n<br><br><br><br><br><br><br><br><br>\n';

console.log(md.render(str));

I used the <br> so that I could actually jump to the heading in a browser. But I guess they can be removed for the test case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It's a bug desktop All desktop platforms mobile All mobile platforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants