Open ThibsG opened 1 year ago
Thanks for reporting this issue, it might be time to update the dependencies. I'll check if just by updating the tag is recognized.
@ThibsG I created a new release and updated the minimum version of ruamel.yaml, I quickly tested it locally and it worked to parse tags. Could you try it and let me know the results?
Hi @ovasquez , thanks a lot for being this responsive!
Unfortunately the new release didn't solve this issue. I dig further and found it is coming from this line: https://github.com/ovasquez/mkdocs-merge/blob/main/mkdocsmerge/merge.py#L68
The ruamel.yaml
documentation says:
typ='safe' accomplishes the same as what safe_load() did before: loading of a document without resolving unknown tags
indeed in my case:
from ruamel.yaml import YAML
from pathlib import Path
yaml=YAML()
yaml.load(Path('./mkdocs.yml'))
works but
from ruamel.yaml import YAML
from pathlib import Path
yaml=YAML(typ='safe')
yaml.load(Path('./mkdocs.yml'))
ends up with an error:
~/.local/lib/python3.10/site-packages/ruamel/yaml/constructor.py in construct_undefined(self, node)
688 def construct_undefined(self, node):
689 # type: (Any) -> None
--> 690 raise ConstructorError(
691 None,
692 None,
ConstructorError: could not determine a constructor for the tag '!!python/name:materialx.emoji.twemoji'
in "mkdocs.yml", line 40, column 18
To be honest I'm not familiar with tags in yaml and I don't really get why those are not resolved.
The typ=safe
seems a good approach, and I was wondering why it is not used to load the master yaml?
edit: found that people got the same issue and a solution with PyYaml
Thanks for noting that there is a solution, I will have to test if using something like that allows processing those tags, or if this is something that can be incorporated in the downstream repos (ruamel or PyYaml).
Hi @ovasquez , thank you for this useful tool!
I encounter an issue when in my
mkdocs.yml
of a sub-site I'm using special characters, such as!
:for example when you setup this extension: https://github.com/facelessuser/mkdocs-material-extensions#inline-svg-icons
turns into:
Sounds like the Ruamel Yaml parser is not working with such
!!
tag