Pasting HTML

Tags ( )

HI,

I know that if I cut-and-paste from a webpage into more, I get beautifully formatted text matching all the sizes and atributes and inline images of the original.

Now, I've been thinking of implementing a markup/markdown type plugin so that one could quickly take some notes like:

!Synthetic Sensor Meeting
!!Agenda
#Discover a new sensing mechanism
#Devlop it
# ???
#Profit

And then the markup plugin would format it with header styles and numbered lists, etc.

However, most of the markup/down languages(Textile, markdown, stx, reStructuredText) output to HTML, so if I had a NSString of HTML that I got back from one of these command-line tools, is there anything already in Mori (like the pasting magic mentioned above) that will convert it to a displayable text. Or does the pasting and servicing from web pages only work because the browser itself already did the formatting work? and likewise, I would have to find something similar (html2rtf or Webkit) to do the work too.

Thanks

NSAttributedString has some

NSAttributedString has some – initWithHTML: methods that will turn HTML into an attributed string. Those might be what you are looking for.

But you might also be able to leverage some work that others have done. Check out HumaneText.service:

http://gu.st/proj/HumaneText.service/

It looks to be free, but not open source at first glace, though there might be a similar project that is open source. But even if the HumaneText.service isn't open source you can still leverage it by using the api (forget name of function at the moment) to invoke a menu item in the service menu.

One interesting (and important) thing that the HumaneText.service seems to support is the ability to reverse the transformation.

Thanks for the pointer about

Thanks for the pointer about initWithHtml. That's what I was looking for.

I've looked into HumaneText.service (which uses Markdown) but was also keeping options open for some of the other structured text types that are a bit more user-extensible (like stx or reST).

Regarding the ability to reverse the transformation: I've been considering that too. It'll be important I think.

This is something I'm also

This is something I'm also interested in seeing. When I used to keep my notes in a wiki I ran through personal Web sharing, one of my favorite things was that I could very quickly type formatted text using the simple markup language. This is something I've tried to replicate with my Mori Math plugin with its autoselect to last $ feature to make rendering math as you type relatively easy.

If you'd like, I can send you the code for a program I was working on called Myki with similar goals to Mori but a different user experience. It implemented a generalized version of what appears in Mori Math. Even if not exactly what you want to do, this might give you some ideas about an approach for implementing a mark-up like feature to Mori.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.