--- layout: default title: Basic Usage description: Basic usage of the CommonMark parser redirect_from: /basic-usage/ --- # Basic Usage **Important:** See the [security](/2.4/security/) section for important details on avoiding security misconfigurations. The `CommonMarkConverter` class provides a simple wrapper for converting Markdown to HTML: ```php require __DIR__ . '/vendor/autoload.php'; use League\CommonMark\CommonMarkConverter; $converter = new CommonMarkConverter(); echo $converter->convert('# Hello World!'); //
Hello World!
``` ## Configuration If you're using the `CommonMarkConverter` or `GithubFlavoredMarkdownConverter` class you can pass configuration options directly into their constructor: ```php use League\CommonMark\CommonMarkConverter; use League\CommonMark\GithubFlavoredMarkdownConverter; $converter = new CommonMarkConverter($config); // or $converter = new GithubFlavoredMarkdownConverter($config); ``` Otherwise, if you’re using `MarkdownConverter` to customize the extensions in your parser, pass the configuration into the `Environment`'s constructor instead: ```php use League\CommonMark\Environment\Environment; use League\CommonMark\Extension\InlinesOnly\InlinesOnlyExtension; use League\CommonMark\MarkdownConverter; // Here's where we set the configuration array: $environment = new Environment($config); // TODO: Add any/all the extensions you wish; for example: $environment->addExtension(new InlinesOnlyExtension()); // Go forth and convert you some Markdown! $converter = new MarkdownConverter($environment); ``` See the [configuration section](/2.4/configuration/) for more information on the available configuration options. ## Supported Character Encodings Please note that only UTF-8 and ASCII encodings are supported. If your Markdown uses a different encoding please convert it to UTF-8 before running it through this library. ## Return Value The `convert()` method actually returns an instance of `League\CommonMark\Output\RenderedContentInterface`. You can cast this (implicitly, as shown above, or explicitly) to a `string` or call `getContent()` to get the final HTML output.