sujith3g / docxtemplater-link-module

:anchor: Hyperlink module for docxtemplater
https://www.npmjs.com/package/docxtemplater-link-module
MIT License
22 stars 15 forks source link

Wrong handling of template if {^link} is written inside of a sentence #10

Closed KharitonOff closed 8 years ago

KharitonOff commented 8 years ago

The link-module replaces the whole sentence instead of replacing only the tag. This happens if you write text with tag inside at a stroke and not if you paste the tag afterwards.

It works with this xml structure (link tag is inside a separate xml tag):

            <w:r>
                <w:rPr>
                    <w:lang w:val="en-GB" /></w:rPr>
                <w:t xml:space="preserve">Lorem ipsum </w:t>
            </w:r>
            <w:r w:rsidR="003F6AE5">
                <w:t>{^link</w:t>
            </w:r>
            <w:r w:rsidR="00EA5324" w:rsidRPr="00EA5324">
                <w:t>}</w:t>
            </w:r>
            <w:r>
                <w:rPr>
                    <w:lang w:val="en-GB" /></w:rPr>
                <w:t xml:space="preserve"> </w:t>
            </w:r>
            <w:proofErr w:type="spellStart" />
            <w:r>
                <w:rPr>
                    <w:lang w:val="en-GB" /></w:rPr>
                <w:t>amet</w:t>
            </w:r>

the result is:

image

but not with this one (link tag is inside the same xml tag with other text):

             <w:r>
                <w:rPr>
                    <w:lang w:val="en-GB" /></w:rPr>
                <w:t xml:space="preserve">Lorem ipsum {^link} </w:t>
            </w:r>
            <w:r w:rsidR="003B141A">
                <w:rPr>
                    <w:lang w:val="en-GB" /></w:rPr>
                <w:t>amet.</w:t>
            </w:r>

the result here is:

image