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

admonitions() breaks when an admonition just before "^---\n" #5

Open
dreampuf opened this issue Dec 16, 2022 · 0 comments
Open

admonitions() breaks when an admonition just before "^---\n" #5

dreampuf opened this issue Dec 16, 2022 · 0 comments

Comments

@dreampuf
Copy link

Thank you for the great tool. I found a corner case of content that would break markdown2's rendering.

https://github.com/tencentcloudstack/terraform-provider-tencentcloud/blob/master/website/docs/r/cdn_domain.html.markdown

---
subcategory: "Content Delivery Network(CDN)"
layout: "tencentcloud"
page_title: "TencentCloud: tencentcloud_cdn_domain"
sidebar_current: "docs-tencentcloud-resource-cdn_domain"
description: |-
  Provides a resource to create a CDN domain.
~> **NOTE:** To disable most of configuration with switch, just modify switch argument to off instead of remove the whole block\n <--- This new line sign will be stripped in admonitions()
---

And later, markdown.convert will fail to extra metadata.

Traceback (most recent call last):
  File "/opt/./scripts/render.py", line 426, in <module>
    main()
  File "/opt/./scripts/render.py", line 80, in main
    body = render_markdown(text=input_data, flavor=args.flavor)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/./scripts/render.py", line 129, in render_markdown
    md = markdown2.markdown(text=text, extras=extras)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/.venv/lib/python3.11/site-packages/markdown2.py", line 185, in markdown
    use_file_vars=use_file_vars, cli=cli).convert(text)
                                          ^^^^^^^^^^^^^
  File "/opt/.venv/lib/python3.11/site-packages/markdown2.py", line 356, in convert
    text = self._extract_metadata(text)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/.venv/lib/python3.11/site-packages/markdown2.py", line 488, in _extract_metadata
    tail = fence_splits[2]
           ~~~~~~~~~~~~^^^
IndexError: list index out of range
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant