Skip to content

Commit 83a8bd6

Browse files
committed
Merge branch 'master' into 1.x
2 parents a4be231 + 15d9c6a commit 83a8bd6

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

coffee/templaterState.coffee

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
module.exports=class TemplaterState
44
moveCharacters:(numXmlTag,newTextLength,oldTextLength)->
5-
if typeof newTextLength!='number' then return @moveCharacters(numXmlTag,newTextLength.length,oldTextLength)
6-
if typeof oldTextLength!='number' then return @moveCharacters(numXmlTag,newTextLength,oldTextLength.length)
75
for k in [numXmlTag..@matches.length]
86
@charactersAdded[k]+=newTextLength-oldTextLength
97
calcStartTag: (tag) -> @calcPosition(tag.start)

coffee/xmlTemplater.coffee

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ module.exports=class XmlTemplater #abstract class !!
7575
replaceSimpleTagRawXml:()->
7676
subContent=new SubContent(@content).getInnerTag(@templaterState).getOuterXml('w:p')
7777
newText=@scopeManager.getValueFromScope(@templaterState.tag)
78-
@templaterState.moveCharacters(@templaterState.tagStart.numXmlTag,newText,subContent.text)
78+
@templaterState.moveCharacters(@templaterState.tagStart.numXmlTag,newText.length,subContent.text.length)
7979
@content= subContent.replace(newText).fullText
8080
deleteTag:(xml,tag)->
8181
@templaterState.tagStart=tag.start
@@ -87,7 +87,7 @@ module.exports=class XmlTemplater #abstract class !!
8787
dashLoop: (elementDashLoop,sharp=false) ->
8888
{_,start,end}= @templaterState.findOuterTagsContent(@content)
8989
outerXml = DocUtils.getOuterXml @content, start, end, elementDashLoop
90-
@templaterState.moveCharacters(0,"",outerXml.startTag)
90+
@templaterState.moveCharacters(0,0,outerXml.startTag)
9191
outerXmlText= outerXml.text
9292
innerXmlText=@deleteOuterTags(outerXmlText,sharp)
9393
@forLoop(innerXmlText,outerXmlText)
@@ -110,7 +110,7 @@ module.exports=class XmlTemplater #abstract class !!
110110
@templaterState.matches[xmlTagNumber][2]=insideValue #so that the templaterState.matches are still correct
111111
startTag= @templaterState.calcXmlTagPosition(xmlTagNumber)#where the open tag starts: <w:t>
112112
#calculate the replacer according to the params
113-
@templaterState.moveCharacters(xmlTagNumber+1,replacer,@templaterState.matches[xmlTagNumber][0])
113+
@templaterState.moveCharacters(xmlTagNumber+1,replacer.length,@templaterState.matches[xmlTagNumber][0].length)
114114
if content.indexOf(@templaterState.matches[xmlTagNumber][0])==-1 then throw new Error("content #{@templaterState.matches[xmlTagNumber][0]} not found in content")
115115
content = DocUtils.replaceFirstFrom content,@templaterState.matches[xmlTagNumber][0], replacer, startTag
116116
@templaterState.matches[xmlTagNumber][0]=replacer

0 commit comments

Comments
 (0)