8000 support KaTeX code block by sakkke · Pull Request #161 · previm/previm · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@sakkke
Copy link
@sakkke sakkke commented Sep 20, 2021
# gravida cum sociis natoque penatibus

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Vivamus arcu felis bibendum ut tristique. Imperdiet massa tincidunt nunc pulvinar sapien et ligula ullamcorper malesuada. Aenean pharetra magna ac placerat vestibulum lectus. Et malesuada fames ac turpis egestas sed tempus urna.

```katex
a_n = a + (n - 1) \cdot d
```

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Aliquet nibh praesent tristique magna sit. Curabitur vitae nunc sed velit dignissim sodales. Tortor dignissim convallis aenean et tortor at risus viverra adipiscing. Eget dolor morbi non arcu risus quis varius.

image

@sakkke sakkke changed the title support KaTeX support KaTeX code block Sep 30, 2021
@sakkke
Copy link
Author
sakkke commented Sep 30, 2021
# Hello

text <span class="inlkatex">42{\pi}</span> text

image

- formulas are centered by `displayMode`.
- `<div>` inside `<p>` is incorrect, so change it to `<span>` inside `<p>`.
@mattn
Copy link
Member
mattn commented Jun 14, 2022

Currently, I'm trying to implement load extra libraries. #170
Can this PR be applied that way if #170 will be merged?

@mattn
Copy link
Member
mattn commented Jun 14, 2022

#170 is merged. Now you can add extra library by you self.

@mattn mattn closed this Jun 14, 2022
@mattn
Copy link
Member
mattn commented Jun 14, 2022

Example to add polyjs

#162 (comment)

@mattn
Copy link
Member
mattn commented Jun 14, 2022
let g:previm_extra_libraries = [
\  {
\    'name': 'katex',
\    'files': [
\      {
\        'type': 'css',
\        'path': '_/js/extra/texmath.min.css',
\        'url': 'https://cdn.jsdelivr.net/npm/markdown-it-texmath/css/texmath.min.css',
\      },
\      {
\        'type': 'css',
\        'path': '_/css/extra/katex.min.css',
\        'url': 'https://cdn.jsdelivr.net/npm/katex@latest/dist/katex.min.css',
\        'code': [
\          'renderMathInElement(document.body)',
\        ],
\      },
\      {
\        'type': 'js',
\        'path': '_/js/extra/katex-auto-render.min.js',
\        'url': 'https://cdn.jsdelivr.net/npm/katex@latest/dist/contrib/auto-render.min.js',
\        'code': [
\          'renderMathInElement(document.body)',
\        ],
\      },
\      {
\        'type': 'js',
\        'path': '_/js/extra/katex.min.js',
\        'url': 'https://cdn.jsdelivr.net/npm/katex@latest/dist/katex.min.js',
\        'code': [
\          'document.querySelectorAll(''pre code.language-katex'').forEach(elem => {',
\          '  const html = katex.renderToString(elem.innerText, {',
\          '    displayMode: true,',
\          '    output: ''html'',',
\          '    throwOnError: false,',
\          '  })',
\          '  const span = document.createElement(''span'')',
\          '  span.innerHTML = html',
\          '  elem.parentNode.replaceWith(span)',
\          '})',
\          'document.querySelectorAll(''.inlkatex'').forEach(elem => {',
\          '  const html = katex.renderToString(elem.innerText, {',
\          '    output: ''html'',',
\          '    throwOnError: false,',
\          '  })',
\          '  const span = document.createElement(''span'')',
\          '  span.innerHTML = html',
\          '  elem.replaceWith(span)',
\          '})',
\        ],
\      },
\    ],
\  },
\]

add this into your vimrc and do :PrevimUpdateAssets. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0