TextformatterRockDown by bernhard

ProcessWire Textformatter for simple WhatsApp style text formatting (*bold*, _italic_, ~strike~, ```mono```

TextformatterRockDown

ProcessWire Textformatter for simple markdown-like text formatting ideal for headlines:

*bold*
_italic_
~strike~
```monospace```
#monospace#

This module does intentionally not support full markdown syntax! It is intended to be used for simple formattings that you usually want to apply to headlines.

Problem


The title field is always available in ProcessWire and it is often used for page headlines. But unfortunately when using such a plain textfield it will not be possible to print some words in bold or italic font.

One solution is to create a CKEditor/TinyMCE field, but it's a lot more tedious to setup. Also it's not easy to make it single-line-only.

Solution


Just apply this textformatter to your field and you'll get quick and easy headlines with bold and italic fonts that will also work with frontend editing.

Backend Editing:

68747470733a2f2f692e696d6775722e636f6d2f734770715a504f2e706e67

Frontend Editing:

68747470733a2f2f692e696d6775722e636f6d2f414333366d65322e706e67

Formatted:

68747470733a2f2f692e696d6775722e636f6d2f4b52556a42337a2e706e67

Usage


Just install the module and add TextformatterRockDown to the field you want to apply it to:

68747470733a2f2f692e696d6775722e636f6d2f41303746656f432e706e67

Then just output the field's value in your template files as usual:

echo $page->title; // plain
echo $page->edit('title'); // fontend editable

Custom tags


You can add custom replacements easily via hook in /site/ready.php

// @something@ --> <span style="color:red;">something</span>
$wire->addHookAfter("TextformatterRockDown::replace", function ($event) {
  $str = $event->arguments(0);
  $start = $event->arguments(1);
  $end = $event->arguments(2);
  $tag = "@"; // set your tag here
  $str = preg_replace(
    "/$start{$tag}(.*?){$tag}$end/",
    "$1<span style=\"color:red;\">$2</span>$3",
    $str
  );
  $event->return = $str;
});

Install and use modules at your own risk. Always have a site and database backup before installing new modules.

Latest news

  • ProcessWire Weekly #559
    The 559th issue of ProcessWire Weekly brings in all the latest news from the ProcessWire community. Modules, sites, and more. Read on!
    Weekly.pw / 25 January 2025
  • ProcessWire 3.0.244 new main/master version
    ProcessWire 3.0.244 is our newest main/master/stable version. It's been more than a year in the making and is packed with tons of new features, issue fixes, optimizations and more. This post covers all the details.
    Blog / 18 January 2025
  • Subscribe to weekly ProcessWire news

“We were really happy to build our new portfolio website on ProcessWire! We wanted something that gave us plenty of control on the back-end, without any bloat on the front end - just a nice, easy to access API for all our content that left us free to design and build however we liked.” —Castus, web design agency in Sheffield, UK