packages feed

org-mode-lucid 1.1.1 → 1.2.0

raw patch · 3 files changed

+38/−23 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Data.Org.Lucid: [separator] :: OrgStyle -> Maybe Char
- Data.Org.Lucid: OrgStyle :: Bool -> Maybe TOC -> Bool -> Highlighting -> OrgStyle
+ Data.Org.Lucid: OrgStyle :: Bool -> Maybe TOC -> Bool -> Highlighting -> Maybe Char -> OrgStyle

Files

CHANGELOG.md view
@@ -1,5 +1,13 @@ # Changelog +## 1.2.0 (2020-03-19)++#### Changed++- `OrgStyle` has been given an extra field, `separator` for defining what should+  appear between adjacent elements (e.g. spaces between words).+- `defaultStyle` has been updated to reflect the above.+ ## 1.1.1 (2020-03-13)  #### Fixed
lib/Data/Org/Lucid.hs view
@@ -50,6 +50,10 @@     -- ^ Whether to add Twitter Bootstrap classes to certain elements.   , highlighting    :: Highlighting     -- ^ A function to give @\<code\>@ blocks syntax highlighting.+  , separator       :: Maybe Char+    -- ^ `Char` to insert between elements during rendering, for example having+    -- a space between words. Asian languages, for instance, might want this to+    -- be `Nothing`.   }  -- | Options for rendering a Table of Contents in the document.@@ -67,7 +71,7 @@ -- include Twitter Bootstrap classes. This mirrors the behaviour of Emacs' -- native HTML export functionality. defaultStyle :: OrgStyle-defaultStyle = OrgStyle True (Just $ TOC "Table of Contents" 3) False codeHTML+defaultStyle = OrgStyle True (Just $ TOC "Table of Contents" 3) False codeHTML (Just ' ')  -- | Convert a parsed `OrgFile` into a full HTML document readable in a browser. html :: OrgStyle -> OrgFile -> Html ()@@ -82,27 +86,27 @@ body :: OrgStyle -> OrgFile -> Html () body os (OrgFile m od) = do   when (includeTitle os) . traverse_ (h1_ [class_ "title"] . toHtml) $ M.lookup "TITLE" m-  traverse_ (`toc` od) $ tableOfContents os+  traverse_ (\t -> toc os t od) $ tableOfContents os   orgHTML os od  -- | A unique identifier that can be used as an HTML @id@ attribute. tocLabel :: NonEmpty Words -> T.Text tocLabel = ("org" <>) . T.pack . take 6 . printf "%x" . hash -toc :: TOC -> OrgDoc -> Html ()-toc _ (OrgDoc _ []) = pure ()-toc t od            = h2_ (toHtml $ tocTitle t) *> toc' t 1 od+toc :: OrgStyle -> TOC -> OrgDoc -> Html ()+toc _ _ (OrgDoc _ []) = pure ()+toc os t od           = h2_ (toHtml $ tocTitle t) *> toc' os t 1 od -toc' :: TOC -> Word -> OrgDoc -> Html ()-toc' _ _ (OrgDoc _ []) = pure ()-toc' t depth (OrgDoc _ ss)+toc' :: OrgStyle -> TOC -> Word -> OrgDoc -> Html ()+toc' _ _ _ (OrgDoc _ []) = pure ()+toc' os t depth (OrgDoc _ ss)   | depth > tocDepth t = pure ()   | otherwise = ul_ $ traverse_ f ss   where     f :: Section -> Html ()     f (Section ws _ od) = do-      li_ $ a_ [href_ $ "#" <> tocLabel ws] $ paragraphHTML ws-      toc' t (succ depth) od+      li_ $ a_ [href_ $ "#" <> tocLabel ws] $ paragraphHTML os ws+      toc' os t (succ depth) od  orgHTML :: OrgStyle -> OrgDoc -> Html () orgHTML os = orgHTML' os 1@@ -114,7 +118,7 @@  sectionHTML :: OrgStyle -> Int -> Section -> Html () sectionHTML os depth (Section ws _ od) = do-  heading [id_ $ tocLabel ws] $ paragraphHTML ws+  heading [id_ $ tocLabel ws] $ paragraphHTML os ws   orgHTML' os (succ depth) od   where     heading :: [Attribute] -> Html () -> Html ()@@ -131,9 +135,9 @@   Quote t      -> blockquote_ . p_ $ toHtml t   Example t    -> pre_ [class_ "example"] $ toHtml t   Code l t     -> highlighting os l t-  List is      -> listItemsHTML is+  List is      -> listItemsHTML os is   Table rw     -> tableHTML os rw-  Paragraph ws -> p_ $ paragraphHTML ws+  Paragraph ws -> p_ $ paragraphHTML os ws  -- | Mimicks the functionality of Emacs' native HTML export. codeHTML :: Highlighting@@ -141,23 +145,26 @@   $ pre_ [classes_ $ "src" : maybe [] (\(Language l') -> ["src-" <> l']) l]   $ toHtml t -paragraphHTML :: NonEmpty Words -> Html ()-paragraphHTML (h :| t) = wordsHTML h <> para h t+paragraphHTML :: OrgStyle -> NonEmpty Words -> Html ()+paragraphHTML os (h :| t) = wordsHTML h <> para h t   where+    sep :: Html ()+    sep = maybe "" (toHtml . T.singleton) $ separator os+     para :: Words -> [Words] -> Html ()     para _ [] = ""     para pr (w:ws) = case pr of       Punct '(' -> wordsHTML w <> para w ws       _ -> case w of-        Punct '(' -> " " <> wordsHTML w <> para w ws+        Punct '(' -> sep <> wordsHTML w <> para w ws         Punct _   -> wordsHTML w <> para w ws-        _         -> " " <> wordsHTML w <> para w ws+        _         -> sep <> wordsHTML w <> para w ws -listItemsHTML :: ListItems -> Html ()-listItemsHTML (ListItems is) = ul_ [class_ "org-ul"] $ traverse_ f is+listItemsHTML :: OrgStyle -> ListItems -> Html ()+listItemsHTML os (ListItems is) = ul_ [class_ "org-ul"] $ traverse_ f is   where     f :: Item -> Html ()-    f (Item ws next) = li_ $ paragraphHTML ws >> traverse_ listItemsHTML next+    f (Item ws next) = li_ $ paragraphHTML os ws >> traverse_ (listItemsHTML os) next  tableHTML :: OrgStyle -> NonEmpty Row -> Html () tableHTML os rs = table_ tblClasses $ do@@ -189,12 +196,12 @@     -- | Render a header row.     g :: Column -> Html ()     g Empty       = th_ [scope_ "col"] ""-    g (Column ws) = th_ [scope_ "col"] $ paragraphHTML ws+    g (Column ws) = th_ [scope_ "col"] $ paragraphHTML os ws      -- | Render a normal row.     k :: Column -> Html ()     k Empty       = td_ ""-    k (Column ws) = td_ $ paragraphHTML ws+    k (Column ws) = td_ $ paragraphHTML os ws  wordsHTML :: Words -> Html () wordsHTML ws = case ws of
org-mode-lucid.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.2 name:               org-mode-lucid-version:            1.1.1+version:            1.2.0 synopsis:           Lucid integration for org-mode. description:        Lucid integration for org-mode. category:           Web