Skip to content

Google Docs (Docx) <li>'s have <blockquotes> inside #8836

Closed
@StephanMeijer

Description

@StephanMeijer

Attachments

List Item Test.docx

Problem

In conversion .docx -> .html, all <li>'s have blockquotes inside.

This is likely because Google Docs doesn't add a pStyle in the pPr of list (items) where Microsoft Word does:

Google Docx' `document.xml`
        <w:p w:rsidR="00000000" w:rsidDel="00000000" w:rsidP="00000000" w:rsidRDefault="00000000" w:rsidRPr="00000000"
             w14:paraId="00000012">
            <w:pPr>
                <w:numPr>
                    <w:ilvl w:val="0"/>
                    <w:numId w:val="1"/>
                </w:numPr>
                <w:ind w:left="720" w:hanging="360"/>
                <w:rPr>
                    <w:u w:val="none"/>
                </w:rPr>
            </w:pPr>
            <w:r w:rsidDel="00000000" w:rsidR="00000000" w:rsidRPr="00000000">
                <w:rPr>
                    <w:rtl w:val="0"/>
                </w:rPr>
                <w:t xml:space="preserve">It uses ‘-’ in the source document.</w:t>
            </w:r>
        </w:p>
Microsoft Word' `document.xml`
       <w:p w:rsidR="00E71277" w:rsidRDefault="00E71277" w:rsidP="00E71277">
            <w:pPr>
                <w:pStyle w:val="Normaalweb"/>
                <w:numPr>
                    <w:ilvl w:val="0"/>
                    <w:numId w:val="1"/>
                </w:numPr>
                <w:shd w:val="clear" w:color="auto" w:fill="FFFFFF"/>
                <w:spacing w:before="0" w:beforeAutospacing="0" w:after="225" w:afterAutospacing="0"/>
                <w:jc w:val="both"/>
                <w:rPr>
                    <w:rFonts w:ascii="Open Sans" w:hAnsi="Open Sans" w:cs="Open Sans"/>
                    <w:color w:val="000000"/>
                    <w:sz w:val="21"/>
                    <w:szCs w:val="21"/>
                    <w:lang w:val="en-US"/>
                </w:rPr>
            </w:pPr>
            <w:proofErr w:type="spellStart"/>
            <w:r>
                <w:rPr>
                    <w:rFonts w:ascii="Open Sans" w:hAnsi="Open Sans" w:cs="Open Sans"/>
                    <w:color w:val="000000"/>
                    <w:sz w:val="21"/>
                    <w:szCs w:val="21"/>
                    <w:lang w:val="en-US"/>
                </w:rPr>
                <w:t>Een</w:t>
            </w:r>
            <w:proofErr w:type="spellEnd"/>
            <w:r>
                <w:rPr>
                    <w:rFonts w:ascii="Open Sans" w:hAnsi="Open Sans" w:cs="Open Sans"/>
                    <w:color w:val="000000"/>
                    <w:sz w:val="21"/>
                    <w:szCs w:val="21"/>
                    <w:lang w:val="en-US"/>
                </w:rPr>
                <w:t xml:space="preserve"> </w:t>
            </w:r>
            <w:proofErr w:type="spellStart"/>
            <w:r>
                <w:rPr>
                    <w:rFonts w:ascii="Open Sans" w:hAnsi="Open Sans" w:cs="Open Sans"/>
                    <w:color w:val="000000"/>
                    <w:sz w:val="21"/>
                    <w:szCs w:val="21"/>
                    <w:lang w:val="en-US"/>
                </w:rPr>
                <w:t>ongeordende</w:t>
            </w:r>
            <w:proofErr w:type="spellEnd"/>
            <w:r>
                <w:rPr>
                    <w:rFonts w:ascii="Open Sans" w:hAnsi="Open Sans" w:cs="Open Sans"/>
                    <w:color w:val="000000"/>
                    <w:sz w:val="21"/>
                    <w:szCs w:val="21"/>
                    <w:lang w:val="en-US"/>
                </w:rPr>
                <w:t xml:space="preserve"> </w:t>
            </w:r>
            <w:proofErr w:type="spellStart"/>
            <w:r>
                <w:rPr>
                    <w:rFonts w:ascii="Open Sans" w:hAnsi="Open Sans" w:cs="Open Sans"/>
                    <w:color w:val="000000"/>
                    <w:sz w:val="21"/>
                    <w:szCs w:val="21"/>
                    <w:lang w:val="en-US"/>
                </w:rPr>
                <w:t>lijst</w:t>
            </w:r>
            <w:proofErr w:type="spellEnd"/>
        </w:p>

I suspect the error might be in src/Text/Pandoc/Readers/Docx.hs:

src/Text/Pandoc/Readers/Docx.hs
paragraphStyleToTransform :: PandocMonad m => ParagraphStyle -> DocxContext m (Blocks -> Blocks)
paragraphStyleToTransform pPr =
  let stylenames = map getStyleName (pStyle pPr)
      transform = if (`elem` listParagraphStyles) `any` stylenames || relativeIndent pPr <= 0
                  then id
                  else blockQuote
  in do
    extStylesEnabled <- asks (isEnabled Ext_styles . docxOptions)
    return $ foldr (\parStyle transform' ->
        (parStyleToTransform extStylesEnabled parStyle) . transform'
      ) transform (pStyle pPr)

parStyleToTransform :: Bool -> ParStyle -> Blocks -> Blocks
parStyleToTransform extStylesEnabled parStyle@(getStyleName -> styleName)
  | (styleName `elem` divsToKeep) || (styleName `elem` listParagraphStyles) =
      divWith ("", [normalizeToClassName styleName], [])
  | otherwise =
      (if extStylesEnabled then divWith (extraAttr parStyle) else id)
      . (if isBlockQuote parStyle then blockQuote else id)

Version

Latest commit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions