Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

257
Views
Why does the line number appear in the wrong place after using the line-number plugin in Prismjs?

I use the following example:

<script setup lang="ts">
import Prism from 'prismjs';
import { onMounted } from 'vue';

const codeTest1 = `
function handle(t, s) {
  let sum = 0
  sum += t * 0.3
  if (s <= 20) {
    sum += s * 1.8
  } else {
    sum += 20 * 1.8 + (s - 20) * 2.5
  }

  return sum < 9 ? 9 : sum
}
`

onMounted(() => {
  Prism.highlightAllUnder(document)
})
</script>

<template>
  <pre class="line-numbers">
    <code class="language-js">{{ codeTest1 }}</code>
  </pre>
</template>

<style>
</style>

But it doesn't work as I expected: result

The demo use vite and vue-ts template. The prismjs's version is ^1.23.0

Can anyone tell me why this is happening?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!