File: outhtml_tooltips.lua

package info (click to toggle)
highlight 4.10-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,556 kB
  • sloc: cpp: 27,579; makefile: 411; sh: 341; ansic: 264; php: 236; python: 217; ruby: 132; perl: 61; tcl: 1
file content (38 lines) | stat: -rw-r--r-- 904 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
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

Description="Add HTML tooltips within comments linked to circled numbers (format as @tip[tooltip text])"

Categories = {"format", "html", "usability" }

function syntaxUpdate(desc)

  ttCnt=0 -- tooltip counter

  table.insert( Keywords,
        { Id=102,
          Regex=[=[\@tip\[.+\]]=],
          Group=0
        })

  function Decorate(token, state)
    if (HL_OUTPUT ~= HL_FORMAT_HTML and HL_OUTPUT ~= HL_FORMAT_XHTML) then
      return
    end

    if (state ~= HL_LINE_COMMENT and state ~= HL_BLOCK_COMMENT) then
      return
    end

    title = string.match(token, "%@tip%[(.+)%]")
    if title~=nil then
          if ttCnt>19 then ttCnt=0 end
          ttCnt = ttCnt + 1
      -- use Unicode circle entities 1..20
          return '<span style="font-style: normal;" title="' .. title ..'">&#'..(ttCnt + 9311)..';</span>'
    end

  end
end

Plugins={
  { Type="lang", Chunk=syntaxUpdate },
}