docx
docx copied to clipboard
i want new paragraph(enter) not new lines(shift+enter)
when add \n in text and then export to docx (\n = pic 1)
i'm use paragraph mark for see shift+enter or enter
but i need a enter not shift+enter
pic 1 shift+enter
pic 2 enter only
@nguyenthenguyen pls help me
@Sakarin23479 This is just a simple project for text replacement in DOCX files. If you want to handle the situation you mentioned, it would be necessary to process the content in XML format. It seems that the current project does not have this capability.
It's difference between hardline and softline. Maybe this is what you need.
const TAB = "</w:t><w:tab/><w:t>"
const NEWLINE = "</w:t><w:br/><w:t>" //<w:p></w:p>
const HARDLINE = "</w:t><w:p></w:p><w:t>"
func encode(s string) (string, error) {
var b bytes.Buffer
enc := xml.NewEncoder(bufio.NewWriter(&b))
if err := enc.Encode(s); err != nil {
return s, err
}
output := strings.Replace(b.String(), "<string>", "", 1) // remove string tag
output = strings.Replace(output, "</string>", "", 1)
output = strings.Replace(output, "
", NEWLINE, -1) // \r\n (Windows newline)
output = strings.Replace(output, "
", NEWLINE, -1) // \r (earlier Mac newline)
output = strings.Replace(output, "
", NEWLINE, -1) // \n (unix/linux/OS X newline)
output = strings.Replace(output, "", HARDLINE, -1) // \n (unix/linux/OS X newline)
output = strings.Replace(output, "	", TAB, -1) // \t (tab)
return output, nil
}
I fix this.