@@ -24,6 +24,7 @@ import Property
2424import Reaction
2525import Text.InterpolatedString.QM
2626import Transport
27+ import OrgMode
2728
2829data HelpState = HelpState
2930 { helpStateGistId :: Maybe GistId
@@ -73,28 +74,31 @@ refreshHelpGistId =
7374 Reaction replyMessage
7475
7576gistRenderCommandTable :: CommandTable -> T. Text
76- gistRenderCommandTable =
77- ([qms |* Builtin Commands\n{header}\n|-\n|] <> ) .
78- T. unlines . map renderRow . M. toList
77+ gistRenderCommandTable commandTable = [qms |* Builtin Commands\n{table}\n|]
7978 where
80- header :: T. Text
81- header = " |Name|Description|Location|"
82- renderRow :: (T. Text , BuiltinCommand ) -> T. Text
83- renderRow (name, command) =
84- [qms ||{name}|{bcDescription command}|{location}||]
85- where
86- location :: T. Text
87- location = [qms |[[{bcGitHubLocation command}][Source↗]]|]
79+ table :: T. Text
80+ table =
81+ renderTable [" Name" , " Description" , " Location" ] $
82+ map
83+ (\ (name, command) ->
84+ [ name
85+ , bcDescription command
86+ , [qms |[[{bcGitHubLocation command}][Source↗]]|]
87+ ]) $
88+ M. toList commandTable
8889
8990gistRenderCustomCommandsTable :: [Entity CustomCommand ] -> T. Text
90- gistRenderCustomCommandsTable =
91- ([qms |* Custom commands\n{header}\n|-\n|] <> ) .
92- T. unlines . map (renderRow . entityPayload)
91+ gistRenderCustomCommandsTable customCommands =
92+ [qms |* Custom commands\n{table}\n|]
9393 where
94- header :: T. Text
95- header = " |Name|Definition|%times|"
96- renderRow (CustomCommand name message times) =
97- [qms ||{name}|{message}|{times}||]
94+ table :: T. Text
95+ table =
96+ renderTable [" Name" , " Definition" , " %times" ] $
97+ map
98+ ((\ (CustomCommand name message times) ->
99+ [name, message, T. pack $ show times]) .
100+ entityPayload)
101+ customCommands
98102
99103refreshHelpGist :: CommandTable -> GistId -> Effect ()
100104refreshHelpGist commandTable gistId = do
0 commit comments