MCPcopy Create free account
hub / github.com/cnodejs/nodeclub / _EncodeCode

Function _EncodeCode

public/libs/pagedown/Markdown.Converter.js:1021–1049  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

1019 }
1020
1021 function _EncodeCode(text) {
1022 //
1023 // Encode/escape certain characters inside Markdown code runs.
1024 // The point is that in code, these characters are literals,
1025 // and lose their special Markdown meanings.
1026 //
1027 // Encode all ampersands; HTML entities are not
1028 // entities within a Markdown code span.
1029 text = text.replace(/&/g, "&");
1030
1031 // Do the angle bracket song and dance:
1032 text = text.replace(/</g, "&lt;");
1033 text = text.replace(/>/g, "&gt;");
1034
1035 // Now, escape characters that are magic in Markdown:
1036 text = escapeCharacters(text, "\*_{}[]\\", false);
1037
1038 // jj the line above breaks this:
1039 //---
1040
1041 //* Item
1042
1043 // 1. Subitem
1044
1045 // special char: *
1046 //---
1047
1048 return text;
1049 }
1050
1051 function _DoItalicsAndBold(text) {
1052

Callers 2

_DoCodeBlocksFunction · 0.70
_DoCodeSpansFunction · 0.70

Calls 1

escapeCharactersFunction · 0.70

Tested by

no test coverage detected