Skip to content

Commit

Permalink
fix tab issues
Browse files Browse the repository at this point in the history
  • Loading branch information
luca-iachini committed Mar 22, 2024
1 parent 5f6d92c commit 890502b
Show file tree
Hide file tree
Showing 3 changed files with 366 additions and 1 deletion.
358 changes: 358 additions & 0 deletions output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,358 @@
yarn node v1.22.19
console.log
Resource {
type: 'Resource',
body: [
Message {
type: 'Message',
id: [Identifier],
value: [Pattern],
attributes: [Array],
comment: null,
span: [Span]
},
Message {
type: 'Message',
id: [Identifier],
value: [Pattern],
attributes: [Array],
comment: null,
span: [Span]
}
],
span: Span { type: 'Span', start: 0, end: 269 }
}

at Object.print (dist/index.js:36:13)

console.log
Message {
type: 'Message',
id: Identifier {
type: 'Identifier',
name: 'login-input',
span: Span { type: 'Span', start: 0, end: 11 }
},
value: Pattern {
type: 'Pattern',
elements: [ [TextElement] ],
span: Span { type: 'Span', start: 14, end: 65 }
},
attributes: [
Attribute {
type: 'Attribute',
id: [Identifier],
value: [Pattern],
span: [Span]
},
Attribute {
type: 'Attribute',
id: [Identifier],
value: [Pattern],
span: [Span]
}
],
comment: null,
span: Span { type: 'Span', start: 0, end: 140 }
}

at Object.print (dist/index.js:36:13)

console.log
Pattern {
type: 'Pattern',
elements: [
TextElement {
type: 'TextElement',
value: 'Predefined value\n\t.placeholder = [email protected]',
span: [Span]
}
],
span: Span { type: 'Span', start: 14, end: 65 }
}

at Object.print (dist/index.js:36:13)

console.log
TextElement {
type: 'TextElement',
value: 'Predefined value\n\t.placeholder = [email protected]',
span: Span { type: 'Span', start: 14, end: 65 }
}

at Object.print (dist/index.js:36:13)

console.log
Attribute {
type: 'Attribute',
id: Identifier {
type: 'Identifier',
name: 'aria-label',
span: Span { type: 'Span', start: 71, end: 81 }
},
value: Pattern {
type: 'Pattern',
elements: [ [TextElement] ],
span: Span { type: 'Span', start: 87, end: 104 }
},
span: Span { type: 'Span', start: 70, end: 104 }
}

at Object.print (dist/index.js:36:13)

console.log
Pattern {
type: 'Pattern',
elements: [
TextElement {
type: 'TextElement',
value: 'Login input value',
span: [Span]
}
],
span: Span { type: 'Span', start: 87, end: 104 }
}

at Object.print (dist/index.js:36:13)

console.log
TextElement {
type: 'TextElement',
value: 'Login input value',
span: Span { type: 'Span', start: 87, end: 104 }
}

at Object.print (dist/index.js:36:13)

console.log
Attribute {
type: 'Attribute',
id: Identifier {
type: 'Identifier',
name: 'title',
span: Span { type: 'Span', start: 108, end: 113 }
},
value: Pattern {
type: 'Pattern',
elements: [ [TextElement] ],
span: Span { type: 'Span', start: 119, end: 140 }
},
span: Span { type: 'Span', start: 107, end: 140 }
}

at Object.print (dist/index.js:36:13)

console.log
Pattern {
type: 'Pattern',
elements: [
TextElement {
type: 'TextElement',
value: 'Type your login email',
span: [Span]
}
],
span: Span { type: 'Span', start: 119, end: 140 }
}

at Object.print (dist/index.js:36:13)

console.log
TextElement {
type: 'TextElement',
value: 'Type your login email',
span: Span { type: 'Span', start: 119, end: 140 }
}

at Object.print (dist/index.js:36:13)

console.log
Message {
type: 'Message',
id: Identifier {
type: 'Identifier',
name: 'password-input',
span: Span { type: 'Span', start: 142, end: 156 }
},
value: Pattern {
type: 'Pattern',
elements: [ [TextElement] ],
span: Span { type: 'Span', start: 159, end: 167 }
},
attributes: [
Attribute {
type: 'Attribute',
id: [Identifier],
value: [Pattern],
span: [Span]
},
Attribute {
type: 'Attribute',
id: [Identifier],
value: [Pattern],
span: [Span]
},
Attribute {
type: 'Attribute',
id: [Identifier],
value: [Pattern],
span: [Span]
}
],
comment: null,
span: Span { type: 'Span', start: 142, end: 268 }
}

at Object.print (dist/index.js:36:13)

console.log
Pattern {
type: 'Pattern',
elements: [
TextElement {
type: 'TextElement',
value: 'Password',
span: [Span]
}
],
span: Span { type: 'Span', start: 159, end: 167 }
}

at Object.print (dist/index.js:36:13)

console.log
TextElement {
type: 'TextElement',
value: 'Password',
span: Span { type: 'Span', start: 159, end: 167 }
}

at Object.print (dist/index.js:36:13)

console.log
Attribute {
type: 'Attribute',
id: Identifier {
type: 'Identifier',
name: 'placeholder',
span: Span { type: 'Span', start: 174, end: 185 }
},
value: Pattern {
type: 'Pattern',
elements: [ [TextElement] ],
span: Span { type: 'Span', start: 191, end: 200 }
},
span: Span { type: 'Span', start: 173, end: 200 }
}

at Object.print (dist/index.js:36:13)

console.log
Pattern {
type: 'Pattern',
elements: [
TextElement {
type: 'TextElement',
value: 'password',
span: [Span]
}
],
span: Span { type: 'Span', start: 191, end: 200 }
}

at Object.print (dist/index.js:36:13)

console.log
TextElement {
type: 'TextElement',
value: 'password',
span: Span { type: 'Span', start: 191, end: 200 }
}

at Object.print (dist/index.js:36:13)

console.log
Attribute {
type: 'Attribute',
id: Identifier {
type: 'Identifier',
name: 'aria-label',
span: Span { type: 'Span', start: 205, end: 215 }
},
value: Pattern {
type: 'Pattern',
elements: [ [TextElement] ],
span: Span { type: 'Span', start: 218, end: 238 }
},
span: Span { type: 'Span', start: 204, end: 238 }
}

at Object.print (dist/index.js:36:13)

console.log
Pattern {
type: 'Pattern',
elements: [
TextElement {
type: 'TextElement',
value: 'Password input value',
span: [Span]
}
],
span: Span { type: 'Span', start: 218, end: 238 }
}

at Object.print (dist/index.js:36:13)

console.log
TextElement {
type: 'TextElement',
value: 'Password input value',
span: Span { type: 'Span', start: 218, end: 238 }
}

at Object.print (dist/index.js:36:13)

console.log
Attribute {
type: 'Attribute',
id: Identifier {
type: 'Identifier',
name: 'title',
span: Span { type: 'Span', start: 241, end: 246 }
},
value: Pattern {
type: 'Pattern',
elements: [ [TextElement] ],
span: Span { type: 'Span', start: 249, end: 268 }
},
span: Span { type: 'Span', start: 240, end: 268 }
}

at Object.print (dist/index.js:36:13)

console.log
Pattern {
type: 'Pattern',
elements: [
TextElement {
type: 'TextElement',
value: 'Type your password',
span: [Span]
}
],
span: Span { type: 'Span', start: 249, end: 268 }
}

at Object.print (dist/index.js:36:13)

console.log
TextElement {
type: 'TextElement',
value: 'Type your password',
span: Span { type: 'Span', start: 249, end: 268 }
}

at Object.print (dist/index.js:36:13)

info Visit https://yarnpkg.com/en/docs/cli/node for documentation about this command.
7 changes: 7 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const parsers: Record<string, Parser<FluentNode>> = {
fluent: {
parse: parseFluent,
astFormat: "fluent-ast",
preprocess,
locStart: (node) => {
return node.span?.start || 0;
},
Expand All @@ -32,13 +33,19 @@ export const printers: Record<string, Printer<FluentNode>> = {
},
};

function preprocess(text: string, _options: object): string {
return text.replace(/^\t+/gm, ' ');
}

function print(
path: AstPath,
_options: ParserOptions<object>,
printFn: (selector: AstPath) => Doc,
): Doc {
const node = path.node;

console.log(node);

switch (node.type) {
case "Resource":
return join(line, path.map(printFn, 'body'));
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('it format', () => {
await test_fixture('message_multiple_lines_spaces');
});
});
describe('attributes', () => {
describe.only('attributes', () => {
test('message with attributes', async () => {
await test_fixture('attributes')
});
Expand Down

0 comments on commit 890502b

Please sign in to comment.