<commit_before>package com.sdl.webapp.smarttarget.markup;

import com.sdl.webapp.common.api.WebRequestContext;
import com.sdl.webapp.common.api.model.ViewModel;
import com.sdl.webapp.common.markup.MarkupDecorator;
import com.sdl.webapp.common.markup.html.HtmlElement;
import com.sdl.webapp.common.markup.html.HtmlNode;
import com.sdl.webapp.common.markup.html.HtmlTextNode;
import com.sdl.webapp.common.markup.html.builders.HtmlBuilders;
import com.sdl.webapp.common.markup.html.builders.SimpleElementBuilder;
import com.sdl.webapp.smarttarget.SmartTargetRegion;

/**
 * SmartTarget Region XPM Markup
 *
 * @author nic
 */
public class SmartTargetRegionXpmMarkup implements MarkupDecorator {

    @Override
    public HtmlNode process(HtmlNode markup, ViewModel model, WebRequestContext webRequestContext) {

        if ( model instanceof SmartTargetRegion )  {
            SmartTargetRegion stRegion = (SmartTargetRegion) model;

            markup  =
                    HtmlBuilders.span()
                            .withLiteralContent(stRegion.getXpmMarkup())
                            .withContent(markup).build();

            /* NEEDED???
            markup = HtmlBuilders.span()
                    .withLiteralContent("<!-- Start Promotion Region: {\"RegionID\": \"" + stRegion.getName() + "\"} -->")
                    .withContent(markup).build();
                    */
        }
        return markup;
    }

    @Override
    public int getPriority() {
        return 0;
    }
}<commit_msg>Only process the Region markup with SmartTarget XPM markup when isPreview().<commit_after>package com.sdl.webapp.smarttarget.markup;

import com.sdl.webapp.common.api.WebRequestContext;
import com.sdl.webapp.common.api.model.ViewModel;
import com.sdl.webapp.common.markup.MarkupDecorator;
import com.sdl.webapp.common.markup.html.HtmlElement;
import com.sdl.webapp.common.markup.html.HtmlNode;
import com.sdl.webapp.common.markup.html.HtmlTextNode;
import com.sdl.webapp.common.markup.html.builders.HtmlBuilders;
import com.sdl.webapp.common.markup.html.builders.SimpleElementBuilder;
import com.sdl.webapp.smarttarget.SmartTargetRegion;

/**
 * SmartTarget Region XPM Markup
 *
 * @author nic
 */
public class SmartTargetRegionXpmMarkup implements MarkupDecorator {

    @Override
    public HtmlNode process(HtmlNode markup, ViewModel model, WebRequestContext webRequestContext) {

        if ( webRequestContext.isPreview() ) {
            if (model instanceof SmartTargetRegion) {
                SmartTargetRegion stRegion = (SmartTargetRegion) model;

                markup =
                        HtmlBuilders.span()
                                .withLiteralContent(stRegion.getXpmMarkup())
                                .withContent(markup).build();

                /* NEEDED???
                markup = HtmlBuilders.span()
                        .withLiteralContent("<!-- Start Promotion Region: {\"RegionID\": \"" + stRegion.getName() + "\"} -->")
                        .withContent(markup).build();
                        */
            }
        }
        return markup;
    }

    @Override
    public int getPriority() {
        return 0;
    }
}
{'fraction_non_alphanumeric': 0.10873664362036455, 'fraction_numerical': 0.0006285355122564425, 'mean_word_length': 2.426264800861141, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2149479', 'n_tokens_mistral': 953, 'n_tokens_neox': 885, 'n_words': 152}