This is the markdown.cl Reference Manual, version 0.1.7, generated automatically by Declt version 4.0 beta 2 "William Riker" on Thu Aug 15 05:51:11 2024 GMT+0.
The main system appears first, followed by any subsystem dependency.
markdown.cl
A markdown parser for Common Lisp
Andrew Danger Lyon <orthecreedence@gmail.com>
MIT
0.1.7
cl-ppcre
(system).
xmls
(system).
split-sequence
(system).
package.lisp
(file).
util.lisp
(file).
html.lisp
(file).
parser.lisp
(file).
Files are sorted by type and then listed depth-first from the systems components trees.
markdown.cl/markdown.cl.asd
markdown.cl/package.lisp
markdown.cl/util.lisp
markdown.cl/html.lisp
markdown.cl/parser.lisp
markdown.cl/util.lisp
package.lisp
(file).
markdown.cl
(system).
*nl*
(special variable).
file-contents
(function).
markdown.cl/html.lisp
util.lisp
(file).
markdown.cl
(system).
error-parsing-html
(condition).
*block-level-elements*
(special variable).
*html-chunks*
(special variable).
block-element-p
(function).
cleanup-markdown-tags
(function).
escape-html-entities
(function).
fix-a-tags
(function).
fix-inline-links
(function).
post-process-markdown-html
(function).
pre-process-markdown-html
(function).
replace-html-blocks
(function).
stash-html-block-tags
(function).
markdown.cl/parser.lisp
html.lisp
(file).
markdown.cl
(system).
parse
(function).
parse-file
(function).
*link-references*
(special variable).
*list-recursion-level*
(special variable).
*scanner-block-list-pos*
(special variable).
*scanner-blockquote*
(special variable).
*scanner-find-first-html-block-element*
(special variable).
*scanner-find-last-html-block-element*
(special variable).
*scanner-lazy-blockquote*
(special variable).
*tmp-storage*
(special variable).
cleanup-code
(function).
cleanup-escaped-characters
(function).
cleanup-hr
(function).
cleanup-newlines
(function).
cleanup-paragraphs
(function).
convert-lazy-blockquote-to-standard
(function).
do-parse-br
(function).
do-parse-code
(function).
do-parse-double-code
(function).
do-parse-em
(function).
do-parse-entities
(function).
escape-html
(function).
escape-links-href
(function).
format-blockquote
(function).
format-code
(function).
format-html-blocks-in-paragraph
(function).
format-lists
(function).
gather-link-references
(function).
inject-saved-blockquotes
(function).
join-list-lines
(function).
make-image
(function).
make-link
(function).
normalize-lists
(function).
pad-string
(function).
paragraph-format
(function).
parse-atx-headers
(function).
parse-blockquote
(function).
parse-br
(function).
parse-code
(function).
parse-em
(function).
parse-embedded-blockquote
(function).
parse-embedded-code
(function).
parse-entities
(function).
parse-escaped-characters
(function).
parse-horizontal-rule
(function).
parse-inline-code
(function).
parse-links
(function).
parse-links-ref
(function).
parse-links-self
(function).
parse-list-blocks
(function).
parse-lists
(function).
parse-not-in-code
(function).
parse-paragraphs
(function).
parse-quick-links
(function).
parse-setext-headers
(function).
parse-table
(function).
pre-format-paragraph-lists
(function).
prepare-markdown-string
(function).
split-blocks
(function).
Packages are listed by definition order.
markdown.cl
markdown
common-lisp
.
error-parsing-html
(condition).
parse
(function).
parse-file
(function).
*block-level-elements*
(special variable).
*html-chunks*
(special variable).
*link-references*
(special variable).
*list-recursion-level*
(special variable).
*nl*
(special variable).
*scanner-block-list-pos*
(special variable).
*scanner-blockquote*
(special variable).
*scanner-find-first-html-block-element*
(special variable).
*scanner-find-last-html-block-element*
(special variable).
*scanner-lazy-blockquote*
(special variable).
*tmp-storage*
(special variable).
block-element-p
(function).
cleanup-code
(function).
cleanup-escaped-characters
(function).
cleanup-hr
(function).
cleanup-markdown-tags
(function).
cleanup-newlines
(function).
cleanup-paragraphs
(function).
convert-lazy-blockquote-to-standard
(function).
do-parse-br
(function).
do-parse-code
(function).
do-parse-double-code
(function).
do-parse-em
(function).
do-parse-entities
(function).
escape-html
(function).
escape-html-entities
(function).
escape-links-href
(function).
file-contents
(function).
fix-a-tags
(function).
fix-inline-links
(function).
format-blockquote
(function).
format-code
(function).
format-html-blocks-in-paragraph
(function).
format-lists
(function).
gather-link-references
(function).
inject-saved-blockquotes
(function).
join-list-lines
(function).
make-image
(function).
make-link
(function).
normalize-lists
(function).
pad-string
(function).
paragraph-format
(function).
parse-atx-headers
(function).
parse-blockquote
(function).
parse-br
(function).
parse-code
(function).
parse-em
(function).
parse-embedded-blockquote
(function).
parse-embedded-code
(function).
parse-entities
(function).
parse-escaped-characters
(function).
parse-horizontal-rule
(function).
parse-inline-code
(function).
parse-links
(function).
parse-links-ref
(function).
parse-links-self
(function).
parse-list-blocks
(function).
parse-lists
(function).
parse-not-in-code
(function).
parse-paragraphs
(function).
parse-quick-links
(function).
parse-setext-headers
(function).
parse-table
(function).
post-process-markdown-html
(function).
pre-format-paragraph-lists
(function).
pre-process-markdown-html
(function).
prepare-markdown-string
(function).
replace-html-blocks
(function).
split-blocks
(function).
stash-html-block-tags
(function).
Definitions are sorted by export status, category, package, and then by lexicographic order.
Parse a markdown string into HTML.
Parse a markdown file into HTML (returned as a string).
Thrown then xmls cannot parse the HTML in a document (make sure your <img> tags are closed.
error
.
Stores all HTML tags considered block-level.
Holds a hash table that harbors HTML tags from the destructive forces of markdown parsing until they are ready to be injected back into the document.
Holds a hash table mapping link ids to URLs.
Holds a string of a single newline character.
Detects if a block has a ul/ol section.
A scanner for finding blockquotes.
A scanner that searches for HTML elements that are not inline.
A scanner that searches for HTML elements that are not inline.
A scanner for finding blockquotes.
Holds a hash table used for temporary blockquote storage.
Test if a given HTML tag is a block-level element.
Let’s convert our {{markdown.cl|code|...}} tags to <code> tags.
Convert escaped characters back to non-escaped.
Due to the way processing <hr> tags occurs, they are always wrapped in <p> blocks. Instead of trying to figure out a way to NOT wrap them in <p> blocks (which would surely screw up the rest of the paragraph formatting) it makes more sense to let it happen, then fix in the final pass.
Here we remove excess newlines and convert any markdown.cl newlines into real ones.
Remove any empty paragraph blocks (it does happen sometimes) and convert all markdown.cl paragraphs into real <p> tags.
Converts a lazy blockquote:
> this a blockquote that
spans multiple lines but
im too lazy to add the ’>’
at the beginning of each line
into:
> this a blockquote that
> spans multiple lines but
> im too lazy to add the ’>’
> at the beginning of each line
Parse <br> tags (when a line ends with two spaces).
Parse ‘...‘ code blocks.
Parse “...“ code blocks.
Parse *, _, **, and __.
Replace non-purposeful entities with escaped equivalents.
Meant to be called on text inside code blocks.
Hide HTML entities from the HTML parser. It doesn’t like them. It has the death penalty on 12 systems.
Escape any underscores in href=... text so it’s not replaced with <em>s
Sucks up an entire file from PATH into a freshly-allocated string, returning two values: the string and the number of bytes read.
XMLS mangles our <a> tags. Fix
Fix <http://teh-link.com> links, which messes with XMLS’ mind.
Given a string that we know is a blockquote, remove the blockquote formatting and recursively parse markdown within the blockquote. If the given blockquote is not ’lazy’ then lazy blockquote parsing is disabled in the recursive parse so as not to screw up formatting.
Sanely formats code blocks.
This is a very helpful function which turns:
<p>this is my text<div>this is inside a block</div> more text</p>
into:
<p>this is my text</p><div>this is inside a block</div><p>more text</p>
In other words, it unwraps <p> tags from around HTML block elements, and does so such that all text between the first block tag found and after the last block tag found is left untouched (and unwrapped by <p>).
This is the function that actually makes lists happen. Once all the blocks
have been diced up into neat little packages ready for formatting, they are
handed off to format-lists.
This function is responsible for adding the <ul>/<ol>/<li> tags around list
items, making sure to only do this for items using the correct indentation
level.
List items inject any saved blockquotes (via inject-saved-blockquotes) before
moving on to paragraph processing. This step is essential because a lot of
the blockquote formatting can screw up the splitting of list items correctly,
resulting in <p> blocks in really weird places.
List items are run through the paragraph filters, have a minimal amount of formatting applied to make sure the recursion goes smoothly, and then are recursively concated onto the final string.
Look for any link references in the document:
[link-id]: http://my-url.com
[4]: http://my-link.com (optional title)
[mylink]: http://my-url.com/lol ’kewl link brah’
[omg]: http://lol.com/wtf "rofl"
and parse them into the *link-references* hash table. The data will be pulled
out when parse-links is called.
Note that as a side effect, this also gathers image references =].
Turns lists broken into multiple lines into (per item) so that there’s one
line per item:
- my list item
broken into multiple
lines
becomes
- my list item broken into multiple lines
Run bullets/lists through some normalization filters to make them easier to parse. Numbered lists are converted to +, regular bullets converted to -. This greatly simplifies parsing later on.
There’s probably a lisp function for this already. Pads the beginning and end of the given string with the given padding (also a string).
This function looks for {{markdown.cl|paragraph}} tags and splits up the text given accordingly, adding opening/closing markdown.cl paragraph tags around each of the splits. It then uses format-html-blocks-in-paragraph to remove any paragraph tags that shouldn’t be there.
Parses ATX-style headers:
### This will be an h3 tag lol
Parse a blockquote recursively, using the passed-in regex.
Parse <br> tags (when a line ends with two spaces).
Parses code sections in markdown.
Parse *, _, **, and __, but only in non-code blocks. It’s tricky though, because our <em>/<strong> elements must be able to span across <code> blocks. What we do it replace any * objects in <code> blocks with a meta string, process the em/strong tags, and then replace the meta char. Works great.
Parse blockquotes that occur inside a list. This must be a separate step,
otherwise things can get wonky when parsing lists. The idea is to find
blockquotes that are embedded in lists *before* the lists are processed, then
turn them into what the list parser views as a standard paragraph.
Instead of injecting embedded blockquotes directly into the list string, they are saved in a hash table and injected afterwards for more accurate parsing.
Parses code that is embedded inside something else (a list, for instance). Generally, embedded code starts with 8 spaces instead of 4.
On top of parsing entities:
I am a sicko & a perv => I am a sicko & a perv
Dogs > cats => Dogs > cats
<em>I’m the best</em> => <em>I’m the best</em>
also escape the inside of <code> blocks:
<code><div>©</div></code>
becomes:
<code><div>&copy;</div></code>
It does this using the parse-not-in-code function, which operates inside code blocks, using do-parse-entities outside code blocks, and escaping everything inside code blocks.
Parse characters that are escaped with \
Make horizontal rules. These are (almost?) always wrapped in <p> tags by the paragraph parser, but this is taken care of in the final parsing pass.
Parse ‘...‘ code blocks.
Parse all link styles. It’s important to note that because the image/link syntax is so similar, the following parsers handle both images and links.
Parse links that are reference-style: [link text][id]
Parse links that are self contained (not a reference): [my link text](http://url.com "title")
This function takes a list block, and splits it into sub-blocks depending on
list type (in other words, if a numbered list directly follows a normal list,
the two are processed separately). This is done recursively.
It also detects the amount of intent the list uses, which it sends into ‘format-lists‘ when an entire block has been singled out.
Parse lists (both bullet and number lists). First, normalizes them (which makes them a whole lot easier to parse) then recursively parses them.
Given a string and a parsing function, run the parsing function over the
parts of the string that are not inside any code block.
Also has the ability to escape the internals of code blocks.
This formats paragraphs in text. Most blocks given to is are treated as
paragraph blocks until otherwise noted. If it detects that another parser
added in paragraph tags, it will skip the block *unless* the pre-formatted
key arg is T (meaning that the string being passed in has paragraph tags
in it that need to be dealt with).
This function also does its best to clean the output by ridding us of empty paragraph blocks.
Parse quick-link style: <http://killtheradio.net>
Parse setext headers:
This will be an h1 ==================
Parse github format tables. Takes a string formated per the github version of markdown. It returns an html table if the block contains a pipe character and the second non-whitespace line in the block contains at least three consecutive dashes e.g. ’—’. Otherwise it returns the original string. See https://help.github.com/articles/organizing-information-with-tables/. The columns can be aligned right, center or left if colons are inserted on the sides of the hyphens within the header row. At the moment you cannot use a pipe as content within the cell.
This function does any needed cleanup to marry inline HTML and markdown.
Format lists in paragraph style to be normalized so they aren’t chopped up by the rest of the parsing.
This function performs any needed parsing on existing HTML of a markdown string.
A lot of the regular expressions, in order to maintain simplicity, expect the strings they are given to be formatted in a certain way. For instance, instead of testing for (^|\n), if every string is started with a \n, then we can just test for \n (and leave out testing for the beginning of the string).
Find any {{markdown.cl|htmlblock|...}} tags and replace them with their saved content.
Splits a markdown document into a set of blocks, each block generally consisting of a certain type (list, blockquote, paragraph, etc).
Finds all top-level HTML block-level tags and saves them for later. Does so by incrementally searching for the next line starting with a block-level tag and using xmls to parse it, adding a placeholder in its stead. Inline elements are just added back into the parts array (not saved). This allows them to be markdown-processed. str is modified destructively as the loop progresses, making sure we don’t get stuck in endless loop finding the same tags over again.
Jump to: | B C D E F G I J M N P R S |
---|
Jump to: | B C D E F G I J M N P R S |
---|
Jump to: | *
S |
---|
Jump to: | *
S |
---|
Jump to: | C E F H M P S U |
---|
Jump to: | C E F H M P S U |
---|