Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
-- This file:
--   http://angg.twu.net/LUA/VideoIndex.lua.html
--   http://angg.twu.net/LUA/VideoIndex.lua
--           (find-angg "LUA/VideoIndex.lua")
-- Author: Eduardo Ochs <eduardoochs@gmail.com>
-- Used by (?):
--   (find-THgrep "grep --color=auto -nH --null -e VideoIndex *.blogme")
-- See:
--   (find-blogme3 "videoindex.lua")


require "Re"  -- (find-angg "LUA/Re.lua")
              -- (find-angg "LUA/Re.lua" "Re-tests")


gram = [=[
  aa  <- ('aa'   -> 'a')
  bss <- ('\\' -> '\')
  bsq <- ('\"' -> '"')
  nbs <- (" "  -> "&nbsp;") 
]=]


gram = [=[
  time  <- ( '"' {  [0-9:]+        } '"')
  str   <- ( '"' {~ (bss / [^"])* ~} '"')
  bss   <- ( ('\\' -> '\') /
             ('\"' -> '"') )
  nbsps <- {~ (" "  -> "&nbsp;")* ~} 
]=]


VideoIndexLine_gram = [=[
  symbol         <- { [-A-Za-z0-9]+ }
  nbsps          <- { " " * } 
  timestr        <- ( '"' { [0-9:]+                  } '"')
  descriptionstr <- ( '"' { ( '\\' / '\"' / [^"] ) * } '"')
  sexp           <- ( '(' symbol " " nbsps timestr nbsps descriptionstr ')' )
]=]

VideoIndexLine = Class {
  type  = "VideoIndexLine",
  new   = function (T) return VideoIndexLine(T or {}) end,
  parse = Re({grammar = VideoIndexLine_gram}):c('top <- sexp'),
  from  = function (str)
      local f, s1, time, s2, descr = VideoIndexLine.parse(str)
      return VideoIndexLine {f=f, s1=s1, time=time, s2=s2, descr=descr}
    end,
  __index = {
    hash = "fpsF_M55W4o", -- Test blocks: http://www.youtube.com/watch?v=fpsF_M55W4o
    nbsp = function (vli, s)
        return (s:gsub(" ", "&nbsp;"))
      end,
    timeurl = function (vli)
        return youtube_make_url(vli.hash, vli.time)
      end,
    timehtml = function (vli)
        return format('<a href="%s">%s<a>', vli:timeurl(), vli.time)
      end,
    descrhtml = function (vli)
        return vli.descr
      end,
    html = function (vli)
        return vli:nbsp(vli.s1)
            .. vli:timehtml()
            .. vli:nbsp(vli.s2)
            .. vli:descrhtml()
      end,
  },
}

vli = VideoIndexLine {}



--[==[
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "VideoIndex.lua"
strs = splitlines [=[
(find-eev2021pevideo  "4:32" "1. Um pouco de contexto")
(find-eev2021pevideo  "5:19"   "1.1.1. hackers felizes")
]=]
PPV(strs)

vli = VideoIndexLine.from(strs[1])
PPV(vli)
= vli:html()

= vli.parse0(strs[1])
PP(vli.parse0(strs[1]))


rtg = Re { print = PP,    grammar = gram }
rth = Re { print = print, grammar = gram }

rtg:c 'top <- sexp ' (strs[1]) 

  rth:c ' top <- str ' [["foo"]]
  rth:c ' top <- str ' [["fo\"o"]]
  rth:c ' top <- str ' [["fo\"o\\"]]
  rth:c ' top <- str ' [["fo\"o\\"a]]


  rth:c ' top <- bss ' [[\\]]
  rth:c ' top <- [^"]* ' [[\\"]]

  rth:c ' top <- bss ' '\\\\'
  rtg:c ' top <- bss ' [[\\\\a\\b\]]
  rtg:c ' top <- {~ (bss / .)* ~} ' [[\\\\a\\b\]]

  rtg:c [[ {~ (bss / bsq / .)* ~} ]]  [[abc\\d\"e]]


= [[\\\\a\\b\]]
  rth:c ' top <- {~ (bss / .)* ~} ' [[\\\\a\\b\]]
   rt:c [[ {~ (('\\\\' -> 'o') / .) * ~} ]] [[\\\\a\\b\]]
   rt:c [[ {~ (('qqqq' -> 'o') / .) * ~} ]] [[\\\\a\\b\]]
   rt:c [[ {~ (('qqqq' -> 'o')    ) * ~} ]] [[\\\\a\\b\]]
   rt:c [[ {~ (('qqqq'       )    ) * ~} ]] [[\\\\a\\b\]]
   rt:c [[ {~ (('qqqq'       )    ) * ~} ]] [[\\\\a\\b\]]
   rt:c [[ {~ (('BQ'  -> 'Q' ) / ('BB' -> 'B') / .) * ~} ]] [[abBQcBBd]]
   rt:c [[ {~ (('\Q'  -> 'Q' ) / ('BB' -> 'B') / .) * ~} ]] [[ab\QcBBd]]



  rtg:c ' top <- {~ (("a" -> "AA") / "b")* ~} ' 'abc'
  rtg:c ' top <- {~ (("a" -> "AA") / .  )* ~} ' 'abca'
  rtg:c ' top <- {~ (("\\\\" -> "IO") / .  )* ~} ' 'abc\\\\a'
  rtg:c ' top <- {~ (("\\\\" -> "IO") / ("\\\"" -> "YE" ) .  )* ~} ' 'abc\\\\a'

  rtg:c ' top <- {~ (backslashseq / [a-z])* ~} ' 'abc09' 
  rtg:c ' top <- {~ (backslashseq / [a-z])* ~} ' 'abc\\09' 

= rtp:c ' "" -> "\\" ' 'a'
= rt0:c ' "" -> "\\" ' 'a'

= rtp:c ' {~ (("__"   -> "_" ) / .)* ~} ' 'ab__cd_ef'
= rtp:c ' {~ (("\\\\" -> "\\") / .)* ~} ' 'ab\\\\cd\\ef'
= rt0:c ' {~ (("\\\\" -> "\\") / .)* ~} ' 'ab\\\\cd\\ef'

= 'ab\\cd'

= rtp:c ' { "a" -> "AA" } ' 'aaab'
= rtg:c ' top <- S ' '   a'
= rtg:c ' top <- str ' '"foo"a'
= rtg:c ' top <- str ' '"f\\"oo"a'
= rtg:c ' top <- {~ backslashseq ~} ' '\\\\'
= print("foo", rtg:c ' top <- {~ backslashseq ~} ' '\"', "bar")

= '\\"'



--]==]