Skip to content

Commit f08ea25

Browse files
committed
Refactor
1 parent ea37228 commit f08ea25

2 files changed

Lines changed: 11 additions & 16 deletions

File tree

src/__snapshots__/index.spec.ts.snap

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ exports[`e2e > alt 1`] = `
3737
xmlns:w16sdtdh="http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash"
3838
xmlns:w16se="http://schemas.microsoft.com/office/word/2015/wordml/symex"
3939
><w:body><w:p><w:hyperlink w:history="1" r:id="rIdmmmmmmmmmmmmmmmmmmmmm"><w:r
40-
><w:rPr><w:b /><w:bCs /><w:color w:val="0563c1" /><w:u
41-
w:val="single"
42-
/></w:rPr><w:t
40+
><w:rPr><w:rStyle w:val="Hyperlink" /><w:b /><w:bCs /></w:rPr><w:t
4341
xml:space="preserve"
4442
>link to GitHub.com</w:t></w:r></w:hyperlink></w:p><w:p><w:r
4543
><w:drawing><wp:inline distT="0" distB="0" distL="0" distR="0"><wp:extent
@@ -619,7 +617,7 @@ exports[`e2e > article 1`] = `
619617
>This is </w:t></w:r><w:hyperlink
620618
w:history="1"
621619
r:id="rIdmmmmmmmmmmmmmmmmmmmmm"
622-
><w:r><w:rPr><w:color w:val="0563c1" /><w:u w:val="single" /></w:rPr><w:t
620+
><w:r><w:rPr><w:rStyle w:val="Hyperlink" /></w:rPr><w:t
623621
xml:space="preserve"
624622
>link to GitHub.com</w:t></w:r></w:hyperlink><w:r><w:t
625623
xml:space="preserve"
@@ -3763,16 +3761,12 @@ aaa</w:t></w:r><w:r><w:rPr><w:b /><w:bCs /><w:i /><w:iCs /></w:rPr><w:t
37633761
>quote</w:t></w:r></w:p><w:p><w:hyperlink
37643762
w:history="1"
37653763
r:id="rIdmmmmmmmmmmmmmmmmmmmmm"
3766-
><w:r><w:rPr><w:b /><w:bCs /><w:color w:val="0563c1" /><w:u
3767-
w:val="single"
3768-
/></w:rPr><w:t
3764+
><w:r><w:rPr><w:rStyle w:val="Hyperlink" /><w:b /><w:bCs /></w:rPr><w:t
37693765
xml:space="preserve"
37703766
>link to GitHub.com</w:t></w:r></w:hyperlink></w:p><w:p><w:hyperlink
37713767
w:history="1"
37723768
r:id="rIdmmmmmmmmmmmmmmmmmmmmm"
3773-
><w:r><w:rPr><w:b /><w:bCs /><w:color w:val="0563c1" /><w:u
3774-
w:val="single"
3775-
/></w:rPr><w:t
3769+
><w:r><w:rPr><w:rStyle w:val="Hyperlink" /><w:b /><w:bCs /></w:rPr><w:t
37763770
xml:space="preserve"
37773771
>link to GitHub.com</w:t></w:r></w:hyperlink></w:p><w:p><w:r
37783772
><w:drawing><wp:inline distT="0" distB="0" distL="0" distR="0"><wp:extent
@@ -4673,7 +4667,7 @@ exports[`e2e > footnotes2 1`] = `
46734667
>Here is a </w:t></w:r><w:hyperlink
46744668
w:history="1"
46754669
r:id="rIdmmmmmmmmmmmmmmmmmmmmm"
4676-
><w:r><w:rPr><w:color w:val="0563c1" /><w:u w:val="single" /></w:rPr><w:t
4670+
><w:r><w:rPr><w:rStyle w:val="Hyperlink" /></w:rPr><w:t
46774671
xml:space="preserve"
46784672
>link with footnote</w:t></w:r><w:r><w:rPr><w:rStyle
46794673
w:val="FootnoteReference"
@@ -6872,7 +6866,7 @@ exports[`e2e > latex 1`] = `
68726866
xmlns:w16sdtdh="http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash"
68736867
xmlns:w16se="http://schemas.microsoft.com/office/word/2015/wordml/symex"
68746868
><w:body><w:p><w:hyperlink w:history="1" r:id="rIdmmmmmmmmmmmmmmmmmmmmm"><w:r
6875-
><w:rPr><w:color w:val="0563c1" /><w:u w:val="single" /></w:rPr><w:t
6869+
><w:rPr><w:rStyle w:val="Hyperlink" /></w:rPr><w:t
68766870
xml:space="preserve"
68776871
>https://mathjax.github.io/MathJax-demos-web/page/tex-chtml.html</w:t></w:r></w:hyperlink></w:p><w:p
68786872
><w:r><w:t xml:space="preserve">When </w:t></w:r><m:oMath><m:r><m:t
@@ -7540,7 +7534,7 @@ exports[`e2e > link-reference 1`] = `
75407534
><w:body><w:p><w:r><w:t xml:space="preserve">This is </w:t></w:r><w:hyperlink
75417535
w:history="1"
75427536
r:id="rIdmmmmmmmmmmmmmmmmmmmmm"
7543-
><w:r><w:rPr><w:color w:val="0563c1" /><w:u w:val="single" /></w:rPr><w:t
7537+
><w:r><w:rPr><w:rStyle w:val="Hyperlink" /></w:rPr><w:t
75447538
xml:space="preserve"
75457539
>link reference</w:t></w:r></w:hyperlink><w:r><w:t
75467540
xml:space="preserve"
@@ -10288,7 +10282,7 @@ exports[`e2e > ml 1`] = `
1028810282
/></w:sectPr></w:pPr></w:p><w:p><w:hyperlink
1028910283
w:history="1"
1029010284
r:id="rIdmmmmmmmmmmmmmmmmmmmmm"
10291-
><w:r><w:rPr><w:color w:val="0563c1" /><w:u w:val="single" /></w:rPr><w:t
10285+
><w:r><w:rPr><w:rStyle w:val="Hyperlink" /></w:rPr><w:t
1029210286
xml:space="preserve"
1029310287
>mailto:foobarbaz</w:t></w:r></w:hyperlink></w:p><w:p><w:r><w:t
1029410288
xml:space="preserve"

src/mdast-util-to-docx.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const CONTENT_WIDTH =
3939
sectionMarginDefaults.LEFT -
4040
sectionMarginDefaults.RIGHT;
4141
const ORDERED_LIST_REF = "ordered";
42+
const HYPERLINK_STYLE_ID = "Hyperlink";
4243
const INDENT = 0.5;
4344

4445
const createFootnoteRegistry = (): FootnoteRegistry => {
@@ -456,8 +457,8 @@ const buildText: NodeBuilder<"text"> = ({ value }, { deco }) => {
456457
strike: deco.strike,
457458
};
458459
if (deco.link) {
459-
options.color = "#0563c1";
460-
options.underline = { type: "single" };
460+
// https://docx.js.org/#/usage/hyperlinks?id=styling-hyperlinks
461+
options.style = HYPERLINK_STYLE_ID;
461462
}
462463
return new TextRun(options);
463464
};

0 commit comments

Comments
 (0)