aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/AsciiDoc.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2025-11-29 14:55:22 +0100
committerJohn MacFarlane <[email protected]>2025-11-29 14:55:22 +0100
commitf17504fc6ef52b123661f607064caeedfd416ef6 (patch)
treea1341c426b940dff349252985b9279ab0ed5b8ba /src/Text/Pandoc/Readers/AsciiDoc.hs
parentd3111733e9e0ec5477ccd0e3a383d7cf5af95a6d (diff)
Use latest asciidoc, support counters.asciidoc-reader
Diffstat (limited to 'src/Text/Pandoc/Readers/AsciiDoc.hs')
-rw-r--r--src/Text/Pandoc/Readers/AsciiDoc.hs13
1 files changed, 10 insertions, 3 deletions
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