-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Multiple markdowns cause identifier problems #117
Comments
Yes, you can render elements with a prefix to avoid id collisions. Here's an example of how you can modify the markdownify function in django-markdown-editor to add a prefix to the ids of Codehilite's tabbed view:
In the above code, we first import the original markdownify function from markdownx.utils. Then, we define a new markdownify function that takes an optional prefix argument. Inside the function, we call the original markdownify function to convert the markdown text to HTML. Then, if a prefix is provided, we use string replacement to add the prefix to the ids and hrefs of Codehilite's tabbed view. For example, if you call markdownify(markdown_text, prefix='my-prefix'), the ids and hrefs of Codehilite's tabbed view will be rendered as id="my-prefix-md-fenced-code-tabs" and href="#my-prefix-md-fenced-code-tabs", respectively. You can use this modified markdownify function in your Django views to render multiple markdown texts with unique ids. |
Hi,
We are displaying multiple markdown texts on a single page. Everything worked fine, except when we tried to use Codehilite's tabbed view.
Since the ids of the Codehilite collide with each other, the JS code doesn't work. For example, the id of the code tabs are the same for 2 markdown areas
md-fenced-code-tabs
Is there a way to render elements with a prefix?
The text was updated successfully, but these errors were encountered: