Franklin.ALL_PAGE_VARS
— ConstantDict to keep track of all pages and their vars. Each key is a relative path to a page, values are PageVars. The keys don't have the file extension so "blog/pg1" => PageVars
.
Franklin.AS
— TypeShorter name for a type that we use everywhere
Franklin.ASSIGN_PAT
— ConstantASSIGN_PAT
Regex to match 'var' in an assignment of the form
var = value
Franklin.BIG_INT
— ConstantBig number when we want things to be far.
Franklin.CLOSEP_INSERT
— ConstantCLOSE_INSERT
String that is plugged as a placeholder of blocks that need further processing in a place where any open paragraph must be closed first. For instance this will be the replacement for a header.
Franklin.CODE_BLOCKS_NAMES
— ConstantCODEBLOCKSNAMES
List of names of code blocks environments.
Franklin.CODE_LANG
— ConstantDict to keep track of languages and how comments are indicated and their extensions. This is relevant to allow hiding lines of code.
Franklin.EOS
— ConstantEOS
Convenience symbol to mark the end of the string to parse (helps with corner cases where a token ends a document without being followed by a space).
Franklin.FOLDER_PATH
— ConstantFOLDER_PATH
Container to keep track of where Franklin is being run.
Franklin.GLOBAL_LXDEFS
— ConstantGLOBAL_LXDEFS
List of latex definitions accessible to all pages. This is filled when the config file is read (via manager/file_utils.jl:process_config
).
Franklin.GLOBAL_VARS
— ConstantGLOBAL_VARS
Dictionary of variables accessible to all pages. Used as an initialiser for LOCAL_VARS
and modified by config.md
. Entries have the format KEY => PAIR where KEY is a string (e.g.: "author") and PAIR is a pair where the first element is the current value for the variable and the second is a tuple of accepted possible (super)types for that value. (e.g.: "THE AUTHOR" => (String, Nothing))
Franklin.HBLOCK_FOR_PAT
— ConstantHBLOCK_FOR_PAT
Regex to match {{ for v in iterate }}
or {{ for (v1, v2) in iterate}} etc where iterate
is an iterator
Franklin.HBLOCK_FUN_PAT
— ConstantHBLOCKFUNPAT
Regex to match {{ fname param₁ param₂ }}
where fname
is a html processing function and paramᵢ
should refer to appropriate variables in the current scope.
Franklin.HFUN_PARAMS_PAT
— ConstantHFUN_PARAMS_PAT
Splits the parameter string of a hfun based on whitespaces but allowing single quoted strings with whitespace not to be split.
Franklin.HTML_1C_TOKENS
— ConstantHTML1CTOKENS
Dictionary of single-char tokens for HTML. Note that these characters are exclusive, they cannot appear again in a larger token.
Franklin.HTML_OCB
— ConstantHTML_OCB
List of HTML Open-Close blocks.
Franklin.HTML_OPEN_COND
— TypeBlocks that can open a conditional block.
Franklin.HTML_OPEN_COND_SP
— TypeBlocks that can open a conditional block which are special.
Franklin.HTML_TOKENS
— ConstantHTML_TOKENS
Dictionary of tokens for HTML. Note that for each, there may be several possibilities to consider in which case the order is important: the first case that works will be taken.
Franklin.IGNORE_FILES
— ConstantIGNORE_FILES
Collection of file names that will be ignored at compile time.
Franklin.INFRA_FILES
— ConstantINFRA_EXT
Collection of file extensions considered as potential infrastructure files.
Franklin.INSERT
— ConstantINSERT
String that is plugged as a placeholder of blocks that need further processing. Note: left space in the pattern is to preserve lists.
Franklin.LOCAL_VARS
— ConstantDictionary of variables accessible to the current page. It's initialised with GLOBAL_VARS
and modified via @def ...
.
Franklin.LOGGING
— ConstantDebugging mode
Franklin.LX_ENVNAME_PAT
— ConstantLXENVNAMEPAT
Regex to find the name in a LXBEGIN or LXEND.
Franklin.LX_NAME_PAT
— ConstantLXNAMEPAT
Regex to find the name in a newcommand or a newenvironment within a brace block. For example:
\newcommand{\com}[2]{def}
will give as first capture group \com
.
Franklin.LX_NARG_PAT
— ConstantLXNARGPAT
Regex to find the number of argument in a new command (if it is given). For example:
\newcommand{\com}[2]{def}
will give as second capture group 2
. If there are no number of arguments, the second capturing group will be nothing
.
Franklin.LX_TOKENS
— ConstantLX_TOKENS
List of names of latex tokens. (See markdown tokens)
Franklin.L_RETURNS
— ConstantL_RETURNS
Convenience tuple containing the name for standard line returns and line returns followed by an indentation (either a quadruple space or a tab).
Franklin.MATH_BLOCKS_NAMES
— ConstantMATH_BLOCKS_NAMES
List of names of all maths environments.
Franklin.MATH_BLOCKS_PARENS
— ConstantMATH_BLOCKS_PARENS
Dictionary to keep track of how math blocks are fenced in standard LaTeX and how these fences need to be adapted for compatibility with KaTeX. Each tuple contains the number of characters to chop off the front and the back of the maths expression (fences) as well as the KaTeX-compatible repl. For instance, $ ... $
will become \( ... \)
chopping off 1 character at the front and the back ($
sign).
Franklin.MATH_DISPLAY_BLOCKS_NAMES
— ConstantMATH_DISPLAY_BLOCKS_NAMES
List of names of maths environments (display mode).
Franklin.MATH_LABEL_PAT
— ConstantMATHLABELPAT
Regex to find labels in math
Franklin.MD_1C_TOKENS
— ConstantMD_1C_TOKENS
Dictionary of single-char tokens for Markdown. Note that these characters are exclusive, they cannot appear again in a larger token.
Franklin.MD_1C_TOKENS_LX
— ConstantMD_TOKENS_LX
Subset of MD_1C_TOKENS
with only the latex tokens (for parsing what's in a math environment).
Franklin.MD_CLOSEP
— ConstantMD_CLOSEP
Blocks which, upon insertion, should close any open paragraph. Order doesn't matter.
Franklin.MD_HEADER
— ConstantMD_HEADER
All header symbols.
Franklin.MD_HEADER_OPEN
— ConstantMD_HEADER_OPEN
All header symbols (opening).
Franklin.MD_OCB
— ConstantMD_OCB
List of Open-Close Blocks whose content should be deactivated (any token within their span should be marked as inactive) until further processing. The keys are identifier for the type of block, the value is a pair with the opening and closing tokens followed by a boolean indicating whether the content of the block should be reprocessed. The only OCBlock
not in this dictionary is the brace block since it should not deactivate its content which is needed to find latex definitions (see parser/markdown/findblocks/findlxdefs).
Franklin.MD_OCB_ALL
— ConstantMD_OCB_ALL
Combination of all MD_OCB
in order. DEV: only really used in tests.
Franklin.MD_OCB_ESC
— ConstantMD_OCB_ESC
Blocks that will be escaped (tokens in their span will be ignored on the current parsing round).
Franklin.MD_OCB_IGNORE
— ConstantMD_OCB_IGNORE
List of names of blocks that will need to be dropped at compile time.
Franklin.MD_OCB_MATH
— ConstantMD_OCB_MATH
Same concept as MD_OCB
but for math blocks, they can't be nested. Separating them from the other dictionary makes their processing easier. Dev note: order does not matter.
Franklin.MD_OCB_NO_INNER
— ConstantMD_OCB_NO_INNER
List of names of blocks which will deactivate any block contained within them as their content will be reprocessed later on. See find_all_ocblocks
.
Franklin.MD_TOKENS
— ConstantMD_TOKENS
Dictionary of tokens for Markdown. Note that for each, there may be several possibilities to consider in which case the order is important: the first case that works will be taken.
Franklin.MD_TOKENS_LX
— ConstantMD_TOKENS_LX
Subset of MD_TOKENS
with only the latex tokens (for parsing what's in a math environment).
Franklin.MESSAGE_FILE_GEN
— ConstantConvenience constants for an automatic message to add to code files.
Franklin.NUM_CHAR
— ConstantSPACER
Convenience list of characters corresponding to digits.
Franklin.OUT_PATH
— ConstantPointer to the /output/
folder associated with an eval block (see also @OUTPUT
).
Franklin.PAGE_BIBREFS
— ConstantPAGE_BIBREFS
Dictionary to keep track of bibliographical references on a page to allow citation within the page.
Franklin.PAGE_EQREFS
— ConstantPAGE_EQREFS
Dictionary to keep track of equations that are labelled on a page to allow references within the page.
Franklin.PAGE_EQREFS_COUNTER
— ConstantPAGEEQREFSCOUNTER
Counter to keep track of equation numbers as they appear along the page, this helps with equation referencing. (The _XC0q
is just a random string to avoid clashes).
Franklin.PAGE_FNREFS
— ConstantPAGE_FNREFS
Keep track of name of seen footnotes; the order is kept as it's a list.
Franklin.PAGE_HEADERS
— ConstantKeep track of seen headers. The key is the refstring, the value contains the title, the occurence number for the first appearance of that title and the level (1, ..., 6).
Franklin.PAGE_LINK_DEFS
— ConstantPAGELINKDEFS
Keep track of link def candidates
Franklin.PATHS
— ConstantPATHS
Dictionary for the paths of the input folders and the output folders. The simpler case only requires the main input folder to be defined i.e. PATHS[:src]
and infers the others via the set_paths!()
function.
Franklin.PREPATH_FIX_PAT
— ConstantPREPATH_FIX_PAT
See fix_links
.
Franklin.SPACE_CHAR
— ConstantSPACE_CHARS
Convenience list of characters that would correspond to a \s
regex. see also https://github.com/JuliaLang/julia/blob/master/base/strings/unicode.jl. To this are added things that would definitely switch token:
- EOS (end of string)
- '}' (if in command)
Franklin.UTILS_NAMES
— ConstantKeep track of the names declared in the Utils module.
Franklin.AbstractBlock
— Typeabstract type AbstractBlock
This is the supertype defining a section of the string into consideration which can be considered as a "block". For instance, abc { ... } def
contains one braces block corresponding to the substring { ... }
. All subtypes of AbstractBlock must have a ss
field corresponding to the substring associated to the block. See also Token
, OCBlock
.
Franklin.EnvBlockError
— TypeAn Env Block was not parsed properly (e.g. the closing delim not found).
Franklin.FileNotFoundError
— TypeA file was not found.
Franklin.HCond
— Typestruct HCond <: Franklin.AbstractBlock
HTML conditional block corresponding to {{if var}} ... {{else}} ... {{end}}
.
Franklin.HElse
— Typestruct HElse <: Franklin.AbstractBlock
HTML token corresponding to {{else}}
.
Franklin.HElseIf
— Typestruct HElseIf <: Franklin.AbstractBlock
HTML token corresponding to {{elseif var}}
.
Franklin.HEnd
— Typestruct HEnd <: Franklin.AbstractBlock
HTML token corresponding to {{end}}
.
Franklin.HFor
— Typestruct HFor <: Franklin.AbstractBlock
HTML token corresponding to {{for x in iterable}}
.
Franklin.HFun
— Typestruct HFun <: Franklin.AbstractBlock
HTML function block corresponding to {{ fname p1 p2 ...}}
.
Franklin.HIf
— Typestruct HIf <: Franklin.AbstractBlock
HTML token corresponding to {{if var}}
.
Franklin.HIsDef
— Typestruct HIsDef <: Franklin.AbstractBlock
HTML token corresponding to {{isdef var}}
.
Franklin.HIsEmpty
— Typestruct HIsEmpty <: Franklin.AbstractBlock
HTML token corresponding to {{isempty var}}
.
Franklin.HIsNotDef
— Typestruct HIsNotDef <: Franklin.AbstractBlock
HTML token corresponding to {{isnotdef var}}
.
Franklin.HIsNotEmpty
— Typestruct HIsNotEmpty <: Franklin.AbstractBlock
HTML token corresponding to {{isnotempty var}}
.
Franklin.HIsNotPage
— Typestruct HIsNotPage <: Franklin.AbstractBlock
HTML token corresponding to {{isnotpage path/page}}
.
Franklin.HIsPage
— Typestruct HIsPage <: Franklin.AbstractBlock
HTML token corresponding to {{ispage path/page}}
.
Franklin.HTMLBlockError
— TypeAn HTML block (e.g. HCond
) was erroneous.
Franklin.HTMLFunctionError
— TypeAn HTML function (e.g. {{fill ...}}
) failed.
Franklin.HTML_OPEN_OTHER
— TypeBlocks that can open another block.
Franklin.HTML_SPCH
— Typestruct HTML_SPCH <: Franklin.AbstractBlock
A special block to wrap special characters like like a html entity and have it left unaffected by the Markdown to HTML transformation so that it can be inserted "as is" in the HTML.
Franklin.HToc
— Typestruct HToc <: Franklin.AbstractBlock
Empty struct to keep the same taxonomy.
Franklin.LiterateRelativePathError
— TypeA relative path was erroneous for Literate.
Franklin.LxCom
— Typestruct LxCom <: Franklin.LxObj
A LxCom
has a similar content as a Block
, with the addition of the definition and a vector of brace blocks.
Franklin.LxDef
— Typestruct LxDef{T}
Structure to keep track of the definition of a latex command declared via a \newcommand{\name}[narg]{def}
or of an environment via \newenvironment{name}[narg]{pre}{post}
. The parametric type depends on the definition type, for a command it will be a SubString (<: AbstractString), for an environment it will be a Pair of SubString (corresponding to pre-post).
Franklin.LxDefError
— TypeA \newcommand
was not parsed properly.
Franklin.LxEnv
— Typestruct LxEnv <: Franklin.LxObj
A LxEnv
is similar to a LxCom
but for an environment.
`\begin{aaa} ... \end{aaa}`
`\begin{aaa}{opt1}{opt2} ... \end{aaa}`
Franklin.LxObj
— Typeabstract type LxObj <: Franklin.AbstractBlock
Super type for LxCom
and LxEnv
.
Franklin.LxObjError
— TypeA latex command or environment was found but could not be processed properly.
Franklin.MathBlockError
— TypeA math block name failed to parse.
Franklin.OCBlock
— TypeOCBlock(η, ω)
OCBlock(η, ω, nestable)
Shorthand constructor to instantiate an OCBlock
inferring the associated substring from the ocpair
(since it's the substring in between the tokens).
Franklin.OCBlock
— Typestruct OCBlock <: Franklin.AbstractBlock
Open-Close block, blocks that are defined by an opening Token
and a closing Token
, they may be nested. For instance braces block are formed of an opening {
and a closing }
and could be nested.
Franklin.OCBlockError
— TypeAn OCBlock was not parsed properly (e.g. the closing token was not found).
Franklin.OCProto
— Typestruct OCProto
Prototype for an open-close block (see OCBlock
) with the symbol of the opening token (e.g. :MATH_A
) and a corresponding list of closing tokens (e.g. (:MATH_A,)
). See also their definitions in parser/md_tokens.jl
.
Franklin.PageVariableError
— TypeA Page Variable wasn't set properly.
Franklin.PageVars
— TypeType of the containers for page variables (local and global).
Franklin.RelativePathError
— TypeA relative path was erroneous.
Franklin.Token
— Typestruct Token <: Franklin.AbstractBlock
A token τ::Token
denotes a part of the source string indicating a region that may need further processing. It is identified by a symbol τ.name
(e.g.: :MATH_ALIGN_OPEN
). Tokens are typically used in this code to identify delimiters of environments. For instance, abc $ ... $ def
contains two tokens :MATH_A
associated with the $
sign. Together they delimit here an inline math expression.
Franklin.TokenFinder
— TypeTokenFinder
Convenience type to define tokens. The Tuple comes from the output of functions such as isexactly
.
Franklin.TrackedFiles
— TypeTrackedFiles
Convenience type to keep track of files to watch.
Franklin._lx_input_code
— MethodHelper function to input a script.
Franklin._lx_input_plot
— FunctionHelper function to input a plot generated by a script.
Franklin.add_disallow_item
— Methodadd_disallow_item()
Add an entry to DISALLOW
.
Franklin.add_if_new_file!
— Functionadd_if_new_file!(dict, fpair, verb)
add_if_new_file!(dict, fpair, verb, in_loop)
Helper function, if fpair
is not referenced in the dictionary (new file) add the entry to the dictionary with the time of last modification as val.
Franklin.add_rss_item
— Methodadd_rss_item()
This is called in convert_and_write
to add an RSS item.
Franklin.add_sitemap_item
— Methodadd_sitemap_item(; html)
Add an entry to SITEMAP_DICT
.
Franklin.attr
— MethodConvenience function to add an id attribute to a html element.
Franklin.build_page
— Methodbuild_page(head, content, pgfoot, foot)
Convenience function to assemble the html of a page out of its parts:
- head
- content and pgfoot (which will be wrapped to form the body)
- foot.
Franklin.change_ext
— Functionchange_ext(fname)
change_ext(fname, ext)
Convenience function to replace the extension of a filename with another.
Franklin.check_for_pat
— Methodcheck_for_pat(v)
Check that we have something like {{for v in iterate}}
or {for (v1,v2) in iterate}}
but not something with unmatched parens.
Franklin.check_ping
— Methodcheck_ping(ipaddr, ttl)
Try a single ping to an address ipaddr
. ttl
limits the maximum number of IP routers that the packet can go through before being thrown away.
Franklin.check_type
— Methodcheck_type(t, tt)
Checks if a data type t
is a subtype of a tuple of accepted types tt
.
Franklin.clean_tags
— Functionclean_tags(rm_tags=nothing)
Check the content of the tag folder and remove orphan pages.
Franklin.cleanpull
— MethodAllows you to pull from your remote git repository after having removed the local output directory. This will help avoid merge clashes.
Franklin.clear_dicts
— Methodclear_dicts()
Clear the environment dictionaries.
Franklin.content
— Methodcontent(lxe)
Content of an LxEnv
block.
`\begin{aaa}{opt1} XXX nd{aaa}` --> ` XXX `
Franklin.content
— Methodcontent(ocb)
Convenience function to return the content of an open-close block (OCBlock
), for instance the content of a {...}
block would be ...
.
Franklin.context
— Methodcontext(parent, position)
Return an informative message of the context of a position and where the position is, this is useful when throwing error messages.
Franklin.convert_and_write
— Methodconvert_and_write(
root,
file,
head,
pgfoot,
foot,
output_path
)
Take a path to an input markdown file (via root
and file
), then construct the appropriate HTML page (inserting head
, pgfoot
and foot
) and finally write it at the appropriate place.
Franklin.convert_block
— Methodconvert_block(β, lxdefs)
Helper function for convert_inter_html
that processes an extracted block given a latex context lxc
and returns the processed html that needs to be plugged in the final html.
Franklin.convert_footnote_def
— Methodconvert_footnote_def(β, lxdefs)
Helper function to convert a [^1]: ...
into a html table for the def.
Franklin.convert_footnote_ref
— Methodconvert_footnote_ref(β)
Helper function to convert a [^1]
into a html sup object with appropriate ref and backref.
Franklin.convert_header
— Methodconvert_header(β, lxdefs)
Helper function for the case of a header block (H1, ..., H6).
- gets a short string for the header anchor
- processes the actual header string as standard markdown (e.g. if has code)
- return the html.
Franklin.convert_html
— MethodConvert a Franklin html string into a html string (i.e. replace {{ ... }}
blocks).
Franklin.convert_html_fblock
— Methodconvert_html_fblock(β)
Helper function to process an individual block when it's a HFun
such as {{ fill author }}
. See also convert_html
.
Franklin.convert_indented_code_block
— Methodconvert_indented_code_block(ss)
Helper function for the indented code block case of convert_block
.
Franklin.convert_inter_html
— Methodconvert_inter_html(ihtml, blocks, lxdefs)
Take a partial markdown string with the INSERT
markers and plug in the appropriately processed block.
Arguments
ihtml
: the intermediary html string (withINSERT
markers)blocks
: vector of blockslxdefs
: latex context
Franklin.convert_math_block
— Methodconvert_math_block(β, lxdefs)
Helper function for the math block case of convert_block
taking the inside of a math block, resolving any latex command in it and returning the correct syntax that KaTeX can render.
Franklin.convert_md
— Functionconvert_md(mds)
convert_md(
mds,
pre_lxdefs;
isrecursive,
isinternal,
isconfig,
has_mddefs,
pagevar,
nostripp
)
Convert a Franklin-Markdown file read as mds
into a Franklin HTML string. Returns the html string as well as a dictionary of page variables.
Arguments
mds
: the markdown string to processpre_lxdefs
: a vector ofLxDef
that are already available.
Keyword arguments
isrecursive=false
: a bool indicating whether the call is the parent call or a child callisinternal=false
: a bool indicating whether the call stems fromfd2html
in internal modeisconfig=false
: a bool indicating whether the file to convert is the configuration filehas_mddefs=true
: a bool indicating whether to look for definitions of page variables
Franklin.convert_md_math
— Functionconvert_md_math(ms)
convert_md_math(ms, lxdefs)
convert_md_math(ms, lxdefs, offset)
Same as convert_md
except tailored for conversion of the inside of a math block (no command definitions, restricted tokenisation to latex tokens). The offset keeps track of where the math block was, which is useful to check whether any of the latex command used in the block have not yet been defined.
Arguments
ms
: the string to convertlxdefs
: existing latex definitions prior to the math blockoffset
: where the mathblock is with respect to the parent string
Franklin.csv2html
— Methodcsv2html(path, header)
Internal function to process an array of strings to markdown table (in one single string). If header is empty, the first row of the file will be used as header.
Franklin.ctok
— Methodctok(ocb)
Convenience function to retrieve the closing token of an OCBlock
.
Franklin.deactivate_blocks_in_envs!
— Methoddeactivate_blocks_in_envs!(blocks, lxenvs)
Deactivate blocks that are contained in an environment so that they be reprocessed later.
Franklin.deactivate_divs
— Methoddeactivate_divs(blocks)
Since divs are recursively processed, once they've been found, everything inside them needs to be deactivated and left for further re-processing to avoid double inclusion.
Franklin.deactivate_inner_blocks!
— Functiondeactivate_inner_blocks!(blocks)
deactivate_inner_blocks!(blocks, nin)
Deactivate blocks inside other blocks when the outer block is bound to be reprocessed. There's effectively two cases:
- (solved here) when a block is inside a larger 'escape' block.
- (solved in
check_and_merge_indented_blocks!
) when an indented code block is contained inside a larger block.
Franklin.deactivate_inner_dbb!
— Methoddeactivate_inner_dbb!(dbb, ranges)
Given ranges found by deactivate_inner_blocks!
deactivate double brace blocks that are within those ranges (they will be reprocessed later).
Franklin.def_GLOBAL_LXDEFS!
— Methoddef_GLOBAL_LXDEFS!()
Convenience function to allocate default values for global latex commands and environments accessible throughout the site. See resolve_lxobj
.
Franklin.def_GLOBAL_VARS!
— MethodRe-initialise the global page vars dictionary. (This is done once).
Franklin.def_LOCAL_VARS!
— MethodRe-initialise the local page vars dictionary. (This is done for every page). Note that a global default overrides a local default. So for instance if title
is defined in the config as @def title = "Universal"
, then the default title on every page will be that.
Franklin.def_PAGE_BIBREFS!
— Methoddef_PAGE_BIBREFS!()
Reset the PAGE_BIBREFS dictionary.
Franklin.def_PAGE_EQREFS!
— Methoddef_PAGE_EQREFS!()
Reset the PAGE_EQREFS dictionary.
Franklin.def_PAGE_FNREFS!
— Methoddef_PAGE_FNREFS!()
Empties PAGE_FNREFS
.
Franklin.def_PAGE_HEADERS!
— Methoddef_PAGE_HEADERS!()
Empties PAGE_HEADERS
.
Franklin.def_PAGE_LINK_DEFS!
— Methoddef_PAGE_LINK_DEFS!()
Empties PAGE_LINK_DEFS
.
Franklin.dpair
— Methoddpair
Helper function to create a default pair for a page variable.
Franklin.emoji
— Methodemoji(token)
Return the emoji corresponding to an Emoji token by querying emoji_symbols
. This assumes that the token has name :EMOJI
and so we know it's in the dict.
Franklin.envbalance
— Methodenvbalance(τ, env)
Helper function to update the inbalance counter when looking for the closing token of an environment block. Adds 1 if the token corresponds to an opening token, removes 1 if it's a closing token and 0 otherwise.
Franklin.envname
— Methodenvname(τ)
Convenience function to get the name of a lx-env delimiter (ignores spaces).
Franklin.fd2html
— Methodfd2html(s; kw)
Take a Markdown string and return the HTML that Franklin would produce for it.
Keywords
internal=false
: if set to true, the current scope (in terms of page variables) will be passed to process the String, otherwise the string will be processed in an isolated scope.dir=""
: if given and ifinternal=false
, sets up a temporary dir for Franklin processing.nop=false
: if set to true, check if the returned HTML string has a starting<p>
and ending</p>
and, if so, strips them off. This should be used with care: for simple strings this is likely to be ok but for strings which would contain multiple paragraphs (e.g. with headers) this may not work well.
Franklin.fd2html_v
— Methodfd2html_v(st; internal, dir, nop)
Return the HTML corresponding to a Franklin-Markdown string as well as all the page variables. See also fd2html
which only returns the html.
Franklin.fd2text
— Methodfd2text(s; kw)
Take a Markdown string and return a version with no markup (used in RSS circumstances). This is bruteforce to say the least, it just discards all HTML tags. It should be safe in that '<' and '>' should have been escaped by the fd2html pass.
Franklin.fd_date
— Methodfd_date(d)
Convenience function taking a DateTime
object and returning the corresponding formatted string with the format contained in LOCAL_VARS["date_format"]
and with the locale data provided in date_months
, date_shortmonths
, date_days
, and date_shortdays
local variables. If short
variations are not provided, automatically construct them using the first three letters of the names in date_months
and date_days
.
Franklin.fd_fullpass
— Functionfd_fullpass(watched_files)
fd_fullpass(watched_files, join_to_prepath)
A single full pass of Franklin looking at all watched files and processing them as appropriate.
Keyword arguments
clear=false
: whether to remove any existing output directoryverb=false
: whether to display messagesis_final_pass=false
: whether it's the final pass before deploymentprerender=false
: whether to prerender katex and code blocksno_fail_prerender=true
: whether to skip if a prerendering goes wrong in which case don't prerender
Franklin.fd_loop
— Methodfd_loop(cycle_counter, _, watched_files)
This is the function that is continuously run, checks if files have been modified and if so, processes them. Every 30 cycles, it checks whether any file was added or deleted and consequently updates the watched_files
.
Franklin.fd_setup
— Functionfd_setup()
fd_setup(no_set_paths)
Sets up the collection of watched files by doing an initial scan of the input directory. It also sets the paths variables and prepares the output directory.
See also serve
.
Franklin.fdplotly
— MethodDisplay a Plotly plot given an exported JSON String
.
using PlotlyJS
fdplotly(json(plot([1, 2]))
Franklin.filter_indented_blocks!
— Methodfilter_indented_blocks!(blocks)
Discard any indented block that is within a larger block to avoid ambiguities (see #285).
Franklin.filter_lr_indent!
— Methodfilter_lr_indent!(vt, s)
In initial phase, discard all :LR_INDENT
that don't meet the requirements for an indented code block. I.e.: where the first line is not preceded by a blank line and then subsequently followed by indented lines.
Franklin.find_all_ocblocks
— Methodfind_all_ocblocks(tokens, ocplist; inmath)
Convenience function to find all ocblocks e.g. such as MD_OCBLOCKS
. Returns a vector of vectors of ocblocks.
Franklin.find_and_fix_md_links
— Methodfind_and_fix_md_links(hs)
Direct inline-style links are properly processed by Julia's Markdown processor but not:
[link title][some reference]
and later[some reference]: http://www.reddit.com
[link title]
and later[link title]: https://www.mozilla.org
[link title](https://www.google.com "Google's Homepage")
(we don't either)
Franklin.find_double_brace_blocks
— Methodfind_double_brace_blocks(tokens)
Find {{
and }}
then form double brace blocks {{ ... }}
(in markdown).
Franklin.find_hrules!
— Methodfind_hrules!(tokens)
Check that a ---
or ***
or ___
starts at the beginning of a line and is preceded by an empty line, if that's not the case, discard it.
Franklin.find_indented_blocks!
— Methodfind_indented_blocks!(tokens, st)
Find markers for indented lines (i.e. a line return followed by a tab or 4 spaces).
Franklin.find_lxcoms
— Functionfind_lxcoms(tokens, lxdefs, braces)
find_lxcoms(tokens, lxdefs, braces, offset; inmath)
Find \command{arg1}{arg2}...
outside of xblocks
and lxdefs
.
Franklin.find_lxdefs
— Methodfind_lxdefs(tokens, blocks)
Find \newcommand
and \newenvironment
elements and try to parse what follows to form a proper Latex command/environment. Return a list of such elements.
The format is:
\newcommand{\NAME}[NARGS]{DEFINITION}
\newenvironment{NAMING}[NARGS]{PRE}{POST}
where [NARGS] is optional.
Franklin.find_lxenv_delims!
— Methodfind_lxenv_delims!(tokens, blocks)
Find \begin{xxx}
and \end{xxx}
blocks.
Franklin.find_lxenvs
— Functionfind_lxenvs(tokens, lxdefs, braces)
find_lxenvs(tokens, lxdefs, braces, offset; inmath)
Find active environment blocks between an opening and matching closing delimiter. These can be nested. See also find_ocblocks
and find_lxcoms
, this is essentially a mix of the two.
Franklin.find_ocblocks
— Methodfind_ocblocks(tokens, ocproto; inmath)
Find active blocks between an opening token (otoken
) and a closing token ctoken
. These can be nested (e.g. braces). Return the list of such blocks.
Franklin.find_opts_braces
— Functionfind_opts_braces(τ, narg, braces)
find_opts_braces(τ, narg, braces, name)
For a command or an environment, find the arguments (i.e. a sequence of braces immediately after the opening token).
Franklin.find_special_chars
— Methodfind_special_chars(tokens)
Take a list of token and return those corresponding to special characters or html entities wrapped in HTML_SPCH
types (will be left alone by the markdown conversion and be inserted as is in the HTML).
Franklin.find_tokens
— Methodfind_tokens(str, dictn, dict1)
Go through a text left to right, one (valid) char at the time and keep track of sequences of chars that match specific tokens. The list of tokens found is returned.
Arguments
str
: the initial textdictn
: dictionary of possible tokens (multiple characters long)dict1
: dictionaro of possible tokens (single character)
Franklin.fix_inserts
— Methodfix_inserts(s)
The insertion token have whitespaces around them: ##FDINSERT##
, this mostly helps but causes a problem when combined with italic or bold markdown mode since _blah_
works but not _ blah _
. This function looks for any occurrence of [\*_] ##FDINSERT##
or the opposite and removes the extraneous whitespace.
Franklin.fix_links
— Methodfix_links(pg)
For a project website, for instance username.github.io/project/
all relative paths should eventually be pre-pended with /project/
. This would happen just before you publish the website (see optimize
or publish
).
Franklin.form_codepaths
— Methodform_codepaths(rpath)
A convenience internal function to get the system paths related to a code script these paths are given raw, without checking whether things exist.
Franklin.form_custom_output_path
— Methodform_custom_output_path(slug)
A user can provide a slug which will then specify the output path. There is the underlying assumption that the path will not clash.
Franklin.form_href
— Methodform_href(lxc, dname; parens, class)
Given a latex command such as \eqref{abc}
, hash the reference (here abc
), check if the given dictionary d
has an entry corresponding to that hash and return the appropriate HTML for it.
Franklin.form_inter_md
— Methodform_inter_md(mds, blocks, lxdefs; isrecursive)
Form an intermediate MD file where special blocks are replaced by a marker (INSERT
) indicating that a piece will need to be plugged in there later.
Arguments
mds
: the (sub)string to convertblocks
: vector of blockslxdefs
: existing latex definitions prior to the math block
Franklin.form_output_path
— Methodform_output_path(base, file, case)
Given a file path split in (base, file)
, form the output path (where the output file will be written/copied).
Franklin.form_super_block!
— Methodform_super_block!(blocks, idx, curseq, del_blocks)
Helper function to merge_indented_blocks
.
Franklin.from
— Methodfrom(ss)
Given a substring ss
, returns the position in the parent string where the substring starts.
Example
julia> ss = SubString("hello", 2:4); Franklin.from(ss)
2
Franklin.from_ifsmaller
— Methodfrom_ifsmaller(v, idx, len)
Convenience function to check if idx
is smaller than the length of v
, if it is, then return the starting point of v[idx]
(via from
), otherwise return BIG_INT
.
Franklin.generate_tag_pages
— Functiongenerate_tag_pages()
generate_tag_pages(refresh_tags)
Create and/or update __site/tag
folders/files. It takes the set of tags to refresh (in which case only the pages associated to those tags will be refreshed) or an empty set in which case all tags will be (re)-generated. Note that if a tag is removed from a page, it may be that refresh_tags
contains a tag which should effectively be removed because no page have it. (This only matters at the end in the call to write_tag_page
). Note: the clean_tags
cleans up orphan tags (tags that wouldn't be pointing to any page anymore).
Franklin.get_for_body
— Methodget_for_body(i, qblocks)
Extract the body of a for loop, keeping track of balancing.
Franklin.get_lxdef_ref
— Functionget_lxdef_ref(lxname, lxdefs)
get_lxdef_ref(lxname, lxdefs, inmath)
get_lxdef_ref(lxname, lxdefs, inmath, offset; isenv)
Get the reference pointing to a LxDef
corresponding to a given lxname
. If no reference is found but inmath=true
, we propagate and let KaTeX deal with it. If something is found, the reference is returned and will be accessed further down. The boolean that is also returned helps keeps track of whether the command or environment was defined in the utils.
Franklin.get_rpath
— Methodget_rpath(fpath)
Extracts the relative file system path out of the full system path to a file currently being processed. Does not start with a path separator. So [some_fs_path]/blog/page.md
–> blog/page.md
(keeps the extension).
Franklin.get_url
— Methodget_url
Take a rpath
and return the corresponding valid url
Franklin.getdef
— Methodgetdef(lxo)
For a given LxObj
, retrieve the definition attached to the corresponding LxDef
via the reference.
Franklin.getname
— Methodgetname(lxc)
For a given LxObj
, retrieve the name of the object via the reference. Example: \cite
–> cite
or \begin{aaa}
–> aaa
.
Franklin.globvar
— Methodglobvar(name; default=nothing)
Convenience function to get the value associated with a global var. Return default
(which is nothing
if not specified) if the variable is not found.
Franklin.hbalance
— Methodhbalance(_)
Internal function to balance conditional blocks. See process_html_qblocks
.
Franklin.hfun_fd2rss
— Methodhfun_fd2rss
Take a fd-markdown string, convert it to HTML and fix relative links.
Franklin.hfun_fill
— Methodhfun_fill(params)
H-Function of the form {{ fill vname }}
or {{ fill vname rpath}}
to plug in the content of a franklin-var vname
(assuming it can be represented as a string).
Franklin.hfun_fix_relative_links
— Methodhfun_fix_relative_links
Makes relative links into full links, typically in the context of RSS.
Franklin.hfun_href
— Methodhfun_href(params)
H-Function of the form {{href ... }}
.
Franklin.hfun_insert
— Methodhfun_insert(params)
H-Function of the form {{ insert fpath }}
to plug in the content of a file at fpath
. Note that the base path is assumed to be PATHS[:layout]
and so paths have to be expressed relative to that.
Franklin.hfun_paginate
— Methodhfun_paginate
Called with {{paginate iterable n_per_page}}
. It is assumed there is only one such call per page. Evaluation is actually delayed.
Franklin.hfun_redirect
— Methodhfun_redirect(params)
H-Function of the form {{redirect /addr/blah.html}}
or {{redirect /addr/blah/}}
if the last part ends with /
then index.html
is appended. Note that the first /
can be omitted.
Franklin.hfun_rfc822
— Methodhfun_RFC822
Print a date with the format 822/1123 (RSS).
Franklin.hfun_sitemap_opts
— Methodhfun_sitemap_opts
Called with {{sitemap_opts monthly 0.5}}
. It is assumed this is called only on raw html pages (e.g. custom landing page).
Example usage
{{sitemap_opts exclude}}
{{sitemap_opts monthly 0.5}}
Franklin.hfun_taglist
— Methodhfun_taglist()
H-Function of the form {{taglist}}
.
Franklin.hfun_toc
— Methodhfun_toc(params)
H-Function of the form {{toc min max}}
(table of contents). Where min
and max
control the minimum level and maximum level of the table of content. The split is as follows:
- key is the refstring
- f[1] is the title (header text)
- f[2] is irrelevant (occurence, used for numbering)
- f[3] is the level
Franklin.html_ahref
— MethodConvenience function to introduce a hyper reference.
Franklin.html_ahref_key
— Methodhtml_ahref_key
Convenience function to introduce a hyper reference relative to a key.
Franklin.html_code
— Functionhtml_code
Convenience function to introduce a code block. With indented blocks, the language will be resolved at build time; as a result no lines will be hidden for such blocks.
Franklin.html_code_inline
— Methodhtml_code_inline
Convenience function to introduce inline code.
Franklin.html_content
— MethodConvenience function for content tagging (see build_page
)
Franklin.html_div
— Methodhtml_div
Convenience function to introduce a div block.
Franklin.html_err
— Functionhtml_err
Insertion of a visible red message in HTML to show there was a problem.
Franklin.html_hk
— MethodConvenience function for a header.
Franklin.html_img
— Functionhtml_img
Convenience function to introduce an image. The alt is escaped just in case the user adds quotation marks in the alt string.
Franklin.html_plotly
— Methodhtml_plotly
Convenience function to plot a Plotly. User need to add a Javascript function PlotlyJS_json
.
Franklin.html_repl_code
— Methodhtml_repl_code
html_skip_hidden
Convenience function to process a code string and hide some lines.
Franklin.html_span
— Methodhtml_span
Convenience function to introduce a named span block.
Franklin.html_sup
— MethodConvenience function for a sup item.
Franklin.html_unescape
— Methodhtml_unescape
Internal function to reverse the escaping of some html code (in order to avoid double escaping when pre-rendering with highlight, see issue 326).
Franklin.include_external_config
— Methodinclude_external_config(filepath)
Given a path to a markdown file, this checks if that file exists. If so, this processes the file as though it were the config.md
markdown file. See process_config
for details.
Note: this should be called from within the utils.jl
so that it's processed before the user's config.md which then takes precedence.
Franklin.incrlook
— Functionincrlook(λ)
incrlook(λ, validator)
Syntactic sugar for the incremental look case for which steps=0
as well as the offset
. This is a case where from a start character we lazily accept the next sequence of characters stopping as soon as a character fails to verify λ(c)
. See also isexactly
.
Franklin.invert_dict
— Methodinvert_dict(dict)
Invert a dictionary i.e transform a=>[1,2],b=>[1] to 1=>[a,b], 2=>[a]
Franklin.is_div_open
— Methodis_div_open(i, c)
In combination with incrlook
, checks to see if we have something that looks like a @@div describing the opening of a div block. Triggering char is a first @
.
Franklin.is_emoji
— Methodis_emoji(i, c)
Check if it looks like an emoji indicator :...
note that it does not take the final :
this is checked and added in validate_emoji!
.
Franklin.is_footnote
— Methodis_footnote(i, c)
Check if it looks like \[\^[\p{L}0-9]+\]:
.
Franklin.is_hr1
— Methodis_hr1(_, c)
Check if it looks like ---+
.
Franklin.is_hr2
— Methodis_hr2(_, c)
Check if it looks like ___+
.
Franklin.is_hr3
— Methodis_hr3(_, c)
Check if it looks like ***+
.
Franklin.is_html_entity
— Methodis_html_entity(i, c)
In combination with incrlook
, checks to see if we have something that looks like a html entity. Note that there can be fake matches, so this will need to be validated later on; if validated it will be treated as HTML; otherwise it will be shown as markdown. Triggerin char is a &
.
Franklin.is_html_escaped
— Methodis_html_escaped
Internal function to check if some html code has been escaped.
Franklin.is_language
— Methodis_language(j)
In combination with incrlook
, checks to see if we have something that looks like a triple backtick followed by a valid combination of letter defining a language. Triggering char is a first backtick.
Franklin.isexactly
— Functionisexactly(refstring)
isexactly(refstring, follow)
isexactly(refstring, follow, isfollowed)
Forward lookup checking if a sequence of characters matches refstring
and is followed (or not followed if isfollowed==false
) by a character out of a list of characters (follow
). It returns
- a number of steps indicating the number of characters to check,
- whether there is an offset or not (if it is required to check a following
character or not),
- a function that can be applied on a sequence of character.
Example
julia> (s, b, f) = isexactly("aabbc", "d", isfollowed=false);
julia> f("aabbcd")
false
julia> f("aabbce")
true
julia> s
5
Franklin.ismodule
— Methodismodule(name)
Checks whether a name is a defined module.
Franklin.join_rpath
— Methodjoin_rpath(rpath)
Internal function to take a unix path, split it along /
and re-join it (which will lead to the same path on unix but not on Windows). This undoes what unixify
does.
Franklin.js2html
— Methodjs2html(hs, jsbuffer, matches, splitter)
Convenience function to run the content of jsbuffer
with node, and lace the results with hs
.
Franklin.js_prerender_highlight
— Methodjs_prerender_highlight(hs)
Takes a html string that may contain <pre><code ... </code></pre>
blocks and use node and highlight.js to pre-render them to HTML.
Franklin.js_prerender_katex
— Methodjs_prerender_katex(hs)
Takes a html string that may contain inline katex blocks \(...\)
or display katex blocks \[ ... \]
and use node and katex to pre-render them to HTML.
Franklin.literate_folder
— FunctionSpecify the folder for the Literate scripts, by default this is scripts/
.
Franklin.literate_post_process
— Methodliterate_post_process(s)
Take a markdown string generated by literate and post-process it to number each code block and mark them as eval-ed ones.
Franklin.literate_to_franklin
— Methodliterate_to_franklin(rpath)
Take a Literate.jl script and transform it into a Franklin-Markdown file.
Franklin.locvar
— Methodlocvar(name; default=nothing)
Convenience function to get the value associated with a local var. Return default
(which is nothing
if not specified) if the variable is not found.
Franklin.lx_figalt
— Method\figalt{...}{...}
Resolve a \figalt{alt}{rpath}
(find a fig and include it with alt).
Franklin.lx_input
— Method\input{qualifier}{rpath}
Resolve a command of the form \input{qualifier}{rpath}
where
qualifier
indicates what should be inserted (either a code block or a generated figure).rpath
indication where it is (in Unix format, seeparse_rpath
).
This command is expected to be used to insert code blocks or the output of code blocks.
Different actions can be taken based on the qualifier:
{lang}
will insert the code in the script with appropriate language indicator. If you want to just include it as plain text, use{plaintext}
.{plot}
or{plot:id}
will look for a displayable image file (gif, png, jp(e)g or svg) in[path_to_script_dir]/output/
and will add animg
block as a result. If anid
is specified, it will try to find an image with the same root name ending withid.ext
whereid
can help identify a specific image if several are generated by the script, typically a number will be used, e.g.:\input{plot:4}{ex2}
.
Franklin.lx_literate
— Method\literate{...}
Resolve a \literate{rpath}
(find a literate script and insert it).
Franklin.lx_nonumber
— Method\nonumber{...}
Suppress the displaying of a number.
Franklin.lx_output
— Method\output{...}
Return the output of a code. Possibly including the result of the code (res=true
) and possibly reprocessing the whole (reproc=true
). At most one will be true. See lx_show
.
Franklin.lx_show
— Method\show{...}
Same as output
but adding the result.
Franklin.lx_tableinput
— Method\tableinput{...}{...}
Resolve a \tableinput{header}{rpath}
(find a table+header and include it).
Franklin.lx_textinput
— Method\textinput{...}
Resolve a \textinput{rpath}
command: insert and reprocess some text. If you just want to include text as a plaintext block use \input{plaintext}{rpath}
instead.
Franklin.lx_textoutput
— Method\textoutput{...}
Same as output
but with re-processing.
Franklin.lxd
— Functionlxd(n, k)
lxd(n, k, d)
Convenience function to create pairs (commandname => simple lxdef)
Franklin.lxe
— Functionlxe(n, k)
lxe(n, k, d)
Convenience function to create pairs (envdname => simple envdef)
Franklin.match_url
— Methodmatch_url(base, cand)
Try to match two url indicators.
Franklin.matchrange
— Methodmatchrange(m)
Returns the string span of a regex match. Assumes there is no unicode in the match.
Example
julia> Franklin.matchrange(match(r"ell", "hello"))
2:4
Franklin.mathenv
— Methodmathenv(s)
Convenience function to denote a string as being in a math context in a recursive parsing situation. These blocks will be processed as math blocks but without adding KaTeX elements to it given that they are part of a larger context that already has KaTeX elements. NOTE: this happens when resolving latex commands in a math environment. So for instance if you have $$ x \in \R $$
and \R
is defined as a command that does \mathbb{R}
well that would be an embedded math environment. These environments are marked as such so that we don't add additional KaTeX markers around them.
Franklin.md2html
— Methodmd2html(ss; stripp)
Convenience function to call the base markdown to html converter on "simple" strings (i.e. strings that don't need to be further considered and don't contain anything else than markdown tokens). The boolean stripp
indicates whether to remove the inserted <p>
and </p>
by the base markdown processor, this is relevant for things that are parsed within latex commands etc.
Franklin.merge_blocks
— Methodmerge_blocks(lvb)
Merge vectors of blocks by order of appearance of the blocks.
Franklin.merge_indented_blocks!
— Methodmerge_indented_blocks!(blocks, mds)
When two indented code blocks follow each other and there's nothing in between (empty line(s)), merge them into a super block.
Franklin.modulename
— Methodmodulename(fpath)
Return a sandbox module name corresponding to the page at fpath
, effectively FD_SANDBOX_*
where *
is a hash of the path.
Franklin.newmodule
— Methodnewmodule(name)
Creates a new module with a given name, if the module exists, it is wiped. Discards the warning message that a module is replaced which may otherwise happen. Return a handle pointing to the module.
Franklin.ocbalance
— Methodocbalance(τ, ocp)
Helper function to update the inbalance counter when looking for the closing token of a block with nesting. Adds 1 if the token corresponds to an opening token, removes 1 if it's a closing token and 0 otherwise.
Franklin.optimize
— Methodoptimize(
;
prepath,
version,
prerender,
minify,
sig,
no_fail_prerender,
on_write,
suppress_errors,
clear,
cleanup,
fail_on_warning
)
Does a full pass followed by a pre-rendering and minification step.
prepath=""
: set this to something like "project-name" if it's a project page (usually this is set via config.md)version=""
: if "dev", the base url will be/{prepath}/dev/
, if "xxx", the base url will be/{prepath}/stable/
, a copy of the website will also be at/{prepath}/xxx/
an example would beversion="v0.15.2"
. If left empty, the base url is just/{prepath}/
.is_preview=false
: if true, then no matter what the version given is, it will not update/stable/
and/dev/
.prerender=true
: whether to pre-render katex and highlight.js (requiresnode.js
)minify=true
: whether to minify output (requirespython3
andcss_html_js_minify
)sig=false
: whether to return an integer indicating success (seepublish
)clear=false
: whether to clear the output dir and thereby regenerate everythingno_fail_prerender=true
: whether to ignore errors during the pre-rendering processsuppress_errors=true
: whether to suppress errorsfail_on_warning=false
: if true, warnings become fatal errorscleanup=true
: whether to empty environment dictionarieson_write(pg, fd_vars)
: callback function after the page is rendered, passing as arguments the rendered page and the page variables
Note: if the prerendering is set to true
, the minification will take longer as the HTML files will be larger (especially if you have lots of maths on pages).
Franklin.otok
— Methodotok(ocb)
Convenience function to retrieve the opening token of an OCBlock
.
Franklin.pagevar
— Methodpagevar(rpath, name; default=nothing)
Convenience function to get the value associated with a var available to a page corresponding to rpath
. So for instance if blog/index.md
has @def var = 0
then this can be accessed with pagevar("blog/index", "var")
or pagevar("blog/index.md", "var")
. If rpath
is not yet a key of ALL_PAGE_VARS
then maybe the page hasn't been processed yet so force a pass over that page.
Return default
(which is nothing
if not specified) if the variable is not found.
Franklin.parse_code
— Methodparse_code(code)
Consumes a string with Julia code, returns a vector of expression(s).
Note: this function was adapted from the parse_input
function from Weave.jl.
Franklin.parse_fenced_block
— Functionparse_fenced_block(ss)
parse_fenced_block(
ss,
scut;
shortcut,
repl,
shell,
pkg,
help
)
Take a fenced code block and return a tuple with the language, the relative path (if any) and the code.
Franklin.parse_rpath
— Methodparse_rpath(rpath; canonical, code)
Internal function to parse a relative path and return either a path relative to the website root folder or the website assets folder or a full system path. This doesn't check whether the path points to an existing asset (for that see resolve_rpath
.
/[path]
: this is a path relative to the website root folder, e.g.:/foo/figs/img1.png
.[path]
: this is a path relative to the site assets folder, e.g.:/assets/foo
../[path]
: this is a path relative to the assets folder with the same path as the calling page. For instance,./im1.png
insrc/pages/pg1.md
will point to/assets/pages/pg1/im1.png
.
Otherwise, if in code
mode, recurse with ./code/path
.
Argument
rpath
: the relative path (always in Unix format)
Keywords
canonical=false
: whether to return a full path on the system (true
) or a unix-path relative to the website root folder (false
).code=false
: whether we're in a code context or not (in which case an additional shortcut form is allowed).
Franklin.pastdef
— Methodpastdef(λ)
Convenience function to return a copy of a definition indicated as having already been earlier in the context i.e.: earlier than any other definition appearing in the current chunk.
Franklin.path
— Methodpath(s)
Return the paths corresponding to s
e.g. path(:folder)
.
Franklin.postprocess_page
— Methodpostprocess_page(pg)
Take a generated HTML string and apply prerendering and link fixing as appropriate.
Franklin.prepare_for_rss
— Methodprepare_for_rss()
If there's an RSS feed to generate, check that the template files are there, if not then get them from FranklinTemplates. Also check that a few key variables are defined.
Franklin.prepare_output_dir
— Methodprepare_output_dir()
Prepare the output directory PATHS[:pub]
. If the environment variable CLEAR is true then the output folder is erased first (can be helpful to clean things and truly start from scratch).
Franklin.preprocess_candidate_mddefs!
— Methodpreprocess_candidate_mddefs!(tokens)
Takes a list of tokens and deactivate tokens that happen to be in a multi-line md-def. Used in convert_md
.
Franklin.process_config
— Methodprocess_config()
Checks for a config.md
file and uses it to set the global variables referenced in GLOBAL_VARS
it also sets the global latex commands via GLOBAL_LXDEFS
. If the configuration file is not found a warning is shown. The keyword init
is used internally to distinguish between the first call where only structural variables are considered (e.g. controlling folder structure).
Franklin.process_file
— Methodprocess_file(case, fpair, args)
See process_file_err
.
Franklin.process_file_err
— Functionprocess_file_err(case, fpair)
process_file_err(case, fpair, head)
process_file_err(case, fpair, head, pgfoot)
process_file_err(case, fpair, head, pgfoot, foot)
process_file_err(case, fpair, head, pgfoot, foot, t)
Considers a source file which, depending on case
could be a HTML file or a file in Franklin-Markdown etc, located in a place described by fpair
, processes it by converting it and adding appropriate header and footer and writes it to the appropriate place. It can throw an error which will be caught in process_file(args...)
.
Franklin.process_html_cond
— Methodprocess_html_cond(hs, qblocks, i)
Recursively process a conditional block from an opening HTMLCONDOPEN to a {{end}}.
Franklin.process_html_for
— Methodprocess_html_for(hs, qblocks, i)
Process a for block (for a variable iterate).
Franklin.process_html_qblocks
— Functionprocess_html_qblocks(hs, qblocks)
process_html_qblocks(hs, qblocks, head)
process_html_qblocks(hs, qblocks, head, tail)
Take a qualified html block stack and go through it, with recursive calling.
Franklin.process_mddefs
— Functionprocess_mddefs(blocks, isconfig)
process_mddefs(blocks, isconfig, pagevar)
process_mddefs(blocks, isconfig, pagevar, isinternal)
Convenience function to process markdown definitions @def ...
as appropriate. Depending on isconfig
, will update GLOBAL_VARS
or LOCAL_VARS
.
Arguments
blocks
: vector of active docsisconfig
: whether the file being processed is the config file (–> global page variables)isinternal
: whether the call is internal (e.g. within hfun). In that case skip tags.
Franklin.process_utils
— Methodprocess_utils()
Checks for a utils.jl
file and uses it to set global computed variables, functions and html functions. Whatever is defined in utils.jl
takes precedence over things defined internally in Franklin or in the global vars; in particular users can redefine the behaviour of hfuns
though that's not recommended.
Franklin.publish
— Methodpublish(
;
prerender,
minify,
nopass,
prepath,
message,
cleanup,
final,
do_push
)
This is a simple wrapper doing a git commit and git push without much fanciness. It assumes the current directory is a git folder. It also fixes all links if you specify prepath
(or if it's set in config.md
).
Keyword arguments
prerender=true
: prerender javascript before pushing seeoptimize
minify=true
: minify output before pushing seeoptimize
nopass=false
: set this to true if you have already runoptimize
manually.prepath=""
: set this to something like "project-name" if it's a project pagemessage="franklin-update"
: add commit message.cleanup=true
: whether to cleanup environment dictionaries (should stay true).final=nothing
: a function()->nothing
to execute last, before doing the git push. It can be used to refresh a Lunr index, generate notebook files with Literate, etc, ... You might want to composefdf_*
functions that are exported by Franklin (or imitate those). It can access GLOBAL_VARS.
Franklin.qualify_html_hblocks
— Methodqualify_html_hblocks(blocks)
Given {{ ... }}
blocks, identify what kind of blocks they are and return a vector of qualified blocks of type AbstractBlock
.
Franklin.refstring
— Methodrefstring(s)
Takes a string s
and replace spaces by underscores so that that we can use it for hyper-references. So for instance "aa bb"
will become aa_bb
. It also defensively removes any non-word character so for instance "aa bb !"
will be "aa_bb"
Franklin.reprocess
— Methodreprocess(s, lxdefs; nostripp)
Convenience function to take a markdown string (e.g. produced by a latex command) and re-parse it.
Franklin.resolve_args
— Methodresolve_args(base, braces)
Resolve arguments for LxObj
by interpolating #k
appropriately.
Franklin.resolve_code_block
— Methodresolve_code_block(ss; shortcut, repl, pkg, shell, help)
Helper function to process the content of a code block. Return the html corresponding to the code block, possibly after having evaluated the code.
Franklin.resolve_lxobj
— Methodresolve_lxobj(lxo, lxdefs; inmath)
Take a <: LxObj
and try to resolve it by looking up the appropriate definition, applying it then reparsing the result.
Franklin.resolve_rpath
— Functionresolve_rpath(rpath)
resolve_rpath(rpath, lang)
Internal function to resolve an input (usually a script in a given language) given a relative path (in unix format) and return a tuple with:
- the full system path to the asset
- the full system path to the directory containing the asset
- the name of the asset without its extension
If an extension is not provided, Franklin will try to find something with an adequate extension or, failing that, will try to find anything that matches the file name.
Franklin.robots_generator
— Methodrobots_generator()
Generate a robots.txt
, if one already exists, it will be replaced.
Franklin.rprint
— Methodrprint(s)
Print an overwriting line being aware of the display width.
Franklin.rss_generator
— Methodrss_generator()
Extract the entries from RSSITEMS and assemble the RSS. If RSSITEMS is empty, nothing is generated. If tags are associated with items, also create one feed per tag.
Note: if a file head_rtag.xml
is available, where rtag
is the refstring of a tag, it will take precedence for the corresponding tag feed; otherwise head.xml
will be used.
Franklin.run_code
— Methodrun_code(mod, code, out_path; warn_err, strip_code)
Run some code in a given module while redirecting stdout to a given path. Return the result of the evaluation or nothing
if the code was empty or the evaluation failed. If the evaluation errors, the error is printed to output then a warning is shown.
Arguments
mod
: the module in which to evaluate the code,code
: string corresponding to the code,out_path
: path where stdout should be redirected
Keywords
warn_err=true
: whether to show a warning in the REPL if there was an error running the code.strip=false
: whether to strip the code, this may already have been done.
Franklin.scan_input_dir!
— Methodscan_input_dir!(args; kw...)
Update the dictionaries referring to input files and their time of last change. The variable verb
propagates verbosity.
Franklin.serve
— Methodserve(
;
clear,
verb,
port,
single,
prerender,
nomess,
is_final_pass,
no_fail_prerender,
eval_all,
silent,
cleanup,
on_write,
log,
host,
show_warnings,
fail_on_warning,
launch,
no_set_paths,
join_to_prepath
)
Runs Franklin in the current directory.
Keyword arguments:
clear=false
: whether to remove any existing output directoryverb=false
: whether to display messagesport=8000
: the port to use for the local server (should pick a number between 8000 and 9000)single=false
: whether to run a single pass or run continuouslynomess=false
: suppresses all messages (internal use).is_final_pass=false
: whether we're in a "final pass" (if so, links are fixed in case of a project website, seeconvert_and_write
.prerender=false
: whether to pre-render javascript (KaTeX and highlight.js)no_fail_prerender=true
: whether, in a prerendering phase, ignore errors and try to produce an outputeval_all=false
: whether to force re-evaluation of all code blockssilent=false
: switch this on to suppress all output (including eval statements).cleanup=true
: whether to clear environment dictionaries, seecleanup
.on_write(pg, fd_vars)
: callback function after the page is rendered, passing as arguments the rendered page and the page variableshost="127.0.0.1"
: the host to use for the local servershow_warnings=true
: whether to show franklin warningslaunch=!single
: whether to launch the browser when serving
Franklin.set_cur_rpath
— Methodset_cur_rpath(fpath)
Takes the path to the current file and sets the fd_rpath
local page variable as well as the FD_ENV[:CUR_PATH]
variable (used for conditional blocks depending on URL for instance).
Franklin.set_page_env
— Methodset_page_env()
Initialises all page dictionaries.
Franklin.set_paths!
— Methodset_paths!()
This assigns all the paths where files will be read and written with root the FOLDER_PATH
which is assigned at runtime.
Franklin.set_var!
— Methodset_var!(vars, key, value; isglobal, check)
Take a var dictionary dict
and update the corresponding pair. This should only be used internally as it does not check the validity of val
. See convert_and_write
where it is used to store a file's creation and last modification time.
Note: check
can be false for DTAG, DTAGI which are considered as UnionAll types.
Franklin.set_vars!
— Methodset_vars!(vars, assignments; isglobal)
Given a set of definitions assignments
, update the variables dictionary vars
. Keys in assignments
that do not match keys in vars
are ignored (a warning message is displayed). The entries in assignments
are of the form KEY => STR
where KEY
is a string key (e.g.: "hasmath") and STR
is an assignment to evaluate (e.g.: "=false").
Franklin.should_eval
— Methodshould_eval(code, rpath)
Return true if the code should be reevaluated and false otherwise. The code should be reevaluated if any of following flags are true:
- global eval flag (
eval_all
) - local eval flag (
reeval
) - stale scope (due to a prior code block having been evaluated)
- the code is different than what's in the script
- the output is missings
Franklin.should_ignore
— Methodshould_ignore(fpath, files2ignore, dirs2ignore)
Check if a file path should be ignored. This is a helper function for the scan_input_dir
functions. A bit of a similar principle to match_url
. The file argument is an absolute path, the list would be a list of relative paths. Rules:
''
or'/'
-> ignore'path/fname'
-> ignore exactly that'path/dir/'
-> ignore everything starting withpath/dir/
Franklin.simplify_ps
— Methodsimplify_ps(s)
In some cases, an insertion might look like <p>INS</p>
and the ps could be dropped. This is a helper function to check that (1) there is only one opening and closing p
tag and (2) that they're at the beginning and end of the string in which case they're removed.
Franklin.sitemap_generator
— Methodsitemap_generator()
Generate a sitemap.xml
, if one already exists, it will be replaced.
Franklin.stent
— FunctionConvenience function to strip the content of a block.
Franklin.str
— Methodstr(s)
Returns the string corresponding to s
: s
itself if it is a string, or the parent string if s
is a substring. Do not confuse with String(s::SubString)
which casts s
into its own object.
Example
julia> a = SubString("hello Fraknlin", 3:8);
julia> Franklin.str(a)
"hello Franklin"
julia> String(a)
"llo Fr"
Franklin.subs
— Methodsubs(s, from, to)
subs(s, from)
subs(s, range)
subs(s)
Convenience functions to take a substring of a string.
Example
julia> Franklin.subs("hello", 2:4)
"ell"
Franklin.time_it_took
— Methodtime_it_took(start)
Convenience function to display a time since start
.
Franklin.to
— Methodto(ss)
Given a substring ss
, returns the position in the parent string where the substring ends.
Example
julia> ss = SubString("hello", 2:4); Franklin.to(ss)
4
Franklin.trim_stacktrace
— Methodtrim_stacktrace(s)
Returns only the stack traces which are related to the user's code. This means removing stack traces pointing to Franklin's code. Return the string as-is if the format is unrecognized.
Franklin.unixify
— Methodunixify(rpath; allow_noext)
Internal function to take a relative path and return a unix version of the path (if it isn't already). Used in resolve_rpath
.
Franklin.url_curpage
— Methodurl_curpage
Helper function to get the relative url of the current page.
Franklin.validate_and_store_link_defs!
— Methodvalidate_and_store_link_defs!(blocks)
Keep track of link defs. Deactivate any blocks that is within the span of a link definition (see issue #314).
Franklin.validate_footnotes!
— Methodvalidate_footnotes!(tokens)
Find footnotes refs and defs and eliminate the ones that don't verify the appropriate regex. For a footnote ref: \[\^[\p{L}0-0]+\]
and \[\^[\p{L}0-0]+\]:
for the def.
Franklin.validate_html_entity
— Methodvalidate_html_entity(ss)
Verify that a given string corresponds to a well formed html entity.
Franklin.validate_start_of_line!
— Methodvalidate_start_of_line!(tokens, names)
Given a candidate header block, check that the opening #
is at the start of a line, otherwise ignore the block.
Franklin.verify_links
— Methodverify_links(; ttl)
Verify all links in generated HTML.
Franklin.verify_links_page
— Methodverify_links_page(path, online)
Take a page (in HTML) and check all href
on it to see if they lead somewhere.
Franklin.write_default_tag_layout
— Methodwrite_default_tag_layout()
If _layout/tag.html
is not defined, input a basic default one indicating that the user has to modify it. This will help users transition when they may have used a template that did not define _layout/tag.html
.
Franklin.write_page
— Methodwrite_page(output_path, content; head, pgfoot, foot)
Write a html page at the appropriate location and with the appropriate structure. This is usually called specifying the scaffolding but can be done without in which case the scaffolding is read from layout
.
Franklin.write_tag_page
— Methodwrite_tag_page(tag)
Internal function to (re)write the tag pages corresponding to update_tags
.
Franklin.α
— Methodα(c)
α(c, ac)
Check whether c
is a letter or is in a vector of character ac
.
Franklin.αη
— Methodαη(c)
αη(c, ac)
Check whether c
is alpha numeric or in vector of character ac
Franklin.@OUTPUT
— MacroThis macro points to the /output/
folder associated with an eval block. So for instance, if an eval block generates a plot, you could save the plot with something like savefig(joinpath(@OUTPUT, "ex1.png"))
.