Skip to content

Commit

Permalink
more progress
Browse files Browse the repository at this point in the history
  • Loading branch information
jgm committed Jan 13, 2024
1 parent 636f48f commit 45f25f0
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions src/Text/Pandoc/Readers/Djot.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ data Env =
deriving (Show, Ord, Eq)

convertBlocks :: PandocMonad m => D.Blocks -> ReaderT Env m Blocks
convertBlocks = fmap mconcat . mapM convertBlock . F.toList . D.unBlocks
convertBlocks = fmap mconcat . mapM convertBlock . F.toList . D.unBlocks

convertBlock :: PandocMonad m => D.Node D.Block -> ReaderT Env m Blocks
convertBlock (D.Node attr bl) = addAttrToBlock attr <$>
Expand All @@ -74,12 +74,30 @@ convertBlock (D.Node attr bl) = addAttrToBlock attr <$>
D.CodeBlock lang bs -> pure $
codeBlockWith ("", [UTF8.toText lang], []) $ UTF8.toText bs
D.Div bls -> divWith nullAttr <$> convertBlocks bls
D.OrderedList listAttr listSpacing items -> pure mempty -- TODO
D.BulletList listSpacing items -> pure mempty -- TODO
D.TaskList listSpacing items -> pure mempty -- TODO -- [(TaskStatus, Blocks)]
D.DefinitionList listSpacing items -> pure mempty -- TODO -- [(Inlines, Blocks)]
D.OrderedList olattr listSpacing items -> -- TODO handle tight/loose listSpacing
orderedListWith olattr' <$> mapM convertBlocks items
where
olattr' = ( D.orderedListStart olattr
, case D.orderedListStyle olattr of
D.Decimal -> Decimal
D.LetterUpper -> UpperAlpha
D.LetterLower -> LowerAlpha
D.RomanUpper -> UpperRoman
D.RomanLower -> LowerRoman
, case D.orderedListDelim olattr of
D.RightPeriod -> Period
D.RightParen -> OneParen
D.LeftRightParen -> TwoParens
)
D.BulletList listSpacing items -> -- TODO handle listSpacing
bulletList <$> mapM convertBlocks items
D.TaskList listSpacing items -> pure $ para $ str "TASKLIST TODO" -- TODO -- [(TaskStatus, Blocks)]
D.DefinitionList listSpacing items -> -- TODO handle listSpacing
definitionList <$> mapM toDlItem items
where
toDlItem (ils,bls) = (,) <$> convertInlines ils <*> ((:[]) <$> convertBlocks bls)
D.ThematicBreak -> pure horizontalRule
D.Table mbCaption rows -> pure mempty -- TODO -- [[Cell]]
D.Table mbCaption rows -> pure $ para $ str "TABLE TODO" -- TODO -- [[Cell]]
D.RawBlock (D.Format fmt) bs -> pure $
rawBlock (UTF8.toText fmt) (UTF8.toText bs)

Expand Down

0 comments on commit 45f25f0

Please sign in to comment.