forked from cory/tildefriends
19 lines
498 B
JavaScript
19 lines
498 B
JavaScript
|
"use strict";
|
||
|
|
||
|
function markdown(md) {
|
||
|
var reader = new commonmark.Parser({safe: true});
|
||
|
var writer = new commonmark.HtmlRenderer();
|
||
|
var parsed = reader.parse(md);
|
||
|
var walker = parsed.walker();
|
||
|
var event, node;
|
||
|
while ((event = walker.next())) {
|
||
|
node = event.node;
|
||
|
if (event.entering && node.type == 'link') {
|
||
|
if (node.destination.startsWith('@') &&
|
||
|
node.destination.endsWith('.ed25519')) {
|
||
|
node.destination = '#' + node.destination;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return writer.render(parsed);
|
||
|
}
|