Skip to content

Commit

Permalink
feat: Add transformInline method
Browse files Browse the repository at this point in the history
Fixes #393
  • Loading branch information
3y3 committed Aug 6, 2024
1 parent dca71bb commit b8db80a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/transform/md.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,12 @@ function initParser(md: MarkdownIt, options: OptionsType, env: EnvType) {
}

function initCompiler(md: MarkdownIt, options: OptionsType, env: EnvType) {
const {needToSanitizeHtml = true, sanitizeOptions} = options;
const {needToSanitizeHtml = true, renderInline = false, sanitizeOptions} = options;

return (tokens: Token[]) => {
const html = md.renderer.render(tokens, md.options, env);
const html = renderInline
? md.renderer.renderInline(tokens, md.options, env)
: md.renderer.render(tokens, md.options, env);

return needToSanitizeHtml ? sanitizeHtml(html, sanitizeOptions) : html;
};
Expand Down
1 change: 1 addition & 0 deletions src/transform/typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export interface OptionsType {
rootPublicPath?: string;
transformLink?: (href: string) => string;
getPublicPath?: (options: OptionsType, href?: string) => string;
renderInline?: boolean;
[x: string]: unknown;
}

Expand Down

0 comments on commit b8db80a

Please sign in to comment.