4fc10f8d260d0f77816cbadd6f64541b49bb272b mspeir Mon Jan 27 09:49:27 2025 -0800 adding images for new tutorial and tweaking makefile and lua file to including different bootstrap css file, refs #30335 diff --git docs/staticPage.lua docs/staticPage.lua index d70dbb82947..34a4ba7859f 100644 --- docs/staticPage.lua +++ docs/staticPage.lua @@ -1,455 +1,456 @@ -- UCSC: Slightly modified to produce html that follows the genome browser -- static pages conventions -- -- -- This is a sample custom writer for pandoc. It produces output -- that is very similar to that of pandoc's HTML writer. -- There is one new feature: code blocks marked with class 'dot' -- are piped through graphviz and images are included in the HTML -- output using 'data:' URLs. -- -- Invoke with: pandoc -t staticPage.lua -- -- Character escaping local function escape(s, in_attribute) return s:gsub("[<>&\"']", function(x) if x == '<' then return '<' elseif x == '>' then return '>' elseif x == '&' then return '&' elseif x == '"' then return '"' elseif x == "'" then return ''' else return x end end) end -- Helper function to convert an attributes table into -- a string that can be put into HTML tags. local function attributes(attr) local attr_table = {} for x,y in pairs(attr) do if y and y ~= "" then table.insert(attr_table, ' ' .. x .. '="' .. escape(y,true) .. '"') end end return table.concat(attr_table) end -- Run cmd on a temporary file containing inp and return result. local function pipe(cmd, inp) local tmp = os.tmpname() local tmph = io.open(tmp, "w") tmph:write(inp) tmph:close() local outh = io.popen(cmd .. " " .. tmp,"r") local result = outh:read("*all") outh:close() os.remove(tmp) return result end -- Table to store footnotes, so they can be included at the end. local notes = {} -- Table to store headers, so they can be inserted at the end local headers = {} -- flag to see if we have to close a previous div local headerOpen = false -- Blocksep is used to separate block elements. function Blocksep() return "\n\n" end -- Print contents of `tbl`, with indentation. -- `indent` sets the initial level of indentation. function tprint (tbl, indent) if not indent then indent = 0 end for k, v in pairs(tbl) do formatting = string.rep(" ", indent) .. k .. ": " if type(v) == "table" then print(formatting) tprint(v, indent+1) elseif type(v) == 'boolean' then print(formatting .. tostring(v)) else print(formatting .. v) end end end -- remove all special chars from the string and remove all html tags function simplifyId(idStr) idStr=idStr:gsub("%b<>", "") idStr = string.lower(string.gsub(idStr, "%s+", "-")) idStr = string.lower(string.gsub(idStr, "[^a-zA-z-]", "")) return idStr end -- This function is called once for the whole document. Parameters: -- body is a string, metadata is a table, variables is a table. -- This gives you a fragment. You could use the metadata table to -- fill variables in a custom lua template. Or, pass `--template=...` -- to pandoc, and pandoc will add do the template processing as -- usual. function Doc(body, metadata, variables) local buffer = {} local function add(s) table.insert(buffer, s) end -- ucsc changes start -- debugging of meta info: -- print("vars") -- tprint(variables) -- print("meta") -- tprint(metadata) if metadata["title"] then add("") add("") add("") add("") add("") add("") add("") + add("/style/bootstrap-3-3-7.min.css\">") add("") add("
" .. escape(s) .. "
"
end
function InlineMath(s)
return "\\(" .. escape(s) .. "\\)"
end
function DisplayMath(s)
return "\\[" .. escape(s) .. "\\]"
end
function SingleQuoted(s)
return "‘" .. s .. "’"
end
function DoubleQuoted(s)
return "“" .. s .. "”"
end
function Note(s)
local num = #notes + 1
-- insert the back reference right before the final closing tag.
s = string.gsub(s,
'(.*)', '%1 ↩')
-- add a list item with the note to the note table.
table.insert(notes, '\n" .. s .. "\n
" end -- lev is an integer, the header level. function Header(lev, s, attr) local lines = { } if lev == 1 then idStr = simplifyId(s) table.insert(headers, s) table.insert(lines, "") table.insert(lines, "\n" .. s .. "\n" end function HorizontalRule() return "
" .. escape(s) ..
"
"
end
end
function BulletList(items)
local buffer = {}
for _, item in pairs(items) do
table.insert(buffer, "' .. caption .. '
\n' .. h .. ' | ') empty_header = empty_header and h == "" end if empty_header then head = "" else add('
---|
' .. c .. ' | ') end add('