mirror of
https://github.com/aelve/guide.git
synced 2024-12-23 12:52:31 +03:00
[GD-10] improve extractFirstParagraph function
This commit is contained in:
parent
01bd067bdb
commit
49180082c2
@ -31,6 +31,7 @@ module Guide.Markdown
|
||||
-- * Misc
|
||||
renderMD,
|
||||
markdownNull,
|
||||
extractFirstParagraph,
|
||||
)
|
||||
where
|
||||
|
||||
@ -139,6 +140,12 @@ stringify = T.concat . map go
|
||||
HTML_BLOCK _ -> ""
|
||||
HTML_INLINE _ -> ""
|
||||
|
||||
-- | Extracts the first paragraph.
|
||||
extractFirstParagraph :: Text -> MarkdownBlock
|
||||
extractFirstParagraph = toMarkdownBlock . annSource . preface . toMdTree
|
||||
where
|
||||
toMdTree = markdownBlockWithTOCMdTree . toMarkdownBlockWithTOC ""
|
||||
|
||||
-- | Flatten Markdown by concatenating all block elements.
|
||||
extractInlines :: [MD.Node] -> [MD.Node]
|
||||
extractInlines = concatMap go
|
||||
|
@ -46,7 +46,6 @@ import Data.IP
|
||||
import Data.Time.Format.Human
|
||||
-- Mustache (templates)
|
||||
import qualified Data.Aeson as A
|
||||
|
||||
import Guide.Config
|
||||
import Guide.State
|
||||
import Guide.Types
|
||||
@ -701,6 +700,8 @@ renderSearchResult r = do
|
||||
SRCategory cat -> do
|
||||
a_ [class_ "category-link", href_ (categoryLink cat)] $
|
||||
toHtml (cat^.title)
|
||||
div_ [class_ "category-description notes-like"] $
|
||||
toHtml (extractFirstParagraph $ cat^.notes^.mdText)
|
||||
SRItem cat item -> do
|
||||
a_ [class_ "category-link in-item-sr", href_ (categoryLink cat)] $
|
||||
toHtml (cat^.title)
|
||||
|
Loading…
Reference in New Issue
Block a user