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 elementElement - Source:
- md/md2html.js
-
<static> md2html(md [, data] [, options])
-
Transform a markdown string to an HTML code
Parameters:
Name Type Argument Description mdString the markdown text
dataObject <optional>
a list of key value to replace in the markdown %key%
optionsObject <optional>
Properties
Name Type Argument Description shiftTitleNumber <optional>
shift title
edugeoboolean <optional>
replace urls 'https://macarte' to 'https://edugeo'
- Source:
- md/md2html.js
Returns:
HTML code
- Type
- HTML
-
deSecure(md)
-
Desecure md string
Parameters:
Name Type Description mdstring the markdown
- Source:
- md/md2html.js
Returns:
result md
- Type
- string
-
doSecure(md)
-
Secure md string: remove code
Parameters:
Name Type Description mdstring 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 mdstring elementElement <optional>
create one if none
dataObject <optional>
optionsObject <optional>
Properties
Name Type Argument Description shiftTitleNumber <optional>
shift title
edugeoboolean <optional>
replace urls 'https://macarte' to 'https://edugeo'
- Source:
- md/md2html.js
Returns:
- Type
- Element
-
encodeUri(uri, componenet)
-
Encode URI and remove special char
Parameters:
Name Type Description uristring componenetboolean - Source:
- md/md2html.js
Returns:
- Type
- string
-
renderWidget(element)
-
Load widget inside the element (twitter, charts, etc.)
Parameters:
Name Type Description elementElement - Source:
- md/md2html.js
-
text(md [, data], escapeHTML)
-
Get a makdown as text
Parameters:
Name Type Argument Description mdstring dataObject <optional>
escapeHTMLbooelan - Source:
- md/md2html.js
Returns:
- Type
- string