File: inlines-filter.lua

package info (click to toggle)
haskell-pandoc-lua-engine 0.2.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 648 kB
  • sloc: haskell: 3,709; makefile: 6
file content (19 lines) | stat: -rw-r--r-- 529 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function isWorldAfterSpace (fst, snd)
  return fst and fst.t == 'LineBreak'
   and snd and snd.t == 'Str' and snd.text == 'World!'
end

function Inlines (inlns)
  -- verify that this looks like a `pandoc.List`
  if not inlns.find or not inlns.map or not inlns.filter then
    error("table doesn't seem to be an instance of pandoc.List")
  end

  -- Remove spaces before string "World"
  for i = #inlns-1,1,-1 do
    if isWorldAfterSpace(inlns[i], inlns[i+1]) then
      inlns[i] = pandoc.Space()
    end
  end
  return inlns
end