{% set name = "markdown-it-py" %}
{% set version = "4.0.0" %}

package:
  name: {{ name|lower }}
  version: {{ version }}

source:
  - url: https://pypi.org/packages/source/{{ name[0] }}/{{ name }}/markdown_it_py-{{ version }}.tar.gz
    sha256: cb0a2b4aa34f932c007117b194e945bd74e0ec24133ceb5bac59009cda1cb9f3
  - url: https://github.com/executablebooks/{{ name }}/archive/refs/tags/v{{ version }}.tar.gz
    sha256: c562899de418498f223f0c48b3d462319a64493bd3b2758e1a76f11ad8f0ae15
    folder: gh

build:
  number: 2
  entry_points:
    - markdown-it = markdown_it.cli.parse:main
  script: {{ PYTHON }} -m pip install . -vv --no-deps --no-build-isolation
  skip: true  # [py<310]

requirements:
  host:
    - python
    - pip
    # AttributeError: module 'ast' has no attribute 'Str' when using flit-core <3.12 on python 3.14.
    # To fix this, the flit-core code needs to be updated to use ast.Constant instead. 
    # flit-core 3.12 is available on the main channel for python 3.14.
    - flit-core >=3.4,<4   # [py<314]
    - flit-core >=3.12,<4  # [py>=314]
  run:
    - python
    - mdurl >=0.1,<0.2
  run_constrained:
    - commonmark >=0.9,<0.10
    - markdown >=3.4,<4
    - mistletoe >=1.0,<2.0
    - mistune >=3.0,<4.0
    - panflute >=2.3,<2.4
    - linkify-it-py >=1,<3
    - mdit-py-plugins >=0.5.0
    - sphinx-book-theme >=1,<2

# E IndexError: string index out of range
{% set tests_to_skip = "test_commonmark_extras" %}
# Missing pytest-regressions in the main channel
{% set tests_to_skip = tests_to_skip + " or test_table_tokens
                                         or test_file or test_use_existing_env
                                         or test_store_labels
                                         or test_inline_definitions
                                         or test_pretty
                                         or test_pretty_text_special" %}

test:
  source_files:
    - gh/tests
  requires:
    - pip
    - pytest
    - linkify-it-py
  imports:
    - markdown_it
    - markdown_it.cli
    - markdown_it.main
    - markdown_it.presets
    - markdown_it.renderer
    - markdown_it.rules_inline
    - markdown_it.token
    - markdown_it.tree
    - markdown_it.utils
  commands:
    - pip check
    - python -c "from importlib.metadata import version; assert(version('{{ name }}')=='{{ version }}')"
    # UnicodeDecodeError: 'charmap' codec can't decode byte
    - set PYTHONUTF8=1              # [win]
    - set PYTHONIOENCODING="UTF-8"  # [win]
    - pytest -k "not({{ tests_to_skip }})" -v gh/tests
    - markdown-it --help

about:
  home: https://github.com/executablebooks/markdown-it-py
  license: MIT
  license_family: MIT
  license_file: LICENSE
  description: |
    Python port of markdown-it. Markdown parsing, done right!
  summary: Python port of markdown-it. Markdown parsing, done right!
  doc_url: https://markdown-it-py.readthedocs.io
  dev_url: https://github.com/executablebooks/markdown-it-py

extra:
  recipe-maintainers:
    - dopplershift
    - choldgraf
