A.K.A., how to lure innocent people with highfalutin jargons
ℤhichu ℂhen (ℝoss)
17 Dec, 2021
JACoW
EvolutionLaTeX
, we can use a decent editor with regular expression support.Cat Scan Tools
by David Button.https://ref.ipac19.org/
or directly go to the homepage for the reference if it’s a JACoW
publication.
SPMS
Some people are colourblind. Maybe with another colour scheme?
Taking advantage of the migration of JPSP
, and the software development during the past decades, I see an opportunity to design a different back-end:
Word
, OpenDocument
, LaTeX
, Markdown
…pandoc
Filter Example{-# LANGUAGE OverloadedStrings #-}
import Data.Text (pack,unpack,Text)
import Text.Pandoc.Builder
import Text.Pandoc
import Text.Pandoc.Walk
import System.Environment (getArgs)
purely :: (b -> PandocPure a) -> b -> a
purely f = either (error . show) id . runPure . f
latex :: Text -> Pandoc
latex = purely $ readLaTeX def{
readerExtensions = getDefaultExtensions "latex" }
data Section = Section
{ level :: Int
, attr :: String
, title :: String
}
createSections :: Pandoc -> [Section]
createSections = query mkSec
where mkSec (Header n _ inline) = [ Section
{ level=n
, attr=""
, title=getPlain inline
}]
mkSec _ = []
getPlain :: [Inline] -> String
getPlain [] = ""
getPlain (x:xs) = stripeFrom x <> getPlain xs
where stripeFrom (Str strs ) = unpack strs
stripeFrom (Code _ strs ) = unpack strs
stripeFrom (Math _ strs ) = unpack strs
stripeFrom (RawInline _ strs ) = unpack strs
stripeFrom (Emph strs ) = getPlain strs
stripeFrom (Underline strs ) = getPlain strs
stripeFrom (Strong strs ) = getPlain strs
stripeFrom (Strikeout strs ) = getPlain strs
stripeFrom (Superscript strs ) = getPlain strs
stripeFrom (Subscript strs ) = getPlain strs
stripeFrom (SmallCaps strs ) = getPlain strs
stripeFrom (Quoted _ strs ) = getPlain strs
stripeFrom (Cite _ strs ) = getPlain strs
stripeFrom (Span _ strs ) = getPlain strs
stripeFrom (Link _ strs _) = getPlain strs
stripeFrom (Image _ strs _) = getPlain strs
stripeFrom Space = " "
stripeFrom _ = ""
main :: IO ()
main = do
(fileName:_) <- getArgs
src <- readFile fileName
let secs = createSections $ latex $ pack src
putStrLn $ printResult $ getContents $ secs
where getLevel (Section n _ str) = n
getLevels = map getLevel
getTitle (Section n attr str) = attr <> (show n) <> resetColor <> " " <> str
diffl1 xs = zipWith (-) xs (0:xs)
getColor n = if n>1 then boldRed else boldGreen
boldRed = "\x1b[1;31m"
boldGreen = "\x1b[1;32m"
resetColor = "\x1b[0m"
convertPretty (k, (Section n _ str)) = Section n (getColor k) str
getContents sec = map convertPretty $ zip (diffl1 $ getLevels $ sec) sec
printResult = unlines . map getTitle
darcs
already takes care of that. I don’t want to go too deep. If interested, please refer to
In addition to the good old pdf
files, an HTML
output is also nice.
The HTML
is ready as soon as the .md
is available. No extra work needed.
Hyperlinks, or fancy interactive graphics with javascript.
Meta goodies: times been cited, view similar papers by keywords/categories, follow-up works, share in Tweeter…
With the plugin feature of pandoc
, we can use code fences to post-process the code to generate outputs/figures online. Especially useful for Wikis.