You may have (partially) answered your own question.
You may have a Mix of (indent) styles that confuses Calibre.
There are multiple setting places that can be used to deal with some of these during conversion. (from your description, you have been using OUTPUT options.
There are 3 areas: Input, common and output. Each affects the conversion pipeline at some point You need to understand YOUR documents internal construction, then adjust each step as needed . spaces vs tab vs margin/indent change