package com.github.onsdigital.babbage.template.handlebars.helpers.markdown.util;

import com.github.onsdigital.babbage.template.TemplateService;

import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by crispin on 11/12/2015.
 */
public class InteractiveTagReplacer extends TagReplacementStrategy {

    private static final Pattern pattern = Pattern.compile("<ons-interactive\\surl=\"([-A-Za-z0-9+&@#/%?=~_|!:,.;()*$]+)\"?\\s?/>");
    private final String template;

    /**
     * Create an instance of a tag replacement strategy with the given page path.
     * <p>
     * The page path is the path of the page having tags replaced. It is used to resolve links that are relative to the page.
     *
     * @param path
     */
    public InteractiveTagReplacer(String path, String template) {
        super(path);
        this.template = template;
    }

    @Override
    Pattern getPattern() {
        return pattern;
    }

    @Override
    String replace(Matcher matcher) throws IOException {
        String tagPath = matcher.group(1);
        LinkedHashMap<String, Object> additionalData = new LinkedHashMap<>();
        additionalData.put("id", UUID.randomUUID().toString().substring(10));
        additionalData.put("url", tagPath);
        return TemplateService.getInstance().renderTemplate(template, null, additionalData);
    }
}

@@ -291,53 +291,8 @@
 n;%0A%0A
-/**%0A * Created by crispin on 11/12/2015.%0A */%0A
 publ
@@ -357,24 +357,26 @@
 tegy %7B%0A%0A    
+//
 private stat
@@ -492,16 +492,181 @@
 s?/%3E%22);%0A
+    private static final Pattern pattern = Pattern.compile(%22%3Cons-interactive%5C%5Csurl=%5C%22(%5B-A-Za-z0-9+&@#/%25?=~_%7C!:,.;()*$%5D+)%5C%22%5C%5Cs?(?:%5C%5Cs?full-width=%5C%22(.*%5B%5E%5C%22%5D)%5C%22)?/%3E%22);%0A
     priv
@@ -1268,16 +1268,61 @@
 oup(1);%0A
+        String fullWidth = matcher.group(2);%0A
         
@@ -1469,16 +1469,16 @@
 g(10));%0A
-
         
@@ -1509,24 +1509,77 @@
 , tagPath);%0A
+        additionalData.put(%22full-width%22, fullWidth);%0A
         retu

Update regex to handle full-width attribute and pass value back to template