"Fossies" - the Fresh Open Source Software Archive

Member "highlight-3.57-x64/plugins/cpp_ref_local_includes.lua" (12 May 2020, 2122 Bytes) of package /windows/www/highlight-3.57-x64.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Lua source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "cpp_ref_local_includes.lua": 3.53_vs_3.54.

    1 --[[
    2 Sample plugin file for highlight 3.9
    3 ]]
    4 
    5 Description="Add reference links to local C or C++ headers in HTML, LaTeX, RTF and ODT output. Set base_url in the plug-in script if needed."
    6 
    7 Categories = {"c++", "html", "rtf", "latex", "odt" }
    8 
    9 
   10 -- optional parameter: syntax description
   11 function syntaxUpdate(desc)
   12 
   13     -- INSERT BASE URL HERE
   14   base_url=''
   15 
   16   if desc~="C and C++" then
   17     return
   18   end
   19 
   20   --see comment in themeUpdate
   21   table.insert( Keywords, { Id=#Keywords+1, Regex=[[\w+\.h[px]*]] } )
   22 
   23   function getURL(token)
   24     url=base_url..string.lower(token).. '.html'
   25 
   26     if (HL_OUTPUT== HL_FORMAT_HTML or HL_OUTPUT == HL_FORMAT_XHTML) then
   27       return '<a class="hl" target="new" href="' .. url .. '">'.. token .. '</a>'
   28     elseif (HL_OUTPUT == HL_FORMAT_LATEX) then
   29       return '\\href{'..url..'}{'..token..'}'
   30     elseif (HL_OUTPUT == HL_FORMAT_RTF) then
   31       return '{{\\field{\\*\\fldinst HYPERLINK "'..url..'" }{\\fldrslt\\ul\\ulc0 '..token..'}}}'
   32     elseif (HL_OUTPUT == HL_FORMAT_ODT) then
   33       return '<text:a xlink:type="simple" xlink:href="'..url..'">'..token..'</text:a>'
   34     end
   35   end
   36 
   37   function Decorate(token, state)
   38 
   39     if state==HL_PREPROC_STRING and string.find(token, "%w+.h[px]*")==1 then
   40       return getURL(token)
   41     end
   42 
   43   end
   44 end
   45 
   46 
   47 function themeUpdate(desc)
   48   -- no need to add a bogus style for the 6th keyword class defined in syntaxUpdate,
   49   -- the regex is just needed to get the complete token, but it will be recognized
   50   -- as string because string has higher priority
   51 
   52   if (HL_OUTPUT == HL_FORMAT_HTML or HL_OUTPUT == HL_FORMAT_XHTML) then
   53     Injections[#Injections+1]="a.hl, a.hl:visited {color:inherit;font-weight:inherit;}"
   54   elseif (HL_OUTPUT==HL_FORMAT_LATEX) then
   55     Injections[#Injections+1]="\\usepackage[colorlinks=false, pdfborderstyle={/S/U/W 1}]{hyperref}"
   56   end
   57 end
   58 
   59 --The Plugins array assigns code chunks to themes or language definitions.
   60 --The chunks are interpreted after the theme or lang file were parsed,
   61 --so you can refer to elements of these files
   62 
   63 Plugins={
   64 
   65   { Type="lang", Chunk=syntaxUpdate },
   66   { Type="theme", Chunk=themeUpdate },
   67 
   68 }