djot 0.1.1.3 → 0.1.2
raw patch · 4 files changed
+58/−53 lines, 4 filesdep +template-haskelldep ~basedep ~bytestringdep ~containersPVP ok
version bump matches the API change (PVP)
Dependencies added: template-haskell
Dependency ranges changed: base, bytestring, containers
API changes (from Hackage documentation)
+ Djot.AST: instance Language.Haskell.TH.Syntax.Lift Djot.AST.Align
+ Djot.AST: instance Language.Haskell.TH.Syntax.Lift Djot.AST.Attr
+ Djot.AST: instance Language.Haskell.TH.Syntax.Lift Djot.AST.Block
+ Djot.AST: instance Language.Haskell.TH.Syntax.Lift Djot.AST.Caption
+ Djot.AST: instance Language.Haskell.TH.Syntax.Lift Djot.AST.Cell
+ Djot.AST: instance Language.Haskell.TH.Syntax.Lift Djot.AST.CellType
+ Djot.AST: instance Language.Haskell.TH.Syntax.Lift Djot.AST.Doc
+ Djot.AST: instance Language.Haskell.TH.Syntax.Lift Djot.AST.Format
+ Djot.AST: instance Language.Haskell.TH.Syntax.Lift Djot.AST.Inline
+ Djot.AST: instance Language.Haskell.TH.Syntax.Lift Djot.AST.ListSpacing
+ Djot.AST: instance Language.Haskell.TH.Syntax.Lift Djot.AST.MathStyle
+ Djot.AST: instance Language.Haskell.TH.Syntax.Lift Djot.AST.NoteMap
+ Djot.AST: instance Language.Haskell.TH.Syntax.Lift Djot.AST.OrderedListAttributes
+ Djot.AST: instance Language.Haskell.TH.Syntax.Lift Djot.AST.OrderedListDelim
+ Djot.AST: instance Language.Haskell.TH.Syntax.Lift Djot.AST.OrderedListStyle
+ Djot.AST: instance Language.Haskell.TH.Syntax.Lift Djot.AST.Pos
+ Djot.AST: instance Language.Haskell.TH.Syntax.Lift Djot.AST.QuoteType
+ Djot.AST: instance Language.Haskell.TH.Syntax.Lift Djot.AST.ReferenceMap
+ Djot.AST: instance Language.Haskell.TH.Syntax.Lift Djot.AST.Target
+ Djot.AST: instance Language.Haskell.TH.Syntax.Lift Djot.AST.TaskStatus
+ Djot.AST: instance Language.Haskell.TH.Syntax.Lift a => Language.Haskell.TH.Syntax.Lift (Djot.AST.Many a)
+ Djot.AST: instance Language.Haskell.TH.Syntax.Lift a => Language.Haskell.TH.Syntax.Lift (Djot.AST.Node a)
Files
- CHANGELOG.md +6/−0
- djot.cabal +27/−31
- src/Djot/AST.hs +24/−22
- src/Djot/Inlines.hs +1/−0
CHANGELOG.md view
@@ -1,5 +1,11 @@ # Revision history for djot +## 0.1.2 -- 2024-05-10++* Allow `_` in symbols (see jgm/djot#296).++* Add Lift derivations to AST datatypes (#5, Gideon Farrell) [API change].+ ## 0.1.1.3 -- 2024-03-17 * Ensure that tables end when we hit a blank line (#4).
djot.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: djot-version: 0.1.1.3+version: 0.1.2 synopsis: Parser and renderer for djot light markup syntax. description: Djot (<https://djot.net>) is a light markup language. This package provides a data structure to represent@@ -17,13 +17,18 @@ extra-source-files: test/*.test benchmark/m.dj +common deps+ build-depends:+ base >= 4.12 && < 5,+ bytestring >= 0.11.3,+ doclayout+ Library- build-depends: base >= 4.12 && < 5,- bytestring >= 0.11.3,- containers,- mtl,+ import: deps+ build-depends: mtl,+ containers >= 0.6.6, text,- doclayout+ template-haskell hs-source-dirs: src default-language: Haskell2010 exposed-modules: Djot@@ -38,49 +43,40 @@ ghc-options: -Wall -O2 executable djoths+ import: deps main-is: Main.hs- build-depends: base >= 4.12 && < 5,- djot,- bytestring,- containers,- text,- doclayout+ build-depends: djot,+ text hs-source-dirs: app default-language: Haskell2010 ghc-options: -Wall -O2 -rtsopts -threaded test-suite test-djot+ import: deps type: exitcode-stdio-1.0 main-is: Main.hs hs-source-dirs: test ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-K40K -with-rtsopts=-kc40K if impl(ghc >= 8.10) ghc-options: -Wunused-packages- build-depends:- base >= 4.12 && <5- , djot- , text- , bytestring- , directory- , filepath- , doclayout- , tasty- , tasty-hunit- , tasty-quickcheck+ build-depends: djot,+ directory,+ filepath,+ tasty,+ tasty-hunit,+ tasty-quickcheck,+ text default-language: Haskell2010 benchmark benchmark-djot+ import: deps type: exitcode-stdio-1.0 main-is: Main.hs hs-source-dirs: benchmark- build-depends:- djot- , base >= 4.9 && < 5- , bytestring- , directory- , filepath- , doclayout- , tasty-bench+ build-depends: djot,+ directory,+ filepath,+ tasty-bench ghc-options: -O2 -threaded -rtsopts -with-rtsopts=-K10K -with-rtsopts=-kc10K if impl(ghc >= 8.10) ghc-options: -Wunused-packages
src/Djot/AST.hs view
@@ -5,6 +5,7 @@ {-# LANGUAGE DeriveTraversable #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE DeriveLift #-} module Djot.AST ( Inline(..), Many(..),@@ -87,11 +88,12 @@ import Data.Data (Data, Typeable) import qualified Data.ByteString.Char8 as B8 import GHC.Generics (Generic)+import Language.Haskell.TH.Syntax (Lift (..)) -- import Debug.Trace newtype Attr = Attr [(ByteString, ByteString)]- deriving (Show, Eq, Ord, Typeable, Data, Generic)+ deriving (Show, Eq, Ord, Typeable, Data, Generic, Lift) instance Semigroup Attr where Attr as <> Attr bs =@@ -112,7 +114,7 @@ | otherwise -> kvs data Pos = NoPos | Pos Int Int Int Int -- start line, start col, end line, end col- deriving (Show, Eq, Ord, Typeable, Data, Generic)+ deriving (Show, Eq, Ord, Typeable, Data, Generic, Lift) instance Semigroup Pos where Pos sl1 sc1 _ _ <> Pos _ _ el2 ec2 =@@ -125,7 +127,7 @@ mempty = NoPos data Node a = Node Pos Attr a- deriving (Show, Eq, Ord, Functor, Traversable, Foldable, Typeable, Data, Generic)+ deriving (Show, Eq, Ord, Functor, Traversable, Foldable, Typeable, Data, Generic, Lift) {-# INLINE addAttr #-} addAttr :: Attr -> Node a -> Node a@@ -136,18 +138,18 @@ addPos pos (Node _ attr bs) = Node pos attr bs newtype Format = Format { unFormat :: ByteString }- deriving (Show, Eq, Ord, Typeable, Data, Generic)+ deriving (Show, Eq, Ord, Typeable, Data, Generic, Lift) data MathStyle = DisplayMath | InlineMath- deriving (Show, Ord, Eq, Typeable, Data, Generic)+ deriving (Show, Ord, Eq, Typeable, Data, Generic, Lift) data Target = Direct ByteString | Reference ByteString- deriving (Show, Ord, Eq, Typeable, Data, Generic)+ deriving (Show, Ord, Eq, Typeable, Data, Generic, Lift) data QuoteType = SingleQuotes | DoubleQuotes- deriving (Show, Ord, Eq, Typeable, Data, Generic)+ deriving (Show, Ord, Eq, Typeable, Data, Generic, Lift) data Inline = Str ByteString@@ -172,10 +174,10 @@ | Quoted QuoteType Inlines | SoftBreak | HardBreak- deriving (Show, Ord, Eq, Typeable, Data, Generic)+ deriving (Show, Ord, Eq, Typeable, Data, Generic, Lift) newtype Many a = Many { unMany :: Seq a }- deriving (Show, Ord, Eq, Functor, Traversable, Foldable, Typeable, Data, Generic)+ deriving (Show, Ord, Eq, Functor, Traversable, Foldable, Typeable, Data, Generic, Lift) type Inlines = Many (Node Inline) @@ -216,37 +218,37 @@ mempty = Many mempty data ListSpacing = Tight | Loose- deriving (Show, Ord, Eq, Typeable, Data, Generic)+ deriving (Show, Ord, Eq, Typeable, Data, Generic, Lift) data OrderedListStyle = Decimal | LetterUpper | LetterLower | RomanUpper | RomanLower- deriving (Show, Ord, Eq, Typeable, Data, Generic)+ deriving (Show, Ord, Eq, Typeable, Data, Generic, Lift) data OrderedListDelim = RightPeriod | RightParen | LeftRightParen- deriving (Show, Ord, Eq, Typeable, Data, Generic)+ deriving (Show, Ord, Eq, Typeable, Data, Generic, Lift) data OrderedListAttributes = OrderedListAttributes { orderedListStyle :: OrderedListStyle , orderedListDelim :: OrderedListDelim , orderedListStart :: Int }- deriving (Show, Ord, Eq, Typeable, Data, Generic)+ deriving (Show, Ord, Eq, Typeable, Data, Generic, Lift) data TaskStatus = Complete | Incomplete- deriving (Show, Ord, Eq, Typeable, Data, Generic)+ deriving (Show, Ord, Eq, Typeable, Data, Generic, Lift) newtype Caption = Caption Blocks- deriving (Show, Ord, Eq, Typeable, Data, Generic)+ deriving (Show, Ord, Eq, Typeable, Data, Generic, Lift) data Align = AlignLeft | AlignRight | AlignCenter | AlignDefault- deriving (Show, Ord, Eq, Typeable, Data, Generic)+ deriving (Show, Ord, Eq, Typeable, Data, Generic, Lift) data CellType = HeadCell | BodyCell- deriving (Show, Ord, Eq, Typeable, Data, Generic)+ deriving (Show, Ord, Eq, Typeable, Data, Generic, Lift) data Cell = Cell CellType Align Inlines- deriving (Show, Ord, Eq, Typeable, Data, Generic)+ deriving (Show, Ord, Eq, Typeable, Data, Generic, Lift) data Block = Para Inlines@@ -262,7 +264,7 @@ | ThematicBreak | Table (Maybe Caption) [[Cell]] | RawBlock Format ByteString- deriving (Show, Ord, Eq, Typeable, Data, Generic)+ deriving (Show, Ord, Eq, Typeable, Data, Generic, Lift) type Blocks = Many (Node Block) @@ -279,7 +281,7 @@ , docReferences :: ReferenceMap , docAutoReferences :: ReferenceMap , docAutoIdentifiers :: Set ByteString- } deriving (Show, Ord, Eq, Typeable, Data, Generic)+ } deriving (Show, Ord, Eq, Typeable, Data, Generic, Lift) instance Semigroup Doc where Doc bs ns rs ar ai <> Doc bs' ns' rs' ar' ai' =@@ -291,7 +293,7 @@ -- | A map from labels to contents. newtype NoteMap = NoteMap { unNoteMap :: M.Map ByteString Blocks }- deriving (Show, Ord, Eq, Semigroup, Monoid, Typeable, Data, Generic)+ deriving (Show, Ord, Eq, Semigroup, Monoid, Typeable, Data, Generic, Lift) insertNote :: ByteString -> Blocks -> NoteMap -> NoteMap insertNote label ref (NoteMap m) =@@ -303,7 +305,7 @@ newtype ReferenceMap = ReferenceMap { unReferenceMap :: M.Map ByteString (ByteString, Attr) }- deriving (Show, Ord, Eq, Semigroup, Monoid, Typeable, Data, Generic)+ deriving (Show, Ord, Eq, Semigroup, Monoid, Typeable, Data, Generic, Lift) normalizeLabel :: ByteString -> ByteString normalizeLabel = B8.unwords . B8.splitWith isWs
src/Djot/Inlines.hs view
@@ -215,6 +215,7 @@ asciiChar ':' bs <- byteStringOf $ skipSome (skipSatisfyByte (\c -> c == '+' || c == '-' ||+ c == '_' || (isAscii c && isAlphaNum c))) asciiChar ':' pure $ symbol bs