<commit_before>{% include 'header.html' %}
<body>
{% include 'styles.html' %}
{% include 'sidebar.html' %}
<h2>Document: {{title}}</h2>
{% if current_date > renew_date %}
    <h3>Expired</h3>
{% else %}
    <h3>Active: {{date}}</h3>
{% endif %}
<h3>Version: {{version}}</h3>
{% if current_date > renew_date %}
    <h3>Review: EXPIRED</h3>
{% else %}
    <h3>Review: {{renew_date}}</h3>
{% endif %}
<small>Authors: {{userid}}</small>
<h3>Category: </h3>
<ul>
{% for item in category %}
     {% if item !='' %}
        <li><a href="/category/{{item}}">{{item}}</a></li>
    {% endif %}
{% endfor %}
</ul>
<hr/>
<h3>Descriptor:</h3>
{{descriptor|safe}}
<hr/>
<h3>Preamble:</h3>
{{preamble|safe}}
<hr/>
<h3>Document Proper:</h3>
{{content_markdown|safe}}


<script src="/static/js/pdfmake.min.js"></script>
<script src="/static/js/vfs_fonts.js"></script>
<script>
var docDefinition = {
  pageSize: "A4",
  pageMargins: [40, 60, 40, 60],
  header: {
    marginLeft: 20,
    marginRight: 20,
    marginTop: 20,
    columns: [
      { text: "Version: {{version}}, Approved: {{date}}"},
      { text: "{{title}}", alignment: "right" }
    ]
  },
  footer: function(pagenumber, pagecount) {
    return {
        marginLeft: 20,
        marginRight: 20,
        columns: [
           {% if logo %}
           [ { image: "data:{{logo}};base64,{{logo_base64}}", width: 100 },
           {% else %}
           [
           {% endif %}
           { text: "Downloaded: {{current_date}}", fontSize: 8 }],
           { text: pagenumber.toString() + " of " + pagecount, alignment: "right" },
        ],
  }},
  content: [
    { text: "Document:", fontSize: 15, alignment: 'center' },
    { text: "{{title|safe}}", fontSize: 20, alignment: 'center' },
    "\n",
    { text: "Authors:", fontSize: 8, alignment: 'center' },
    { text: "{{userid}}", fontSize: 8, alignment: 'center' },
    "\n",
    { text: "Version:", fontSize: 15 },
    "{{version}}",
    "\n",
    {% if date == 'InActive' %}
        { text: 'Active: Not Active'},
    {% elif current_date > renew_date %}
        { text: "Active: No Longer Active", fontSize: 15 },
    {% else %}
        { text: "Active as of {{date}}", fontSize: 15 },
    {% endif %}
    "\n",
    {% if date == 'InActive' %}
        { text: 'Review: Not Active'},
    {% elif current_date > renew_date %}
        { text: "Review: Past Review Date", fontSize: 15 },
    {% else %}
        { text: "Review by the {{renew_date}}", fontSize: 15 },
    {% endif %}
    "\n",
    { text: "Category:", fontSize: 15 },
    "\n",
    {
      ul: [
        {% for item in category %}
            "{{item|safe}}",
        {% endfor %}
      ],
    },
    "\n",
    { text: "Descriptor:", fontSize: 15, alignment: 'center' },
    "\n",
    "{{descriptor_json|safe}}",
    { text: "Preamble", fontSize: 15, pageBreak: "before" },
    "\n",
    "{{preamble_json|safe}}",
    "\n",
    { text: "Document Proper:", fontSize: 15, pageBreak: "before" },
    "\n",
    {% for line in content_json %}
        {% if content_json.index(line) == content_json[-1] %}
            "{{line|safe}}"
        {% elif "#" in line %}
            {% if line.count("#") == 1 %}
                { text: "{{line.replace("#","").strip()|safe}}", fontSize: 15, bold: true},
                "\n",
            {% elif line.count("#") == 2 %}
                { text: "{{line.replace("#","").strip()|safe}}", fontSize: 13, bold: true},
                "\n",
            {% elif line.count("#") == 3 %}
                { text: "{{line.replace("#","").strip()|safe}}", fontSize: 12, bold: true},
                "\n",
            {% endif %}
        {% else %}
            "{{line|safe}}",
            "\n",
        {% endif %}
    {% endfor %}
  ]
}
</script>
</body>
<commit_msg>Beginning to render HTML content correctly in PDF<commit_after>{% include 'header.html' %}
<body>
{% include 'styles.html' %}
{% include 'sidebar.html' %}
<h2>Document: {{title}}</h2>
{% if current_date > renew_date %}
    <h3>Expired</h3>
{% else %}
    <h3>Active: {{date}}</h3>
{% endif %}
<h3>Version: {{version}}</h3>
{% if current_date > renew_date %}
    <h3>Review: EXPIRED</h3>
{% else %}
    <h3>Review: {{renew_date}}</h3>
{% endif %}
<small>Authors: {{userid}}</small>
<h3>Category: </h3>
<ul>
{% for item in category %}
     {% if item !='' %}
        <li><a href="/category/{{item}}">{{item}}</a></li>
    {% endif %}
{% endfor %}
</ul>
<hr/>
<h3>Descriptor:</h3>
{{descriptor|safe}}
<hr/>
<h3>Preamble:</h3>
{{preamble|safe}}
<hr/>
<h3>Document Proper:</h3>
{{content_markdown|safe}}


<script src="/static/js/pdfmake.min.js"></script>
<script src="/static/js/vfs_fonts.js"></script>
<script>
var docDefinition = {
  pageSize: "A4",
  pageMargins: [40, 60, 40, 60],
  header: {
    marginLeft: 20,
    marginRight: 20,
    marginTop: 20,
    columns: [
      { text: "Version: {{version}}, Approved: {{date}}"},
      { text: "{{title}}", alignment: "right" }
    ]
  },
  footer: function(pagenumber, pagecount) {
    return {
        marginLeft: 20,
        marginRight: 20,
        columns: [
           {% if logo %}
           [ { image: "data:{{logo}};base64,{{logo_base64}}", width: 100 },
           {% else %}
           [
           {% endif %}
           { text: "Downloaded: {{current_date}}", fontSize: 8 }],
           { text: pagenumber.toString() + " of " + pagecount, alignment: "right" },
        ],
  }},
  content: [
    { text: "Document:", fontSize: 15, alignment: 'center' },
    { text: "{{title|safe}}", fontSize: 20, alignment: 'center' },
    "\n",
    { text: "Authors:", fontSize: 8, alignment: 'center' },
    { text: "{{userid}}", fontSize: 8, alignment: 'center' },
    "\n",
    { text: "Version:", fontSize: 15 },
    "{{version}}",
    "\n",
    {% if date == 'InActive' %}
        { text: 'Active: Not Active'},
    {% elif current_date > renew_date %}
        { text: "Active: No Longer Active", fontSize: 15 },
    {% else %}
        { text: "Active as of {{date}}", fontSize: 15 },
    {% endif %}
    "\n",
    {% if date == 'InActive' %}
        { text: 'Review: Not Active'},
    {% elif current_date > renew_date %}
        { text: "Review: Past Review Date", fontSize: 15 },
    {% else %}
        { text: "Review by the {{renew_date}}", fontSize: 15 },
    {% endif %}
    "\n",
    { text: "Category:", fontSize: 15 },
    "\n",
    {
      ul: [
        {% for item in category %}
            "{{item|safe}}",
        {% endfor %}
      ],
    },
    "\n",
    { text: "Descriptor:", fontSize: 15, alignment: 'center' },
    "\n",
    "{{descriptor_json|safe}}",
    { text: "Preamble", fontSize: 15, pageBreak: "before" },
    "\n",
    "{{preamble_json|safe}}",
    "\n",
    { text: "Document Proper:", fontSize: 15, pageBreak: "before" },
    "\n",
    {% for line in content_json %}
       {% if 'h1' in line %}
       {% set line = re.sub('<[^<]+?>', '', line) %}
       { text: "{{line|safe}}", fontSize: 15 },
       {% endif %}
       {% if 'h2' in line %}
       {% set line = re.sub('<[^<]+?>', '', line) %}
       { text: "{{line|safe}}", fontSize: 12, bold: true },
       {% endif %}
       {% if 'h3' in line %}
       {% set line = re.sub('<[^<]+?>', '', line) %}
       { text: "{{line|safe}}", fontSize: 10, italics: true },
       {% endif %}
       {% if 'em' in line %}
       {% if 'strong' not in line %}
       {% set line = re.sub('<[^<]+?>', '', line) %}
       { text: "{{line|safe}}", italics: true },
       {% endif %}
       {% endif %}
        "\n",
    {% endfor %}
  ]
}
</script>
</body>

{'fraction_non_alphanumeric': 0.23346148747182818, 'fraction_numerical': 0.021344292721728754, 'mean_word_length': 2.3875168387965875, 'pattern_counts': {'":': 0, '<': 89, '<?xml version=': 0, '>': 93, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5672875', 'n_tokens_mistral': 2919, 'n_tokens_neox': 2591, 'n_words': 604}