[][src]Trait markdown_composer::transforms::CodeBlock

pub trait CodeBlock {
    fn to_code_block(&self) -> String;
fn to_code_block_with_language<S: AsRef<str>>(&self, language: S) -> String; }

An extension trait for code block transformations.

Required methods

fn to_code_block(&self) -> String

Transforms the given text into a code block.

Example

use markdown_composer::transforms::CodeBlock;

let text = "print(\"Hello world!\")";
let code_block = text.to_code_block();
assert_eq!(code_block, "```\nprint(\"Hello world!\")\n```");

fn to_code_block_with_language<S: AsRef<str>>(&self, language: S) -> String

Transforms the given text into a code block, allowing to specify the language to use for highlighting.

Example

use markdown_composer::transforms::CodeBlock;

let text = "print(\"Hello world!\")";
let code_block = text.to_code_block_with_language("python");
assert_eq!(code_block, "```python\nprint(\"Hello world!\")\n```");
Loading content...

Implementors

impl<T> CodeBlock for T where
    T: AsRef<str>, 
[src]

Loading content...