Is there a way to place soft-hyphens in MD?

Hey there,

Is there a default way to place soft-hypens (i.e. ­) in the content?

The Markdown syntax does not include a special formatting for soft hyphens, but you can use the HTML entity ­ directly in your Markdown/Kirbytext content.

That does not work easily as it would sometimes just strip those out when saving the content.

Even if they are still there as invisible UTF8-Characters, the editor still loses control over them.

In this case I’ll go for an addon (: Thanks anyway!

Oh, you mean in the Panel? Yes, that’s true. I have created an issue over on GitHub.

Ah great! Sorry for the confusion

You can use Kirbytext filters to prevent the replacing with a Unicode char. I use {{shy}} for example:

File site/plugins/textsnippets.php:

kirbytext::$pre[] = function($kirbytext, $value) {

    $snippets = c::get('kirbytext.snippets', array());
    $values   = array_values($snippets);
    $keys     = array_map(function($key) {
    return '{{' . $key . '}}';
    }, array_keys($snippets));

    return str_replace($keys, $values, $value);

};

And in the config:

c::set('kirbytext.snippets', array(
    'shy' => '­',
));

See http://getkirby.com/docs/advanced/kirbytext#kirbytext-filters

3 Likes