@diplodoc/cli 4.9.0 → 4.10.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/constants.ts CHANGED
@@ -50,6 +50,23 @@ export enum Lang {
50
50
  EN = 'en',
51
51
  }
52
52
 
53
+ export const RTL_LANGS = [
54
+ 'ar',
55
+ 'arc',
56
+ 'ckb',
57
+ 'dv',
58
+ 'fa',
59
+ 'ha',
60
+ 'he',
61
+ 'khw',
62
+ 'ks',
63
+ 'ps',
64
+ 'sd',
65
+ 'ur',
66
+ 'uz_AF',
67
+ 'yi',
68
+ ];
69
+
53
70
  export enum Platforms {
54
71
  WINDOWS = 'win32',
55
72
  MAC = 'darwin',
package/src/models.ts CHANGED
@@ -37,6 +37,7 @@ interface YfmConfig {
37
37
  removeHiddenTocItems: boolean;
38
38
  connector?: VCSConnectorConfig;
39
39
  lang?: Lang;
40
+ langs?: [];
40
41
  lintDisabled: boolean;
41
42
  buildDisabled: boolean;
42
43
  lintConfig: LintConfig;
@@ -43,7 +43,7 @@ export async function resolveMd2HTML(options: ResolverOptions): Promise<ResolveM
43
43
  pathToDir === tocBase ? '' : pathToDir.replace(`${tocBase}${sep}`, '');
44
44
  const relativePathToIndex = relative(pathToDir, `${tocBase}${sep}`);
45
45
 
46
- const {input, lang, allowCustomResources} = ArgvService.getConfig();
46
+ const {input, lang, langs, allowCustomResources} = ArgvService.getConfig();
47
47
  const resolvedPath: string = resolve(input, inputPath);
48
48
  const content: string = readFileSync(resolvedPath, 'utf8');
49
49
 
@@ -71,6 +71,7 @@ export async function resolveMd2HTML(options: ResolverOptions): Promise<ResolveM
71
71
  fileMeta.style = [];
72
72
  fileMeta.script = [];
73
73
  }
74
+ const tocLang = langs.includes(tocBase) && tocBase;
74
75
 
75
76
  const props = {
76
77
  data: {
@@ -82,7 +83,7 @@ export async function resolveMd2HTML(options: ResolverOptions): Promise<ResolveM
82
83
  router: {
83
84
  pathname: join(relativePathToIndex, pathToFileDir, basename(outputPath)),
84
85
  },
85
- lang: lang || Lang.RU,
86
+ lang: lang || tocLang || Lang.RU,
86
87
  };
87
88
 
88
89
  const outputDir = dirname(outputPath);
@@ -1,7 +1,7 @@
1
1
  import {join} from 'path';
2
2
  import {platform} from 'process';
3
3
 
4
- import {CUSTOM_STYLE, Platforms, ResourceType} from '../constants';
4
+ import {CUSTOM_STYLE, Platforms, RTL_LANGS, ResourceType} from '../constants';
5
5
  import {Resources, SinglePageResult} from '../models';
6
6
  import {ArgvService, PluginService} from '../services';
7
7
  import {preprocessPageHtmlForSinglePage} from './singlePage';
@@ -34,10 +34,11 @@ export function generateStaticMarkup(
34
34
  const {staticContent} = ArgvService.getConfig();
35
35
 
36
36
  const html = staticContent ? render(props) : '';
37
+ const isRTL = RTL_LANGS.includes(props.lang);
37
38
 
38
39
  return `
39
40
  <!DOCTYPE html>
40
- <html lang="${props.lang}">
41
+ <html lang="${props.lang}" dir="${isRTL ? 'rtl' : 'ltr'}">
41
42
  <head>
42
43
  <meta charset="utf-8">
43
44
  ${getMetadata(props.data.meta as Record<string, string>)}
@@ -49,6 +50,7 @@ export function generateStaticMarkup(
49
50
  }
50
51
  </style>
51
52
  ${manifest.css
53
+ .filter((file) => isRTL === file.includes('.rtl.css'))
52
54
  .map(dst(pathToBundle))
53
55
  .map((src: string) => `<link type="text/css" rel="stylesheet" href="${src}" />`)
54
56
  .join('\n')}