
if #arg == 1 then
  local file = io.open(arg[1], 'r')
  local text = file:read('*a')
  file:close()

  local title = string.match(text, '# [^\n]+')
  if title then
    title = string.sub(title, 3):gsub('"', '')
    local cmd = 'sh pandoc.sh ' .. arg[1] .. ' "' .. title .. '"'
    print('[pandoc.lua] cmd: ' .. cmd)
    os.execute(cmd)
  else
    print('Impossible de détecter le titre')
  end
else
  print('Paramètres manquants')
end
