Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
name: github-action

on: [push, pull_request]
on: [push, pull_request]

jobs:
build:
strategy:
fail-fast: false
matrix:
ghc: ['8.6.5', '8.8.4']
ghc: ['8.6.5', '8.8.4', '8.10.7', '9.0.2', '9.2.5', '9.4.5', '9.6.1', '9.8.2', '9.10.1', '9.12.1']
os: ['ubuntu-latest', 'macos-latest']
runs-on: ${{ matrix.os }}

name: GHC ${{ matrix.ghc }} on ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-haskell@v1

- uses: actions/checkout@v3

- uses: haskell-actions/[email protected]
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: '3.10.3.0'

- name: Cache
uses: actions/cache@v1
uses: actions/cache@v3
env:
cache-name: cache-cabal
with:
Expand All @@ -33,7 +38,12 @@ jobs:
run: |
cabal update
cabal build --only-dependencies --enable-tests --enable-benchmarks

- name: Build
run: cabal build --enable-tests --enable-benchmarks all

- name: Run tests
run: cabal test all
run: cabal test --enable-tests all

- name: Build Docs
run: cabal haddock
10 changes: 4 additions & 6 deletions dombuilder-pandoc.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ extra-source-files: CHANGELOG.md
library
exposed-modules: Reflex.Dom.Builder.Pandoc
Reflex.Dom.Builder.Pandoc.RawHtml
build-depends: base >=4.12 && <4.15
, containers >= 0.6 && <0.7
build-depends: base >=4.12 && <4.22
, containers >= 0.6 && <0.8
, html-parse >= 0.2 && <0.3
, pandoc-types >= 1.22 && <1.23
, pandoc-types >= 1.23 && <1.24
, reflex-dom-core >= 0.7 && < 0.9
, text >= 1.2 && <1.3
-- We don't actually need aeson, but pandoc-types has a too-lenient bound
, aeson >= 1.4 && <2.2
, text >= 1.2 && <2.2
hs-source-dirs: src
default-language: Haskell2010
ghc-options: -Wall
19 changes: 12 additions & 7 deletions src/Reflex/Dom/Builder/Pandoc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ attr (ident, classes, other) = Map.fromListWith (\a b -> a <> " " <> b) $
, ("class", T.intercalate " " classes)
] <> other

caption :: DomBuilder t m => Caption -> m ()
caption = \case
Caption (Just short) xs -> do
mapM_ inline short
mapM_ block xs
Caption Nothing xs -> mapM_ block xs

block :: DomBuilder t m => Block -> m ()
block = \case
Plain xs -> mapM_ inline xs
Expand All @@ -42,16 +49,15 @@ block = \case
Header lvl a xs -> elAttr ("h" <> T.pack (show lvl)) (attr a) $
mapM_ inline xs
HorizontalRule -> el "hr" $ pure ()
Table a caption _colSpecs (TableHead hattrs hrows) tbody (TableFoot fattrs frows) ->
Figure a cap xs -> elAttr "figure" (attr a) $ do
el "figcaption" $ caption cap
mapM_ block xs
Table a cap _colSpecs (TableHead hattrs hrows) tbody (TableFoot fattrs frows) ->
-- TODO: format columns
-- TODO: format cells
-- TODO: handle intermediate table heads in body
elAttr "table" (attr a) $ do
el "caption" $ case caption of
(Caption (Just short) xs) -> do
mapM_ inline short
mapM_ block xs
(Caption Nothing xs) -> mapM_ block xs
el "caption" $ caption cap
let mkRow cell (Row ra cs) = elAttr "tr" (attr ra) $
mapM_ (\(Cell ca _align _rowSpan _colSpan ys) ->
elAttr cell (attr ca) $ mapM_ block ys) cs
Expand All @@ -60,7 +66,6 @@ block = \case
elAttr "tbody" (attr ba) $ mapM_ (mkRow "td") cs
elAttr "tfoot" (attr fattrs) $ mapM_ (mkRow "td") frows
Div a xs -> elAttr "div" (attr a) $ mapM_ block xs
Null -> blank
where
listStyle = \case
DefaultStyle -> mempty
Expand Down
Loading