packages feed

pandoc-crossref 0.3.9.1 → 0.3.10.0

raw patch · 17 files changed

+283/−35 lines, 17 filesdep ~pandocPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: pandoc

API changes (from Hackage documentation)

+ Text.Pandoc.CrossRef: setLabelAttribute :: forall a_asO6. ToMetaValue a_asO6 => a_asO6 -> Meta
- Text.Pandoc.CrossRef: autoEqnLabels :: forall a_atFG. ToMetaValue a_atFG => a_atFG -> Meta
+ Text.Pandoc.CrossRef: autoEqnLabels :: forall a_asO2. ToMetaValue a_asO2 => a_asO2 -> Meta
- Text.Pandoc.CrossRef: autoSectionLabels :: forall a_atF6. ToMetaValue a_atF6 => a_atF6 -> Meta
+ Text.Pandoc.CrossRef: autoSectionLabels :: forall a_asNs. ToMetaValue a_asNs => a_asNs -> Meta
- Text.Pandoc.CrossRef: ccsDelim :: forall a_atFD. ToMetaValue a_atFD => a_atFD -> Meta
+ Text.Pandoc.CrossRef: ccsDelim :: forall a_asNZ. ToMetaValue a_asNZ => a_asNZ -> Meta
- Text.Pandoc.CrossRef: ccsLabelSep :: forall a_atFE. ToMetaValue a_atFE => a_atFE -> Meta
+ Text.Pandoc.CrossRef: ccsLabelSep :: forall a_asO0. ToMetaValue a_asO0 => a_asO0 -> Meta
- Text.Pandoc.CrossRef: ccsTemplate :: forall a_atFy. ToMetaValue a_atFy => a_atFy -> Meta
+ Text.Pandoc.CrossRef: ccsTemplate :: forall a_asNU. ToMetaValue a_asNU => a_asNU -> Meta
- Text.Pandoc.CrossRef: chapDelim :: forall a_atFm. ToMetaValue a_atFm => a_atFm -> Meta
+ Text.Pandoc.CrossRef: chapDelim :: forall a_asNI. ToMetaValue a_asNI => a_asNI -> Meta
- Text.Pandoc.CrossRef: chapters :: forall a_au78. ToMetaValue a_au78 => a_au78 -> Meta
+ Text.Pandoc.CrossRef: chapters :: forall a_atg5. ToMetaValue a_atg5 => a_atg5 -> Meta
- Text.Pandoc.CrossRef: chaptersDepth :: forall a_atF3. ToMetaValue a_atF3 => a_atF3 -> Meta
+ Text.Pandoc.CrossRef: chaptersDepth :: forall a_asNp. ToMetaValue a_asNp => a_asNp -> Meta
- Text.Pandoc.CrossRef: codeBlockCaptions :: forall a_atF5. ToMetaValue a_atF5 => a_atF5 -> Meta
+ Text.Pandoc.CrossRef: codeBlockCaptions :: forall a_asNr. ToMetaValue a_asNr => a_asNr -> Meta
- Text.Pandoc.CrossRef: cref :: forall a_atF2. ToMetaValue a_atF2 => a_atF2 -> Meta
+ Text.Pandoc.CrossRef: cref :: forall a_asNo. ToMetaValue a_asNo => a_asNo -> Meta
- Text.Pandoc.CrossRef: crossrefYaml :: forall a_au76. ToMetaValue a_au76 => a_au76 -> Meta
+ Text.Pandoc.CrossRef: crossrefYaml :: forall a_atg3. ToMetaValue a_atg3 => a_atg3 -> Meta
- Text.Pandoc.CrossRef: customHeadingLabel :: forall a_atFC. ToMetaValue a_atFC => a_atFC -> Meta
+ Text.Pandoc.CrossRef: customHeadingLabel :: forall a_asNY. ToMetaValue a_asNY => a_asNY -> Meta
- Text.Pandoc.CrossRef: customLabel :: forall a_atFB. ToMetaValue a_atFB => a_atFB -> Meta
+ Text.Pandoc.CrossRef: customLabel :: forall a_asNX. ToMetaValue a_asNX => a_asNX -> Meta
- Text.Pandoc.CrossRef: eqLabels :: forall a_au7a. ToMetaValue a_au7a => a_au7a -> Meta
+ Text.Pandoc.CrossRef: eqLabels :: forall a_atg7. ToMetaValue a_atg7 => a_atg7 -> Meta
- Text.Pandoc.CrossRef: eqnPrefix :: forall a_atFa. ToMetaValue a_atFa => a_atFa -> Meta
+ Text.Pandoc.CrossRef: eqnPrefix :: forall a_asNw. ToMetaValue a_asNw => a_asNw -> Meta
- Text.Pandoc.CrossRef: eqnPrefixTemplate :: forall a_atFf. ToMetaValue a_atFf => a_atFf -> Meta
+ Text.Pandoc.CrossRef: eqnPrefixTemplate :: forall a_asNB. ToMetaValue a_asNB => a_asNB -> Meta
- Text.Pandoc.CrossRef: figLabels :: forall a_au79. ToMetaValue a_au79 => a_au79 -> Meta
+ Text.Pandoc.CrossRef: figLabels :: forall a_atg6. ToMetaValue a_atg6 => a_atg6 -> Meta
- Text.Pandoc.CrossRef: figPrefix :: forall a_atF9. ToMetaValue a_atF9 => a_atF9 -> Meta
+ Text.Pandoc.CrossRef: figPrefix :: forall a_asNv. ToMetaValue a_asNv => a_asNv -> Meta
- Text.Pandoc.CrossRef: figPrefixTemplate :: forall a_atFe. ToMetaValue a_atFe => a_atFe -> Meta
+ Text.Pandoc.CrossRef: figPrefixTemplate :: forall a_asNA. ToMetaValue a_asNA => a_asNA -> Meta
- Text.Pandoc.CrossRef: figureTemplate :: forall a_atFv. ToMetaValue a_atFv => a_atFv -> Meta
+ Text.Pandoc.CrossRef: figureTemplate :: forall a_asNR. ToMetaValue a_asNR => a_asNR -> Meta
- Text.Pandoc.CrossRef: figureTitle :: forall a_au72. ToMetaValue a_au72 => a_au72 -> Meta
+ Text.Pandoc.CrossRef: figureTitle :: forall a_atfZ. ToMetaValue a_atfZ => a_atfZ -> Meta
- Text.Pandoc.CrossRef: lastDelim :: forall a_atFp. ToMetaValue a_atFp => a_atFp -> Meta
+ Text.Pandoc.CrossRef: lastDelim :: forall a_asNL. ToMetaValue a_asNL => a_asNL -> Meta
- Text.Pandoc.CrossRef: linkReferences :: forall a_atFI. ToMetaValue a_atFI => a_atFI -> Meta
+ Text.Pandoc.CrossRef: linkReferences :: forall a_asO4. ToMetaValue a_asO4 => a_asO4 -> Meta
- Text.Pandoc.CrossRef: listingTemplate :: forall a_atFA. ToMetaValue a_atFA => a_atFA -> Meta
+ Text.Pandoc.CrossRef: listingTemplate :: forall a_asNW. ToMetaValue a_asNW => a_asNW -> Meta
- Text.Pandoc.CrossRef: listingTitle :: forall a_au74. ToMetaValue a_au74 => a_au74 -> Meta
+ Text.Pandoc.CrossRef: listingTitle :: forall a_atg1. ToMetaValue a_atg1 => a_atg1 -> Meta
- Text.Pandoc.CrossRef: listings :: forall a_atF4. ToMetaValue a_atF4 => a_atF4 -> Meta
+ Text.Pandoc.CrossRef: listings :: forall a_asNq. ToMetaValue a_asNq => a_asNq -> Meta
- Text.Pandoc.CrossRef: lofTitle :: forall a_atFr. ToMetaValue a_atFr => a_atFr -> Meta
+ Text.Pandoc.CrossRef: lofTitle :: forall a_asNN. ToMetaValue a_asNN => a_asNN -> Meta
- Text.Pandoc.CrossRef: lolTitle :: forall a_atFt. ToMetaValue a_atFt => a_atFt -> Meta
+ Text.Pandoc.CrossRef: lolTitle :: forall a_asNP. ToMetaValue a_asNP => a_asNP -> Meta
- Text.Pandoc.CrossRef: lotTitle :: forall a_atFs. ToMetaValue a_atFs => a_atFs -> Meta
+ Text.Pandoc.CrossRef: lotTitle :: forall a_asNO. ToMetaValue a_asNO => a_asNO -> Meta
- Text.Pandoc.CrossRef: lstLabels :: forall a_au7c. ToMetaValue a_au7c => a_au7c -> Meta
+ Text.Pandoc.CrossRef: lstLabels :: forall a_atg9. ToMetaValue a_atg9 => a_atg9 -> Meta
- Text.Pandoc.CrossRef: lstPrefix :: forall a_atFc. ToMetaValue a_atFc => a_atFc -> Meta
+ Text.Pandoc.CrossRef: lstPrefix :: forall a_asNy. ToMetaValue a_asNy => a_asNy -> Meta
- Text.Pandoc.CrossRef: lstPrefixTemplate :: forall a_atFh. ToMetaValue a_atFh => a_atFh -> Meta
+ Text.Pandoc.CrossRef: lstPrefixTemplate :: forall a_asND. ToMetaValue a_asND => a_asND -> Meta
- Text.Pandoc.CrossRef: nameInLink :: forall a_atFJ. ToMetaValue a_atFJ => a_atFJ -> Meta
+ Text.Pandoc.CrossRef: nameInLink :: forall a_asO5. ToMetaValue a_asO5 => a_asO5 -> Meta
- Text.Pandoc.CrossRef: numberSections :: forall a_atF7. ToMetaValue a_atF7 => a_atF7 -> Meta
+ Text.Pandoc.CrossRef: numberSections :: forall a_asNt. ToMetaValue a_asNt => a_asNt -> Meta
- Text.Pandoc.CrossRef: outFormat :: forall a_atFu. ToMetaValue a_atFu => a_atFu -> Meta
+ Text.Pandoc.CrossRef: outFormat :: forall a_asNQ. ToMetaValue a_asNQ => a_asNQ -> Meta
- Text.Pandoc.CrossRef: pairDelim :: forall a_atFo. ToMetaValue a_atFo => a_atFo -> Meta
+ Text.Pandoc.CrossRef: pairDelim :: forall a_asNK. ToMetaValue a_asNK => a_asNK -> Meta
- Text.Pandoc.CrossRef: rangeDelim :: forall a_atFn. ToMetaValue a_atFn => a_atFn -> Meta
+ Text.Pandoc.CrossRef: rangeDelim :: forall a_asNJ. ToMetaValue a_asNJ => a_asNJ -> Meta
- Text.Pandoc.CrossRef: refDelim :: forall a_atFq. ToMetaValue a_atFq => a_atFq -> Meta
+ Text.Pandoc.CrossRef: refDelim :: forall a_asNM. ToMetaValue a_asNM => a_asNM -> Meta
- Text.Pandoc.CrossRef: refIndexTemplate :: forall a_atFj. ToMetaValue a_atFj => a_atFj -> Meta
+ Text.Pandoc.CrossRef: refIndexTemplate :: forall a_asNF. ToMetaValue a_asNF => a_asNF -> Meta
- Text.Pandoc.CrossRef: secHeaderDelim :: forall a_au7e. ToMetaValue a_au7e => a_au7e -> Meta
+ Text.Pandoc.CrossRef: secHeaderDelim :: forall a_atgb. ToMetaValue a_atgb => a_atgb -> Meta
- Text.Pandoc.CrossRef: secHeaderTemplate :: forall a_atFl. ToMetaValue a_atFl => a_atFl -> Meta
+ Text.Pandoc.CrossRef: secHeaderTemplate :: forall a_asNH. ToMetaValue a_asNH => a_asNH -> Meta
- Text.Pandoc.CrossRef: secLabels :: forall a_au7d. ToMetaValue a_au7d => a_au7d -> Meta
+ Text.Pandoc.CrossRef: secLabels :: forall a_atga. ToMetaValue a_atga => a_atga -> Meta
- Text.Pandoc.CrossRef: secPrefix :: forall a_atFd. ToMetaValue a_atFd => a_atFd -> Meta
+ Text.Pandoc.CrossRef: secPrefix :: forall a_asNz. ToMetaValue a_asNz => a_asNz -> Meta
- Text.Pandoc.CrossRef: secPrefixTemplate :: forall a_atFi. ToMetaValue a_atFi => a_atFi -> Meta
+ Text.Pandoc.CrossRef: secPrefixTemplate :: forall a_asNE. ToMetaValue a_asNE => a_asNE -> Meta
- Text.Pandoc.CrossRef: sectionsDepth :: forall a_atF8. ToMetaValue a_atF8 => a_atF8 -> Meta
+ Text.Pandoc.CrossRef: sectionsDepth :: forall a_asNu. ToMetaValue a_asNu => a_asNu -> Meta
- Text.Pandoc.CrossRef: subfigGrid :: forall a_atFH. ToMetaValue a_atFH => a_atFH -> Meta
+ Text.Pandoc.CrossRef: subfigGrid :: forall a_asO3. ToMetaValue a_asO3 => a_asO3 -> Meta
- Text.Pandoc.CrossRef: subfigLabels :: forall a_au77. ToMetaValue a_au77 => a_au77 -> Meta
+ Text.Pandoc.CrossRef: subfigLabels :: forall a_atg4. ToMetaValue a_atg4 => a_atg4 -> Meta
- Text.Pandoc.CrossRef: subfigureChildTemplate :: forall a_atFx. ToMetaValue a_atFx => a_atFx -> Meta
+ Text.Pandoc.CrossRef: subfigureChildTemplate :: forall a_asNT. ToMetaValue a_asNT => a_asNT -> Meta
- Text.Pandoc.CrossRef: subfigureRefIndexTemplate :: forall a_atFk. ToMetaValue a_atFk => a_atFk -> Meta
+ Text.Pandoc.CrossRef: subfigureRefIndexTemplate :: forall a_asNG. ToMetaValue a_asNG => a_asNG -> Meta
- Text.Pandoc.CrossRef: subfigureTemplate :: forall a_atFw. ToMetaValue a_atFw => a_atFw -> Meta
+ Text.Pandoc.CrossRef: subfigureTemplate :: forall a_asNS. ToMetaValue a_asNS => a_asNS -> Meta
- Text.Pandoc.CrossRef: tableEqns :: forall a_atFF. ToMetaValue a_atFF => a_atFF -> Meta
+ Text.Pandoc.CrossRef: tableEqns :: forall a_asO1. ToMetaValue a_asO1 => a_asO1 -> Meta
- Text.Pandoc.CrossRef: tableTemplate :: forall a_atFz. ToMetaValue a_atFz => a_atFz -> Meta
+ Text.Pandoc.CrossRef: tableTemplate :: forall a_asNV. ToMetaValue a_asNV => a_asNV -> Meta
- Text.Pandoc.CrossRef: tableTitle :: forall a_au73. ToMetaValue a_au73 => a_au73 -> Meta
+ Text.Pandoc.CrossRef: tableTitle :: forall a_atg0. ToMetaValue a_atg0 => a_atg0 -> Meta
- Text.Pandoc.CrossRef: tblLabels :: forall a_au7b. ToMetaValue a_au7b => a_au7b -> Meta
+ Text.Pandoc.CrossRef: tblLabels :: forall a_atg8. ToMetaValue a_atg8 => a_atg8 -> Meta
- Text.Pandoc.CrossRef: tblPrefix :: forall a_atFb. ToMetaValue a_atFb => a_atFb -> Meta
+ Text.Pandoc.CrossRef: tblPrefix :: forall a_asNx. ToMetaValue a_asNx => a_asNx -> Meta
- Text.Pandoc.CrossRef: tblPrefixTemplate :: forall a_atFg. ToMetaValue a_atFg => a_atFg -> Meta
+ Text.Pandoc.CrossRef: tblPrefixTemplate :: forall a_asNC. ToMetaValue a_asNC => a_asNC -> Meta
- Text.Pandoc.CrossRef: titleDelim :: forall a_au75. ToMetaValue a_au75 => a_au75 -> Meta
+ Text.Pandoc.CrossRef: titleDelim :: forall a_atg2. ToMetaValue a_atg2 => a_atg2 -> Meta

Files

CHANGELOG.md view
@@ -1,3 +1,22 @@+## 0.3.10.0++-   \[Fix\] Avoid expensive set difference, use filter+-   \[Tweak\] For div-wrapped listings merge attributes and classes++    Previously, classes and attributes on the wrapping div were ignored. Now, those are merged with classes and attributes on the listing.++-   \[Feat\] Add option to set label attributes to actual numbering used++    New option `setLabelAttribute` which sets `label` attribute on sections, figures, etc to actual number used for referencing. This can be useful for post-processing.++-   \[Fix\] Omit empty section\/item labels++    Objects (sections, figures) can have empty labels (i.e. no number). Previously, if those labels were referenced (particularly with chapters enabled) this would create references like `fig 1..2`. Now these labels are omitted. It can lead to duplicate numbers in references though.++-   \[Fix\] Chapter delimiter in section numbers should be chapDelim (was '.')++    `chapDelim` now observed in section numbers (when `numberSections` is enabled)+ ## 0.3.9.1  -   [CI] Bump pandoc version
docs/index.md view
@@ -355,6 +355,9 @@ ``` &lt;/div&gt; </pre>++Any additional attributes and classes on the wrapping div will be merged with classes/attributes on the listing itself. In case of duplicate attributes, the behaviour is unspecified, but likely either both values will end up in the output, or div attributes will take precedence. This is important to keep in mind if you need to do some additional post-processing.+ ## References  ``` markdown@@ -491,6 +494,8 @@ -   `tableEqns`, default `false`: Typeset equations and equation numbers     in tables instead of embedding numbers into equations themselves.     Depending on output format, this might work better or worse.+-   `setLabelAttribute`, default `false`: set `label` attribute on objects to+    actual number used for referencing. This can be useful for post-processing.  ### Item title format 
lib/Text/Pandoc/CrossRef/References/Blocks.hs view
@@ -69,6 +69,13 @@   noTableHead = TableHead nullAttr []   noTableFoot = TableFoot nullAttr [] +setLabel :: Options -> [Inline] -> [(T.Text, T.Text)] -> [(T.Text, T.Text)]+setLabel opts idx+  | setLabelAttribute opts+  = (("label", stringify idx) :)+  . filter ((/= "label") . fst)+  | otherwise = id+ replaceBlock :: Options -> Block -> WS (ReplacedResult Block) replaceBlock opts (Header n (label, cls, attrs) text')   = do@@ -97,14 +104,16 @@                || n <= if sectionsDepth opts == 0 then chaptersDepth opts else sectionsDepth opts                , "unnumbered" `notElem` cls                = applyTemplate' (M.fromDistinctAscList [-                    ("i", [Str (T.intercalate "." $ map show' cc)])+                    ("i", idxStr)                   , ("n", [Str $ T.pack $ show $ n - 1])                   , ("t", text')                   ]) $ secHeaderTemplate opts                | otherwise = text'-        show' (_, Just s) = s-        show' (i, Nothing) = T.pack $ show i-    replaceNoRecurse $ Header n (label', cls, attrs) textCC+        idxStr = chapPrefix (chapDelim opts) cc+        attrs' | "unnumbered" `notElem` cls+               = setLabel opts idxStr attrs+               | otherwise = attrs+    replaceNoRecurse $ Header n (label', cls, attrs') textCC -- subfigures replaceBlock opts (Div (label,cls,attrs) images)   | "fig:" `T.isPrefixOf` label@@ -147,7 +156,7 @@                        , Span nullAttr caption]               , RawBlock (Format "latex") $ mkLaTeXLabel label               , RawBlock (Format "latex") "\\end{pandoccrossrefsubfigures}"]-          _  -> replaceNoRecurse $ Div (label, "subfigures":cls, attrs) $ toTable cont capt+          _  -> replaceNoRecurse $ Div (label, "subfigures":cls, setLabel opts idxStr attrs) $ toTable cont capt   where     opts' = opts               { figureTemplate = subfigureChildTemplate opts@@ -189,7 +198,7 @@         inlToCell (Image (id', cs, as) txt tgt)  = Just [Para [Image (id', cs, setW as) txt tgt]]         inlToCell _ = Nothing         setW as = ("width", "100%"):filter ((/="width") . fst) as-replaceBlock opts (Div divOps@(label,_,attrs) [Table tattr (Caption short (btitle:rest)) colspec header cells foot])+replaceBlock opts (Div (label,clss,attrs) [Table tattr (Caption short (btitle:rest)) colspec header cells foot])   | not $ null title   , "tbl:" `T.isPrefixOf` label   = do@@ -200,9 +209,9 @@                 RawInline (Format "latex") (mkLaTeXLabel label) : title               _  -> applyTemplate idxStr title $ tableTemplate opts         caption' = Caption short (walkReplaceInlines title' title btitle:rest)-    replaceNoRecurse $ Div divOps [Table tattr caption' colspec header cells foot]+    replaceNoRecurse $ Div (label, clss, setLabel opts idxStr attrs) [Table tattr caption' colspec header cells foot]   where title = blocksToInlines [btitle]-replaceBlock opts (Table divOps@(label,_,attrs) (Caption short (btitle:rest)) colspec header cells foot)+replaceBlock opts (Table (label,clss,attrs) (Caption short (btitle:rest)) colspec header cells foot)   | not $ null title   , "tbl:" `T.isPrefixOf` label   = do@@ -213,7 +222,7 @@                 RawInline (Format "latex") (mkLaTeXLabel label) : title               _  -> applyTemplate idxStr title $ tableTemplate opts         caption' = Caption short (walkReplaceInlines title' title btitle:rest)-    replaceNoRecurse $ Table divOps caption' colspec header cells foot+    replaceNoRecurse $ Table (label, clss, setLabel opts idxStr attrs) caption' colspec header cells foot   where title = blocksToInlines [btitle] replaceBlock opts cb@(CodeBlock (label, classes, attrs) code)   | not $ T.null label@@ -241,11 +250,11 @@         let caption' = applyTemplate idxStr cap $ listingTemplate opts         replaceNoRecurse $ Div (label, "listing":classes, []) [             mkCaption opts "Caption" caption'-          , CodeBlock ("", classes, attrs \\ [("caption", caption)]) code+          , CodeBlock ("", classes, filter ((/="caption") . fst) $ setLabel opts idxStr attrs) code           ] replaceBlock opts-  (Div (label,"listing":_, [])-    [Para caption, CodeBlock ("",classes,attrs) code])+  (Div (label,"listing":divClasses, divAttrs)+    [Para caption, CodeBlock ("",cbClasses,cbAttrs) code])   | not $ T.null label   , "lst:" `T.isPrefixOf` label   = case outFormat opts of@@ -269,16 +278,18 @@         let caption' = applyTemplate idxStr caption $ listingTemplate opts         replaceNoRecurse $ Div (label, "listing":classes, []) [             mkCaption opts "Caption" caption'-          , CodeBlock ("", classes, attrs) code+          , CodeBlock ("", classes, setLabel opts idxStr attrs) code           ]-replaceBlock opts (Para [Span attrs [Math DisplayMath eq]])+  where attrs = divAttrs <> cbAttrs+        classes = nub $ divClasses <> cbClasses+replaceBlock opts (Para [Span sattrs@(label, cls, attrs) [Math DisplayMath eq]])   | not $ isLatexFormat (outFormat opts)   , tableEqns opts   = do-    (eq', idx) <- replaceEqn opts attrs eq-    replaceNoRecurse $ Div attrs [+    (eq', idxStr) <- replaceEqn opts sattrs eq+    replaceNoRecurse $ Div (label,cls,setLabel opts idxStr attrs) [       simpleTable [AlignCenter, AlignRight] [ColWidth 0.9, ColWidth 0.09]-       [[[Plain [Math DisplayMath eq']], [eqnNumber idx]]]]+       [[[Plain [Math DisplayMath eq']], [eqnNumber $ stringify idxStr]]]]   where   eqnNumber idx     | outFormat opts == Just (Format "docx")@@ -290,7 +301,7 @@     where mathIdx = Plain [Math DisplayMath $ "(" <> idx <> ")"] replaceBlock _ _ = noReplaceRecurse -replaceEqn :: Options -> Attr -> T.Text -> WS (T.Text, T.Text)+replaceEqn :: Options -> Attr -> T.Text -> WS (T.Text, [Inline]) replaceEqn opts (label, _, attrs) eq = do   let label' | T.null label = Left "eq"              | otherwise = Right label@@ -298,28 +309,30 @@   let eq' | tableEqns opts = eq           | otherwise = eq<>"\\qquad("<>idxTxt<>")"       idxTxt = stringify idxStr-  return (eq', idxTxt)+  return (eq', idxStr)  replaceInlineMany :: Options -> [Inline] -> WS (ReplacedResult [Inline])-replaceInlineMany opts (Span attrs@(label,_,_) [Math DisplayMath eq]:xs)+replaceInlineMany opts (Span spanAttr@(label,clss,attrs) [Math DisplayMath eq]:xs)   | "eq:" `T.isPrefixOf` label || T.null label && autoEqnLabels opts   = replaceRecurse . (<>xs) =<< case outFormat opts of       f | isLatexFormat f ->         pure [RawInline (Format "latex") "\\begin{equation}"-        , Span attrs [RawInline (Format "latex") eq]+        , Span spanAttr [RawInline (Format "latex") eq]         , RawInline (Format "latex") $ mkLaTeXLabel label <> "\\end{equation}"]-      _ -> pure . Span attrs . (:[]) . Math DisplayMath . fst <$> replaceEqn opts attrs eq+      _ -> do+        (eq', idxStr) <- replaceEqn opts spanAttr eq+        pure [Span (label,clss,setLabel opts idxStr attrs) [Math DisplayMath eq']] replaceInlineMany _ _ = noReplaceRecurse  replaceInline :: Options -> Inline -> WS (ReplacedResult Inline)-replaceInline opts (Image attr@(label,_,attrs) alt img@(_, tit))+replaceInline opts (Image (label,cls,attrs) alt img@(_, tit))   | "fig:" `T.isPrefixOf` label && "fig:" `T.isPrefixOf` tit   = do     idxStr <- replaceAttr opts (Right label) (lookup "label" attrs) alt imgRefs     let alt' = case outFormat opts of           f | isLatexFormat f -> alt           _  -> applyTemplate idxStr alt $ figureTemplate opts-    replaceNoRecurse $ Image attr alt' img+    replaceNoRecurse $ Image (label,cls,setLabel opts idxStr attrs) alt' img replaceInline _ _ = noReplaceRecurse  replaceSubfigs :: Options -> [Inline] -> WS (ReplacedResult [Inline])@@ -340,7 +353,7 @@               tit' | "nocaption" `elem` cls = fromMaybe tit $ T.stripPrefix "fig:" tit                    | "fig:" `T.isPrefixOf` tit = tit                    | otherwise = "fig:" <> tit-          in return [Image (label, cls, attrs) alt' (src, tit')]+          in return [Image (label, cls, setLabel opts idxStr attrs) alt' (src, tit')] replaceSubfig _ x = return [x]  divBlocks :: Block -> Block
lib/Text/Pandoc/CrossRef/Util/CodeBlockCaptions.hs view
@@ -45,13 +45,13 @@   , Just caption <- getCodeBlockCaption ils   , not $ T.null label   , "lst" `T.isPrefixOf` label-  = return $ Div (label,"listing":classes, [])+  = return $ Div (label,["listing"], [])       [Para caption, CodeBlock ("",classes,attrs) code] : xs orderAgnostic opts (Para ils:CodeBlock (_,classes,attrs) code:xs)   | codeBlockCaptions opts   , Just (caption, labinl) <- splitLast <$> getCodeBlockCaption ils   , Just label <- getRefLabel "lst" labinl-  = return $ Div (label,"listing":classes, [])+  = return $ Div (label,["listing"], [])       [Para $ init caption, CodeBlock ("",classes,attrs) code] : xs   where     splitLast xs' = splitAt (length xs' - 1) xs'
lib/Text/Pandoc/CrossRef/Util/Options.hs view
@@ -67,4 +67,5 @@                        , subfigGrid :: Bool                        , linkReferences :: Bool                        , nameInLink :: Bool+                       , setLabelAttribute :: Bool                        }
lib/Text/Pandoc/CrossRef/Util/Util.hs view
@@ -67,7 +67,11 @@   | otherwise = False  chapPrefix :: [Inline] -> Index -> [Inline]-chapPrefix delim index = toList $ intercalate' (fromList delim) (map (str . uncurry (fromMaybe . T.pack . show)) index)+chapPrefix delim = toList+  . intercalate' (fromList delim)+  . map str+  . filter (not . T.null)+  . map (uncurry (fromMaybe . T.pack . show))  data ReplacedResult a = Replaced Bool a | NotReplaced Bool type GenRR m = forall a. Data a => (a -> m (ReplacedResult a))
pandoc-crossref.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 5ca00ee6e80501d52f8cd0b7fdfc2fe2b83fc57a68b1c2efe471f696dd95567b+-- hash: 5a129dfce5b068071f7222d4862b7159b9293232e08ec191d8446632b0fe6314  name:           pandoc-crossref-version:        0.3.9.1+version:        0.3.10.0 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@@ -25,9 +25,15 @@ data-files:     docs/demo/demo.md     docs/index.md+    test/m2m/chapDelim/expect.md+    test/m2m/chapDelim/expect.tex+    test/m2m/chapDelim/input.md     test/m2m/delim/expect.md     test/m2m/delim/expect.tex     test/m2m/delim/input.md+    test/m2m/emptyChapterLabels/expect.md+    test/m2m/emptyChapterLabels/expect.tex+    test/m2m/emptyChapterLabels/input.md     test/m2m/equations-auto/expect.md     test/m2m/equations-auto/expect.tex     test/m2m/equations-auto/input.md@@ -67,6 +73,9 @@     test/m2m/section-template/expect.md     test/m2m/section-template/expect.tex     test/m2m/section-template/input.md+    test/m2m/setLabelAttribute/expect.md+    test/m2m/setLabelAttribute/expect.tex+    test/m2m/setLabelAttribute/input.md     test/m2m/subfigures-ccsDelim/expect.md     test/m2m/subfigures-ccsDelim/expect.tex     test/m2m/subfigures-ccsDelim/input.md@@ -119,7 +128,7 @@     , directory >=1 && <1.4     , filepath >=1.1 && <1.5     , mtl >=1.1 && <2.3-    , pandoc >=2.10 && <2.12+    , pandoc >=2.10 && <2.13     , pandoc-types >=1.21 && <1.23     , roman-numerals ==0.5.*     , syb >=0.4 && <0.8@@ -150,7 +159,7 @@     , mtl >=1.1 && <2.3     , open-browser >=0.2 && <0.3     , optparse-applicative >=0.13 && <0.17-    , pandoc >=2.10 && <2.12+    , pandoc >=2.10 && <2.13     , pandoc-crossref     , pandoc-types >=1.21 && <1.23     , roman-numerals ==0.5.*@@ -178,7 +187,7 @@     , filepath >=1.1 && <1.5     , hspec >=2.4.4 && <3     , mtl >=1.1 && <2.3-    , pandoc >=2.10 && <2.12+    , pandoc >=2.10 && <2.13     , pandoc-crossref     , pandoc-types >=1.21 && <1.23     , roman-numerals ==0.5.*@@ -227,7 +236,7 @@     , filepath >=1.1 && <1.5     , hspec >=2.4.4 && <3     , mtl >=1.1 && <2.3-    , pandoc >=2.10 && <2.12+    , pandoc >=2.10 && <2.13     , pandoc-types >=1.21 && <1.23     , roman-numerals ==0.5.*     , syb >=0.4 && <0.8
+ test/m2m/chapDelim/expect.md view
@@ -0,0 +1,9 @@+# 1 Section {#sec:section}++## 1delim1 Subsection {#sec:subsection}++### 1delim1delim1 Subsubsection {#sec:subsubsection}++# 2 Section {#sec:section-1}++### 2delim1delim1 Subsubsection {#sec:subsubsection-1}
+ test/m2m/chapDelim/expect.tex view
@@ -0,0 +1,14 @@+\hypertarget{sec:section}{%+\section{1 Section}\label{sec:section}}++\hypertarget{sec:subsection}{%+\subsection{1delim1 Subsection}\label{sec:subsection}}++\hypertarget{sec:subsubsection}{%+\subsubsection{1delim1delim1 Subsubsection}\label{sec:subsubsection}}++\hypertarget{sec:section-1}{%+\section{2 Section}\label{sec:section-1}}++\hypertarget{sec:subsubsection-1}{%+\subsubsection{2delim1delim1 Subsubsection}\label{sec:subsubsection-1}}
+ test/m2m/chapDelim/input.md view
@@ -0,0 +1,16 @@+---+chapDelim: "delim"+numberSections: true+sectionsDepth: -1+autoSectionLabels: true+...++# Section++## Subsection++### Subsubsection++# Section++### Subsubsection
+ test/m2m/emptyChapterLabels/expect.md view
@@ -0,0 +1,15 @@+# 1 Section {#sec:section}++## 1 Subsection {#sec:subsection label=""}++![Figure 1: Figure1](./image.png){#fig:figure1}++### 1.1 Subsubsection {#sec:subsubsection}++# 2 Section {#sec:section-1}++### 2.1.1 Subsubsection {#sec:subsubsection-1}++sec. 1.1++fig. 1
+ test/m2m/emptyChapterLabels/expect.tex view
@@ -0,0 +1,26 @@+\hypertarget{sec:section}{%+\section{1 Section}\label{sec:section}}++\hypertarget{sec:subsection}{%+\subsection{1 Subsection}\label{sec:subsection}}++\begin{figure}+\hypertarget{fig:figure1}{%+\centering+\includegraphics{./image.png}+\caption{Figure1}\label{fig:figure1}+}+\end{figure}++\hypertarget{sec:subsubsection}{%+\subsubsection{1.1 Subsubsection}\label{sec:subsubsection}}++\hypertarget{sec:section-1}{%+\section{2 Section}\label{sec:section-1}}++\hypertarget{sec:subsubsection-1}{%+\subsubsection{2.1.1 Subsubsection}\label{sec:subsubsection-1}}++sec.~\ref{sec:subsubsection}++fig.~\ref{fig:figure1}
+ test/m2m/emptyChapterLabels/input.md view
@@ -0,0 +1,21 @@+---+numberSections: true+sectionsDepth: -1+autoSectionLabels: true+...++# Section++## Subsection {label=""}++![Figure1](./image.png){#fig:figure1}++### Subsubsection++# Section++### Subsubsection++@sec:subsubsection++@fig:figure1
+ test/m2m/setLabelAttribute/expect.md view
@@ -0,0 +1,23 @@+# Section {#section label="1"}++![Figure 1.1: Figure](./image.png){#fig:1 label="1.1"}++[$$equation\qquad(1.1)$$]{#eq:1 label="1.1"}++::: {#tbl:1 label="1.1"}+  a   b+  --- ---+  1   2++  : Table 1.1: Table+:::++::: {#lst:1 .listing}+Listing 1.1: Code Listing++``` {label="1.1"}+code+```+:::++## Section {#section-1 label="1.customLabel"}
+ test/m2m/setLabelAttribute/expect.tex view
@@ -0,0 +1,42 @@+\hypertarget{section}{%+\section{Section}\label{section}}++\begin{figure}+\hypertarget{fig:1}{%+\centering+\includegraphics{./image.png}+\caption{Figure}\label{fig:1}+}+\end{figure}++\begin{equation}\protect\hypertarget{eq:1}{}{equation}\label{eq:1}\end{equation}++\hypertarget{tbl:1}{}+\begin{longtable}[]{@{}ll@{}}+\caption{\label{tbl:1}Table}\tabularnewline+\toprule+a & b \\+\midrule+\endfirsthead+\toprule+a & b \\+\midrule+\endhead+1 & 2 \\+\bottomrule+\end{longtable}++\begin{codelisting}++\caption{Code Listing}++\hypertarget{lst:1}{%+\label{lst:1}}%+\begin{verbatim}+code+\end{verbatim}++\end{codelisting}++\hypertarget{section-1}{%+\subsection{Section}\label{section-1}}
+ test/m2m/setLabelAttribute/input.md view
@@ -0,0 +1,25 @@+---+setLabelAttribute: true+codeBlockCaptions: true+chapters: true+...++# Section++![Figure](./image.png){#fig:1}++$$equation$${#eq:1}++| a | b |+|---|---|+| 1 | 2 |++: Table {#tbl:1}++```+code+```++: Code Listing {#lst:1}++## Section {label="customLabel"}
test/test-pandoc-crossref.hs view
@@ -244,7 +244,7 @@      describe "Util.CodeBlockCaptions" $       it "Transforms table-style codeBlock captions to codeblock divs" $ do-        let t x = testCBCaptions x (codeBlockDiv "Code Block" "cb")+        let t x = testCBCaptions x (codeBlockDiv' "Code Block" "cb")         t (codeBlockForTable "cb" <> paraText ": Code Block")         t (codeBlockForTable "cb" <> paraText "Listing: Code Block")         t (paraText ": Code Block" <> codeBlockForTable "cb")@@ -405,6 +405,12 @@  codeBlockDiv :: T.Text -> T.Text -> Blocks codeBlockDiv title ref = divWith ("lst:"<>ref, ["listing","haskell"],[]) $+  para (text title) <>+  codeBlockWith+    ("",["haskell"],[]) "main :: IO ()"++codeBlockDiv' :: T.Text -> T.Text -> Blocks+codeBlockDiv' title ref = divWith ("lst:"<>ref, ["listing"],[]) $   para (text title) <>   codeBlockWith     ("",["haskell"],[]) "main :: IO ()"