From e8f84412d0ad54ec1eba1fac00891ec6a5484b5a Mon Sep 17 00:00:00 2001 From: Dimitri Lozeve Date: Tue, 22 Mar 2022 17:34:53 +0100 Subject: [PATCH 1/4] Update to LTS 19.0 --- newblog.cabal | 1 - stack.yaml | 10 ++++------ stack.yaml.lock | 37 ++++++++++--------------------------- 3 files changed, 14 insertions(+), 34 deletions(-) diff --git a/newblog.cabal b/newblog.cabal index a3aceb2..1375a46 100644 --- a/newblog.cabal +++ b/newblog.cabal @@ -8,7 +8,6 @@ executable site build-depends: base , containers , pandoc - , pandoc-citeproc , pandoc-sidenote , hakyll ghc-options: -threaded diff --git a/stack.yaml b/stack.yaml index 0af0c5e..f0ffcbe 100644 --- a/stack.yaml +++ b/stack.yaml @@ -17,7 +17,7 @@ # # resolver: ./custom-snapshot.yaml # resolver: https://example.com/snapshots/2018-01-01.yaml -resolver: lts-16.11 +resolver: lts-19.0 # User packages to be built. # Various formats can be used as shown in the example below. @@ -38,11 +38,9 @@ packages: # using the same syntax as the packages field. # (e.g., acme-missiles-0.3) extra-deps: - - github: jez/pandoc-sidenote - commit: 7aacfa4b20a44562de48725dea812c5de2c5aeac - #- pandoc-sidenote-0.19.0.0@sha256:f5a5fdab1900da7b26ca673d14302b0a27b56024ca811babcacab79ba9614e90,1196 - - monad-gen-0.3.0.1@sha256:a2569465cfbd468d3350ef25de56b3362580e77537224313aab1210f40804a3b,821 - - hakyll-4.13.4.0@sha256:d97cb1b1cf7b901ce049e6e0aa5b1ac702cf52d2e475f5d3fe2de3694bb7dc7b,8867 + - git: https://github.com/jez/pandoc-sidenote.git + commit: c9dfcadfcff475e6e26626af379b8b6d3f38d187 +# - monad-gen-0.3.0.1@sha256:a2569465cfbd468d3350ef25de56b3362580e77537224313aab1210f40804a3b,821 # Override default flag values for local packages and extra-deps # flags: {} diff --git a/stack.yaml.lock b/stack.yaml.lock index 50d4931..9720aeb 100644 --- a/stack.yaml.lock +++ b/stack.yaml.lock @@ -5,36 +5,19 @@ packages: - completed: - size: 4871 - url: https://github.com/jez/pandoc-sidenote/archive/7aacfa4b20a44562de48725dea812c5de2c5aeac.tar.gz - cabal-file: - size: 1578 - sha256: 27753af099fd14469ec326713c5437ff8dcf9307c9711ab8d319a7ae9678a862 name: pandoc-sidenote - version: 0.20.0.0 - sha256: 280c0ef67602128f0e8f9f184868f14a71c3938bebf8644c55e6988413db7e9f + version: 0.22.2.0 + git: https://github.com/jez/pandoc-sidenote.git pantry-tree: size: 575 - sha256: ace183ff53f1fe2987fc3ae77f38fa8c5ee1e656fe3bed0941691150bc1771ab + sha256: 45a4f6017904d000a25f0ddcd7a1b92c3ef9926dfb4b35630878908e10cf62fa + commit: c9dfcadfcff475e6e26626af379b8b6d3f38d187 original: - url: https://github.com/jez/pandoc-sidenote/archive/7aacfa4b20a44562de48725dea812c5de2c5aeac.tar.gz -- completed: - hackage: monad-gen-0.3.0.1@sha256:a2569465cfbd468d3350ef25de56b3362580e77537224313aab1210f40804a3b,821 - pantry-tree: - size: 288 - sha256: a825dc8dcc3ee27dbbc1b71f6853703790ed320249b8f8510bb36d726664e795 - original: - hackage: monad-gen-0.3.0.1@sha256:a2569465cfbd468d3350ef25de56b3362580e77537224313aab1210f40804a3b,821 -- completed: - hackage: hakyll-4.13.4.0@sha256:d97cb1b1cf7b901ce049e6e0aa5b1ac702cf52d2e475f5d3fe2de3694bb7dc7b,8867 - pantry-tree: - size: 7841 - sha256: e31b612480429149bd2c042dd49cdb1a5eb9c807d4acce4a971a6da3d6f5db81 - original: - hackage: hakyll-4.13.4.0@sha256:d97cb1b1cf7b901ce049e6e0aa5b1ac702cf52d2e475f5d3fe2de3694bb7dc7b,8867 + git: https://github.com/jez/pandoc-sidenote.git + commit: c9dfcadfcff475e6e26626af379b8b6d3f38d187 snapshots: - completed: - size: 532381 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/11.yaml - sha256: 1f43c4ad661a114a4f9dd4580988f30da1208d844c097714f5867c52a02e0aa1 - original: lts-16.11 + size: 616897 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/0.yaml + sha256: bbf2be02f17940bac1f87cb462d4fb0c3355de6dcfc53d84f4f9ad3ee2164f65 + original: lts-19.0 From f0a827c6358ce534a209b9b1e3e43b161c6218f4 Mon Sep 17 00:00:00 2001 From: Dimitri Lozeve Date: Tue, 22 Mar 2022 18:43:43 +0100 Subject: [PATCH 2/4] Fix bibliography generation --- site.hs | 34 ++-------------------------------- 1 file changed, 2 insertions(+), 32 deletions(-) diff --git a/site.hs b/site.hs index 9366a87..c4d65fb 100644 --- a/site.hs +++ b/site.hs @@ -3,8 +3,6 @@ import qualified Data.Map as Map import Data.Monoid (mappend) -import qualified Text.CSL as CSL -import Text.CSL.Pandoc (processCites) import Text.Pandoc import Text.Pandoc.Options import Text.Pandoc.Highlighting @@ -136,35 +134,7 @@ postCtxWithTags tags = tagsField "tags" tags <> postCtx feedCtx :: Context String feedCtx = postCtx <> bodyField "description" --- Add links to references ------------------------------------------ --- Source: https://github.com/jaspervdj/hakyll/issues/471#issuecomment-244540329 -addLinkCitations (Pandoc meta a) = - let prevMap = unMeta meta - newMap = Map.insert "link-citations" (MetaBool True) prevMap - newMeta = Meta newMap - in Pandoc newMeta a - -myReadPandocBiblio :: ReaderOptions - -> Item CSL - -> Item Biblio - -> (Item String) - -> Compiler (Item Pandoc) -myReadPandocBiblio ropt csl biblio item = do - -- Parse CSL file, if given - provider <- compilerProvider <$> compilerAsk - style <- unsafeCompiler $ - CSL.readCSLFile Nothing . (resourceFilePath provider) . itemIdentifier $ csl - - -- We need to know the citation keys, add then *before* actually parsing the - -- actual page. If we don't do this, pandoc won't even consider them - -- citations! - let Biblio refs = itemBody biblio - pandoc <- itemBody <$> readPandocWith ropt item - let pandoc' = processCites style refs (addLinkCitations pandoc) - - return $ fmap (const pandoc') item - --- Pandoc compiler with maths, TOC, sidenots, and bibliography support -------------------- +-- Pandoc compiler with maths, TOC, sidenotes, and bibliography support -------------------- customPandocCompiler :: Bool -> Compiler (Item String) customPandocCompiler withTOC = let customExtensions = extensionsFromList [Ext_latex_macros] @@ -191,7 +161,7 @@ customPandocCompiler withTOC = csl <- load $ fromFilePath "csl/chicago-author-date.csl" bib <- load $ fromFilePath "bib/bibliography.bib" writePandocWith (if withTOC then writerOptionsWithTOC else writerOptions) <$> - (getResourceBody >>= myReadPandocBiblio readerOptions csl bib >>= traverse (return . usingSideNotes)) + (getResourceBody >>= readPandocBiblio readerOptions csl bib >>= traverse (return . usingSideNotes)) type FeedRenderer = FeedConfiguration -> Context String From 3408e55747a512747629d5b253dd24ad6a828f1c Mon Sep 17 00:00:00 2001 From: Dimitri Lozeve Date: Tue, 22 Mar 2022 18:44:01 +0100 Subject: [PATCH 3/4] Fix some sidenotes with a single image --- posts/operations-research-references.org | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/posts/operations-research-references.org b/posts/operations-research-references.org index ebe9320..37ec1fe 100644 --- a/posts/operations-research-references.org +++ b/posts/operations-research-references.org @@ -68,7 +68,7 @@ particular, it is one of the best presentations of dynamic programming that I have ever read. The explanation of the simplex algorithm is also excellent.) -[fn:wentzel] {-} +[fn:wentzel] {-}   #+ATTR_HTML: :width 200px [[file:/images/or_references/wentzel.jpg]] @@ -102,7 +102,7 @@ great resource to build a "mental map" of the field, avoiding getting lost in the jungle of linear, stochastic, mixed integer, quadratic, and other network problems. -[fn:williams] {-} +[fn:williams] {-}   #+ATTR_HTML: :width 200px [[file:/images/or_references/williams.jpg]] @@ -153,7 +153,7 @@ the list (because it is very recent) but is also excellent, with examples in Julia covering nearly every kind of optimization algorithms. -[fn:kochenderfer] {-} +[fn:kochenderfer] {-}   #+ATTR_HTML: :width 200px [[file:/images/or_references/kochenderfer.jpg]] @@ -212,7 +212,7 @@ packages. (Even if you don't know Julia, this is a great and easy way to start!) If you'd rather use Python, you can use Google's [[https://developers.google.com/optimization/introduction/python][OR-Tools]] or [[https://github.com/coin-or/pulp][PuLP]] for linear programming. -[fn:jump] {-} +[fn:jump] {-}   #+ATTR_HTML: :width 250px :style background-color: #cccccc; [[file:/images/or_references/jump.svg]] From 2f264b3b4b89351b71563ece63b58e3173859bc3 Mon Sep 17 00:00:00 2001 From: Dimitri Lozeve Date: Wed, 23 Mar 2022 19:06:16 +0100 Subject: [PATCH 4/4] Add CSS for better-looking bibliography entries --- css/pandoc.css | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/css/pandoc.css b/css/pandoc.css index b2676b2..aab5e46 100644 --- a/css/pandoc.css +++ b/css/pandoc.css @@ -85,3 +85,11 @@ pre:not(.sourceCode) code { word-wrap: break-word; overflow-wrap: break-word; } + +/* Bibliograpy entries */ +.csl-entry { + font-size: 1.2rem; + padding-top: 0.4rem; + padding-bottom: 0.4rem; + width: 87.5%; +}