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

Variables don't get resolved in Snippets #45

Open
Stwissel opened this issue Feb 17, 2023 · 5 comments
Open

Variables don't get resolved in Snippets #45

Stwissel opened this issue Feb 17, 2023 · 5 comments

Comments

@Stwissel
Copy link

I'm using your nice plugin together with the pymdownx.snippets plugin

I have

extra:
  test: 1.0.0
plugins:
  - search
  - awesome-pages
  - section-index
  - tags
  - markdownextradata: {}

and a test.md

# Test of extras

This is top: {{test}}

--8<-- "snippet.md"

End

and a snippet.md

In the snippet: {{test}}

Expected outcome

<h1>Test of extras</h1>

This is top: 1.0.0
In the snippet: 1.0.0

End

Actual outcome

<h1>Test of extras</h1>

This is top: 1.0.0
In the snippet: {{test}}

End

What do I miss?

@rosscdh
Copy link
Owner

rosscdh commented Feb 17, 2023 via email

@Stwissel
Copy link
Author

Tried that too. I suspect it might be the sequence of plugins. Mkdocs is particular about it. I'll experiment and report back

@Stwissel
Copy link
Author

Played with various combinations of plugin and markdown extension sequences to no success.
I also renamed in one attempt the snippet directory to .snippet so it would be first in the directory list.

Interesting observation: when I load snippet.md directly from the URL, it works as expected and variables are resolved. Looks to me like a lifecycle issue where the snippet plugin ignores the markdownextradata.

@rosscdh
Copy link
Owner

rosscdh commented Feb 18, 2023 via email

@Stwissel
Copy link
Author

Here you go:

#Project Information
site_name: MKDocs Test
site_url: https://github.com/
site_description: >-
  A test
use_directory_urls: false
# Theme Configuration
theme:
  name: material
  language: en
  features:
    - navigation.tabs
    - navigation.indexes
    - navigation.top
    - navigation.instant
    - search.highlight
    - search.share
    - search.suggest
  #custom_dir: theme_overrides/
  icon:
    repo: fontawesome/brands/github
  font:
    text: Roboto
    code: Roboto Mono
  favicon: favicon.ico

  # Static files
  static_templates:
    - 404.html

# Markdown Extensions
markdown_extensions:
  - admonition
  - pymdownx.details
  - pymdownx.superfences
  - attr_list
  - pymdownx.tabbed:
      alternate_style: true
  - pymdownx.emoji:
      emoji_index: !!python/name:materialx.emoji.twemoji
      emoji_generator: !!python/name:materialx.emoji.to_svg
  - pymdownx.snippets:
      base_path:
        - "docs/snippets"

extra:
  test: 1.0.0
  
plugins:
  - markdownextradata
  - search
  - awesome-pages
  - section-index
  - tags

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

2 participants