From 19faa16169b44f52bedf1401b4a97b2a8ffdeacb Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Sun, 20 Apr 2025 03:17:19 +0530 Subject: [PATCH] feat: add dir=ltr by default on code block pre elements instead of relying on css --- .../theme-default/styles/components/vp-doc.css | 12 ------------ src/node/markdown/plugins/highlight.ts | 8 +++++++- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/client/theme-default/styles/components/vp-doc.css b/src/client/theme-default/styles/components/vp-doc.css index 89991184..85961e43 100644 --- a/src/client/theme-default/styles/components/vp-doc.css +++ b/src/client/theme-default/styles/components/vp-doc.css @@ -305,21 +305,9 @@ .vp-doc [class*='language-'] pre, .vp-doc [class*='language-'] code { - /*rtl:ignore*/ - direction: ltr; - /*rtl:ignore*/ - text-align: left; - white-space: pre; - word-spacing: normal; - word-break: normal; - word-wrap: normal; -moz-tab-size: 4; -o-tab-size: 4; tab-size: 4; - -webkit-hyphens: none; - -moz-hyphens: none; - -ms-hyphens: none; - hyphens: none; } .vp-doc [class*='language-'] pre { diff --git a/src/node/markdown/plugins/highlight.ts b/src/node/markdown/plugins/highlight.ts index eef32b58..f1285ed7 100644 --- a/src/node/markdown/plugins/highlight.ts +++ b/src/node/markdown/plugins/highlight.ts @@ -80,7 +80,13 @@ export async function highlight( classActivePre: 'has-focused-lines' }), transformerNotationHighlight(), - transformerNotationErrorLevel() + transformerNotationErrorLevel(), + { + name: 'vitepress:add-dir', + pre(node) { + node.properties.dir = 'ltr' + } + } ] const vueRE = /-vue(?=:|$)/