erudit 2.0.0-dev.8 → 3.0.0-dev.1
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/.nuxtrc +1 -1
- package/app/components/SiteMain.vue +2 -2
- package/app/components/aside/major/panes/Search.vue +10 -2
- package/app/components/aside/minor/AsideMinorContributor.vue +1 -1
- package/app/components/aside/minor/AsideMinorPane.vue +2 -3
- package/app/components/aside/minor/topic/TopicToc.vue +2 -1
- package/app/components/aside/minor/topic/TopicTocItem.vue +3 -3
- package/app/components/bitran/BitranContent.vue +20 -21
- package/app/components/bitran/RenderWrapper.vue +2 -4
- package/app/components/main/topic/MainTopic.vue +1 -1
- package/app/components/main/utils/ContentDescription.vue +3 -4
- package/app/components/main/utils/ContentFlag.vue +3 -4
- package/app/components/main/utils/ContentReferences.vue +16 -22
- package/app/components/main/utils/ContentSection.vue +21 -18
- package/app/components/main/utils/ContentTitle.vue +12 -10
- package/app/components/main/utils/reference/ReferenceGroup.vue +5 -8
- package/app/components/main/utils/reference/ReferenceItem.vue +25 -21
- package/app/components/main/utils/reference/ReferenceSource.vue +42 -36
- package/app/components/preview/PreviewLoading.vue +2 -3
- package/app/components/preview/display/Unique.vue +2 -2
- package/app/components/transition/Fade.vue +4 -7
- package/app/components/tree/TreeContainer.vue +2 -3
- package/app/composables/bitran.ts +127 -132
- package/app/composables/bitranContent.ts +37 -36
- package/app/composables/bitranLocation.ts +7 -7
- package/app/composables/contentData.ts +36 -36
- package/app/composables/contentPage.ts +156 -156
- package/app/composables/contentRoute.ts +45 -45
- package/app/composables/darkMagic.ts +24 -24
- package/app/composables/externalApi.ts +63 -63
- package/app/composables/favicon.ts +8 -8
- package/app/composables/formatText.ts +86 -86
- package/app/composables/majorPane.ts +60 -60
- package/app/composables/theme.ts +29 -29
- package/app/composables/url.ts +33 -33
- package/app/pages/article/[...articleId].vue +1 -1
- package/app/pages/group/[...groupId].vue +2 -1
- package/app/pages/members.vue +2 -3
- package/app/pages/practice/[...practice].vue +1 -1
- package/app/pages/summary/[...summaryId].vue +1 -1
- package/app/public/favicon/article.svg +9 -9
- package/app/public/favicon/default.svg +9 -9
- package/app/public/favicon/practice.svg +9 -9
- package/app/public/favicon/summary.svg +9 -9
- package/app/public/logotype.svg +16 -16
- package/app/public/user.svg +9 -9
- package/app/scripts/_immediate.js +7 -2
- package/app/scripts/aside/index.ts +59 -59
- package/app/scripts/aside/major/nav.ts +26 -26
- package/app/scripts/aside/minor/state.ts +37 -37
- package/app/scripts/aside/minor/topic.ts +3 -3
- package/app/scripts/preview/build.ts +73 -84
- package/app/scripts/preview/data/alert.ts +19 -19
- package/app/scripts/preview/data/custom.ts +8 -8
- package/app/scripts/preview/data/genericLink.ts +24 -24
- package/app/scripts/preview/data/pageLink.ts +20 -20
- package/app/scripts/preview/data/unique.ts +70 -70
- package/app/scripts/preview/data.ts +24 -26
- package/app/scripts/preview/display.ts +37 -39
- package/app/scripts/preview/footer.ts +9 -9
- package/app/scripts/preview/request.ts +51 -51
- package/app/scripts/preview/state.ts +63 -63
- package/app/styles/_immediate.css +6 -2
- package/app/styles/_util.scss +13 -20
- package/app/styles/app.scss +91 -91
- package/app/styles/def/_bp.scss +27 -24
- package/app/styles/def/_size.scss +7 -7
- package/app/styles/def/_z.scss +5 -5
- package/app/styles/default.scss +33 -35
- package/app/styles/normalize.scss +63 -63
- package/app/styles/partials/_darkMagic.scss +3 -5
- package/app/styles/partials/_fnav.scss +4 -7
- package/app/styles/partials/_preview.scss +3 -5
- package/globals/bitran.ts +47 -39
- package/globals/content.ts +22 -22
- package/globals/contributor.ts +5 -5
- package/module/bitran.ts +34 -34
- package/module/index.ts +12 -0
- package/module/paths.ts +22 -22
- package/nuxt.config.ts +20 -5
- package/package.json +9 -6
- package/server/api/contributor/count.ts +6 -6
- package/server/api/fake/content.ts +6 -6
- package/server/api/preview/page/[...parts].ts +1 -1
- package/server/plugin/bitran/content.ts +187 -176
- package/server/plugin/bitran/location.ts +25 -25
- package/server/plugin/bitran/products/include.ts +230 -229
- package/server/plugin/bitran/products/link.ts +116 -114
- package/server/plugin/bitran/setup.ts +9 -10
- package/server/plugin/bitran/toc.ts +83 -82
- package/server/plugin/bitran/transpiler.ts +46 -0
- package/server/plugin/build/jobs/content/builderArgs.ts +8 -8
- package/server/plugin/build/jobs/content/generic.ts +176 -176
- package/server/plugin/build/jobs/content/parse.ts +100 -90
- package/server/plugin/build/jobs/content/path.ts +6 -6
- package/server/plugin/build/jobs/content/type/book.ts +9 -9
- package/server/plugin/build/jobs/content/type/group.ts +37 -37
- package/server/plugin/build/jobs/content/type/topic.ts +36 -36
- package/server/plugin/build/jobs/contributors.ts +66 -66
- package/server/plugin/build/jobs/nav.ts +209 -209
- package/server/plugin/content/absoluteId.ts +94 -94
- package/server/plugin/content/context.ts +112 -112
- package/server/plugin/db/entities/Book.ts +7 -7
- package/server/plugin/db/entities/Content.ts +49 -49
- package/server/plugin/db/entities/Contribution.ts +10 -10
- package/server/plugin/db/entities/Contributor.ts +16 -16
- package/server/plugin/db/entities/Group.ts +14 -14
- package/server/plugin/db/entities/Hash.ts +15 -15
- package/server/plugin/db/entities/Topic.ts +20 -20
- package/server/plugin/db/entities/Unique.ts +21 -21
- package/server/plugin/db/setup.ts +34 -34
- package/server/plugin/nav/node.ts +26 -26
- package/server/plugin/nav/utils.ts +129 -129
- package/server/plugin/repository/book.ts +21 -21
- package/server/plugin/repository/content.ts +238 -238
- package/server/plugin/repository/contributor.ts +8 -8
- package/server/plugin/repository/frontNav.ts +148 -148
- package/server/plugin/repository/topic.ts +32 -32
- package/shared/aside/minor.ts +50 -50
- package/shared/asset.ts +15 -15
- package/shared/bitran/context.ts +8 -7
- package/shared/bitran/default.ts +46 -0
- package/shared/bitran/{products/link/render → link}/Link.vue +167 -174
- package/shared/bitran/link/factory.ts +24 -0
- package/shared/bitran/link/languages/en.ts +7 -0
- package/shared/bitran/link/languages/ru.ts +7 -0
- package/shared/bitran/link/renderer.ts +21 -0
- package/shared/bitran/link/shared.ts +17 -0
- package/shared/bitran/{products/link → link}/target.ts +134 -134
- package/shared/bitran/link/transpiler.ts +10 -0
- package/shared/bitran/location.ts +166 -166
- package/shared/bitran/toc.ts +8 -8
- package/shared/contributor.ts +5 -5
- package/shared/frontNav.ts +41 -41
- package/shared/icons.ts +38 -38
- package/shared/image.ts +5 -5
- package/shared/utils/objectsEqual.ts +4 -4
- package/shared/utils/stringColor.ts +9 -9
- package/test/bitran/{products/link → link}/target.test.ts +141 -138
- package/test/bitran/location.test.ts +143 -143
- package/server/plugin/bitran/core.ts +0 -51
- package/shared/bitran/alias.ts +0 -17
- package/shared/bitran/products/alias/core/factory.ts +0 -46
- package/shared/bitran/products/alias/core/index.ts +0 -13
- package/shared/bitran/products/alias/render/Alias.vue +0 -10
- package/shared/bitran/products/alias/render/icon.svg +0 -3
- package/shared/bitran/products/alias/render/index.ts +0 -17
- package/shared/bitran/products/alias/render/languages/en.ts +0 -5
- package/shared/bitran/products/alias/render/languages/ru.ts +0 -5
- package/shared/bitran/products/alias/shared.ts +0 -11
- package/shared/bitran/products/heading/core/factory.ts +0 -53
- package/shared/bitran/products/heading/core/index.ts +0 -19
- package/shared/bitran/products/heading/render/Heading.vue +0 -47
- package/shared/bitran/products/heading/render/icon.svg +0 -3
- package/shared/bitran/products/heading/render/index.ts +0 -17
- package/shared/bitran/products/heading/render/languages/en.ts +0 -5
- package/shared/bitran/products/heading/render/languages/ru.ts +0 -5
- package/shared/bitran/products/heading/shared.ts +0 -13
- package/shared/bitran/products/include/core/factory.ts +0 -61
- package/shared/bitran/products/include/core/index.ts +0 -13
- package/shared/bitran/products/include/render/Include.vue +0 -13
- package/shared/bitran/products/include/render/icon.svg +0 -3
- package/shared/bitran/products/include/render/index.ts +0 -18
- package/shared/bitran/products/include/render/languages/en.ts +0 -5
- package/shared/bitran/products/include/render/languages/ru.ts +0 -5
- package/shared/bitran/products/include/shared.ts +0 -15
- package/shared/bitran/products/link/core/factory.ts +0 -20
- package/shared/bitran/products/link/core/index.ts +0 -17
- package/shared/bitran/products/link/render/index.ts +0 -17
- package/shared/bitran/products/link/render/languages/en.ts +0 -5
- package/shared/bitran/products/link/render/languages/ru.ts +0 -5
- package/shared/bitran/products/link/shared.ts +0 -15
- package/test/bitran/alias.test.ts +0 -44
- package/test/bitran/products/alias.test.ts +0 -83
- package/test/bitran/products/heading.test.ts +0 -119
- package/test/bitran/products/include.test.ts +0 -77
- package/test/bitran/products/link/factory.test.ts +0 -30
- /package/shared/bitran/{products/link/render → link}/icon.svg +0 -0
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BlockParseFactory,
|
|
3
|
-
ObjBlockParseFactory,
|
|
4
|
-
ObjProductStrFactory,
|
|
5
|
-
ProductStrFactory,
|
|
6
|
-
type keyable,
|
|
7
|
-
} from 'bitran/process';
|
|
8
|
-
|
|
9
|
-
import { includeName, type IncludeData, type IncludeType } from '../shared';
|
|
10
|
-
|
|
11
|
-
export class IncludeParser extends BlockParseFactory<IncludeType> {
|
|
12
|
-
regexp = /^<~ (\S+)$/;
|
|
13
|
-
location!: string;
|
|
14
|
-
|
|
15
|
-
canParse(strBlock: string) {
|
|
16
|
-
const match = strBlock.match(this.regexp);
|
|
17
|
-
|
|
18
|
-
if (match && match[1]) {
|
|
19
|
-
this.location = match[1];
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
async createParseData() {
|
|
27
|
-
return {
|
|
28
|
-
location: this.location,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export class ResolvedIncludeParser extends ObjBlockParseFactory<IncludeType> {
|
|
34
|
-
objName = includeName;
|
|
35
|
-
|
|
36
|
-
async parseDataFromObj(obj: keyable): Promise<IncludeData> {
|
|
37
|
-
if (obj.error) throw obj.error;
|
|
38
|
-
|
|
39
|
-
return {
|
|
40
|
-
location: obj.location,
|
|
41
|
-
resolved: true,
|
|
42
|
-
blocks: await this.parseBlocks(obj.blocks),
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export class IncludeStr extends ProductStrFactory<IncludeType> {
|
|
48
|
-
stringifyData(data: IncludeData): string {
|
|
49
|
-
if (data.resolved) {
|
|
50
|
-
const obj: any = {};
|
|
51
|
-
|
|
52
|
-
obj.resolved = true;
|
|
53
|
-
obj.location = data.location;
|
|
54
|
-
|
|
55
|
-
if (data.error) obj.error = data.error;
|
|
56
|
-
else obj.blocks = this.stringify(data.blocks!);
|
|
57
|
-
|
|
58
|
-
return ObjProductStrFactory.strObjBlock(includeName, obj);
|
|
59
|
-
} else return `<~ ${data.location}`;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { BlockNode } from 'bitran/dom';
|
|
2
|
-
import { defineProductCore } from 'bitran/core';
|
|
3
|
-
|
|
4
|
-
import type { IncludeType } from '../shared';
|
|
5
|
-
import { IncludeParser, IncludeStr, ResolvedIncludeParser } from './factory';
|
|
6
|
-
|
|
7
|
-
export class IncludeNode extends BlockNode<IncludeType> {}
|
|
8
|
-
|
|
9
|
-
export const include = defineProductCore({
|
|
10
|
-
Node: IncludeNode,
|
|
11
|
-
Parser: [IncludeParser, ResolvedIncludeParser],
|
|
12
|
-
Stringifier: IncludeStr,
|
|
13
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import { Render, useParseData, type ProductProps } from 'bitran/render';
|
|
3
|
-
|
|
4
|
-
import type { IncludeType } from '../shared';
|
|
5
|
-
|
|
6
|
-
const { node } = defineProps<ProductProps<IncludeType>>();
|
|
7
|
-
const { blocks } = useParseData(node);
|
|
8
|
-
</script>
|
|
9
|
-
|
|
10
|
-
<template>
|
|
11
|
-
<Render v-if="blocks" v-for="node of blocks.children" :node />
|
|
12
|
-
<div v-else>Блоков нема</div>
|
|
13
|
-
</template>
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 24 24">
|
|
2
|
-
<path d="M0,13.3l8-8,1.9,1.9-4.8,4.8h12.9c.9,0,1.7-.3,2.4-1,.6-.6,1-1.4,1-2.4s-.3-1.7-1-2.4-1.4-1-2.4-1h-.7v-2.7h.7c1.7,0,3.1.6,4.2,1.7s1.7,2.6,1.7,4.2-.6,3.1-1.7,4.2-2.6,1.7-4.2,1.7H5.1s4.8,4.8,4.8,4.8l-1.9,1.9L0,13.3Z"/>
|
|
3
|
-
</svg>
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defineIcon,
|
|
3
|
-
defineLanguages,
|
|
4
|
-
defineProductComponent,
|
|
5
|
-
defineProductRender,
|
|
6
|
-
RenderMode,
|
|
7
|
-
} from 'bitran/render';
|
|
8
|
-
|
|
9
|
-
export const include = defineProductRender({
|
|
10
|
-
mode: RenderMode.Server,
|
|
11
|
-
component: defineProductComponent(() => import('./Include.vue')),
|
|
12
|
-
icon: defineIcon(() => import('./icon.svg?raw')),
|
|
13
|
-
customLayout: true,
|
|
14
|
-
languages: defineLanguages({
|
|
15
|
-
en: () => import('./languages/en'),
|
|
16
|
-
ru: () => import('./languages/ru'),
|
|
17
|
-
}),
|
|
18
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { DefineProductType } from 'bitran';
|
|
2
|
-
import type { BlocksNode } from 'bitran/default';
|
|
3
|
-
|
|
4
|
-
export interface IncludeData {
|
|
5
|
-
location: string;
|
|
6
|
-
resolved?: boolean;
|
|
7
|
-
blocks?: BlocksNode;
|
|
8
|
-
error?: any;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export type IncludeType = DefineProductType<{
|
|
12
|
-
ParseData: IncludeData;
|
|
13
|
-
}>;
|
|
14
|
-
|
|
15
|
-
export const includeName = '__include';
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { ProductStrFactory, RegexpInlinerParseFactory } from 'bitran/process';
|
|
2
|
-
|
|
3
|
-
import type { LinkData, LinkType } from '../shared';
|
|
4
|
-
|
|
5
|
-
export class LinkParser extends RegexpInlinerParseFactory<LinkType> {
|
|
6
|
-
regexp = /\[(.+?)\]\((.+?)\)/gm;
|
|
7
|
-
|
|
8
|
-
async parseDataFromRegexp(match: RegExpExecArray) {
|
|
9
|
-
return {
|
|
10
|
-
label: match[1]!,
|
|
11
|
-
target: match[2]!,
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export class LinkStr extends ProductStrFactory<LinkType> {
|
|
17
|
-
stringifyData(parseData: LinkData) {
|
|
18
|
-
return `[${parseData.label}](${parseData.target})`;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { InlinerNode } from 'bitran/dom';
|
|
2
|
-
import { defineProductCore } from 'bitran/core';
|
|
3
|
-
|
|
4
|
-
import type { LinkType } from '../shared';
|
|
5
|
-
import { LinkParser, LinkStr } from './factory';
|
|
6
|
-
|
|
7
|
-
export class LinkNode extends InlinerNode<LinkType> {}
|
|
8
|
-
|
|
9
|
-
export const link = defineProductCore<LinkType>({
|
|
10
|
-
Node: LinkNode,
|
|
11
|
-
Parser: LinkParser,
|
|
12
|
-
Stringifier: LinkStr,
|
|
13
|
-
renderDataSide: 'pre',
|
|
14
|
-
buildRenderData: async () => {
|
|
15
|
-
throw Error('Cache for Links must be built only on server!');
|
|
16
|
-
},
|
|
17
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defineIcon,
|
|
3
|
-
defineLanguages,
|
|
4
|
-
defineProductComponent,
|
|
5
|
-
defineProductRender,
|
|
6
|
-
RenderMode,
|
|
7
|
-
} from 'bitran/render';
|
|
8
|
-
|
|
9
|
-
export const link = defineProductRender({
|
|
10
|
-
mode: RenderMode.Server,
|
|
11
|
-
component: defineProductComponent(() => import('./Link.vue')),
|
|
12
|
-
icon: defineIcon(() => import('./icon.svg?raw')),
|
|
13
|
-
languages: defineLanguages({
|
|
14
|
-
en: () => import('./languages/en'),
|
|
15
|
-
ru: () => import('./languages/ru'),
|
|
16
|
-
}),
|
|
17
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { DefineProductType } from 'bitran';
|
|
2
|
-
|
|
3
|
-
import type { LinkTarget } from './target';
|
|
4
|
-
|
|
5
|
-
export interface LinkData {
|
|
6
|
-
target: string;
|
|
7
|
-
label: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export type LinkType = DefineProductType<{
|
|
11
|
-
ParseData: LinkData;
|
|
12
|
-
RenderData: LinkTarget;
|
|
13
|
-
}>;
|
|
14
|
-
|
|
15
|
-
export const linkName = '__link';
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { tryReplaceAlias } from '@erudit/shared/bitran/alias';
|
|
2
|
-
|
|
3
|
-
const aliases = {
|
|
4
|
-
a1: 'foo',
|
|
5
|
-
a2: 'bar',
|
|
6
|
-
a3: 'baz',
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const replaceTargets = ['~a1', '~a2', '~a3'];
|
|
10
|
-
|
|
11
|
-
const noTouchTargets = [
|
|
12
|
-
'foo|bar|baz',
|
|
13
|
-
'https://www.google.com',
|
|
14
|
-
'~',
|
|
15
|
-
' ~a1',
|
|
16
|
-
'~ a1',
|
|
17
|
-
'~a1 ',
|
|
18
|
-
'~a1 a2',
|
|
19
|
-
];
|
|
20
|
-
|
|
21
|
-
const throwTargets = ['~a4'];
|
|
22
|
-
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
|
|
27
|
-
describe('tryReplaceAlias', () => {
|
|
28
|
-
for (const target of replaceTargets) {
|
|
29
|
-
// @ts-ignore
|
|
30
|
-
const replaceValue = aliases[target.substring(1)];
|
|
31
|
-
|
|
32
|
-
it(`should replace target "${target}" with "${replaceValue}"`, () => {
|
|
33
|
-
expect(tryReplaceAlias(target, aliases)).toBe(replaceValue);
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
it.each(noTouchTargets)('should not change target "%s"', (target) => {
|
|
38
|
-
expect(tryReplaceAlias(target, aliases)).toBe(target);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it.each(throwTargets)('should throw on target "%s"', (target) => {
|
|
42
|
-
expect(() => tryReplaceAlias(target, aliases)).toThrow();
|
|
43
|
-
});
|
|
44
|
-
});
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { createBitranCore, ParagraphNode } from 'bitran/core';
|
|
2
|
-
import { ErrorNode } from 'bitran/default';
|
|
3
|
-
|
|
4
|
-
import { AliasNode, defineAlias } from '@shared/bitran/products/alias/core';
|
|
5
|
-
import type { AliasType } from '@shared/bitran/products/alias/shared';
|
|
6
|
-
|
|
7
|
-
const bitran = createBitranCore({
|
|
8
|
-
products: {
|
|
9
|
-
alias: defineAlias({
|
|
10
|
-
a1: 'context alias 1',
|
|
11
|
-
a3: 'context alias 3',
|
|
12
|
-
}),
|
|
13
|
-
},
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
test('Alias parse and stringify', async () => {
|
|
17
|
-
const text = `
|
|
18
|
-
|
|
19
|
-
~ foo article|foo|bar
|
|
20
|
-
|
|
21
|
-
~ bar article|foo|bar
|
|
22
|
-
~ baz article|foo|bar
|
|
23
|
-
|
|
24
|
-
`;
|
|
25
|
-
|
|
26
|
-
const parsed = await bitran.parser.parse(text);
|
|
27
|
-
|
|
28
|
-
const data: AliasType['ParseData'][] = [
|
|
29
|
-
{ foo: 'article|foo|bar' },
|
|
30
|
-
{
|
|
31
|
-
bar: 'article|foo|bar',
|
|
32
|
-
baz: 'article|foo|bar',
|
|
33
|
-
},
|
|
34
|
-
];
|
|
35
|
-
|
|
36
|
-
expect(
|
|
37
|
-
parsed.children.map((node) => (node as AliasNode).parseData),
|
|
38
|
-
).toEqual(data);
|
|
39
|
-
|
|
40
|
-
expect(bitran.stringifier.stringify(parsed)).toEqual(text.trim());
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test('Fake aliases', async () => {
|
|
44
|
-
const text = `
|
|
45
|
-
|
|
46
|
-
~ NoSpaceBetween
|
|
47
|
-
|
|
48
|
-
~ foo targetFoo
|
|
49
|
-
~ NoSpaceBetween
|
|
50
|
-
|
|
51
|
-
~ NoSpaceBetween
|
|
52
|
-
~ foo targetFoo
|
|
53
|
-
|
|
54
|
-
Some text
|
|
55
|
-
~ foo targetFoo
|
|
56
|
-
|
|
57
|
-
~foo
|
|
58
|
-
|
|
59
|
-
~ foo targetFoo
|
|
60
|
-
Some text
|
|
61
|
-
|
|
62
|
-
`;
|
|
63
|
-
|
|
64
|
-
const paragraphs = (await bitran.parser.parse(text)).children;
|
|
65
|
-
|
|
66
|
-
for (const paragraph of paragraphs)
|
|
67
|
-
expect(paragraph).toBeInstanceOf(ParagraphNode);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
test('Invalid aliases', async () => {
|
|
71
|
-
const text = `
|
|
72
|
-
|
|
73
|
-
~ a1 <invalid>
|
|
74
|
-
|
|
75
|
-
~ a2 fooTarget
|
|
76
|
-
~ a3 <invalid>
|
|
77
|
-
|
|
78
|
-
`;
|
|
79
|
-
|
|
80
|
-
const aliases = (await bitran.parser.parse(text)).children;
|
|
81
|
-
|
|
82
|
-
for (const alias of aliases) expect(alias).toBeInstanceOf(ErrorNode);
|
|
83
|
-
});
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { ErrorNode } from 'bitran/default';
|
|
2
|
-
import { createBitranCore, ParagraphNode } from 'bitran/core';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
defineLocaleHeading,
|
|
6
|
-
heading,
|
|
7
|
-
HeadingNode,
|
|
8
|
-
} from '@shared/bitran/products/heading/core';
|
|
9
|
-
|
|
10
|
-
const bitran = createBitranCore({
|
|
11
|
-
products: {
|
|
12
|
-
heading,
|
|
13
|
-
},
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
test('Headings parse and stringify', async () => {
|
|
17
|
-
const text = `
|
|
18
|
-
|
|
19
|
-
# Hello!
|
|
20
|
-
|
|
21
|
-
## This is me.
|
|
22
|
-
|
|
23
|
-
### All this is valid, event "with $special$ characters"!
|
|
24
|
-
|
|
25
|
-
`;
|
|
26
|
-
|
|
27
|
-
const parsed = await bitran.parser.parse(text);
|
|
28
|
-
|
|
29
|
-
expect(
|
|
30
|
-
parsed.children.map((node) => (node as HeadingNode).parseData),
|
|
31
|
-
).toEqual([
|
|
32
|
-
{ level: 0, title: 'Hello!' },
|
|
33
|
-
{ level: 1, title: 'This is me.' },
|
|
34
|
-
{
|
|
35
|
-
level: 2,
|
|
36
|
-
title: 'All this is valid, event "with $special$ characters"!',
|
|
37
|
-
},
|
|
38
|
-
]);
|
|
39
|
-
|
|
40
|
-
expect(bitran.stringifier.stringify(parsed)).toEqual(text.trim());
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test('Invalid headings', async () => {
|
|
44
|
-
const text = `
|
|
45
|
-
|
|
46
|
-
#### Just too many!
|
|
47
|
-
|
|
48
|
-
`;
|
|
49
|
-
|
|
50
|
-
const headings = (await bitran.parser.parse(text)).children;
|
|
51
|
-
|
|
52
|
-
for (const heading of headings) expect(heading).toBeInstanceOf(ErrorNode);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
test('Paragraphs which tricks parser to think they are headings', async () => {
|
|
56
|
-
const text = `
|
|
57
|
-
|
|
58
|
-
#
|
|
59
|
-
|
|
60
|
-
###
|
|
61
|
-
|
|
62
|
-
# Some
|
|
63
|
-
text
|
|
64
|
-
|
|
65
|
-
Some
|
|
66
|
-
# text
|
|
67
|
-
|
|
68
|
-
`;
|
|
69
|
-
|
|
70
|
-
const paragraphs = (await bitran.parser.parse(text)).children;
|
|
71
|
-
|
|
72
|
-
for (const paragraph of paragraphs)
|
|
73
|
-
expect(paragraph).toBeInstanceOf(ParagraphNode);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
test('Auto IDs with unset locale', async () => {
|
|
77
|
-
const text = `
|
|
78
|
-
|
|
79
|
-
# Some long phrase
|
|
80
|
-
|
|
81
|
-
# Containing-!#$%*():bad characters
|
|
82
|
-
|
|
83
|
-
# И немного текста
|
|
84
|
-
|
|
85
|
-
# Some long phrase
|
|
86
|
-
|
|
87
|
-
`;
|
|
88
|
-
|
|
89
|
-
const headings = (await bitran.parser.parse(text)).children;
|
|
90
|
-
|
|
91
|
-
expect(
|
|
92
|
-
headings.map((heading) => (heading as HeadingNode).generated.autoId),
|
|
93
|
-
).toEqual([
|
|
94
|
-
'some-long-phrase',
|
|
95
|
-
'containing-dollarpercentbad-characters',
|
|
96
|
-
'i-nemnogo-teksta',
|
|
97
|
-
'some-long-phrase-',
|
|
98
|
-
]);
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
test('Auto IDs with locale', async () => {
|
|
102
|
-
const text = `
|
|
103
|
-
|
|
104
|
-
# Маленький Подъезд
|
|
105
|
-
|
|
106
|
-
`;
|
|
107
|
-
|
|
108
|
-
const localeBitran = createBitranCore({
|
|
109
|
-
products: {
|
|
110
|
-
heading: defineLocaleHeading({ languageCode: 'bg' }),
|
|
111
|
-
},
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
const headings = (await localeBitran.parser.parse(text)).children;
|
|
115
|
-
|
|
116
|
-
expect(
|
|
117
|
-
headings.map((heading) => (heading as HeadingNode).generated.autoId),
|
|
118
|
-
).toEqual(['malenykiy-podaezd']);
|
|
119
|
-
});
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { createBitranCore, ParagraphNode } from 'bitran/core';
|
|
2
|
-
|
|
3
|
-
import { include, IncludeNode } from '@shared/bitran/products/include/core';
|
|
4
|
-
import { includeName } from '@shared/bitran/products/include/shared';
|
|
5
|
-
|
|
6
|
-
const bitranCore = createBitranCore({
|
|
7
|
-
products: {
|
|
8
|
-
[includeName]: include,
|
|
9
|
-
},
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
test('Includes parse and stringify', async () => {
|
|
13
|
-
const text = `
|
|
14
|
-
|
|
15
|
-
<~ definition:set
|
|
16
|
-
|
|
17
|
-
<~ group|triangle|theorem:pifagorean-theorem
|
|
18
|
-
|
|
19
|
-
<~ summary|baz
|
|
20
|
-
|
|
21
|
-
`;
|
|
22
|
-
|
|
23
|
-
const parsed = await bitranCore.parser.parse(text);
|
|
24
|
-
|
|
25
|
-
const locations: string[] = [
|
|
26
|
-
'definition:set',
|
|
27
|
-
'group|triangle|theorem:pifagorean-theorem',
|
|
28
|
-
'summary|baz',
|
|
29
|
-
];
|
|
30
|
-
|
|
31
|
-
expect(
|
|
32
|
-
parsed.children.map((node) => (node as IncludeNode).parseData.location),
|
|
33
|
-
).toEqual(locations);
|
|
34
|
-
|
|
35
|
-
expect(bitranCore.stringifier.stringify(parsed)).toEqual(text.trim());
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test('Resolved include parse and stringify', async () => {
|
|
39
|
-
const text = `
|
|
40
|
-
|
|
41
|
-
@__include
|
|
42
|
-
location: foo
|
|
43
|
-
resolved: true
|
|
44
|
-
blocks: |
|
|
45
|
-
Paragraph 1
|
|
46
|
-
|
|
47
|
-
Paragraph 2
|
|
48
|
-
|
|
49
|
-
`;
|
|
50
|
-
|
|
51
|
-
const parsed = await bitranCore.parser.parse(text);
|
|
52
|
-
|
|
53
|
-
expect(bitranCore.stringifier.stringify(parsed)).toEqual(text.trim());
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
test('Invalid includes', async () => {
|
|
57
|
-
const text = `
|
|
58
|
-
|
|
59
|
-
<~
|
|
60
|
-
|
|
61
|
-
<~
|
|
62
|
-
|
|
63
|
-
<~ one two three
|
|
64
|
-
|
|
65
|
-
<~ id
|
|
66
|
-
text
|
|
67
|
-
|
|
68
|
-
Some
|
|
69
|
-
<~ id
|
|
70
|
-
|
|
71
|
-
`;
|
|
72
|
-
|
|
73
|
-
const paragraphs = (await bitranCore.parser.parse(text)).children;
|
|
74
|
-
|
|
75
|
-
for (const paragraph of paragraphs)
|
|
76
|
-
expect(paragraph).toBeInstanceOf(ParagraphNode);
|
|
77
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { createBitranCore } from 'bitran/core';
|
|
2
|
-
|
|
3
|
-
import { link, LinkNode } from '@shared/bitran/products/link/core';
|
|
4
|
-
import type { LinkData } from '@shared/bitran/products/link/shared';
|
|
5
|
-
|
|
6
|
-
const bitran = createBitranCore({
|
|
7
|
-
products: {
|
|
8
|
-
link,
|
|
9
|
-
},
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
test('Link parse and stringify', async () => {
|
|
13
|
-
const text = `This [is](target1) long line <<of [text](target2)>>!`;
|
|
14
|
-
|
|
15
|
-
const parsed = await bitran.parser.parseInliners(text);
|
|
16
|
-
|
|
17
|
-
// @ts-ignore
|
|
18
|
-
const links = [parsed[1], parsed[3]['parseData'].children[1]];
|
|
19
|
-
|
|
20
|
-
for (const link of links) expect(link).toBeInstanceOf(LinkNode);
|
|
21
|
-
|
|
22
|
-
expect(links[0].parseData).toEqual(<LinkData>{
|
|
23
|
-
label: 'is',
|
|
24
|
-
target: 'target1',
|
|
25
|
-
});
|
|
26
|
-
expect(links[1].parseData).toEqual(<LinkData>{
|
|
27
|
-
label: 'text',
|
|
28
|
-
target: 'target2',
|
|
29
|
-
});
|
|
30
|
-
});
|
|
File without changes
|