Menu

NPPExporter, export styling to a HTML file

2007-12-11
2012-11-14
  • Nobody/Anonymous

    I've written a quick n dirty plugin to export your sourcecode to HTML much like SciTe does. However, there is no support for codepages other than ANSI, which effectively means you cannot use it when you use Unicode characters (it was meant for code anyway, which ususally is written in ANSI) or when you export .nfo files. Also, control characters are removed, so binary data gets lost. It probably needs alot of fixing, but its a start.
    Currently HTML only, since that was the most simple to export to (it isn't called Markup Language for nothing ;)).

    Download it here:
    http://harrysnppstuff.webs.com/

    Another free webhost, only this time it has a homepage ;)

    -Harry

     
    • Nobody/Anonymous

      1. Isn't this what the shortcut mapper is for? I dont like setting too many shortcuts, one wrong key and your sourcecode is altered to something funky ;) (it was reported as a bug somewhere that F9 did something to the encoding for example). For the same reason FTP_S doesn't have any shortcut set by default either.
      2. I think PDF is even harder than LaTeX, but I'll take a look into it.

      I'll see if I can copy everything to the clipboard, it's probably a few tweaks away.

      -Harry

       
    • steakhacher

      steakhacher - 2007-12-12

      It's work fine.
      Thank you for your job.

       
      • Nobody/Anonymous

        I get a 404 error when I try to download the zip file. It's a server error. Any ideas?

         
        • Nobody/Anonymous

          Its working fine for me using Firefox. Does your browser handle the link correctly?

           
    • Nobody/Anonymous

      Did you ever looked on www.andre-simon.de?

      Best Regards
      Jens

       
    • Nobody/Anonymous

      I did, and I found that although it does the same job, it does it differently and from outside Notepad++. I like the Notepad++ styling and this program does it just a tad differently. Also, it requires yet another program which makes Notepad++ editing less portable if I want to export it (I know WinHighlight is portable as well, I jsut like the have everything confined to one package).
      The application is actually what got me started on this anyway =].

      My aim is that when ever it gets implemented, the plugin uses the contenxt menu and allows me to copy text to RTF, or something like that, and paste in in a word processor.

       
    • Don HO

      Don HO - 2007-12-12

      Harry,

      I have 4 words to you :
      EX CE LLEN T !

      I wanted this feature badly, but I have no time yet to implement it.

      The html export works perfectly.
      There's only a little problem for rtf : all the '{' and '}' are not printed, but I think it's easy to fix.

      May I do one suggestion? If you can copy the content from Scintilla to clipboard as format rtf, it'll allow user paste the styled content into word.

      Don

       
    • Nobody/Anonymous

      The rtf { and } is something I completely forgot about, the documentation says so very explicitly to escape those characters :').
      I was wanting to do the clipboard thing to make it more accessible, but I've only been working for 2 days on the plugin so it isn't very mature yet.

      Yet another incentive to add those little context menu additions that have been mentioned.

       
      • Nobody/Anonymous

        fixed that RTF bug and added fontsize handling

         
        • Martijn Coppoolse

          Harry,

          Puik werk!  :-)

          Two notes:
          * With the 'new' version (still numbered 0.0.0.1, BTW), a javascript regular expression containing a space has that space magically doubled when exported to RTF.  It's displayed correctly in HTML (even the HTML source doesn't have two spaces).
          * I agree with Don, it would be very nice to be able to copy the styled (selected) text onto the clipboard — though I'd personally prefer it to be the HTML text; that would allow pasting into Thunderbird and GMail etc. as well as in Word.

           
    • Nobody/Anonymous

      I found a bug. You should export the content of the actual buffer. Try following:

      - Open some files and move one of the buffer to the other view
      - Activate the file in the other view
      - Export
      - You see, wrong buffer was exported but with the correct file name

       
    • Nobody/Anonymous

      Well, once I get theclipboard sorted out I suppose both HTML and RTF can be added, even at the same time. Point is, you have to figure out just how much memory it would take to generate the clipboard content, and then actually write it. It'd be nice if it didn't do everything twice =].

      Can you post that regular expression? RTF uses spaces to determine the end of a control keyword so it may trip because of that.

      The wrong buffer issue is being fixed (already is, not released)

       
    • Nobody/Anonymous

      I've uploaded a newer version. Changed the version numbering to something less crude too ;).

      I havent tried the HTML clipboard thing myself actually, its just a raw copy of the exported data so it might not work.

       
      • Martijn Coppoolse

        Hai Harry,

        Cool!

        But alas, you're right, HTML copying doesn't work; that needs some more information (so as to enable copying of HTML fragments):
        http://msdn2.microsoft.com/en-us/library/aa767917.aspx

        Copy RTF to clipboard works fine, OTOH.

        About the regular expression that gets an extra space, it turns out to *be* a single space, it merely looks like two spaces; I've no idea why.  Anyway, here's the expression (javascript):
        if(id = file.Name.match(/ - (\d{6,})_/)) {

        As for the large file size, that can be reduced quite a bit by using shorter CSS class names (.s0 thru .s14 instead of .SpanClass0 thru .SpanClass14, for example -- those get repeated pretty often), and by encoding the HTML file using UTF-8, and writing character #160 directly instead of using the   entity (UTF-8 requires two bytes for character 160; whereas the entity requires six).

        Just by applying these two tricks, I was able to reduce a file from 354.420 bytes to 250.778 bytes. (30% gain!)

        If you don't implement it, it might be a nice one for the FAQ.  Or something.  :-)

        Keep up the good work,
        --
        Martijn

         
    • Nobody/Anonymous

      Yeah I found that link and indeed I didnt implement that header. Thats why I pointed out it might not work ;).
      Been busy the whole day trying to get XP x64 to work so development is halted, it still doesn't work (and linux doesn't recognize my burner so it gets quite tricky from here, my nLited setup is corrupt).

       
    • Harry

      Harry - 2007-12-25

      I fixed the HTML clipboard format so it should work now.
      Merry Christmas ;)

      BTW, I just realized (by a recent post made by some user) that there was actually already such a plugin, I thought only an external tool, completely misunderstood Jens. Oh well :P

       
      • Don HO

        Don HO - 2007-12-25

        Where can I download this version?
        I didn't see it here :
        http://sourceforge.net/project/showfiles.php?group_id=189927

        Don

         
        • Harry

          Harry - 2007-12-25
           
          • Don HO

            Don HO - 2007-12-26

            It's just amazing Harry!

            A couple of suggestions :
            1. add the shortcuts for copying the RTF/HTML into clipboard.
            2. PDF Export.

            It's an excellent plugin and it'll be in v4.7.

            Don

             
      • Nobody/Anonymous

        Vrolijke feestdagen Harry! (and everybody else, of course :-))

        HTML now seems to works perfectly.  One last request, perhaps to Don also, and then I'll be happy: would it be possible to do a copy of plain text (unstyled), HTML and RTF at the same time?  This would allow performing a single copy operation, and let the application we're pasting into pick its preferred format (or let the use choose).

        BTW, I'm glad you misunderstood Jens's post, Harry! I much prefer the tighter integration with Np++ you provide, as well as the WYSIWYG-effect.  Highlighter uses different styling algorithms than Np++. I also don't like having to specify my style preferences more than once.  :)

         
  • Medicine  Man

    Medicine Man - 2009-10-19

    Hi Harry / Don

    I'm currently looking
    into good efficient ways to document C# sourcecode (such
    that syntax-highlighted sourcecode chunks are integrated into
    good-looking, standardised, descriptive web-based documents)
    and it occurred to me that when I paste some C# code into
    Notepad++ and click on Language>C>C# what Notepad++ is doing
    behind the scenes goes a long way down the road toward
    allowing me the user to save that highlighted text *as html*
    (where the highlighting {the rtf?} could be translated into html
    {or even xml} tags). Such functionality, currently not there
    in Notepad++, would be really useful to me at least (and I
    imagine many other developers too).
    The Export To HTML add-on (Plugins/NppExport/Export To HTML)
    will save a Notepad++ file  to disc
    in such a way that the text is enclosed in HTML, to make a
    valid web page, but the language-specific syntax highlighting
    information is lost. Being able to save syntax highlighting
    information as html or xml would be a (very) useful Notepad++
    feature.

    Great work you guys.

    Richard Ebbs

     
  • cchris

    cchris - 2009-10-19

    When I use NppExport -> Export to HTML, the page I get keeps all the colourisation the source dcument had in Notepad++. The changes in appearance stem from the browser mangling the fonts.

    If you look more closely at the output, you'll see that each element is colourised by applying a class to it, the name of which has the form "sc\d+" . These classes directly relate to the style being used, which in turn can be read from langs.xml. The \d+part is the styleID number.

    So, it doesn't seem that any syntactic information is lost. If you think there still is, could you elaborate?

    CChris