diff --git a/lib/Drupal/toc_formatter/Plugin/Field/FieldFormatter/TextTocFormatter.php b/lib/Drupal/toc_formatter/Plugin/Field/FieldFormatter/TextTocFormatter.php
new file mode 100644
index 0000000..03fe493
--- /dev/null
+++ b/lib/Drupal/toc_formatter/Plugin/Field/FieldFormatter/TextTocFormatter.php
@@ -0,0 +1,48 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\toc_formatter\Plugin\field\formatter\TextDefaultFormatter.
+ */
+
+namespace Drupal\toc_formatter\Plugin\Field\FieldFormatter;
+
+use Drupal\Core\Field\FormatterBase;
+use Drupal\Core\Field\FieldItemListInterface;
+
+/**
+ * Plugin implementation of the 'toc_formatter' formatter.
+ *
+ * @FieldFormatter(
+ *   id = "toc_formatter",
+ *   label = @Translation("Table Of Contents"),
+ *   field_types = {
+ *     "text",
+ *     "text_long",
+ *     "text_with_summary"
+ *   },
+ *   edit = {
+ *     "editor" = "direct"
+ *   }
+ * )
+ */
+class TextTocFormatter extends FormatterBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function viewElements(FieldItemListInterface $items) {
+    $elements = array();
+
+    foreach ($items as $delta => $item) {
+      $elements[$delta] = array(
+        '#theme' => 'toc_formatter_table_of_contents',
+        '#content' => $item->processed,
+        '#title' => t('Content'),
+      );
+    }
+
+    return $elements;
+  }
+
+}
diff --git a/toc_formatter.info b/toc_formatter.info
deleted file mode 100755
index 220677e..0000000
--- a/toc_formatter.info
+++ /dev/null
@@ -1,4 +0,0 @@
-name = TOC Formatter
-description = Display formatter that adds a TOC to the top of a text area field.
-package = Fields
-core = 7.x
diff --git a/toc_formatter.info.yml b/toc_formatter.info.yml
new file mode 100755
index 0000000..5913c78
--- /dev/null
+++ b/toc_formatter.info.yml
@@ -0,0 +1,5 @@
+name: TOC Formatter
+description: Display formatter that adds a TOC to the top of a text area field.
+package: Fields
+type: module
+core: 8.x
diff --git a/toc_formatter.module b/toc_formatter.module
index 69e3cec..faf6a8b 100755
--- a/toc_formatter.module
+++ b/toc_formatter.module
@@ -1,43 +1,6 @@
 <?php
 
 /**
- * Implementation of hook_field_formatter_info().
- */
-function toc_formatter_field_formatter_info() {
-  $formatters = array(
-    'toc_formatter' => array(
-      'label' => t('Table Of Contents'),
-      'field types' => array('text', 'text_long', 'text_with_summary'),
-      'description' => t('Adds a Table Of Contents linking to headings in content of field.'),
-      'multiple values' => FIELD_BEHAVIOR_DEFAULT,
-    ),
-  );
-
-  return $formatters;
-}
-
-/**
- * Implementation of hook_field_formatter_view().
- */
-function toc_formatter_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
-
-  $element = array();
-
-  if ($display['type'] == 'toc_formatter') {
-    foreach ($items as $delta => $item) {
-
-      $element[$delta] = array(
-        '#theme' => 'toc_formatter_table_of_contents',
-        '#content' => $item['safe_value'],
-        '#title' => t('Content'),
-      );
-    }
-  }
-
-  return $element;
-}
-
-/**
  * Implementation of hook_theme().
  */
 function toc_formatter_theme() {
@@ -59,7 +22,7 @@ function toc_formatter_theme() {
  */
 function theme_toc_formatter_move_to_top_link($variables) {
   $content = $variables['content'];
-  $path_alias = drupal_get_path_alias($_GET['q']);
+  $path_alias = request_uri();
   $link = '<div class="toc-top-links">';
   $link .= l(t('Move to top'), $path_alias, array('fragment' => 'table-of-contents'));
   $link .= '</div>';
@@ -78,7 +41,7 @@ function theme_toc_formatter_table_of_contents($variables) {
   $content = $variables['content'];
   $type = $variables['type'];
 
-  $path = drupal_get_path_alias($_GET['q']);
+  $path = request_uri();
   $links = array();
   $anchor = 0;
   $output = '';
