From 2a0d371ca3a7c216185eb8f4bc3831420b3c9d1c Mon Sep 17 00:00:00 2001 From: Mohammad Sadegh Salimi <45296858+SMSadegh19@users.noreply.github.com> Date: Thu, 6 Jan 2022 01:44:32 +0330 Subject: [PATCH] Adding support for RTL languages for readme markdown preview. (#139644) * [markdown preview] dir "auto" added to the markdown-body class. * fix markdown preview for RTL languages --- .../src/features/previewContentProvider.ts | 2 +- extensions/markdown-language-features/src/markdownEngine.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/extensions/markdown-language-features/src/features/previewContentProvider.ts b/extensions/markdown-language-features/src/features/previewContentProvider.ts index 6d86de5351fab..8a973f9faa025 100644 --- a/extensions/markdown-language-features/src/features/previewContentProvider.ts +++ b/extensions/markdown-language-features/src/features/previewContentProvider.ts @@ -111,7 +111,7 @@ export class MarkdownContentProvider { resourceProvider: WebviewResourceProvider, ): Promise { const rendered = await this.engine.render(markdownDocument, resourceProvider); - const html = `
${rendered.html}
`; + const html = `
${rendered.html}
`; return { html, containingImages: rendered.containingImages diff --git a/extensions/markdown-language-features/src/markdownEngine.ts b/extensions/markdown-language-features/src/markdownEngine.ts index 8460b71dcd8a8..72bdba51fcb5f 100644 --- a/extensions/markdown-language-features/src/markdownEngine.ts +++ b/extensions/markdown-language-features/src/markdownEngine.ts @@ -25,6 +25,7 @@ const pluginSourceMap: MarkdownIt.PluginSimple = (md): void => { if (token.map && token.type !== 'inline') { token.attrSet('data-line', String(token.map[0])); token.attrJoin('class', 'code-line'); + token.attrJoin('dir', 'auto'); } } }); @@ -178,7 +179,7 @@ export class MarkdownEngine { return engine.parse(text.replace(UNICODE_NEWLINE_REGEX, ''), {}); } - + public resetSlugCount(): void { this._slugCount = new Map(); }