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

[bug] sth missing in line number plugin initialization process #2730

Closed
dna2github opened this issue Jan 20, 2021 · 0 comments · Fixed by #2732
Closed

[bug] sth missing in line number plugin initialization process #2730

dna2github opened this issue Jan 20, 2021 · 0 comments · Fixed by #2732

Comments

@dna2github
Copy link

Information:

  • Prism version: 1.23.0
  • Plugins: Line Highlight, Line Number
  • Environment: Chrome

Description

i would like to report bug related to Line Number plugin. i am not sure it is right place so feel free to close if it is not proper.
i can find the plugin author but i cannot find the right project about the plugin. and now the prism.js with the plugin can be downloaded at Prism Download page, therefore, i create a bug here.

  • download prism.js with line highlight and line number plugins; download prism.css
  • open example html say file:///path/to/xxx.html
  • bug 1: although we have linkable-line-numbers for the pre element, but we cannot click any line number to highlight the line and update the location hash (no event registered at init, need to manually change hash to e.g. #play.2 to trigger event registration).
  • open example html like file:///path/to/xxx.html#play.3
  • bug 2: the 3rd line is not highlighted at init

how to fix in minimized version: add /*bugfix*/var z=/#(\w+)\.([\d-,]+)/.exec(location.hash)||[];if(n.id===z[1]&&y(n, "line-numbers"))setTimeout(function(){l(n,z[2]||"1","temporary ")();u();});/*end*/ in Prism.hooks.add("complete", ...); it will fix bug 1 and bug 2.

Example

<html>
<head>
   <link rel="stylesheet" href="prism.css" />
</head>
<body>
<div class="main-container">
   <div class="content-container">
      <div class="content-area">
         <pre id="play" class="line-numbers linkable-line-numbers"><code class="language-go">package main

import "fmt"

func main() {
   fmt.Println("Hello, World!")
}</code></pre>
      </div>
   </div>
</div>
<script src="prism.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants