Skip to content

Commit 4bb21ad

Browse files
committed
feat: add document properties support to MarkdownDocx options and improve image rendering logic
1 parent f531fc4 commit 4bb21ad

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/MarkdownDocx.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export class MarkdownDocx {
5656
const doc = new Document({
5757
numbering,
5858
styles: createDocumentStyle(),
59+
...this.options.document,
5960
...options,
6061
footnotes: this.footnotes,
6162
sections: [

src/renders/render-image.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import { ITextAttr } from '../types'
66
import { renderText } from './render-text'
77

88
export function renderImage(render: MarkdownDocx, block: Tokens.Image, attr: ITextAttr) {
9+
if (render.ignoreImage) {
10+
return false
11+
}
12+
913
const image = render.findImage(block)
1014

1115
if (!image || !image.type) {

src/types.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { IParagraphStylePropertiesOptions, IRunStylePropertiesOptions, IShadingAttributesProperties } from 'docx'
1+
import {
2+
IParagraphStylePropertiesOptions, IPropertiesOptions, IRunStylePropertiesOptions, IShadingAttributesProperties
3+
} from 'docx'
24
import { MarkedOptions, Tokens } from 'marked'
35

46
import { Footnote, FootnoteRef } from './extensions'
@@ -34,6 +36,11 @@ export interface MarkdownDocxOptions extends MarkedOptions {
3436
* @default false
3537
*/
3638
ignoreHtml?: boolean
39+
40+
/**
41+
* Properties for the document
42+
*/
43+
document?: Omit<IPropertiesOptions, 'sections'>
3744
}
3845

3946
export type IBlockToken =

0 commit comments

Comments
 (0)