<commit_before>require "gds_api/fact_cave"

class GovspeakPresenter
  EMBEDDED_FACT_REGEXP = /\[fact\:([a-z0-9-]+)\]/i # e.g. [fact:vat-rates]

  def initialize(markup)
    @markup = markup
  end

  def html
    markdown_with_facts = interpolate_fact_values(@markup)
    Govspeak::Document.new(markdown_with_facts).to_html.html_safe
  end

  private<commit_msg>Render the HTML before interpolating facts<commit_after>require "gds_api/fact_cave"

class GovspeakPresenter
  EMBEDDED_FACT_REGEXP = /\[fact\:([a-z0-9-]+)\]/i # e.g. [fact:vat-rates]

  def initialize(markup)
    @markup = markup
  end

  def html
    html = Govspeak::Document.new(@markup).to_html.html_safe
    interpolate_fact_values(html)
  end

  private
{'fraction_non_alphanumeric': 0.12482662968099861, 'fraction_numerical': 0.005547850208044383, 'mean_word_length': 4.231884057971015, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6327358', 'n_tokens_mistral': 300, 'n_tokens_neox': 282, 'n_words': 44}