Skip to content

Commit a4cf2ae

Browse files
committed
chore: format source code
1 parent 0639099 commit a4cf2ae

22 files changed

+272
-202
lines changed

docs/inspector/block.vue

+13-7
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@
22
import Group from './group.vue'
33
import Single from './single.vue'
44
5-
defineProps<{ data: any, modified?: boolean }>()
5+
defineProps<{ data: any; modified?: boolean }>()
66
</script>
77

8-
<template
9-
><template v-for="token in data.tokens"
8+
<template>
9+
<template v-for="token in data.tokens"
1010
><template v-if="token.type === 'group'"
11-
><Group :data="token" :modified="modified" :start="data.start" /></template
11+
><Group
12+
:data="token"
13+
:modified="modified"
14+
:start="data.start" /></template
1215
><template v-else
13-
><Single :data="token" :modified="modified" :start="data.start" /></template
14-
></template
15-
></template>
16+
><Single
17+
:data="token"
18+
:modified="modified"
19+
:start="data.start" /></template
20+
></template>
21+
</template>

docs/inspector/group.vue

+43-31
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { inject, toRef, computed, Ref } from 'vue'
33
import SingleToken from './single.vue'
44
5-
const props = defineProps<{ data: any, modified: boolean, start: number }>()
5+
const props = defineProps<{ data: any; modified: boolean; start: number }>()
66
const data = toRef(props, 'data')
77
const start = toRef(props, 'start')
88
const startIndex = computed(() => start.value + data.value.startIndex)
@@ -21,35 +21,47 @@ const setCurrent = (prop) => {
2121
}
2222
</script>
2323

24-
<template
25-
><span @click="setCurrent('startValue')" :class="{
26-
'qutation-start-value': true,
27-
changed: data.startValue !== data.modifiedStartValue,
28-
ignored: 'ignoredStartValue' in data,
29-
[`start-${startIndex}`]: true,
30-
current: current === data && currentProp === 'startValue'
31-
}">{{
32-
modified ? data.modifiedStartValue : data.startValue
33-
}}</span
34-
><span v-if="modified ? data.modifiedInnerSpaceBefore : data.innerSpaceBefore" @click="setCurrent('innerSpaceBefore')" :class="{
35-
'qutation-inner-space-before': true,
36-
changed: data.innerSpaceBefore !== data.modifiedInnerSpaceBefore,
37-
ignored: 'ignoredInnerSpaceBefore' in data,
38-
[`start-${startIndex}`]: true,
39-
current: current === data && currentProp === 'innerSpaceBefore'
40-
}">{{
41-
modified ? data.modifiedInnerSpaceBefore : data.innerSpaceBefore
42-
}}</span
43-
><SingleToken v-for="(token, i) in data.map(x => x)" :key="i" :data="token" :modified="modified" :start="start"
44-
/><span @click="setCurrent('endValue')" :class="{
45-
'qutation-end-value': true,
46-
changed: data.endValue !== data.modifiedEndValue,
47-
ignored: 'ignoredEndValue' in data,
48-
[`start-${endIndex}`]: true,
49-
current: current === data && currentProp === 'endValue'
50-
}">{{
51-
modified ? data.modifiedEndValue : data.endValue
52-
}}</span
53-
></template>
24+
<template>
25+
<span
26+
@click="setCurrent('startValue')"
27+
:class="{
28+
'qutation-start-value': true,
29+
changed: data.startValue !== data.modifiedStartValue,
30+
ignored: 'ignoredStartValue' in data,
31+
[`start-${startIndex}`]: true,
32+
current: current === data && currentProp === 'startValue'
33+
}"
34+
>{{ modified ? data.modifiedStartValue : data.startValue }}</span
35+
><span
36+
v-if="modified ? data.modifiedInnerSpaceBefore : data.innerSpaceBefore"
37+
@click="setCurrent('innerSpaceBefore')"
38+
:class="{
39+
'qutation-inner-space-before': true,
40+
changed: data.innerSpaceBefore !== data.modifiedInnerSpaceBefore,
41+
ignored: 'ignoredInnerSpaceBefore' in data,
42+
[`start-${startIndex}`]: true,
43+
current: current === data && currentProp === 'innerSpaceBefore'
44+
}"
45+
>{{
46+
modified ? data.modifiedInnerSpaceBefore : data.innerSpaceBefore
47+
}}</span
48+
><SingleToken
49+
v-for="(token, i) in data.map((x) => x)"
50+
:key="i"
51+
:data="token"
52+
:modified="modified"
53+
:start="start"
54+
/><span
55+
@click="setCurrent('endValue')"
56+
:class="{
57+
'qutation-end-value': true,
58+
changed: data.endValue !== data.modifiedEndValue,
59+
ignored: 'ignoredEndValue' in data,
60+
[`start-${endIndex}`]: true,
61+
current: current === data && currentProp === 'endValue'
62+
}"
63+
>{{ modified ? data.modifiedEndValue : data.endValue }}</span
64+
>
65+
</template>
5466

5567
<style scoped src="./labels.css"></style>

docs/inspector/inspector.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<script setup lang="ts">
2-
import { provide, ref, toRef, watch } from 'vue';
2+
import { provide, ref, toRef, watch } from 'vue'
33
44
import NonBlock from './non-block.vue'
55
import Block from './block.vue'
66
import Status from './status.vue'
7-
import Legends from './legends.vue';
7+
import Legends from './legends.vue'
88
99
const props = defineProps<{ data: any }>()
1010
const data = toRef(props, 'data')

docs/inspector/labels.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@
3333

3434
.current {
3535
background-color: #f0f0ff;
36-
}
36+
}

docs/inspector/legends.vue

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<template>
22
<div class="legends">
33
<h3>Legends</h3>
4-
<pre
5-
><span class="color" style="background-color: #f0f0ff"></span> Selected<br
4+
<pre><span class="color" style="background-color: #f0f0ff"></span> Selected<br
65
/><span class="color" style="background-color: #ff0000"></span> English<br
76
/><span class="color" style="background-color: #0000ff"></span> Chinese<br
87
/><span class="color" style="background-color: #660066"></span> Punctuation<br

docs/inspector/non-block.vue

+12-7
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import { inject, toRef, computed, Ref } from 'vue'
44
const props = defineProps<{ data: any }>()
55
const data = toRef(props, 'data')
66
7-
const pseudoToken = computed(() =>({
7+
const pseudoToken = computed(() => ({
88
type: 'non-block',
99
modifiedType: 'non-block',
1010
value: data.value.value,
1111
modifiedValue: data.value.value,
12-
index: data.value.start,
12+
index: data.value.start
1313
}))
1414
1515
const current = inject<Ref<any>>('current')
@@ -27,10 +27,15 @@ const setCurrent = () => {
2727
console.log('data', data)
2828
</script>
2929

30-
<template
31-
><span class="non-block" :class="{
32-
current: current?.index === pseudoToken?.index,
33-
}" @click="setCurrent">{{ data.value }}</span
34-
></template>
30+
<template>
31+
<span
32+
class="non-block"
33+
:class="{
34+
current: current?.index === pseudoToken?.index
35+
}"
36+
@click="setCurrent"
37+
>{{ data.value }}</span
38+
>
39+
</template>
3540

3641
<style scoped src="./labels.css"></style>

docs/inspector/single.vue

+31-22
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { inject, toRef, computed, Ref } from 'vue'
33
import GroupToken from './group.vue'
44
5-
const props = defineProps<{ data: any, modified: boolean, start: number }>()
5+
const props = defineProps<{ data: any; modified: boolean; start: number }>()
66
const data = toRef(props, 'data')
77
const start = toRef(props, 'start')
88
const index = computed(() => start.value + data.value.index)
@@ -20,26 +20,35 @@ const setCurrent = (prop) => {
2020
}
2121
</script>
2222

23-
<template
24-
><GroupToken v-if="data.type === 'group'" :data="data" :modified="modified" :start="start"
25-
/><span v-else @click="setCurrent('value')" :class="{
26-
[data.modifiedType]: true,
27-
changed: data.value !== data.modifiedValue,
28-
ignored: 'ignoredValue' in data,
29-
[`start-${index}`]: true,
30-
current: current === data && currentProp === 'value'
31-
}">{{
32-
modified ? data.modifiedValue : data.value
33-
}}</span
34-
><span v-if="modified ? data.modifiedSpaceAfter : data.spaceAfter" @click="setCurrent('spaceAfter')" :class="{
35-
'token-space-after': true,
36-
changed: data.spaceAfter !== data.modifiedSpaceAfter,
37-
ignored: 'ignoredSpaceAfter' in data,
38-
[`start-${index}`]: true,
39-
current: current === data && currentProp === 'spaceAfter'
40-
}">{{
41-
modified ? data.modifiedSpaceAfter : data.spaceAfter
42-
}}</span
43-
></template>
23+
<template>
24+
<GroupToken
25+
v-if="data.type === 'group'"
26+
:data="data"
27+
:modified="modified"
28+
:start="start"
29+
/><span
30+
v-else
31+
@click="setCurrent('value')"
32+
:class="{
33+
[data.modifiedType]: true,
34+
changed: data.value !== data.modifiedValue,
35+
ignored: 'ignoredValue' in data,
36+
[`start-${index}`]: true,
37+
current: current === data && currentProp === 'value'
38+
}"
39+
>{{ modified ? data.modifiedValue : data.value }}</span
40+
><span
41+
v-if="modified ? data.modifiedSpaceAfter : data.spaceAfter"
42+
@click="setCurrent('spaceAfter')"
43+
:class="{
44+
'token-space-after': true,
45+
changed: data.spaceAfter !== data.modifiedSpaceAfter,
46+
ignored: 'ignoredSpaceAfter' in data,
47+
[`start-${index}`]: true,
48+
current: current === data && currentProp === 'spaceAfter'
49+
}"
50+
>{{ modified ? data.modifiedSpaceAfter : data.spaceAfter }}</span
51+
>
52+
</template>
4453

4554
<style scoped src="./labels.css"></style>

docs/inspector/status.vue

+33-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { Ref, computed, inject } from 'vue';
2+
import { Ref, computed, inject } from 'vue'
33
44
const TOKEN_TYPE_MAP = {
55
'': '',
@@ -13,9 +13,9 @@ const TOKEN_TYPE_MAP = {
1313
'hyper-content': 'Non-content',
1414
'code-content': 'Code',
1515
'bracket-mark': 'Bracket',
16-
'group': 'Quotation',
17-
'unmatched': 'Unpaired bracket/quotation',
18-
'non-block': 'Non-content',
16+
group: 'Quotation',
17+
unmatched: 'Unpaired bracket/quotation',
18+
'non-block': 'Non-content'
1919
}
2020
const PROP_MAP = {
2121
// type: {
@@ -26,34 +26,35 @@ const PROP_MAP = {
2626
value: {
2727
modified: 'modifiedValue',
2828
ignored: 'ignoredValue',
29-
label: 'Value',
29+
label: 'Value'
3030
},
3131
spaceAfter: {
3232
modified: 'modifiedSpaceAfter',
3333
ignored: 'ignoredSpaceAfter',
34-
label: 'Space After',
34+
label: 'Space After'
3535
},
3636
startValue: {
3737
modified: 'modifiedStartValue',
3838
ignored: 'ignoredStartValue',
39-
label: 'Left Quotation',
39+
label: 'Left Quotation'
4040
},
4141
innerSpaceBefore: {
4242
modified: 'modifiedInnerSpaceBefore',
4343
ignored: 'ignoredInnerSpaceBefore',
44-
label: 'Inner Left Space in Quotations',
44+
label: 'Inner Left Space in Quotations'
4545
},
4646
endValue: {
4747
modified: 'modifiedEndValue',
4848
ignored: 'ignoredEndValue',
49-
label: 'Right Quotation',
50-
},
49+
label: 'Right Quotation'
50+
}
5151
}
5252
5353
const current = inject<Ref<any>>('current')
5454
const currentProp = inject<Ref<string>>('currentProp')
5555
56-
const checkSpace = prop => prop === 'spaceAfter' || prop === 'innerSpaceBefore'
56+
const checkSpace = (prop) =>
57+
prop === 'spaceAfter' || prop === 'innerSpaceBefore'
5758
5859
const checkType = (data, prop) => {
5960
if (!data || !prop) {
@@ -65,24 +66,41 @@ const checkType = (data, prop) => {
6566
if (data?.type === data?.modifiedType) {
6667
return TOKEN_TYPE_MAP[data?.type]
6768
} else {
68-
return TOKEN_TYPE_MAP[data?.type] + ' is modified into ' + TOKEN_TYPE_MAP[data?.modifiedType]
69+
return (
70+
TOKEN_TYPE_MAP[data?.type] +
71+
' is modified into ' +
72+
TOKEN_TYPE_MAP[data?.modifiedType]
73+
)
6974
}
7075
}
7176
7277
const checkProp = (data, prop) => {
7378
if (!data || !prop) {
74-
return { desc: 'click the tokens in "Origin" or "Formatted" to see more details' }
79+
return {
80+
desc: 'click the tokens in "Origin" or "Formatted" to see more details'
81+
}
7582
}
7683
const { modified, ignored } = PROP_MAP[prop]
77-
console.log(data, prop, modified, ignored, data[modified] === data[prop], ignored in data)
84+
console.log(
85+
data,
86+
prop,
87+
modified,
88+
ignored,
89+
data[modified] === data[prop],
90+
ignored in data
91+
)
7892
if (data[modified] !== data[prop]) {
7993
if (checkSpace(prop)) {
8094
if (data[modified] && data[prop]) {
8195
return { desc: 'normalized' }
8296
}
8397
return { desc: !data[prop] ? 'added' : 'removed' }
8498
}
85-
return { desc: ' is modified into ', original: data[prop], modified: data[modified] }
99+
return {
100+
desc: ' is modified into ',
101+
original: data[prop],
102+
modified: data[modified]
103+
}
86104
} else if (ignored in data) {
87105
return { desc: 'modification ignored' }
88106
} else {

src/hypers/types.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export type ParsedStatus = {
2424
blocks: Block[]
2525
}
2626

27-
export type ParsedBlock = Block & MutableParseResult & {
28-
originValue: string
29-
}
27+
export type ParsedBlock = Block &
28+
MutableParseResult & {
29+
originValue: string
30+
}

src/hypers/vuepress.ts

+1-7
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,7 @@ try {
1919
const parser = (data: ParsedStatus): ParsedStatus => {
2020
data.modifiedValue = data.modifiedValue.replace(
2121
matcher,
22-
(
23-
raw: string,
24-
start: string,
25-
value: string,
26-
end: string,
27-
index: number
28-
) => {
22+
(raw: string, start: string, value: string, end: string, index: number) => {
2923
const { length } = raw
3024
const name = start.substring(3).trim().split(' ')[0] || 'default'
3125
data.ignoredByParsers.push({

0 commit comments

Comments
 (0)