Thanks everyone, the env vars worked perfectly well. I got it to almost work doing reinterpretation of the AST. There is just one tiny thing that doesn't seem to work, and that is adding a citation to a Listing. I am going to copy-paste the filter and the example. Hopefully, someone who knows more Pandoc internals can help me understand what is going on, and possibly, how to fix it. Thanks ```Haskell filter module Main where import Text.Pandoc.JSON import System.IO.Error (catchIOError) import System.Environment (getEnv) import Text.Pandoc import Data.Text (Text, pack) import qualified Data.Map as M writeMd :: Pandoc -> PandocIO Text writeMd p = writeMarkdown def p readMd :: Text -> PandocIO Pandoc readMd t = readMarkdown def t removeFenceNotes :: Block -> Block removeFenceNotes cb@(CodeBlock (_, _, namevals) _) = case lookup "note" namevals of Just _ -> Div ("", [], []) [] Nothing -> cb removeFenceNotes x = x reinterpretation :: Block -> IO [Block] reinterpretation cb@(CodeBlock (_, _, namevals) text) = case lookup "note" namevals of Just _ -> do p <- runIOorExplode $ readMd (pack text) textMd <- runIOorExplode $ writeMd p p' <- runIOorExplode $ readMd textMd case p' of Pandoc _ b -> return b Nothing -> return [cb] reinterpretation x = return [x] main = do v <- catchIOError (getEnv "FILTERING_MODE") (\_ -> return "") case v of "WITH_COMMENTS" -> toJSONFilter reinterpretation "NO_COMMENTS" -> toJSONFilter removeFenceNotes -- disable comments _ -> return () ``` I call Pandoc with the following command: ``` FILTERING_MODE=WITH_COMMENTS pandoc -s -f markdown -F filters -F pandoc-crossref meta.yaml -o test.pdf TEST.md ``` and the TEST.md file looks as follows: ``` # Capabilities status ```{#lst:maybeLinearSupport .encore caption="Support for `Maybe`'s do not fully work with `linear` types."} subord class Two var x: int def init(): unit this.x = 5 end end linear class One: Id var sub: Two def init(): unit this.sub = new Two() end def x(): int this.sub.x end def setX(x: int): unit this.sub.x = x end end -- this function does not compile. I cannot get it to -- compile in any possible way fun moo(var m: Maybe[One]): One match consume m with case Nothing => consume new One() case Just(z) => consume(z) end end ``` In @lst:maybeLinearSupport, if `One` is `read`, then the function `moo` who receives a `Maybe[One]` works. The distinction between a `read Maybe[One]` and a `linear Maybe[One]` prevents us from reusing this function, i.e., the annotations of `var` and `val` are different and the function cannot be polymorphic on its *mode*. ~~~{note=""} linearity seems to be more related to a property of the object rather than a mode by itself. this means, @lst:maybeLinearSupport can declare a function that we know does not use any linear and we could declare another function that may be `read`, `local` or any other mode that has to be treated *linearly*. what are the implications of this? ~~~ ``` The end result contains the notes without the code block scope and also contain the all markdown items well-formatted, i.e., bold, italics, etc. The only thing that didn't work was reading the reference `@lst:maybeLinearSupport`, which is printed as it looks, instead of referencing the figure. Thanks. On Tuesday, October 2, 2018 at 11:39:41 PM UTC+2, Kolen Cheung wrote: > > c.f. the thread in > https://groups.google.com/d/msg/pandoc-discuss/LIAfgkZKUiE/_KfI3VI6EgAJ about > filter arg. In short env. var. is the way to go right now. > -- You received this message because you are subscribed to the Google Groups "pandoc-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/53d16307-c278-4f3a-8934-f44d9e40862c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.