generateTOC headers x@(BulletList (( (( Plain ((Str txt):_)):_)):_)) =
  case tocParams txt of
  Just (mstartlevel, mendlevel) -> 
    render .
    forestDrop mstartlevel .
    forestPrune mendlevel .
    groupByHierarchy $
    headers -- (! A.class_ "right-toc") .
    where
      render = (RawBlock "html") . renderHtml . createTable
  Nothing -> x
generateTOC headers x@(BulletList (( (( Plain ((Str txt):_)):_)):_)) =
  case tocParams txt of
  Just (mstartlevel, mendlevel) -> 
    render .
    forestDrop mstartlevel .
    forestPrune mendlevel .
    groupByHierarchy $
    headers -- (! A.class_ "right-toc") .
    where
      render = (RawBlock "html") . renderHtml . createTable
  Nothing -> x
generateTOC headers x@(BulletList (( (( Plain ((Str txt):_)):_)):_)) =
  case tocParams txt of
  Just (mstartlevel, mendlevel) -> 
    render .
    forestDrop mstartlevel .
    forestPrune mendlevel .
    groupByHierarchy $
    headers -- (! A.class_ "right-toc") .
    where
      render = (RawBlock "html") . renderHtml . createTable
  Nothing -> x