API
This is a list of documentation associated with every single exported function or object from NoteMate.jl
. There are a few different sections with a brief explanation of what these sections are followed by relevant functions.
Structs
These are the core objects used to represent various note species within NoteMate.jl
. They are designed to be extended or parsed as needed:
NoteMate.FranklinNote
— TypeFranklinNote
Struct representing a Note
to be deployed to a Franklin website.
A note
headed for expression as a Franklin markdown and then a webpage requires additional metadata demanded by Franklin to execute the whole conversion, including information for the RSS feed.
NoteMate.Note
— TypeStruct representing a note in Zettelkasten
The generic Open Knowledge Model note with its key structures, isolated as single strings and some further metadata in appropiate types. Within the constraints of NoteMate this is the generic type to which any note from any specific format parses down, and from which other note structures for representation targets are build using templating functions.
Parsing
These functions are built to parse different sorts of files into NoteMate.jl
objects (i.e. structs). Multiple sections exist to denote what markup languages are able to be parsed as of now:
Markdown
The parsing for NoteMate.jl
supports Markdown – specifically, CommonMark Markdown is supported but support for other variants could be added in the future:
NoteMate.find_citation_groups
— FunctionGiven text and a regular expression that matches a citation group (e.g. pandoc, etc.), extract and return a vector of citation groups from within that text.
Arguments
text::String
- text to be processed
Keyword Arguments
key_regex::Regex
- regular expression to capture citation groups; default captures citation key groups of the form,[@citation]
or[@citation_1; @citation_2]
Returns
- Vector of strings with captured citation key groups
NoteMate.create_inline_citations
— FunctionGiven a list of citation key groups, create inline citations based on a given CSL and a bibliography provided in bibtex.
Arguments
citation_groups::Vector{String}
- a vector of strings containing citation key groupsbibtex_path::String
- path to a bibliography (.bib
format supported)csl_path::String
- path a a CSL standard (i.e..csl
format)
Returns
- Dict with keys as the original citation groups and values as their corresponding inline citation
NoteMate.create_references
— FunctionGiven a list of citation key groups, create a reference list based on a given CSL and a bibtex bibliography.
Arguments
citation_groups::Vector{String}
- a vector of strings containing citation key groupsbibtex_path::String
- path to a bibliography (.bib
format supported)csl_path::String
- path a a CSL standard (i.e..csl
format)
Returns
- String containing an ordered reference list
NoteMate.find_markdown_links
— FunctionGiven text and a regular expression that matches a markdown link, extract and return a vector of markdown links from within that text.
Arguments
text::String
- text to be processed
Keyword Arguments
key_regex::Regex
- regular expression to capture markdown links; default captures markdown links of the form,[linked text](https:://duckduckgo.com)
group_links::Bool
- a boolean that determines if the function should try to determine what kind of link a markdown link is (e.g. a website link, a relative file link, etc.) and returns a dictionary instead of a vector with only the links
Returns
- Vector of strings with captured markdown links
NoteMate.create_relative_links
— FunctionGiven a list of strings denoting a markdown link of the form [text](link)
, update the link to a relative link format.
Arguments
link_strings::Vector
- markdown links to be processed
Keyword Arguments
prefix::String
- a prefix to add to each link; default is""
Returns
- Dict with keys as the original markdown links and values as their corresponding revised relative links
NoteMate.get_headers
— Functionget_headers()
Finds all the MarkDown headers in a file's parse tree.
Arguments
contents
: TheVector
of content structs of a MD struct from Julia standard libraryMarkdown.parse
Returns
The vector of all headers in the parsed Markdown document
NoteMate.get_sections
— Functionget_sections
Separate a whole parsed Markdown document into blocks of the text between headers.
Arguments
contents
: TheVector
of content structs of a MD struct from Julia standard libraryMarkdown.parse
headers
: Vector ofHeader
structs that are found in the submitted document
Keyword Arguments
name_sections = true
: boolean setting to get a dictionary instead of a vector.
Returns
- By default, a dictionary of the headers first word as key and the sections between the headers
- A Vector of all section texts between the headers of the document
NoteMate.get_title_section
— Functionget_title_section
Get the sections that sit underneath title headers.
Arguments
contents
: TheVector
of content structs of a MD struct from Julia standard libraryMarkdown.parse
title_headers
: Vector ofHeader
structs that are considered title headers
Keyword Arguments
name_sections = true
: boolean setting to get a dictionary instead of a vector.
Returns
- By default, a dictionary of the title section under the "Title" key
- A Vector of all section texts started by title headers
Targeting
After parsing a note into a NoteMate.jl
object, these functions support translating each object into a specified target output. These targets are designed to quickly translate one's note to a publishable artifact for the internet (or other future supported platforms). The following sections denote functions that support a given target:
Franklin
Franklin.jl
is a static site generator written in the Julia programming language. It uses its own variant of markdown called "Franklin Markdown" to assist in publishing content to the web:
NoteMate.create_franklin_note
— Functioncreate_franklin_note(note::Note; date_format::String = "U d y")
Transform a generic Note
into a [FranklinNote](@ref)
data structure with special metadata from Note
content.
Arguments
note
: aNote
object that will be used for conversion
Keyword Arguments
date_format
: aString
that accepts a date format; default "U d y" (see:Dates.format
for options)
Return
- A newly prepared
FranklinNote
object
NoteMate.generate_franklin_template
— Functiongenerate_franklin_template()
Generates a template for a Franklin markdown page.
Keyword Arguments
title
: Page title. Default isnothing
slug
: Specifies web page url path (after base path). Default isnothing
tags
: Keywords or tags associated with page. Default isnothing
description
: Description of page contents. Default isnothing
rss_title
: Page title that shows up on RSS feeds. Default isnothing
rss_description
: Description that goes along with RSS updates. Default isnothing
rss_pubdate
: Publication date for RSS feed. Default isnothing
These kwargs are "page variables" that come directly from Franklin.jl
's documentation. For more specific details, please see Page Variables
Return
- A
String
object that contains a valid Franklin template that can then be modified further
Example
If the following call is made: generate_franklin_template(; title = "All-Payer Claims Database", tags = ["apcd", "claims", "database"])
, the following string will be returned:
+++
title = "All-Payer Claims Database"
tags = ["zettel", "apcd", "claims", "database", "archive"]
+++
This can then be edited or formatted further as needed.
NoteMate.generate_note_summary
— Functiongenerate_note_summary
Generate a note summary section using note title, publishing date, rss summary and any keywords.
Arguments
note
: aFranklinNote
struct whose information is formated for the note summary section
Return
- a string formated according to the Open Knowledge Model standard for Franklin, starting with a note title, followed by the Date in
monthname day year
form, the RSS summary of the note, and comma-separated keywords for the note.
An example formating:
Example title:
=========
**Date:** May 12 2020
**Summary:** This is the summary of an example note
**Keywords:** example files, demonstration, documentation
NoteMate.generate_bibliography
— Functiongenerate_bibliography
Generate a bibliography section for a Franklin page.
Arguments
note
: aFranklinNote
struct whose bibliography string will be included in the output
Return
- a string starting with a Fraklin section header, followed after a double newline by the bibliography string stored in the note struct.
NoteMate.generate_citation
— Functiongenerate_citation()
Generate the citation string that can be used to reference the page of this document.
Arguments
note
: aFranklinNote
struct whose information will be used to format the citation strings
Keyword Arguments
citations
: TODO clarify type and structure here
Return
Return string always begin with ## How to Cite\n\n
followed by either:
- if the citation argument is empty, returns a standard citation string with primary author name, note title, homepage link and
monthname day year
date. - if the citation argument is non-empty, will generate a longer citation string with list of all authors before note title, homepage link and
monthname day year
date.
FIXME: This is currently hardcoded for my own personal website. We need to adjust this to not be that way.
NoteMate.generate_references
— Functiongenerate_references
Returns the references string for the note.
Arguments
note
: aFranklinNote
struct whose references string will be included in the output
Return
- the note references string as is, without further formating
NoteMate.generate_comments
— Functiongenerate_comments()
Generates a Fraklin page macro to embed a comments section into a page.
Return
- A string containing a Franklin macro to add comments to a Franklin page. See Franklin Utils for more information.
NoteMate.generate_table_of_contents
— Functiongenerate_table_of_contents()
Generate a hyperlinked Table of Contents for a Franklin page.
Return
- A string containing a Franklin macro to add a table of contents to a Franklin page. See Table of Contents for more information.
Miscellaneous
These functions are mostly for occasional use or do not fit cleanly into anyone section yet.
Missing docstring for sync_file
. Check Documenter's build log for details.