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

Search highlight interprets code blocks as JavaScript #2068

Closed
5 tasks done
michael-nok opened this issue Nov 23, 2020 · 3 comments
Closed
5 tasks done

Search highlight interprets code blocks as JavaScript #2068

michael-nok opened this issue Nov 23, 2020 · 3 comments
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open

Comments

@michael-nok
Copy link
Contributor

michael-nok commented Nov 23, 2020

I've found a bug and checked that ...

  • ... the problem doesn't occur with the default MkDocs template
  • ... the problem is not in any of my customizations (CSS, JS, template)
  • ... the documentation does not mention anything about my problem
  • ... there are no open or closed issues that are related to my problem

Description

When perform a search query with search.highlight enabled, code blocks may get interpreted as JavaScript functions, causing the code block to partially render.

Steps to reproduce the bug

  1. Create a page that contains a code block and a <script name> section:

Code block testing

   This is a <script name> testing
   Can anyone read me?
  1. Do a search for "anyone" or anything else on the page, and when it displays, the code block will be cut off.
    mywebsite.com/test.html?h=testing

Expected output

Expected output

Actual output

Actual output

Package versions

Python 2.7.18
mkdocs, version 1.1.2 from /home/ec2-user/.local/lib/python3.7/site-packages/mkdocs (Python 3.7)
Version: 6.1.0+insiders.1.7.0

@facelessuser
Copy link
Contributor

This issue is not a theme issue. Most likely it is a Markdown parsing issue. I can't tell what version of Python you are actually using as you've mentioned both 2.7.18 and Python 3.7.

Most likely, I'm guessing you are using Python Markdown 3.3+ which uses a new HTML parser. There are still some bugs being worked out of it as I think it was a bit prematurely released (there just weren't tests in place to catch the kind of edge cases that were discovered after release). You most likely won't have an issue if you use Python Markdown 3.2.2 IIRC.

@squidfunk
Copy link
Owner

It could be a theme issue, I already have an idea what's probably causing it - I'll investigate it asap!

@squidfunk squidfunk added bug Issue reports a bug needs investigation Issue must be investigated by the maintainers and removed needs investigation Issue must be investigated by the maintainers labels Nov 23, 2020
@squidfunk
Copy link
Owner

squidfunk commented Nov 29, 2020

Fixed and released as part of Insiders 1.11.2! Text nodes are now properly escaped when using search highlighting:

Bildschirmfoto 2020-11-29 um 22 02 23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open
Projects
None yet
Development

No branches or pull requests

3 participants