<commit_before>{% load i18n %}

<form class="post-form" action="{% if forum %}{% url pybb_add_topic forum.pk %}{% else %}{% url pybb_add_post topic.pk %}{% endif %}" method="post" enctype="multipart/form-data">
    <div class="preview-box" style="display: none">
        <div class="header">{% trans "Preview" %}</div>
        <div class="content"></div>
    </div>
    <fieldset>
        <legend>{% if forum %}{% trans "New topic" %}{% else %}{% trans "New reply" %}{% endif %}</legend>
        {{ form.as_p }}
        <p class="submit">
            <input type="submit" value="{% trans 'Submit' %}" />
            <input class="preview-button" type="button" value="{% trans 'Preview' %}" />
        </p>
    </fieldset>
</form>

<script type="text/javascript">
$(function() {
    $('.post-form .preview-button').click(function() {
        var raw_content = $.trim($('.post-form #id_body').val());

        args = {'content': raw_content, 'markup': '{{ current_markup }}'}
        $.post('{% url pybb_post_ajax_preview %}', args, function(data) {
            if (data.error) {
                alert(data.error);
            } else {
                $('.preview-box .content').html(data.content);<commit_msg>Fix preview error<commit_after>{% load i18n %}

<form class="post-form" action="{% if forum %}{% url pybb_add_topic forum.pk %}{% else %}{% url pybb_add_post topic.pk %}{% endif %}" method="post" enctype="multipart/form-data">
    <div class="preview-box" style="display: none">
        <div class="header">{% trans "Preview" %}</div>
        <div class="content"></div>
    </div>
    <fieldset>
        <legend>{% if forum %}{% trans "New topic" %}{% else %}{% trans "New reply" %}{% endif %}</legend>
        {{ form.as_p }}
        <p class="submit">
            <input type="submit" value="{% trans 'Submit' %}" />
            <input class="preview-button" type="button" value="{% trans 'Preview' %}" />
        </p>
    </fieldset>
</form>

<script type="text/javascript">
$(function() {
    $('.post-form .preview-button').click(function() {
        var raw_content = $.trim($('.post-form #id_body').val());

        args = {'content': raw_content, 'markup': '{{ PYBB_MARKUP }}'}
        $.post('{% url pybb_post_ajax_preview %}', args, function(data) {
            if (data.error) {
                alert(data.error);
            } else {
                $('.preview-box .content').html(data.content);
{'fraction_non_alphanumeric': 0.21514273893256103, 'fraction_numerical': 0.0016549441456350847, 'mean_word_length': 2.7488372093023257, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, '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': '7043993', 'n_tokens_mistral': 799, 'n_tokens_neox': 766, 'n_words': 171}