Skip to content

Commit

Permalink
latex codeblock as code
Browse files Browse the repository at this point in the history
  • Loading branch information
ngxson committed Dec 14, 2024
1 parent cd40156 commit 858dad8
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Binary file modified examples/server/public/index.html.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions examples/server/webui/public/demo-conversation.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{
"id": 1734087548327,
"role": "assistant",
"content": "This is the formula:\n$\\frac{e^{x_i}}{\\sum_{j=1}^{n}e^{x_j}}$\n\nGiven an input vector \\(\\mathbf{x} = [x_1, x_2, \\ldots, x_n]\\)\n\n\\[\ny_i = \\frac{e^{x_i}}{\\sum_{j=1}^n e^{x_j}}\n\\]\n\nCode block latex:\n```latex\n\\frac{e^{x_i}}{\\sum_{j=1}^{n}e^{x_j}}\n```\n\nTest dollar sign: $1234 $4567\n\nInvalid latex syntax: $E = mc^$ and $$E = mc^$$",
"content": "This is the formula:\n\n$\\frac{e^{x_i}}{\\sum_{j=1}^{n}e^{x_j}}$\n\nGiven an input vector \\(\\mathbf{x} = [x_1, x_2, \\ldots, x_n]\\)\n\n\\[\ny_i = \\frac{e^{x_i}}{\\sum_{j=1}^n e^{x_j}}\n\\]\n\nCode block latex:\n```latex\n\\frac{e^{x_i}}{\\sum_{j=1}^{n}e^{x_j}}\n```\n\nTest dollar sign: $1234 $4567\n\nInvalid latex syntax: $E = mc^$ and $$E = mc^$$",
"timings": {
"prompt_n": 1,
"prompt_ms": 28.923,
Expand All @@ -27,7 +27,7 @@
{
"id": 1734087548329,
"role": "assistant",
"content": "Code block js:\n```js\nconsole.log('hello world')\n```"
"content": "Code block:\n```js\nconsole.log('hello world')\n```\n```sh\nls -la /dev\n```"
}
]
}
3 changes: 3 additions & 0 deletions examples/server/webui/src/highlight-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import elixir from 'highlight.js/lib/languages/elixir';
import kotlin from 'highlight.js/lib/languages/kotlin';
import lua from 'highlight.js/lib/languages/lua';
import php from 'highlight.js/lib/languages/php';
import latex from 'highlight.js/lib/languages/latex';

hljs.registerLanguage('python', python);
hljs.registerLanguage('javascript', javascript);
Expand All @@ -42,11 +43,13 @@ hljs.registerLanguage('elixir', elixir);
hljs.registerLanguage('kotlin', kotlin);
hljs.registerLanguage('lua', lua);
hljs.registerLanguage('php', php);
hljs.registerLanguage('latex', latex);

// reuse some languages to further reduce bundle size

hljs.registerLanguage('shell', bash);
hljs.registerLanguage('bash', bash);
hljs.registerLanguage('sh', bash);

hljs.registerLanguage('css', scss);
hljs.registerLanguage('scss', scss);
Expand Down
3 changes: 0 additions & 3 deletions examples/server/webui/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ const VueMarkdown = defineComponent(
const md = shallowRef(new MarkdownIt({
breaks: true,
highlight: function (str, lang) { // Add highlight.js
if (lang === 'latex') {
return renderLatexHTML(str, true);
}
if (lang && hljs.getLanguage(lang)) {
try {
return '<pre><code class="hljs">' +
Expand Down

0 comments on commit 858dad8

Please sign in to comment.