markers and otl2hmtl.py fix

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

markers and otl2hmtl.py fix

Anders Bo Rasmussen-2
Hi. Thanks for a great tool. It works great. I have had to make two
small fixes in otl2html.py:

First it didn't print my danish characters which was in UTF-8 correct,
when I loaded the output in Firefox. So I inserted charset to be utf-8:
  print"<!--  $Author: noel $ -->"
  print"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"

I don't know what is the correct solution here, because it could be that
the .otl isn't in utf-8. Any suggestions on how to handle this better?
Maybe some auto recognition on whether the input file is in utf-8?


My second problem was that it didn't converted <'s and >'s to HTML. This
gave me problems since I have written things like:

Start using vim outliner
    Convert todo list to .otl <done>
    Subscribe to the mailing list <p2>
   
And <done> and <p2> was not shown in the html, since it wasn't escaped,
so I inserted "import cgi" in the beginning and used the escape function
in the beginning of beautifyLine():

def beautifyLine(line):
  if (lstrip(rstrip(line)) == "----------------------------------------"):
        return "<br><hr><br>"
   
  out = cgi.escape(line)
  line = ""

I have made the assumption that you shouldn't be able to write html
inside the .otl file. And with the escaping I now see my marks in the
html output.

I have also a quesiton regarding <done> and <p2>. I was thinking that I
would change it to <key:value> so these two examples would be:
<status:done> and <priority:2>. Then I would like to somehow be able to
sort on e.g. priority and grep on e.g. status. Of course it should be
made general so sorting and grepping is possible for any key in the
.otl.

Is there already a way to put this information in a .otl?
Is my syntax badly chosen?

The sorting and greping I think I can make with Node.pm as long as it is
good enough to have it outside vim. I guess Node.pm is the right thing
to use for this?

Regards
 Anders Bo Rasmussen
_______________________________________________
VimOutliner mailing list
[hidden email]
http://www.lists.vimoutliner.org/mailman/listinfo/vimoutliner
Reply | Threaded
Open this post in threaded view
|

Re: markers and otl2hmtl.py fix

Steve Litt
On Friday 10 April 2009 07:04:07 am Anders Bo Rasmussen wrote:

> First it didn't print my danish characters which was in UTF-8 correct,
> when I loaded the output in Firefox. So I inserted charset to be utf-8:
>   print"<!--  $Author: noel $ -->"
>   print"<meta http-equiv=\"Content-Type\" content=\"text/html;
> charset=utf-8\" />"

I think VO does whatever Vim does as far as characters and language. Try the
command:

:language

When I do that, it says this:

Current language: "en_US.UTF-8"

Maybe you have to find a way to strongarm it to Danish. To find out more, do
this:

:h language

HTH

SteveT

Steve Litt
Recession Relief Package
http://www.recession-relief.US

_______________________________________________
VimOutliner mailing list
[hidden email]
http://www.lists.vimoutliner.org/mailman/listinfo/vimoutliner
Reply | Threaded
Open this post in threaded view
|

Re: markers and otl2hmtl.py fix

Ulrich Brinkmann
In reply to this post by Anders Bo Rasmussen-2
Am Friday, 10. April 2009 schrieb Anders Bo Rasmussen:

> Hi. Thanks for a great tool. It works great. I have had to make two
> small fixes in otl2html.py:
>
> First it didn't print my danish characters which was in UTF-8 correct,
> when I loaded the output in Firefox. So I inserted charset to be utf-8:
>   print"<!--  $Author: noel $ -->"
>   print"<meta http-equiv=\"Content-Type\" content=\"text/html;
> charset=utf-8\" />"
>
> I don't know what is the correct solution here, because it could be that
> the .otl isn't in utf-8. Any suggestions on how to handle this better?
> Maybe some auto recognition on whether the input file is in utf-8?
>


I tweaked otl2html.py the same way. Had the same problem in viewing the html
output in Firefox. I ignored the < > problem, though, because I don't use
that in my otls.

Regards Uli Brinkmann

--
Ulrich Brinkmann
_______________________________________________
VimOutliner mailing list
[hidden email]
http://www.lists.vimoutliner.org/mailman/listinfo/vimoutliner
Reply | Threaded
Open this post in threaded view
|

Re: markers and otl2hmtl.py fix

Anders Bo Rasmussen-2
In reply to this post by Steve Litt
On Fri, Apr 10, 2009 at 12:34:10PM -0400, Steve Litt wrote:
> > First it didn't print my danish characters which was in UTF-8 correct,
> > when I loaded the output in Firefox. So I inserted charset to be utf-8:
> >   print"<!--  $Author: noel $ -->"
> >   print"<meta http-equiv=\"Content-Type\" content=\"text/html;
> > charset=utf-8\" />"
>
> I think VO does whatever Vim does as far as characters and language. Try the
> command:

When I'm in vim the utf8 works fine. And the output is in principle also
correct from otl2html.py. But then I need to tell firefox manually that
it is an utf-8 html file it is reading - firefox doesn't default to the
locale setting. To do it manual is not a good solution.  Inserting the
utf-8 as charset in the header in otl2html.py might also not be the best
solution, since it could be that someone is not using utf-8.

I think the right solution would be to read in the .otl with the system
locale setting and then write the html in utf-8 with utf-8 defined as
charset in the Content-Type. This way the user can run with whatever
locale he want and still get correct html.

To make this solution I think the following should be enough in main():

  file = open(inputfile,"r")
  file = codecs.getreader(locale.getpreferredencoding())(file)
  sys.stdout = codecs.getwriter('utf-8')(sys.stdout)

Regards
 Anders
_______________________________________________
VimOutliner mailing list
[hidden email]
http://www.lists.vimoutliner.org/mailman/listinfo/vimoutliner