Enables:
TODO table
TODO todo lists
markdown2 :: markdown_github $ MdInlineParser
Parser for inline content (text, links, emphasis, etc)markdown2 :: markdown_github $ MdInlineParser
Parser for inline content (text, links, emphasis, etc)core :: union_find
union–find algorithm using an efficient disjoint-set data structuremarkdown2 :: markdown_html_rendering
HTML rendering of Markdown documentsmarkdown2 :: markdown_latex_rendering
LaTeX rendering of Markdown documentsmarkdown2 :: markdown_man_rendering
Manpages rendering of Markdown documentsmarkdown2 :: markdown_md_rendering
Markdown rendering of Markdown documents
# Markdown Github mode
#
# Enables:
# * strike processing: ~strike~
# * super processing: ^super^
#
# TODO table
# TODO todo lists
module markdown_github
intrude import markdown_inline_parsing
intrude import markdown_block_parsing
redef class MdParser
# Enable Github mode
var github_mode = false is writable
redef var inline_parser is lazy do
var parser = super
parser.github_mode = github_mode
return parser
end
end
redef class MdInlineParser
# Enable Github mode
private var github_mode = false
redef var delimiter_processors is lazy do
var delimiters = super
if github_mode then
delimiters.add new MdStrikeProcessor
delimiters.add new MdSuperProcessor
end
return delimiters
end
end
# Strike processor
class MdStrikeProcessor
super MdEmphasisDelimiterProcessor
noautoinit
redef var delimiter_char = '~'
redef var min_length = 1
redef fun delimiter_use(opener, closer) do return opener.original_length
redef fun process(opener, closer, delimiter_use) do
var node = new MdStrike(
new MdLocation(
opener.location.line_start,
opener.location.column_start,
closer.location.line_end,
closer.location.column_end),
opening_delimiter.to_s * delimiter_use)
var tmp = opener.next
while tmp != null and tmp != closer do
var next = tmp.next
node.append_child(tmp)
tmp = next
end
opener.insert_after(node)
end
end
# Striked text
class MdStrike
super MdDelimited
end
# Super processor
class MdSuperProcessor
super MdEmphasisDelimiterProcessor
noautoinit
redef var delimiter_char = '^'
redef var min_length = 1
redef fun delimiter_use(opener, closer) do return opener.original_length
redef fun process(opener, closer, delimiter_use) do
var node = new MdSuper(
new MdLocation(
opener.location.line_start,
opener.location.column_start,
closer.location.line_end,
closer.location.column_end),
opening_delimiter.to_s * delimiter_use)
var tmp = opener.next
while tmp != null and tmp != closer do
var next = tmp.next
node.append_child(tmp)
tmp = next
end
opener.insert_after(node)
end
end
# Super text
class MdSuper
super MdDelimited
end
lib/markdown2/markdown_github.nit:15,1--117,3