Skip to content

Commit

Permalink
Adding support for RTL languages for readme markdown preview. (#139644)
Browse files Browse the repository at this point in the history
* [markdown preview] dir "auto" added to the markdown-body class.

* fix markdown preview for RTL languages
  • Loading branch information
SMSadegh19 authored Jan 5, 2022
1 parent 883009b commit 2a0d371
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export class MarkdownContentProvider {
resourceProvider: WebviewResourceProvider,
): Promise<MarkdownContentProviderOutput> {
const rendered = await this.engine.render(markdownDocument, resourceProvider);
const html = `<div class="markdown-body">${rendered.html}<div class="code-line" data-line="${markdownDocument.lineCount}"></div></div>`;
const html = `<div class="markdown-body" dir="auto">${rendered.html}<div class="code-line" data-line="${markdownDocument.lineCount}"></div></div>`;
return {
html,
containingImages: rendered.containingImages
Expand Down
3 changes: 2 additions & 1 deletion extensions/markdown-language-features/src/markdownEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
});
Expand Down Expand Up @@ -178,7 +179,7 @@ export class MarkdownEngine {

return engine.parse(text.replace(UNICODE_NEWLINE_REGEX, ''), {});
}

public resetSlugCount(): void {
this._slugCount = new Map<string, number>();
}
Expand Down

0 comments on commit 2a0d371

Please sign in to comment.