Skip to content

Commit 748dbf4

Browse files
committed
Wrap adjacent inline runs with one paragraph instead of one for each
1 parent 7587cc3 commit 748dbf4

16 files changed

+2729
-348
lines changed

Diff for: src/constants.ts

+96-56
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import lodash from "lodash"
22
import { type DocumentOptions } from "./types.ts"
33

4-
const applicationName = "html-to-docx"
5-
const defaultOrientation = "portrait"
6-
const landscapeWidth = 15840
7-
const landscapeHeight = 12240
8-
const landscapeMargins = {
4+
export const applicationName = "html-to-docx"
5+
export const defaultOrientation = "portrait"
6+
export const landscapeWidth = 15840
7+
export const landscapeHeight = 12240
8+
export const landscapeMargins = {
99
top: 1800,
1010
right: 1440,
1111
bottom: 1800,
@@ -14,7 +14,7 @@ const landscapeMargins = {
1414
footer: 720,
1515
gutter: 0,
1616
}
17-
const portraitMargins = {
17+
export const portraitMargins = {
1818
top: 1440,
1919
right: 1800,
2020
bottom: 1440,
@@ -23,10 +23,10 @@ const portraitMargins = {
2323
footer: 720,
2424
gutter: 0,
2525
}
26-
const defaultFont = "Times New Roman"
27-
const defaultFontSize = 22
28-
const defaultLang = "en-US"
29-
const defaultDocumentOptions: DocumentOptions = {
26+
export const defaultFont = "Times New Roman"
27+
export const defaultFontSize = 22
28+
export const defaultLang = "en-US"
29+
export const defaultDocumentOptions: DocumentOptions = {
3030
orientation: defaultOrientation,
3131
margins: lodash.cloneDeep(portraitMargins),
3232
creator: applicationName,
@@ -41,21 +41,21 @@ const defaultDocumentOptions: DocumentOptions = {
4141
},
4242
defaultLang,
4343
}
44-
const defaultHTMLString = "<p></p>"
45-
const relsFolderName = "_rels"
46-
const headerFileName = "header1"
47-
const footerFileName = "footer1"
48-
const themeFileName = "theme1"
49-
const documentFileName = "document"
50-
const headerType = "header"
51-
const footerType = "footer"
52-
const themeType = "theme"
53-
const hyperlinkType = "hyperlink"
54-
const imageType = "image"
55-
const internalRelationship = "Internal"
56-
const wordFolder = "word"
57-
const themeFolder = "theme"
58-
const paragraphBordersObject = {
44+
export const defaultHTMLString = "<p></p>"
45+
export const relsFolderName = "_rels"
46+
export const headerFileName = "header1"
47+
export const footerFileName = "footer1"
48+
export const themeFileName = "theme1"
49+
export const documentFileName = "document"
50+
export const headerType = "header"
51+
export const footerType = "footer"
52+
export const themeType = "theme"
53+
export const hyperlinkType = "hyperlink"
54+
export const imageType = "image"
55+
export const internalRelationship = "Internal"
56+
export const wordFolder = "word"
57+
export const themeFolder = "theme"
58+
export const paragraphBordersObject = {
5959
top: {
6060
size: 0,
6161
spacing: 3,
@@ -77,35 +77,75 @@ const paragraphBordersObject = {
7777
color: "FFFFFF",
7878
},
7979
}
80-
const colorlessColors = ["transparent", "auto"]
81-
const verticalAlignValues = ["top", "middle", "bottom"]
80+
export const colorlessColors = ["transparent", "auto"]
81+
export const verticalAlignValues = ["top", "middle", "bottom"]
8282

83-
export {
84-
applicationName,
85-
colorlessColors,
86-
defaultDocumentOptions,
87-
defaultFont,
88-
defaultFontSize,
89-
defaultHTMLString,
90-
defaultLang,
91-
defaultOrientation,
92-
documentFileName,
93-
footerFileName,
94-
footerType,
95-
headerFileName,
96-
headerType,
97-
hyperlinkType,
98-
imageType,
99-
internalRelationship,
100-
landscapeHeight,
101-
landscapeMargins,
102-
landscapeWidth,
103-
paragraphBordersObject,
104-
portraitMargins,
105-
relsFolderName,
106-
themeFileName,
107-
themeFolder,
108-
themeType,
109-
verticalAlignValues,
110-
wordFolder,
111-
}
83+
export const htmlInlineElements = [
84+
"a",
85+
"abbr",
86+
"acronym",
87+
"b",
88+
"bdo",
89+
"big",
90+
"br",
91+
"button",
92+
"cite",
93+
"code",
94+
"dfn",
95+
"em",
96+
"i",
97+
"img",
98+
"input",
99+
"kbd",
100+
"label",
101+
"map",
102+
"object",
103+
"output",
104+
"q",
105+
"samp",
106+
"script",
107+
"select",
108+
"small",
109+
"span",
110+
"strong",
111+
"sub",
112+
"sup",
113+
"textarea",
114+
"time",
115+
"tt",
116+
"var",
117+
]
118+
119+
export const htmlHeadings = ["h1", "h2", "h3", "h4", "h5", "h6"]
120+
121+
// export const htmlBlockElements = [
122+
// "address",
123+
// "article",
124+
// "aside",
125+
// "blockquote",
126+
// "canvas",
127+
// "dd",
128+
// "div",
129+
// "dl",
130+
// "dt",
131+
// "fieldset",
132+
// "figcaption",
133+
// "figure",
134+
// "footer",
135+
// "form",
136+
// "header",
137+
// ...htmlHeadings,
138+
// "hr",
139+
// "li",
140+
// "main",
141+
// "nav",
142+
// "noscript",
143+
// "ol",
144+
// "p",
145+
// "pre",
146+
// "section",
147+
// "table",
148+
// "tfoot",
149+
// "ul",
150+
// "video",
151+
// ]

0 commit comments

Comments
 (0)