Skip to content

Commit

Permalink
Fix subsyntaxes if their language cannot be inferred
Browse files Browse the repository at this point in the history
Closes GH-17.
Closes GH-18.

Reviewed-by: Takayuki Shimada <taka@tsmd.jp>

Co-authored-by: Takayuki Shimada <taka@tsmd.jp>
  • Loading branch information
wooorm and tsmd authored May 20, 2019
1 parent 51b3d4a commit fda353b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,12 @@ function coreHighlight(name, value, ignore, prefix, continuation) {
})
}

// If we couldn’t highlight, for example because the requests subset isn’t
// loaded, return a text node.
if (!subvalue.language) {
return [buildText(modeBuffer)]
}

// Counting embedded language score towards the host language may be
// disabled with zeroing the containing mode relevance.
// Usecase in point is Markdown that allows XML everywhere and makes every
Expand Down
1 change: 1 addition & 0 deletions test/fixture/xml-sublanguages-2/input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<script>foo()</script>
1 change: 1 addition & 0 deletions test/fixture/xml-sublanguages-2/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<span class="hljs-tag">&#x3C;<span class="hljs-name">script</span>></span>foo()<span class="hljs-tag">&#x3C;/<span class="hljs-name">script</span>></span>

0 comments on commit fda353b

Please sign in to comment.