title: How to use str.format() with a markdown file with some latex inside
body: <p>I have the following a markdown file "loan.md":</p>
  
  <pre><code>#### &lt;u&gt;Loan data:&lt;/u&gt;
  + Loan amount: {amount}
  + Loan term: {term}
  + Annual istallments: {instalments}
  + Loan interest rate: {rate}
  
  #### &lt;u&gt;Monthly loan installment:&lt;/u&gt;
  + Monthly payment: {payment}
  
  #### &lt;u&gt;Formula to calculate the monthly loan installment:&lt;/u&gt;
  
  \[
  P = A \times\frac{r_i}{1-(1+r_i)^{-t}}
  \]
  
  
  &lt;u&gt;Where:&lt;/u&gt;
  
  
  \[
  r_k = \frac{r}{i}
  \]
  
  + $P$ : Monthly payment.
  + $A$ : Loan amount.
  + $r$ : Interest rate.
  + $i$ :Annual istallments.
  + $t$ : Loan term.
  </code></pre>
  
  <p>I have the following script in python </p>
  
  <pre class="lang-py prettyprint-override"><code>loan_data = {'amount':'10000.00',
               'term':'60',
               'installments':'12',
               'rate':'5,95%',
               'payment':'193,10'
               }
  
  with open('loan.md') as f:
      text = f.read()
      text = text.format(**loan_data)
      out_file = open('output.md', 'w')
      out_file.write(text)
  </code></pre>
  
  <p>When I run the script a get an error the following error message:</p>
  
  <pre><code>Traceback (most recent call last):
    File "loan.py", line 10, in &lt;module&gt;
      text = text.format(**loan_data)
  KeyError: 'r_i'
  </code></pre>
  
  <p>I know that the error is produced by the Latex in the markdown</p>
  
  <p>It is possible to load a markdown file like the one above in python and fill the replacement field with data?</p>