Merge branch 'update-lts-19'

This commit is contained in:
Dimitri Lozeve 2022-03-23 19:07:10 +01:00
commit cbf9ee89b0
6 changed files with 28 additions and 70 deletions

View file

@ -85,3 +85,11 @@ pre:not(.sourceCode) code {
word-wrap: break-word; word-wrap: break-word;
overflow-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%;
}

View file

@ -8,7 +8,6 @@ executable site
build-depends: base build-depends: base
, containers , containers
, pandoc , pandoc
, pandoc-citeproc
, pandoc-sidenote , pandoc-sidenote
, hakyll , hakyll
ghc-options: -threaded ghc-options: -threaded

View file

@ -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 that I have ever read. The explanation of the simplex algorithm is
also excellent.) also excellent.)
[fn:wentzel] {-} [fn:wentzel] {-}  
#+ATTR_HTML: :width 200px #+ATTR_HTML: :width 200px
[[file:/images/or_references/wentzel.jpg]] [[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, lost in the jungle of linear, stochastic, mixed integer, quadratic,
and other network problems. and other network problems.
[fn:williams] {-} [fn:williams] {-}  
#+ATTR_HTML: :width 200px #+ATTR_HTML: :width 200px
[[file:/images/or_references/williams.jpg]] [[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 examples in Julia covering nearly every kind of optimization
algorithms. algorithms.
[fn:kochenderfer] {-} [fn:kochenderfer] {-}  
#+ATTR_HTML: :width 200px #+ATTR_HTML: :width 200px
[[file:/images/or_references/kochenderfer.jpg]] [[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]] 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. or [[https://github.com/coin-or/pulp][PuLP]] for linear programming.
[fn:jump] {-} [fn:jump] {-}  
#+ATTR_HTML: :width 250px :style background-color: #cccccc; #+ATTR_HTML: :width 250px :style background-color: #cccccc;
[[file:/images/or_references/jump.svg]] [[file:/images/or_references/jump.svg]]

34
site.hs
View file

@ -3,8 +3,6 @@
import qualified Data.Map as Map import qualified Data.Map as Map
import Data.Monoid (mappend) import Data.Monoid (mappend)
import qualified Text.CSL as CSL
import Text.CSL.Pandoc (processCites)
import Text.Pandoc import Text.Pandoc
import Text.Pandoc.Options import Text.Pandoc.Options
import Text.Pandoc.Highlighting import Text.Pandoc.Highlighting
@ -136,35 +134,7 @@ postCtxWithTags tags = tagsField "tags" tags <> postCtx
feedCtx :: Context String feedCtx :: Context String
feedCtx = postCtx <> bodyField "description" feedCtx = postCtx <> bodyField "description"
-- Add links to references ------------------------------------------ -- Pandoc compiler with maths, TOC, sidenotes, and bibliography support --------------------
-- 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 --------------------
customPandocCompiler :: Bool -> Compiler (Item String) customPandocCompiler :: Bool -> Compiler (Item String)
customPandocCompiler withTOC = customPandocCompiler withTOC =
let customExtensions = extensionsFromList [Ext_latex_macros] let customExtensions = extensionsFromList [Ext_latex_macros]
@ -191,7 +161,7 @@ customPandocCompiler withTOC =
csl <- load $ fromFilePath "csl/chicago-author-date.csl" csl <- load $ fromFilePath "csl/chicago-author-date.csl"
bib <- load $ fromFilePath "bib/bibliography.bib" bib <- load $ fromFilePath "bib/bibliography.bib"
writePandocWith (if withTOC then writerOptionsWithTOC else writerOptions) <$> 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 type FeedRenderer = FeedConfiguration
-> Context String -> Context String

View file

@ -17,7 +17,7 @@
# #
# resolver: ./custom-snapshot.yaml # resolver: ./custom-snapshot.yaml
# resolver: https://example.com/snapshots/2018-01-01.yaml # resolver: https://example.com/snapshots/2018-01-01.yaml
resolver: lts-16.11 resolver: lts-19.0
# User packages to be built. # User packages to be built.
# Various formats can be used as shown in the example below. # Various formats can be used as shown in the example below.
@ -38,11 +38,9 @@ packages:
# using the same syntax as the packages field. # using the same syntax as the packages field.
# (e.g., acme-missiles-0.3) # (e.g., acme-missiles-0.3)
extra-deps: extra-deps:
- github: jez/pandoc-sidenote - git: https://github.com/jez/pandoc-sidenote.git
commit: 7aacfa4b20a44562de48725dea812c5de2c5aeac commit: c9dfcadfcff475e6e26626af379b8b6d3f38d187
#- pandoc-sidenote-0.19.0.0@sha256:f5a5fdab1900da7b26ca673d14302b0a27b56024ca811babcacab79ba9614e90,1196 # - monad-gen-0.3.0.1@sha256:a2569465cfbd468d3350ef25de56b3362580e77537224313aab1210f40804a3b,821
- monad-gen-0.3.0.1@sha256:a2569465cfbd468d3350ef25de56b3362580e77537224313aab1210f40804a3b,821
- hakyll-4.13.4.0@sha256:d97cb1b1cf7b901ce049e6e0aa5b1ac702cf52d2e475f5d3fe2de3694bb7dc7b,8867
# Override default flag values for local packages and extra-deps # Override default flag values for local packages and extra-deps
# flags: {} # flags: {}

View file

@ -5,36 +5,19 @@
packages: packages:
- completed: - completed:
size: 4871
url: https://github.com/jez/pandoc-sidenote/archive/7aacfa4b20a44562de48725dea812c5de2c5aeac.tar.gz
cabal-file:
size: 1578
sha256: 27753af099fd14469ec326713c5437ff8dcf9307c9711ab8d319a7ae9678a862
name: pandoc-sidenote name: pandoc-sidenote
version: 0.20.0.0 version: 0.22.2.0
sha256: 280c0ef67602128f0e8f9f184868f14a71c3938bebf8644c55e6988413db7e9f git: https://github.com/jez/pandoc-sidenote.git
pantry-tree: pantry-tree:
size: 575 size: 575
sha256: ace183ff53f1fe2987fc3ae77f38fa8c5ee1e656fe3bed0941691150bc1771ab sha256: 45a4f6017904d000a25f0ddcd7a1b92c3ef9926dfb4b35630878908e10cf62fa
commit: c9dfcadfcff475e6e26626af379b8b6d3f38d187
original: original:
url: https://github.com/jez/pandoc-sidenote/archive/7aacfa4b20a44562de48725dea812c5de2c5aeac.tar.gz git: https://github.com/jez/pandoc-sidenote.git
- completed: commit: c9dfcadfcff475e6e26626af379b8b6d3f38d187
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
snapshots: snapshots:
- completed: - completed:
size: 532381 size: 616897
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/11.yaml url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/0.yaml
sha256: 1f43c4ad661a114a4f9dd4580988f30da1208d844c097714f5867c52a02e0aa1 sha256: bbf2be02f17940bac1f87cb462d4fb0c3355de6dcfc53d84f4f9ad3ee2164f65
original: lts-16.11 original: lts-19.0