NacoWiki PHP API

PluginMarkdown
in package

NacoWiki MarkDown

This plugin is used to provide Markdown functionality to NacoWiki. It provides the following:

  • Markdown renderer with extended syntax.
  • CodeMirror for editor.
  • Allows the inclusion of a YAML block at the beginning to store meta data.

Meta data

Meta data is stored in a block at the top of the file of the form:

---
title: sample block
date: "2023-03-02"
---

Only the title attribute is used by NacoWiki. But any data can be stored in the YAML block.

Markup

In addition to Parsedown and ParsedownExtra markup it adds the following extensions:

  • checkboxes in lists [x] and [ ] markup
  • table span. See markup
  • ~~ ~~strike-through~~ (del)
  • ++ ++insert++ (ins)
  • ^^ ^^superscript^^ (sup)
  • ,, ,,subscript,, (sub)
  • == ==keyboard== (kbd)
  • ?? ??highlight?? (mark)
  • "\" at the end of the line to generate a line break
  • Links ending with ^ will open in a new window.
  • headown
    • header html tags in the content start at H2 (since H1 is used by the wiki's document title.
    • #++ and #-- is used to increment headown level. (Use this in combination with file includes.
  • diagrams in fenced code blocks.
    • Adding to a fenced code block a tag such as:
      • graphviz-dot
      • graphviz-neato
      • graphviz-fdp
      • graphviz-sfdp
      • graphviz-twopi
      • graphviz-circo
      • lineart or bob or aafigure : parsed using svgbob
    • This will render the given code as a SVG.
  • Allows the use of fenced code blocks with tags to allow for syntax highlighting.
    • Lines begining with ```tag where tag is a language for syntax highlighting.
  • Markdown libraries:
  • Unordered list are tweaked to my personal preferences.
Tags
phpcod

PluginMarkDown

Table of Contents

Constants

VERSION  = '2.0.0'
var string

Methods

edit()  : bool|null
Edit event handler
load()  : void
Loading entry point for this class
makeSource()  : string
Formats metadata and Markdown content
preSave()  : bool|null
preSave event handler
read()  : bool|null
Read event handler
readStruct()  : string
Read structured data
render()  : bool|null
Render event handler

Constants

Methods

edit()

Edit event handler

public static edit(NanoWikiApp $wiki, array<string|int, mixed> &$data) : bool|null

Handles edit:[ext] events.

It creates a page with CodeMirror configured in Markdown mode.

Parameters
$wiki : NanoWikiApp

running wiki instance

$data : array<string|int, mixed>
Return values
bool|null

load()

Loading entry point for this class

public static load(array<string|int, mixed> $cfg) : void

Hooks Markdown media implemented by this class

Parameters
$cfg : array<string|int, mixed>

makeSource()

Formats metadata and Markdown content

public static makeSource(array<string|int, mixed> $meta, string $body) : string

Formats the file contents to have a metadata in a YAML block at the top, followed by Markdown content right afterwards.

Parameters
$meta : array<string|int, mixed>
$body : string

Markdown payload

Return values
string

full file with YAML block and Markdown content

preSave()

preSave event handler

public static preSave(NanoWikiApp $wiki, array<string|int, mixed> &$ev) : bool|null

Handles preSave:[ext] events.

Reads from the submitted text and modifes it to make sure that there is a YAML block followed by the Markdown text.

This makes the saved file in a consistent format.

Parameters
$wiki : NanoWikiApp

running wiki instance

$ev : array<string|int, mixed>

passed event

Return values
bool|null

read()

Read event handler

public static read(NanoWikiApp $wiki, array<string|int, mixed> &$ev) : bool|null

Handles read:[ext] events.

Reads the file extract meta data tags from the YAML block and separates the Markdown content.

Parameters
$wiki : NanoWikiApp

running wiki instance

$ev : array<string|int, mixed>

passed event

Return values
bool|null

readStruct()

Read structured data

public static readStruct(string $source, array<string|int, mixed> &$meta) : string

Extracts meta data from the YAML from matter at the beginning of the file. And the MarkDown source right after.

Parameters
$source : string

text to process

$meta : array<string|int, mixed>

receives the read meta data

Return values
string

Returns Markdown payload

render()

Render event handler

public static render(NanoWikiApp $wiki, array<string|int, mixed> &$ev) : bool|null

Handles render:[ext] events.

Convert Markdown to HTML

Parameters
$wiki : NanoWikiApp

running wiki instance

$ev : array<string|int, mixed>

passed event

Return values
bool|null

        
On this page

Search results