markdown-pre-code
v1.0.25
Published
Transform triple backtick ``` to code for code mirroir and the like.
Downloads
11
Maintainers
Readme
Markdown Pre Code
Transform triple backtick to code.
Insert in project
import markdownToCode from 'markdown-pre-code'; // should use "type": "module", in package.json
//const markdownToCode = require('markdown-pre-code'); // should remove "type": "module", in package.json or use "type": "commonjs",
const Example_Text_Markdown = "Here un example de code:\n```javascript\nconsole.log('Hello, World!');\n```";
const resultatCode = markdownToCode(Example_Text_Markdown, 'code');
console.
Basic Usage
Create <pre> or <code> or <code><pre> around triple backtick: ```
const Example_Text_Markdown = "Here un example de code:\n```javascript\nconsole.log('Hello, World!');\n```";
const resultatCode = markdownToCode(Example_Text_Markdown, 'code');
console.log("Option 'code':", resultatCode); // <code>javascript console.log('Hello, World!');</code>
const resultatPre = markdownToCode(Example_Text_Markdown, 'pre');
console.log("Option 'pre':", resultatPre); // <pre>javascript console.log('Hello, World!');</pre>
const resultatCodePre = markdownToCode(Example_Text_Markdown, 'code-pre');
console.log("Option 'code-pre':", resultatCodePre); // <code><pre>javascript console.log('Hello, World!');</pre></code>