summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlierdakil <>2020-11-21 21:02:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2020-11-21 21:02:00 (GMT)
commita739aa303976f9b3b248759ed41f76618868de42 (patch)
tree683b19c8dc6e5a98d66aba86b5416e0577860d22
parent9f30b258b755f00af22daa064222b8c90937e5d4 (diff)
version 0.3.8.4HEAD0.3.8.4master
-rwxr-xr-xCHANGELOG.md6
-rw-r--r--docs/index.md3
-rw-r--r--lib/Text/Pandoc/CrossRef/References/Blocks.hs6
-rw-r--r--pandoc-crossref.cabal7
-rw-r--r--src/ManData.hs9
-rw-r--r--test/m2m/secLabels/expect.md16
-rw-r--r--test/m2m/secLabels/expect.tex33
-rw-r--r--test/m2m/secLabels/input.md22
-rw-r--r--test/m2m/section-template/expect.md6
9 files changed, 96 insertions, 12 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index da4240a..5ce53ac 100755
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+## 0.3.8.4
+
+- [Fix] secLabels
+- [ManData] Generate table of contents in embedded html; filter out kramdown toc marker
+- [Docs] Add toc to gh-pages
+
## 0.3.8.3
- [Fix] Pandoc 2.11.0.1 fixes the issue fixed in the previous release upstream.
diff --git a/docs/index.md b/docs/index.md
index c55f040..b59efda 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -7,6 +7,9 @@ title: 'pandoc-crossref(1)'
pandoc-crossref is a pandoc filter for numbering figures, equations,
tables and cross-references to them.
+* TOC
+{:toc}
+
# Caveats
## LaTeX output and `--include-in-header`
diff --git a/lib/Text/Pandoc/CrossRef/References/Blocks.hs b/lib/Text/Pandoc/CrossRef/References/Blocks.hs
index d3c057c..2ca0390 100644
--- a/lib/Text/Pandoc/CrossRef/References/Blocks.hs
+++ b/lib/Text/Pandoc/CrossRef/References/Blocks.hs
@@ -78,11 +78,11 @@ replaceBlock opts (Header n (label, cls, attrs) text')
unless ("unnumbered" `elem` cls) $ do
modify curChap $ \cc ->
let ln = length cc
- cl = lookup "label" attrs
- inc l = init l <> [(fst (last l) + 1, cl)]
+ cl i = lookup "label" attrs <> customLabel opts "sec" i
+ inc l = let i = fst (last l) + 1 in init l <> [(i, cl i)]
cc' | ln > n = inc $ take n cc
| ln == n = inc cc
- | otherwise = cc <> take (n-ln-1) (zip [1,1..] $ repeat Nothing) <> [(1,cl)]
+ | otherwise = cc <> take (n-ln-1) (zip [1,1..] $ repeat Nothing) <> [(1,cl 1)]
in cc'
when ("sec:" `T.isPrefixOf` label') $ do
index <- get curChap
diff --git a/pandoc-crossref.cabal b/pandoc-crossref.cabal
index 7a589c3..00ba379 100644
--- a/pandoc-crossref.cabal
+++ b/pandoc-crossref.cabal
@@ -4,10 +4,10 @@ cabal-version: 1.12
--
-- see: https://github.com/sol/hpack
--
--- hash: 39f79bf240895e159f195d272e9604b08b795a6bce6ce663305b8aee2189ab82
+-- hash: e482ef1e6f935e9229bb87d11a279dd174efa3767a94b99a83941d6bd6cfad1e
name: pandoc-crossref
-version: 0.3.8.3
+version: 0.3.8.4
synopsis: Pandoc filter for cross-references
description: pandoc-crossref is a pandoc filter for numbering figures, equations, tables and cross-references to them.
category: Text
@@ -55,6 +55,9 @@ data-files:
test/m2m/multiple-eqn-same-para/expect.md
test/m2m/multiple-eqn-same-para/expect.tex
test/m2m/multiple-eqn-same-para/input.md
+ test/m2m/secLabels/expect.md
+ test/m2m/secLabels/expect.tex
+ test/m2m/secLabels/input.md
test/m2m/section-template/expect.md
test/m2m/section-template/expect.tex
test/m2m/section-template/input.md
diff --git a/src/ManData.hs b/src/ManData.hs
index 112f81a..c1a8f0b 100644
--- a/src/ManData.hs
+++ b/src/ManData.hs
@@ -23,6 +23,7 @@ module ManData where
import Language.Haskell.TH.Syntax
import qualified Data.Text as T
+import qualified Data.Text.IO as T
import System.IO
import qualified Text.Pandoc as P
import Control.DeepSeq
@@ -32,18 +33,18 @@ import Text.Pandoc.Highlighting (pygments)
dataFile :: FilePath
dataFile = "docs/index.md"
-readDataFile :: IO String
+readDataFile :: IO T.Text
readDataFile =
withFile dataFile ReadMode $ \h -> do
hSetEncoding h utf8
- cont <- hGetContents h
+ cont <- T.replace "* TOC\n{:toc}\n" "" <$> T.hGetContents h
return $!! cont
embedManual :: (P.Pandoc -> P.PandocPure T.Text) -> Q Exp
embedManual fmt = do
qAddDependentFile dataFile
d <- runIO readDataFile
- let pd = either (error . show) id $ P.runPure $ P.readMarkdown readerOpts (T.pack d)
+ let pd = either (error . show) id $ P.runPure $ P.readMarkdown readerOpts d
let txt = either (error . show) id $ P.runPure $ fmt pd
strToExp $ T.unpack txt
@@ -63,6 +64,8 @@ embedManualHtml = do
embedManual $ P.writeHtml5String P.def{
P.writerTemplate = Just tt
, P.writerHighlightStyle = Just pygments
+ , P.writerTOCDepth = 6
+ , P.writerTableOfContents = True
}
strToExp :: String -> Q Exp
diff --git a/test/m2m/secLabels/expect.md b/test/m2m/secLabels/expect.md
new file mode 100644
index 0000000..19a6c53
--- /dev/null
+++ b/test/m2m/secLabels/expect.md
@@ -0,0 +1,16 @@
+# a First Level Section {#first-level-section}
+
+## a.a Second Level Section {#second-level-section}
+
+![Figure a: my figure](myfig.png){#fig:myfig}
+
+## a.b Other Second Level Section {#other-second-level-section}
+
+::: {#tbl:mytable}
+ a b c
+ --- --- ---
+ 1 2 3
+ 4 5 6
+
+ : Table I: My table
+:::
diff --git a/test/m2m/secLabels/expect.tex b/test/m2m/secLabels/expect.tex
new file mode 100644
index 0000000..4c26614
--- /dev/null
+++ b/test/m2m/secLabels/expect.tex
@@ -0,0 +1,33 @@
+\hypertarget{first-level-section}{%
+\section{a First Level Section}\label{first-level-section}}
+
+\hypertarget{second-level-section}{%
+\subsection{a.a Second Level Section}\label{second-level-section}}
+
+\begin{figure}
+\hypertarget{fig:myfig}{%
+\centering
+\includegraphics{myfig.png}
+\caption{my figure}\label{fig:myfig}
+}
+\end{figure}
+
+\hypertarget{other-second-level-section}{%
+\subsection{a.b Other Second Level
+Section}\label{other-second-level-section}}
+
+\hypertarget{tbl:mytable}{}
+\begin{longtable}[]{@{}lll@{}}
+\caption{\label{tbl:mytable}My table}\tabularnewline
+\toprule
+a & b & c\tabularnewline
+\midrule
+\endfirsthead
+\toprule
+a & b & c\tabularnewline
+\midrule
+\endhead
+1 & 2 & 3\tabularnewline
+4 & 5 & 6\tabularnewline
+\bottomrule
+\end{longtable}
diff --git a/test/m2m/secLabels/input.md b/test/m2m/secLabels/input.md
new file mode 100644
index 0000000..c7e71ca
--- /dev/null
+++ b/test/m2m/secLabels/input.md
@@ -0,0 +1,22 @@
+---
+numberSections: true
+sectionsDepth: -1
+secLabels: alpha a
+figLabels: alpha a
+tblLabels: roman
+---
+
+# First Level Section
+
+## Second Level Section
+
+![my figure](myfig.png){#fig:myfig}
+
+## Other Second Level Section
+
+a b c
+--- --- ---
+1 2 3
+4 5 6
+
+: My table {#tbl:mytable}
diff --git a/test/m2m/section-template/expect.md b/test/m2m/section-template/expect.md
index c9629b8..3100e32 100644
--- a/test/m2m/section-template/expect.md
+++ b/test/m2m/section-template/expect.md
@@ -1,8 +1,6 @@
-Chapter 1. First Level Section {#first-level-section}
-==============================
+# Chapter 1. First Level Section {#first-level-section}
-Section 1.1. Second Level Section {#second-level-section}
----------------------------------
+## Section 1.1. Second Level Section {#second-level-section}
### Paragraph 1.1.1. Thrid Level Section {#thrid-level-section}