From 01da4c3402dc7f19ac80f4daec7c224e8a4ecd08 Mon Sep 17 00:00:00 2001 From: moki Date: Tue, 21 Nov 2023 22:15:06 +0400 Subject: [PATCH] feat(xlf/renderer/md-xlf): html inline --- src/xlf/renderer/md-xlf/rules/html-inline.ts | 19 +++++++++++++++++++ src/xlf/renderer/md-xlf/rules/index.ts | 3 ++- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 src/xlf/renderer/md-xlf/rules/html-inline.ts diff --git a/src/xlf/renderer/md-xlf/rules/html-inline.ts b/src/xlf/renderer/md-xlf/rules/html-inline.ts new file mode 100644 index 00000000..4c8e7e58 --- /dev/null +++ b/src/xlf/renderer/md-xlf/rules/html-inline.ts @@ -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, tokens: Token[], i: number) { + const {content, type} = tokens[i]; + + return generateX({ctype: type, equivText: content}); +} + +export {htmlInline}; +export default {htmlInline}; diff --git a/src/xlf/renderer/md-xlf/rules/index.ts b/src/xlf/renderer/md-xlf/rules/index.ts index be238e16..aaea3ec5 100644 --- a/src/xlf/renderer/md-xlf/rules/index.ts +++ b/src/xlf/renderer/md-xlf/rules/index.ts @@ -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; @@ -23,7 +24,6 @@ function rules() { hardbreak: () => '', softbreak: () => '\n', html_block: () => '', - html_inline: () => '', heading_open: () => '', heading_close: () => '', paragraph_open: () => '', @@ -45,6 +45,7 @@ function rules() { ...video, ...anchor, ...file, + ...htmlInline, }; }