question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing italic styles in 0.11?

See original GitHub issue

Reproduction (https://runkit.com/brc-dd/6309d1529e302e000a926cad):

const shiki_10 = require('shiki@0.10.1')
const shiki_11 = require('shiki')

const h_10 = await shiki_10.getHighlighter({ theme: 'material-palenight' })
const h_11 = await shiki_11.getHighlighter({ theme: 'material-palenight' })

console.log(h_10.codeToHtml(`import foo from 'bar'`, { lang: 'js' }))
console.log(h_11.codeToHtml(`import foo from 'bar'`, { lang: 'js' }))

Output (notice the difference in style of import and from):

image

Is some additional config required to render it like before, or the theme itself has changed?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
octrefcommented, Sep 21, 2022

Thanks @LaPenna for the test case! This is a tokenization problem and I fixed it by upgrading to vscode-textmate@7.0.1.

0reactions
LaPennacommented, Sep 20, 2022

Experiencing the same lack of italics issue.

Interestingly, if I specify "fontStyle": "bold" in the theme, then it applies the "font-style: italic" style.

Here are some tests

import { getHighlighter } from '../index'

// passes
test('No font-style is applied if none is specified', async () => {
  const highlighter = await getHighlighter({
    theme: 'font-none',
    langs: ['js']
  })
  const out = highlighter.codeToHtml(`function() {return 1}`, { lang: 'js' })

  expect(out).not.toContain('font-style:')
})

// fails - doesn't apply any font-style
test('An italic font-style is applied if specified', async () => {
  const highlighter = await getHighlighter({
    theme: 'font-italic',
    langs: ['js']
  })
  const out = highlighter.codeToHtml(`function() {return 1}`, { lang: 'js' })

  expect(out).toContain('font-style: italic')
})

// fails - incorrectly applies font-style: italic
test('A bold font-style is applied if specified', async () => {
  const highlighter = await getHighlighter({
    theme: 'font-bold',
    langs: ['js']
  })
  const out = highlighter.codeToHtml(`function() {return 1}`, { lang: 'js' })

  expect(out).toContain('font-style: bold')
})

// fails - test for the bug encountered above
test('A bold fontStyle should not apply an italic font-style', async () => {
  const highlighter = await getHighlighter({
    theme: 'font-bold',
    langs: ['js']
  })
  const out = highlighter.codeToHtml(`function() {return 1}`, { lang: 'js' })

  expect(out).not.toContain('font-style: italic')
})

For simplicity & isolation I used the following stubs as the themes but the same issue occurs when I test with any normal theme that uses italics.

// font-none.json
{
  "tokenColors": [
    {
      "name": "Keyword",
      "scope": "keyword",
      "settings": {
        "foreground": "#ffffff"
      }
    }
  ]
}

// font-bold.json
{
  "tokenColors": [
    {
      "name": "Keyword",
      "scope": "keyword",
      "settings": {
        "foreground": "#ffffff",
        "fontStyle": "bold"
      }
    }
  ]
}

// font-italic.json
{
  "tokenColors": [
    {
      "name": "Keyword",
      "scope": "keyword",
      "settings": {
        "foreground": "#ffffff",
        "fontStyle": "italic"
      }
    }
  ]
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Font style bold and italic cannot be generated in the pdf file · Issue ...
However, I see a different style in my resume.pdf. No bold and italic fonts are generated in the pdf file. ... Looks like...
Read more >
The italic font style option is missing from a layout in ArcGIS Pro
On the ribbon, on the contextual Format tab and in the Text Symbol group, click the Text Symbol Font Style drop-down menu, and...
Read more >
@teambit/design.ui.styles.muted-italic | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
Plotting — CliMetLab 0.11.13 documentation
Use a predefined style depending on the general theme ... Line style of map grid lines ... Style of the font normal/bold/italic. “normal”,...
Read more >
italic, bold, link buttons gone in ff2.0.0.12? | MetaTalk
I have another computer still at 2.0.0.11 which shows the buttons fine. ... Hmm, still missing through a restart firefox/clear cache.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found