Simple markdown to html convertor
- Source:
- md/md2html.js
Example
import md2html from 'mcutils/md/md2html' const element = document.getElementById('myId'); // Display md in the element element.innerHTML = md2html('# Hello %name%', { name: 'world' }) // or md2html.element('# Hello %name%', element, { name: 'world' })
Methods
-
<static> iconize(element)
-
Render icons in a markdown text
Parameters:
Name Type Description element
Element - Source:
- md/md2html.js
-
<static> md2html(md [, data] [, options])
-
Transform a markdown string to an HTML code
Parameters:
Name Type Argument Description md
String the markdown text
data
Object <optional>
a list of key value to replace in the markdown %key%
options
Object <optional>
Properties
Name Type Argument Description shiftTitle
Number <optional>
shift title
edugeo
boolean <optional>
replace urls 'https://macarte' to 'https://edugeo'
- Source:
- md/md2html.js
Returns:
HTML code
- Type
- HTML
-
doSecure(md)
-
Secure md string: remove code
Parameters:
Name Type Description md
string the markdown
- Source:
- md/md2html.js
Returns:
result md
- Type
- string
-
element(md [, element] [, data] [, options])
-
Create an element with the given markdown
Parameters:
Name Type Argument Description md
string element
Element <optional>
create one if none
data
Object <optional>
options
Object <optional>
Properties
Name Type Argument Description shiftTitle
Number <optional>
shift title
edugeo
boolean <optional>
replace urls 'https://macarte' to 'https://edugeo'
- Source:
- md/md2html.js
Returns:
- Type
- Element
-
encodeUri(uri)
-
Encode URI and remove special char
Parameters:
Name Type Description uri
string - Source:
- md/md2html.js
-
renderWidget(element)
-
Load widget inside the element (twitter, charts, etc.)
Parameters:
Name Type Description element
Element - Source:
- md/md2html.js
-
text(md [, data], escapeHTML)
-
Get a makdown as text
Parameters:
Name Type Argument Description md
string data
Object <optional>
escapeHTML
booelan - Source:
- md/md2html.js
Returns:
- Type
- string