Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with line breaks #176

Closed
jefraroce opened this issue Oct 20, 2015 · 6 comments
Closed

Problem with line breaks #176

jefraroce opened this issue Oct 20, 2015 · 6 comments

Comments

@jefraroce
Copy link

Hello everyone,

I'm working in a report so I need to add line breaks in the tags. This only I could do using the raw tags {@tag}, however, I found some problems. The main problem is when there is a raw tag together other the first absorb the second one.

I think that happens because when I write in a word document @ It embeds this into many different xml tags, by example:

{@my_first_tag}{my_second_tag}

<w:p>
    <w:r>
        <w:t>{@</w:t>
    </w:r>
    <w:proofErr w:type="spellStart"/>
    <w:r>
        <w:t>my_first_tag</w:t>
    </w:r>
    <w:proofErr w:type="spellEnd"/>
    <w:r>
        <w:t>}</w:t>
    </w:r>
    <w:r>
        <w:t>{</w:t>
    </w:r>
    <w:proofErr w:type="spellStart"/>
    <w:r>
        <w:t>my_</w:t>
    </w:r>
    <w:r>
        <w:t>second</w:t>
    </w:r>
    <w:r>
        <w:t>_tag</w:t>
    </w:r>
    <w:proofErr w:type="spellEnd"/>
    <w:r>
        <w:t>}</w:t>
    </w:r>
</w:p>

{my_third_tag}

<w:p w:rsidR="00EC3159" w:rsidRDefault="00EC3159" w:rsidP="00EC3159">
    <w:r>
        <w:t>{my_third_tag}</w:t>
    </w:r>
</w:p>

I'm not sure about the real reason, but I think the seeker confused the start and end of the raw tags.

I'm a little noob in this, please can anyone help me?, is there other way to add line breaks?

@edi9999
Copy link
Member

edi9999 commented Oct 21, 2015

http://docxtemplater.readthedocs.org/en/latest/syntax.html#raw-xml-syntax

The raw xml syntax replaces the whole contents of a paragraph w:p so any additional text in the paragraph will seem to have been "deleted"

@glendel
Copy link

glendel commented Oct 22, 2015

Hello guys, really awesome library, I am pretty happy with it! :) But sadly I am having the same issue, any workaround ? How could I do something like what @jefraroce says above, something like :

{@my_first_tag}{my_second_tag}

or like :

{@my_first_tag}{@my_second_tag}

Maybe I am not using the library as it must, or I am not creating the XML with the best structure, actually, and to be honest I did not understand pretty well what @edi9999 means with his comment! Sorry about! What do you mean, is it possible, is it a bug, is it a missing feature or just we are not using the library as it must ?

Please any help would be appreciated.

Thanks, and again it is an amazing library, congratulations! :)

@edi9999
Copy link
Member

edi9999 commented Oct 22, 2015

Writing

{@my_first_tag}{my_second_tag}

Or even

Hello {@my_first_tag}

Is misusing docxtemplater.

The @ at the beginning means "replace the xml of the current paragraph with scope.my_first_tag" so that means that everything else in that Paragraph will be removed.

A workaround is to put the text of the second tag in the first tag. (The tag must of course be valid xml)

@jefraroce
Copy link
Author

I think that could be a solution to the problem with line breaks, if we can add "\n" to the normal tags {my_tag}, so, the library could be replace them with

<w:br/> 

directly. Maybe it could work!

@edi9999
Copy link
Member

edi9999 commented Oct 23, 2015

@jefraroce I won't be implementing \n to <w:br/> because it would increase complexity a lot (and could provoke side-effects) . See #159

@jefraroce
Copy link
Author

@edi9999 and @glendel Thank you very much for your answers and for your time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants