Skip to content

Commit

Permalink
feat(xlf/renderer/md-xlf): html inline
Browse files Browse the repository at this point in the history
  • Loading branch information
moki committed Nov 21, 2023
1 parent ff5d933 commit 01da4c3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/xlf/renderer/md-xlf/rules/html-inline.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {CustomRenderer} from '@diplodoc/markdown-it-custom-renderer';
import Renderer from 'markdown-it/lib/renderer';
import Token from 'markdown-it/lib/token';

import {XLFRendererState} from 'src/xlf/renderer/md-xlf/state';
import {generateX} from 'src/xlf/generator';

const htmlInline: Renderer.RenderRuleRecord = {
html_inline: htmlInlineRule,
};

function htmlInlineRule(this: CustomRenderer<XLFRendererState>, tokens: Token[], i: number) {
const {content, type} = tokens[i];

return generateX({ctype: type, equivText: content});
}

export {htmlInline};
export default {htmlInline};
3 changes: 2 additions & 1 deletion src/xlf/renderer/md-xlf/rules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {image} from './image';
import {video} from './video';
import {anchor} from './anchor';
import {file} from './file';
import {htmlInline} from './html-inline';

export type XLFRulesState = LinkRuleState & DiplodocRulesState;

Expand All @@ -23,7 +24,6 @@ function rules() {
hardbreak: () => '',
softbreak: () => '\n',
html_block: () => '',
html_inline: () => '',
heading_open: () => '',
heading_close: () => '',
paragraph_open: () => '',
Expand All @@ -45,6 +45,7 @@ function rules() {
...video,
...anchor,
...file,
...htmlInline,
};
}

Expand Down

0 comments on commit 01da4c3

Please sign in to comment.