Mkdocs-material: Search highlight interprets code blocks as JavaScript

Created on 23 Nov 2020  路  3Comments  路  Source: squidfunk/mkdocs-material

__I've found a bug and checked that ...__

  • [x] ... the problem doesn't occur with the default MkDocs template
  • [x] ... the problem is not in any of my customizations (CSS, JS, template)
  • [x] ... the documentation does not mention anything about my problem
  • [x] ... 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

All 3 comments

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.

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ngtrian picture ngtrian  路  3Comments

oliverschwendener picture oliverschwendener  路  4Comments

Timber232 picture Timber232  路  3Comments

LinusGeffarth picture LinusGeffarth  路  3Comments

HerbFargus picture HerbFargus  路  4Comments