diff options
| -rw-r--r-- | cabal.project | 2 | ||||
| -rw-r--r-- | src/Text/Pandoc/Readers/AsciiDoc.hs | 13 | ||||
| -rw-r--r-- | stack.yaml | 2 | ||||
| -rw-r--r-- | test/asciidoc-reader.native | 46 |
4 files changed, 41 insertions, 22 deletions
diff --git a/cabal.project b/cabal.project index df97ccac3..cd32b33b0 100644 --- a/cabal.project +++ b/cabal.project @@ -30,4 +30,4 @@ source-repository-package source-repository-package type: git location: https://github.com/jgm/asciidoc-hs.git - tag: d92676a1e88e474fcd85ec29c6d4f40f4a95be59 + tag: 91cbc83837feafea827211f128528d05eaa69d4b diff --git a/src/Text/Pandoc/Readers/AsciiDoc.hs b/src/Text/Pandoc/Readers/AsciiDoc.hs index 608160f97..44e5d8c47 100644 --- a/src/Text/Pandoc/Readers/AsciiDoc.hs +++ b/src/Text/Pandoc/Readers/AsciiDoc.hs @@ -38,7 +38,7 @@ import Text.Pandoc.Logging import Text.Pandoc.Sources import Control.Monad.State import Data.List (intersperse, foldl') -import Data.Char (chr) +import Data.Char (chr, ord) import qualified Data.Text as T import qualified Data.Map as M import Data.Maybe (fromMaybe) @@ -59,8 +59,9 @@ readAsciiDoc _opts inp = do >>= toPandoc where getIncludeFile fp = UTF8.toText <$> readFileStrict fp - raiseError pos msg = throwError $ PandocParseError $ T.pack - $ msg <> " at position " <> show pos + raiseError fp pos msg = throwError $ PandocParseError $ T.pack + $ msg <> " at " <> show fp <> + " char " <> show pos toPandoc :: PandocMonad m => A.Document -> m Pandoc toPandoc doc = @@ -393,6 +394,12 @@ doInline (A.Inline (A.Attr _ps kvs') it) = do pure $ B.spanWith ("",["index"],[("term",t)]) (B.text t) A.IndexEntry (A.TermConcealed ts) -> pure $ B.spanWith ("",["index"],[("term",T.intercalate "," ts)]) mempty + A.Counter name ctype val -> + pure $ B.spanWith ("",["counter"],[("name",name)]) $ B.str $ + case ctype of + A.DecimalCounter -> tshow val + A.UpperAlphaCounter -> T.singleton $ chr (ord 'A' + val - 1) + A.LowerAlphaCounter -> T.singleton $ chr (ord 'a' + val - 1) -- Passthrough is hard to get right, because pandoc's RawInline needs -- a format specifier. Often in asciidoc passthrough is used as a form -- of escaping, so the best approach seems to be treating it as HTML diff --git a/stack.yaml b/stack.yaml index ba1199683..b531cfd0e 100644 --- a/stack.yaml +++ b/stack.yaml @@ -23,7 +23,7 @@ extra-deps: - git: https://github.com/jgm/djoths.git commit: 7dc8da53fc092d2d4d91f5f0988840f4faf90368 - git: https://github.com/jgm/asciidoc-hs.git - commit: d92676a1e88e474fcd85ec29c6d4f40f4a95be59 + commit: 91cbc83837feafea827211f128528d05eaa69d4b ghc-options: "$locals": -fhide-source-paths -Wno-missing-home-modules resolver: lts-24.20 diff --git a/test/asciidoc-reader.native b/test/asciidoc-reader.native index 6349c697b..106407f84 100644 --- a/test/asciidoc-reader.native +++ b/test/asciidoc-reader.native @@ -1223,23 +1223,35 @@ Pandoc , Str "Grail" ] ] - , BlockQuote - [ Para - [ Str "Roads?" - , Space - , Str "Where" - , Space - , Str "we\8217re" - , Space - , Str "going," - , Space - , Str "we" - , Space - , Str "don\8217t" - , Space - , Str "need" - , Space - , Str "roads." + , Div + ( "roads" , [ "movie" ] , [ ( "wrapper" , "1" ) ] ) + [ BlockQuote + [ Para + [ Str "Roads?" + , Space + , Str "Where" + , Space + , Str "we\8217re" + , Space + , Str "going," + , Space + , Str "we" + , Space + , Str "don\8217t" + , Space + , Str "need" + , Space + , Str "roads." + ] + , Para + [ Str "\8212" + , Space + , Str "Dr." + , Space + , Str "Emmett" + , Space + , Str "Brown" + ] ] ] , Header 2 ( "_pass" , [] , [] ) [ Str "Pass" ] |
