forked from pub-solar/pub.solar
41 lines
1.7 KiB
TypeScript
41 lines
1.7 KiB
TypeScript
import MarkdownIt from "https://jspm.dev/markdown-it";
|
||
|
||
const mdIt = new MarkdownIt({
|
||
html: false, // Enable HTML tags in source
|
||
xhtmlOut: false, // Use '/' to close single tags (<br />).
|
||
// This is only for full CommonMark compatibility.
|
||
breaks: true, // Convert '\n' in paragraphs into <br>
|
||
langPrefix: 'language-', // CSS language prefix for fenced blocks. Can be
|
||
// useful for external highlighters.
|
||
linkify: true, // Autoconvert URL-like text to links
|
||
|
||
// Enable some language-neutral replacement + quotes beautification
|
||
// For the full list of replacements, see https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/replacements.js
|
||
typographer: false,
|
||
|
||
// Double + single quotes replacement pairs, when typographer enabled,
|
||
// and smartquotes on. Could be either a String or an Array.
|
||
//
|
||
// For example, you can use '«»„“' for Russian, '„“‚‘' for German,
|
||
// and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
|
||
quotes: '“”‘’',
|
||
|
||
// Highlighter function. Should return escaped HTML,
|
||
// or '' if the source string is not changed and should be escaped externally.
|
||
// If result starts with <pre... internal wrapper is skipped.
|
||
highlight: function (/*str, lang*/) { return ''; }
|
||
});
|
||
|
||
export const md = (string) => mdIt.render(string);
|
||
|
||
export const title = (value = '') => value + (value ? " | " : "") + "pub.solar";
|
||
|
||
export const i18n = (value) => value.en;
|
||
|
||
export const de = (value) => value.de;
|
||
|
||
export const objectToArray = (value = {}) => Object.keys(value)
|
||
.sort()
|
||
.map(key => value[key])
|
||
.filter(val => !!val);
|