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

Remove zero width space U+200B in from code snippets #2206

Closed
wants to merge 2 commits into from
Closed

Remove zero width space U+200B in from code snippets #2206

wants to merge 2 commits into from

Conversation

fjp
Copy link

@fjp fjp commented Jan 11, 2021

When I tried to use pymdownx.snippets, and copied the code from the adding-a-glossary, the abbreviation docs wasn't included.
Instead after serving the site locally I got no abbreviation underlines in the text followed by

--8<--​ "includes/abbreviation.md"

I then realized that there is a "zero width space" character (U+200B) after the --8<-- which prevented the snippets extension from correctly parsing the include.

Notice the red dot after --8<-- in the following screenshot:

mkdocs-char

To see the hidden character I also used: https://www.soscisurvey.de/tools/view-chars.php

image

This PR removes those "zero width space" characters.

@facelessuser
Copy link
Contributor

That may be intentional to keep it from triggering and including snippets. You can use snippets even in code blocks as snippets are run very early on.

@facelessuser
Copy link
Contributor

I am guessing you didn't run the documents and view how it looks after you made this change?

@fjp
Copy link
Author

fjp commented Jan 12, 2021

I am guessing you didn't run the documents and view how it looks after you made this change?

Not up until now, sorry for that. I am getting an error when I try to run mkdocs serve:

INFO    -  Building documentation... 
INFO    -  Cleaning site directory 
ERROR   -  Error reading page 'reference/abbreviations.md': Snippet at path includes/abbreviations.md could not be found 

Snippet at path includes/abbreviations.md could not be found

@fjp fjp marked this pull request as draft January 12, 2021 00:33
@fjp
Copy link
Author

fjp commented Jan 12, 2021

I guess the way you did it here is the way to go:

<pre><code>--8&lt;-- "filename.ext"</code></pre>

@facelessuser
Copy link
Contributor

Yeah, I did this thing where if you add a space at the end, it won't trigger, but then people would copy and paste it as an example without really reading about the whitespace part and then complain it doesn't work, so then I did it like you pointed out so they could copy it. It was just easier. It's a syntax I'd never really use anywhere else except to insert snippets (and obviously the one-time case where I explain how snippets work 🙂).

@squidfunk
Copy link
Owner

Oh my 🤦‍♂️ I thought I'd be clever tricking the Snippets extension into not expanding the macro, but obviously haven't thought about users copy & pasting the code and wondering why it doesn't work. A better way is of course to just use the literal HTML, so Snippets won't expand it.

However, I've found no way to make this work inside a tabbed container without messing up the formatting. If somebody could make this work without the zero-width whitespace, I'm happy to merge.

Possible explanation for #2154.

facelessuser added a commit to facelessuser/mkdocs-material that referenced this pull request Jan 12, 2021
@facelessuser
Copy link
Contributor

I created a working pull at #2207

@squidfunk
Copy link
Owner

Superseded by 6cb4c86, see discussion in #2207.

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

Successfully merging this pull request may close these issues.

None yet

3 participants