1 |
On 2017-02-08, Grant Edwards <grant.b.edwards@×××××.com> wrote: |
2 |
> I usually try to avoid Qt apps, but I needed a way to preview markdown |
3 |
> text. One option was pandoc, but it needed to install 100+ packages |
4 |
> as dependancies. Another option was retext, which only required a few |
5 |
> new packages. |
6 |
> |
7 |
> So I installed retext. The install seemed to go fine, but it doesn't run: |
8 |
> [...] |
9 |
|
10 |
[This was with the stable retext.] |
11 |
|
12 |
I looked at the retext sources, and AFAICT with no command-line args |
13 |
there are situations retext tries to mix QT4 and QT5 modules (that |
14 |
seems obviouisly wrong, but I'm no Qt expert). I tried forcing retext |
15 |
to use qt4 only by specifying --pyqt4, but that failed in other ways. |
16 |
|
17 |
I gave up on the stable version of retext and tried the ~amd64 version |
18 |
of retext, and it wanted to install more QT5 stuff than I had patience |
19 |
for. |
20 |
|
21 |
So I finally gave up on retext and wrote my own command-line markdown |
22 |
to html converter utility: |
23 |
|
24 |
------------------------------------------------------------------------ |
25 |
#!/usr/bin/python |
26 |
import sys,markups |
27 |
argc,argv = len(sys.argv),sys.argv |
28 |
|
29 |
if argc > 3: |
30 |
sys.stderr.write("usage: %s [infile [outfile]]\n" % argv[0]) |
31 |
|
32 |
if argc > 2 and argv[2] != '-': |
33 |
out_file = open(argv[2],"w") |
34 |
else: |
35 |
out_file = sys.stdout |
36 |
|
37 |
if argc > 1 and argv[1] != '-': |
38 |
with open(sys.argv[1],"r") as f: |
39 |
in_text = f.read() |
40 |
else: |
41 |
in_text = sys.stdin.read() |
42 |
|
43 |
cm = markups.MarkdownMarkup().convert(in_text) |
44 |
out_file.write(cm.get_whole_html()) |
45 |
------------------------------------------------------------------------ |
46 |
|
47 |
|
48 |
|
49 |
-- |
50 |
Grant Edwards grant.b.edwards Yow! Hold the MAYO & pass |
51 |
at the COSMIC AWARENESS ... |
52 |
gmail.com |