git.iko.soy/typeable/pandoc
on master help sign in
Replace "emacs" extension with "amuse" extension
3a83b38Alexander Krotov
src/Text/Pandoc/Extensions.hs+4−1
@@ -153,7 +153,7 @@ data Extension =
153 | Ext_smart -- ^ "Smart" quotes, apostrophes, ellipses, dashes
153 | Ext_smart -- ^ "Smart" quotes, apostrophes, ellipses, dashes
154 | Ext_old_dashes -- ^ -- = em, - before number = en
154 | Ext_old_dashes -- ^ -- = em, - before number = en
155 | Ext_spaced_reference_links -- ^ Allow space between two parts of ref link
155 | Ext_spaced_reference_links -- ^ Allow space between two parts of ref link
156− | Ext_emacs -- ^ Try to emulate Emacs Muse instead of Amusewiki
156+ | Ext_amuse -- ^ Enable Text::Amuse extensions to Emacs Muse markup
157 deriving (Show, Read, Enum, Eq, Ord, Bounded, Data, Typeable, Generic)
157 deriving (Show, Read, Enum, Eq, Ord, Bounded, Data, Typeable, Generic)
158
158
159instance ToJSON Extension where
159instance ToJSON Extension where
@@ -315,6 +315,9 @@ getDefaultExtensions "markdown_phpextra" = phpMarkdownExtraExtensions
315getDefaultExtensions "markdown_mmd" = multimarkdownExtensions
315getDefaultExtensions "markdown_mmd" = multimarkdownExtensions
316getDefaultExtensions "markdown_github" = githubMarkdownExtensions
316getDefaultExtensions "markdown_github" = githubMarkdownExtensions
317getDefaultExtensions "markdown" = pandocExtensions
317getDefaultExtensions "markdown" = pandocExtensions
318+getDefaultExtensions "muse" = extensionsFromList
319+ [Ext_amuse,
320+ Ext_auto_identifiers]
318getDefaultExtensions "plain" = plainExtensions
321getDefaultExtensions "plain" = plainExtensions
319getDefaultExtensions "gfm" = githubMarkdownExtensions
322getDefaultExtensions "gfm" = githubMarkdownExtensions
320getDefaultExtensions "org" = extensionsFromList
323getDefaultExtensions "org" = extensionsFromList
src/Text/Pandoc/Readers/Muse.hs+1−1
@@ -423,7 +423,7 @@ definitionListItem = try $ do
423 pure $ do lineContent' <- lineContent
423 pure $ do lineContent' <- lineContent
424 pure (B.text term, [lineContent'])
424 pure (B.text term, [lineContent'])
425 where
425 where
426− termParser = (guardEnabled Ext_emacs <|> void spaceChar) >> -- Initial space is required by Amusewiki, but not Emacs Muse
426+ termParser = (guardDisabled Ext_amuse <|> void spaceChar) >> -- Initial space is required by Amusewiki, but not Emacs Muse
427 many spaceChar >>
427 many spaceChar >>
428 many1Till anyChar (lookAhead (void (try (spaceChar >> string "::")) <|> void newline))
428 many1Till anyChar (lookAhead (void (try (spaceChar >> string "::")) <|> void newline))
429 endOfInput = try $ skipMany blankline >> skipSpaces >> eof
429 endOfInput = try $ skipMany blankline >> skipSpaces >> eof
test/Tests/Readers/Muse.hs+4−8
@@ -10,20 +10,16 @@ import Text.Pandoc
10import Text.Pandoc.Arbitrary ()
10import Text.Pandoc.Arbitrary ()
11import Text.Pandoc.Builder
11import Text.Pandoc.Builder
12
12
13−muse :: Text -> Pandoc
13+amuse :: Text -> Pandoc
14−muse = purely $ \s -> do
14+amuse = purely $ readMuse def { readerExtensions = extensionsFromList [Ext_amuse]}
15− setInputFiles ["in"]
16− setOutputFile (Just "out")
17− readMuse def s
18
15
19emacsMuse :: Text -> Pandoc
16emacsMuse :: Text -> Pandoc
20−emacsMuse = purely $ readMuse def { readerExtensions =
17+emacsMuse = purely $ readMuse def { readerExtensions = emptyExtensions }
21− enableExtension Ext_emacs pandocExtensions }
22
18
23infix 4 =:
19infix 4 =:
24(=:) :: ToString c
20(=:) :: ToString c
25 => String -> (Text, c) -> TestTree
21 => String -> (Text, c) -> TestTree
26−(=:) = test muse
22+(=:) = test amuse
27
23
28spcSep :: [Inlines] -> Inlines
24spcSep :: [Inlines] -> Inlines
29spcSep = mconcat . intersperse space
25spcSep = mconcat . intersperse space
test/Tests/Writers/Muse.hs+3−1
@@ -8,7 +8,9 @@ import Text.Pandoc.Arbitrary ()
8import Text.Pandoc.Builder
8import Text.Pandoc.Builder
9
9
10muse :: (ToPandoc a) => a -> String
10muse :: (ToPandoc a) => a -> String
11−muse = museWithOpts def{ writerWrapText = WrapNone }
11+muse = museWithOpts def{ writerWrapText = WrapNone,
12+ writerExtensions = extensionsFromList [Ext_amuse,
13+ Ext_auto_identifiers] }
12
14
13museWithOpts :: (ToPandoc a) => WriterOptions -> a -> String
15museWithOpts :: (ToPandoc a) => WriterOptions -> a -> String
14museWithOpts opts = unpack . purely (writeMuse opts) . toPandoc
16museWithOpts opts = unpack . purely (writeMuse opts) . toPandoc