paveld / markdown-wiki
An extension of cebe/markdown library for parsing markdown to wiki text
Requires
- php: >=5.4.0
- ext-mbstring: *
- lib-pcre: *
- cebe/markdown: 1.2.1
Requires (Dev)
- ext-curl: *
- phpunit/phpunit: 4.1.*
README
About
Extension of the Cebe's Markdown library for parsing Mrkdown into WikiText syntax.
It's used as backend library for MediaWiki MarkdownWiki parser.
Features
The parser render links and tables in wiki format.
Supported elements
Inline elemets
- bold
- italc
- code highlit
- links
- images
Block elements
- blockquote
- headlines
- horizontal ruler
- ordered and unordered lists
- paragraphs
- preformatted text
- tables
Extra structures
Templates
Example:
---
template: temaplate name
myparam1: content of my param1
myparam2: content of my param2
---
first 2 lines are mandatory. Other lines are optional. Code check if :
is present.
End of parsing is on the end of the template or on first empty line.
Magic words
Double underscored behavior switches for MediaWiki parser has the same format as markdown bold text. To avoid issues with that words new format is introduced.
{{__NOTOC__}}
instread of simple __NOTOC__
. The markdown-wiki parser is removing curly brackets and magic word is applyed during wiki parsing.
Installation
The installation is following the reccomandation of the original Cebe's Markdown library.
Installation is recommended to be done via composer) by running:
composer require paveld/markdown-wiki "*"
and then
composer update paveld/markdown-wiki
Configuration
If you don't need to parse some of the elements it's possible to remove parsing by following directive.
$m = new MarkdownWiki();\ $m->disableParsingRule('headline'); $wikTextb = $m->parse($MarkdownText);
List of possible paramters for the disableParsingRule()
method:
Some elements are idetified by by several rules.
Block elements
- Code block by
code
andfencedcode
- Headline by
headline
- Horizontal ruler by
ahr
andhr
- HTML elements by
html
- Markdown table by
table
- Ordered list by
ol
- Quote block by
quote
- Template by
aaatemplate
andtemplate
- Unordered list by
bul
andul
Inline elements
- Escape by
parseEscape
- Greater-than sign by
parseGt
- HTML entities by
parseEntity
- Image by
parseImage
- Inline code by
parseInlineCode
- Links by
parseLink
- Magic word by
parseMagicWord
- Special attributes by
parseSpecialAttributes
- Strong and intalic by
parseEmphStrong
License
MIT