Categories > OpenTBS general >

Possible Bug with Editing TBS codes in Word

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Philip
Date: 2014-10-23
Time: 10:47

Possible Bug with Editing TBS codes in Word

Hi

I think there might be a bug which means that TBS does not understand the TBS codes correctly when you edit them in word. I have created an example, start with a blank word document and type in:
This is my first bit of text [onshow;block=tbs:p;when'[Fruit_Type]'~='/(.*Apple.*|Pear)/']
This is my second bit of text

I highlight the TBS code in red to make it clearer and this might have a bearing on the issue. The XML for the above looks like:
-<w:p w:rsidP="00B66139" w:rsidRDefault="00B66139" w:rsidR="00B66139">
-<w:r>
<w:t xml:space="preserve">This is my first bit of text </w:t>
</w:r>
<w:bookmarkStart w:name="_GoBack" w:id="0"/>
-<w:r w:rsidRPr="00B66139">
-<w:rPr>
<w:color w:val="FF0000"/>
</w:rPr>
<w:t>[onshow</w:t>
</w:r>
<w:proofErr w:type="gramStart"/>
-<w:r w:rsidRPr="00B66139">
-<w:rPr>
<w:color w:val="FF0000"/>
</w:rPr>
<w:t>;block</w:t>
</w:r>
<w:proofErr w:type="gramEnd"/>
-<w:r w:rsidRPr="00B66139">
-<w:rPr>
<w:color w:val="FF0000"/>
</w:rPr>
<w:t>=</w:t>
</w:r>
<w:proofErr w:type="spellStart"/>
-<w:r w:rsidRPr="00B66139">
-<w:rPr>
<w:color w:val="FF0000"/>
</w:rPr>
<w:t>tbs:p;when</w:t>
</w:r>
<w:proofErr w:type="spellEnd"/>
-<w:r w:rsidRPr="00B66139">
-<w:rPr>
<w:color w:val="FF0000"/>
</w:rPr>
<w:t>'[Fruit_Type]'~='/(.*Apple.*|Pear)/']</w:t>
</w:r>
<w:bookmarkEnd w:id="0"/>
</w:p>
-<w:p w:rsidP="00B66139" w:rsidRDefault="00B66139" w:rsidR="00377DC9">
-<w:r>
<w:t>This is my second bit of text</w:t>
</w:r>
</w:p>

If I then copy and paste the same code in word and make it look for Orange instead of Apple (just overtyping the text), so it now looks like this in word...
This is my first bit of text [onshow;block=tbs:p;when'[Fruit_Type]'~='/(.*Apple.*|Pear)/']
This is my second bit of text

This is my first bit of text [onshow;block=tbs:p;when'[Fruit_Type]'~='/(.*Orange.*|Pear)/']
This is my second bit of text

The TBS code is still highlighted in red and now the XML code looks like this...
-<w:p w:rsidP="00B66139" w:rsidRDefault="00B66139" w:rsidR="00B66139">
-<w:r>
<w:t xml:space="preserve">This is my first bit of text </w:t>
</w:r>
-<w:r w:rsidRPr="00B66139">
-<w:rPr>
<w:color w:val="FF0000"/>
</w:rPr>
<w:t>[onshow</w:t>
</w:r>
<w:proofErr w:type="gramStart"/>
-<w:r w:rsidRPr="00B66139">
-<w:rPr>
<w:color w:val="FF0000"/>
</w:rPr>
<w:t>;block</w:t>
</w:r>
<w:proofErr w:type="gramEnd"/>
-<w:r w:rsidRPr="00B66139">
-<w:rPr>
<w:color w:val="FF0000"/>
</w:rPr>
<w:t>=</w:t>
</w:r>
<w:proofErr w:type="spellStart"/>
-<w:r w:rsidRPr="00B66139">
-<w:rPr>
<w:color w:val="FF0000"/>
</w:rPr>
<w:t>tbs:p;when</w:t>
</w:r>
<w:proofErr w:type="spellEnd"/>
-<w:r w:rsidRPr="00B66139">
-<w:rPr>
<w:color w:val="FF0000"/>
</w:rPr>
<w:t>'[Fruit_Type]'~='/(.*Apple.*|Pear)/']</w:t>
</w:r>
</w:p>
-<w:p w:rsidP="00B66139" w:rsidRDefault="00B66139" w:rsidR="00377DC9">
-<w:r>
<w:t>This is my second bit of text</w:t>
</w:r>
</w:p>
<w:p w:rsidP="00B66139" w:rsidRDefault="00AD6348" w:rsidR="00AD6348"/>
-<w:p w:rsidP="00AD6348" w:rsidRDefault="00AD6348" w:rsidR="00AD6348">
-<w:r>
<w:t xml:space="preserve">This is my first bit of text </w:t>
</w:r>
-<w:r w:rsidRPr="00B66139">
-<w:rPr>
<w:color w:val="FF0000"/>
</w:rPr>
<w:t>[onshow</w:t>
</w:r>
<w:proofErr w:type="gramStart"/>
-<w:r w:rsidRPr="00B66139">
-<w:rPr>
<w:color w:val="FF0000"/>
</w:rPr>
<w:t>;block</w:t>
</w:r>
<w:proofErr w:type="gramEnd"/>
-<w:r w:rsidRPr="00B66139">
-<w:rPr>
<w:color w:val="FF0000"/>
</w:rPr>
<w:t>=</w:t>
</w:r>
<w:proofErr w:type="spellStart"/>
-<w:r w:rsidRPr="00B66139">
-<w:rPr>
<w:color w:val="FF0000"/>
</w:rPr>
<w:t>tbs:p;when</w:t>
</w:r>
<w:proofErr w:type="spellEnd"/>
-<w:r w:rsidRPr="00B66139">
-<w:rPr>
<w:color w:val="FF0000"/>
</w:rPr>
<w:t>'[Fruit_Type]'~='/(.*</w:t>
</w:r>
-<w:r>
-<w:rPr>
<w:color w:val="FF0000"/>
</w:rPr>
<w:t>Orange</w:t>
</w:r>
<w:bookmarkStart w:name="_GoBack" w:id="0"/>
<w:bookmarkEnd w:id="0"/>
-<w:r w:rsidRPr="00B66139">
-<w:rPr>
<w:color w:val="FF0000"/>
</w:rPr>
<w:t>.*|Pear)/']</w:t>
</w:r>
</w:p>
-<w:p w:rsidP="00AD6348" w:rsidRDefault="00AD6348" w:rsidR="00AD6348">
-<w:r>
<w:t>This is my second bit of text</w:t>
</w:r>
</w:p>

The first bit of XML is the same, the second copy though, you can see the Orange bit of the TBS string is now split up. This seems to cause TBS to fail (i.e. it will not show the second line of text in my example) but it will remove the TBS command so I think in the background the TBS code must be putting a space or something causing the pattern not to match.

To fix the problem I have to clear the formats and then the XML looks fine (I reapply the red text to the TBS code mind):
-<w:p w:rsidP="00B66139" w:rsidRDefault="00B66139" w:rsidR="00B66139">
-<w:r>
<w:t xml:space="preserve">This is my first bit of text </w:t>
</w:r>
-<w:r w:rsidRPr="00B66139">
-<w:rPr>
<w:color w:val="FF0000"/>
</w:rPr>
<w:t>[onshow</w:t>
</w:r>
<w:proofErr w:type="gramStart"/>
-<w:r w:rsidRPr="00B66139">
-<w:rPr>
<w:color w:val="FF0000"/>
</w:rPr>
<w:t>;block</w:t>
</w:r>
<w:proofErr w:type="gramEnd"/>
-<w:r w:rsidRPr="00B66139">
-<w:rPr>
<w:color w:val="FF0000"/>
</w:rPr>
<w:t>=</w:t>
</w:r>
<w:proofErr w:type="spellStart"/>
-<w:r w:rsidRPr="00B66139">
-<w:rPr>
<w:color w:val="FF0000"/>
</w:rPr>
<w:t>tbs:p;when</w:t>
</w:r>
<w:proofErr w:type="spellEnd"/>
-<w:r w:rsidRPr="00B66139">
-<w:rPr>
<w:color w:val="FF0000"/>
</w:rPr>
<w:t>'[Fruit_Type]'~='/(.*Apple.*|Pear)/']</w:t>
</w:r>
</w:p>
-<w:p w:rsidP="00B66139" w:rsidRDefault="00B66139" w:rsidR="00377DC9">
-<w:r>
<w:t>This is my second bit of text</w:t>
</w:r>
</w:p>
<w:p w:rsidP="00B66139" w:rsidRDefault="00AD6348" w:rsidR="00AD6348"/>
-<w:p w:rsidP="001B48F9" w:rsidRDefault="00AD6348" w:rsidR="00AD6348" w:rsidRPr="001B48F9">
-<w:r w:rsidRPr="001B48F9">
<w:t xml:space="preserve">This is my first bit of text </w:t>
</w:r>
<w:bookmarkStart w:name="_GoBack" w:id="0"/>
-<w:r w:rsidRPr="001B48F9">
-<w:rPr>
<w:color w:val="FF0000"/>
</w:rPr>
<w:t>[onshow</w:t>
</w:r>
<w:proofErr w:type="gramStart"/>
-<w:r w:rsidRPr="001B48F9">
-<w:rPr>
<w:color w:val="FF0000"/>
</w:rPr>
<w:t>;block</w:t>
</w:r>
<w:proofErr w:type="gramEnd"/>
-<w:r w:rsidRPr="001B48F9">
-<w:rPr>
<w:color w:val="FF0000"/>
</w:rPr>
<w:t>=</w:t>
</w:r>
<w:proofErr w:type="spellStart"/>
-<w:r w:rsidRPr="001B48F9">
-<w:rPr>
<w:color w:val="FF0000"/>
</w:rPr>
<w:t>tbs:p;when</w:t>
</w:r>
<w:proofErr w:type="spellEnd"/>
-<w:r w:rsidRPr="001B48F9">
-<w:rPr>
<w:color w:val="FF0000"/>
</w:rPr>
<w:t>'[Fruit_Type]'~='/(.*Orange.*|Pear)/']</w:t>
</w:r>
<w:bookmarkEnd w:id="0"/>
</w:p>
-<w:p w:rsidP="001B48F9" w:rsidRDefault="00AD6348" w:rsidR="00AD6348" w:rsidRPr="001B48F9">
-<w:r w:rsidRPr="001B48F9">
<w:t>This is my second bit of text</w:t>
</w:r>
</w:p>

As you can see the TBS code now looks like the first line. This is a real pain because from word it looks fine but the code does not work. Is there a way to fix this or is it a problem in the plugin or something?

Thanks in advance
By: Skrol29
Date: 2014-10-27
Time: 02:46

Re: Possible Bug with Editing TBS codes in Word

Hi Philip,

The documentation or the DOCX example deserve more notes about the problem you're pointing on.

When you're editing a piece of text, MS Word may insert invisible elements that split the TBS tag. So the TBS tag is corrupted.
Such invisible elements can be: language-spelling-grammar information, markers for reviewing, automatic bookmarks.

OpenTBS tries to find and delete such elements. But when it seems hazardous to delete an element, OpenTBS let it as it is. So you may sometimes be bothered by TBS tags that seems to not be recognized or be cut.

Here is some tip and tricks to get around the problem :

- If there is a spelling or grammar color that is underlying the TBS tags, then select the TBS tag and click on the Review ribbon, in the Proofing group, click the Set Language button. In the dialog, make sure the "Do not check
spelling or grammar" box is checked and "Detect language automatically" is NOT checked.

- To avoid review makers and automatic bookmarks: select the TBS tag, cut it, then do a "paste only text". This command is available in the clipboard button available in the Home ribbon or in the contextual menu.

- To permanently avoid review makers: go to the Trust Center in the Word options, and turn off the setting: "Store random number to improve combine accuracy".

- To temporary avoid review makers: press [Alt][F11] to open the Visual Basic console. Then enter "Word.Options.StoreRSIDOnSave = false" in the Execution frame.


By: Philip
Date: 2014-10-27
Time: 18:19

Re: Possible Bug with Editing TBS codes in Word

Hi

Thanks, the "Word.Options.StoreRSIDOnSave = false" seems to make a difference and improve things.

You say "OpenTBS tries to find and delete such elements. But when it seems hazardous to delete an element, OpenTBS let it as it is. So you may sometimes be bothered by TBS tags that seems to not be recognized or be cut."

I understand why it will not delete this but can you make the TBS code write an error into the log or even better via...
[onshow..error_msg]
My main issue is that I cannot easily tell if I have a problem by looking at the template and I have to test every permutation which is a problem for a large template.

Thanks