Skip to content

Commit

Permalink
test(xlf/renderer/xlf-md): ref link syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
moki committed Oct 19, 2023
1 parent 0791704 commit 527e090
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ exports[`renders xlf to markdown renders link wrapped in <g> and <x> tags 1`] =
exports[`renders xlf to markdown renders plain text 1`] = `"Sentence about something. Another sentence."`;
exports[`renders xlf to markdown renders ref link wrapped in <g> and <x> tags 1`] = `"Предложение номер [{#T}](one.md \\"one\\")."`;
exports[`renders xlf to markdown renders s wrapped in <g> tags 1`] = `"Предложение номер ~~один~~."`;
exports[`renders xlf to markdown renders samp wrapped in <g> tags 1`] = `"Предложение номер ##один##."`;
Expand Down
56 changes: 56 additions & 0 deletions src/xlf/renderer/xlf-md/renderer-inline.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,4 +285,60 @@ describe('renders xlf to markdown', () => {
const rendered = renderer.render(tokens);
expect(rendered).toMatchSnapshot();
});

it('renders ref link wrapped in <g> and <x> tags', () => {
const renderer = new XLFMDRenderer();
const tokens: Array<XLFToken> = [
{type: 'tag', data: 'target', nodeType: 'open'},
{type: 'text', data: 'Предложение номер '},
{
type: 'tag',
data: 'x',
nodeType: 'self-closing',
syntax: 'link_reflink',
equivText: '[{#T}]',
},
{
type: 'tag',
data: 'g',
nodeType: 'open',
syntax: 'link_attributes_part',
equivText: '()',
},
{
type: 'tag',
data: 'x',
nodeType: 'self-closing',
syntax: 'link_attributes_href',
equivText: 'one.md',
},
{
type: 'tag',
data: 'g',
nodeType: 'open',
syntax: 'link_attributes_title',
equivText: '""',
},
{type: 'text', data: 'one'},
{
type: 'tag',
data: 'g',
nodeType: 'close',
syntax: 'link_attributes_title',
equivText: '""',
},
{
type: 'tag',
data: 'g',
nodeType: 'close',
syntax: 'link_attributes_part',
equivText: '()',
},
{type: 'text', data: '.'},
{type: 'tag', data: 'target', nodeType: 'close'},
];

const rendered = renderer.render(tokens);
expect(rendered).toMatchSnapshot();
});
});

0 comments on commit 527e090

Please sign in to comment.