docx icon indicating copy to clipboard operation
docx copied to clipboard

Adding a validator

Open martijn10kb opened this issue 2 years ago • 4 comments

Currently it is possible to add a paragraph inside a paragraph. And having documents with more then 200 pages in a production environment makes it sometimes quite cumbersome to debug what went wrong. Especially because of word failing to give any error message whatsoever.

It would be really nice if there would be a validator that raises an exception as soon as you try to add a paragraph inside a paragraph, or any other illegal action.

martijn10kb avatar Oct 25 '23 14:10 martijn10kb

It should be captured by type definitions, so it shouldn't be possible to add a paragraph inside a paragraph. It wouldn't compile

dolanmiu avatar Oct 26 '23 22:10 dolanmiu

No, this is not true at all. We use the type definitions heavily, but we are still able to do this very easily

Op vr 27 okt. 2023 00:14 schreef Dolan @.***>:

It should be captured by type definitions, so it shouldn't be possible to add a paragraph inside a paragraph. It wouldn't compile

— Reply to this email directly, view it on GitHub https://github.com/dolanmiu/docx/issues/2395#issuecomment-1781964246, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANSQXPEJ6LWQPRSBWV4EKZ3YBLOGDAVCNFSM6AAAAAA6POTGVCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBRHE3DIMRUGY . You are receiving this because you authored the thread.Message ID: @.***>

martijn10kb avatar Oct 27 '23 05:10 martijn10kb

@dolanmiu Could you reopen this? I think you misunderstood me.

martijn10kb avatar Oct 30 '23 20:10 martijn10kb

Oh I see

Then there is something wrong with the type definitions.

Regarding a validator: docx uses https://github.com/ChristophWurst/xmllint-action to validate the generated xml against https://github.com/dolanmiu/docx/blob/master/ooxml-schemas/microsoft/wml-2010.xsd

Maybe you could implement something similar?

dolanmiu avatar Oct 30 '23 23:10 dolanmiu