~reesmichael1/roman

ref: 913498680070c6a5a619cb533e93ecaaee4b821e roman/src/romanpkg/htmlextractor.nim -rw-r--r-- 403 bytes View raw
91349868Michael Rees Use constructor to create Subscriptions 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import terminal

import nimpy

import errors

from config import conf


proc extractBody*(body: string): string {.raises: [RomanError].} =
  try:
    let width = min(conf.postWidth, terminalWidth())
    let html2text = pyImport("html2text").HTML2Text(bodywidth = width)
    result = html2text.handle(body).to(string)
  except:
    raise newException(RomanError, "could not use Python module html2text")