PHP code example of stanislas-poisson / kmark

1. Go to this page and download the library: Download stanislas-poisson/kmark library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

stanislas-poisson / kmark example snippets




use KMark\Convert;

itle {#top}\n\nSome text with a [link](https://example.com).\n\n- One\n- Two");

$html = (new Convert())
    ->withText("# Title")
    ->convert()
    ->getText();


echo 'Hello world';
 {#snippet .dark}`, which gives them to the `<pre>`.

The id and classes go on the headings, paragraphs, lists and their items, quotes, tables, code blocks, links, images and code spans. For the text styles, use the option `tags`.

Only the first id is kept, and only letters, digits, `_` and `-` are accepted in a name. If the braces hold anything else, they stay in the text.

### Safety

By default the input is escaped: HTML written in the text is shown as text, so `<script>` is never executed. Only the links and images with a relative URL or an allowed scheme (`http`, `https`, `mailto`, `tel` and `ftp` by default) are kept. For any other scheme (`javascript:`, `data:`…), the text of the link is written without the link.

## Options

The settings are given with an immutable `Options` object, to `Convert::toHtml()` or to the constructor of `Convert`. Use the named arguments to change one:


// <strong>, <em>, <ins> and <s>
$semantic = new Options(tags: [
    'bold'      => new Tag('strong'),
    'italic'    => new Tag('em'),
    'underline' => new Tag('ins'),
    'strike'    => new Tag('s'),
]);

// <span class="b">, <span class="i">…
$spans = new Options(tags: [
    'bold'      => new Tag('span', ['b']),
    'italic'    => new Tag('span', ['i']),
    'underline' => new Tag('span', ['u']),
    'strike'    => new Tag('span', ['s']),
]);
html
<pre><code class="language-php">&lt;?php
echo 'Hello world';
</code></pre>