Skip to content

Commit

Permalink
Add CustomFormat, modify JATS sub-format relation
Browse files Browse the repository at this point in the history
The new CustomFormat will allow for filter writers to use raw elements
with custom formats, and to use custom formats in
conditionally-rendered elements. They are invisible to castsToKnown
and knownMatch.

The Formats type had to be modified to accommodate that change, and
additional conversion and convenience functions were added.

jats_articleauthoring is a super-format of jats_publishing. The
listSubformats relation was modified to take this into account.
  • Loading branch information
despresc committed Sep 6, 2020
1 parent 5ccd7ba commit 80f9bd7
Show file tree
Hide file tree
Showing 3 changed files with 258 additions and 146 deletions.
11 changes: 9 additions & 2 deletions src/Text/Pandoc/Arbitrary.hs
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,16 @@ instance Arbitrary ListNumberDelim where
3 -> return TwoParens
_ -> error "FATAL ERROR: Arbitrary instance, logic bug"

instance Arbitrary F.Format where
instance Arbitrary F.KnownFormat where
arbitrary = arbitraryBoundedEnum

instance Arbitrary F.Format where
arbitrary = frequency $ [(80, F.KnownFormat <$> arbitrary)
,(20, F.CustomFormat . T.pack <$> arbitrary)]
shrink F.KnownFormat{} = []
shrink (F.CustomFormat t) = F.CustomFormat <$> shrinkText t

instance Arbitrary F.Formats where
arbitrary = F.exactly <$> arbitrary
shrink (F.Formats s) = F.exactly <$> shrink (Set.toList s)
shrink (F.OneOfFormats s) = F.exactly <$> shrink (Set.toList s)
shrink (F.NoneOfFormats s) = F.exactlyNone <$> shrink (Set.toList s)
Loading

0 comments on commit 80f9bd7

Please sign in to comment.