Loading ...
Sorry, an error occurred while loading the content.

Re: preserving folding during :TOhtml?

Expand Messages
  • Antony Scriven
    ... I think I posted something similar to the mailing list some time ago. I m now convinced it is full to the brim with bugs. I ve not really tested this
    Message 1 of 11 , Nov 2, 2004
    • 0 Attachment
      Peoter Veliki wrote:

      > I'd like to use :TOhtml to generate and HTML file of my
      > source code, but I'd like to be able to set the fold
      > levels in my code and and then convert it to HTML without
      > expanding the folds. For example, with the folds set tot
      > he maximum (zM) the file looks like an API with a list of
      > the functions and a description of each. I'd like to
      > generate an HTML file that preserves this view. Can this
      > be done?
      >
      > If not, anyone figured out a good hack for doing this,
      > other than say doing a series of 'Print Screens'? (I
      > tried that, it was a nightmare.)

      I think I posted something similar to the mailing list some
      time ago. I'm now convinced it is full to the brim with
      bugs. I've not really tested this version either, so you'd
      have to do that. It seemed to work on a very short example,
      but who knows?

      You pass the function two line numbers and it returns those
      lines and all in between as a string, exactly as it is
      displyed in Vim.

      fun Text_as_displayed(line1, line2)

      let line1 = a:line1 < 1 ? 1 : a:line1
      let line2 = a:line2 > line('$') ? line('$') : a:line2
      let lines = ''
      let l = line1

      while l <= line2

      let fend = foldclosedend(l)
      let fstart = foldclosed(l)

      if fstart == l || fend == -1
      let lines = lines . "\n" . getline(l)
      let l = l + 1
      elseif fend == line('$')
      break
      else
      exe fend
      norm! j
      let l = line('.')
      endif

      endwhile

      return strpart(lines,1)
      endfun

      E.g. :let @a = Text_as_displayed(1,999)

      Then you can put the text in another buffer. Or you could
      wrap the function up in a command to make it more convenient
      to use. You can then do :TOhtml on that buffer. You may lose
      the nice syntax highlighting with this approach, however.

      > What would be really cool is if when it generated the
      > HTML file, it created a whole set of HTML files that were
      > all linked, where instead of opening a fold, you'd click
      > on a hyperlink that shows that opens another HTML page
      > with the contents of that fold, and so on and so fourth.
      > That would be extremely slick. Project!

      You didn't mention what language you are writing your code
      in. Tools to do this may already exist. I'd suggest using
      Google before coming up with a Vim way to do this. If you
      do need to use Vim maybe my function will be a start.

      Antony
    • Mikolaj Machowski
      ... Set of files, each with one fold, would be hard to manage and browsing. Better would be set of files with various levels of folding open and one fully
      Message 2 of 11 , Nov 2, 2004
      • 0 Attachment
        Dnia niedziela, 31 października 2004 17:52, Peoter Veliki napisał:
        > What would be really cool is if when it generated the HTML file, it
        > created a whole set of HTML files that were all linked, where instead of
        > opening a fold, you'd click on a hyperlink that shows that opens
        > another HTML page with the contents of that fold, and so on and so
        > fourth. That would be extremely slick. Project!

        Set of files, each with one fold, would be hard to manage and browsing.

        Better would be set of files with various levels of folding open and one
        fully expanded file with <a name> tags.

        m.

        --
        LaTeX + Vim = http://vim-latex.sourceforge.net/
        Vim-list(s) Users Map: (last change 6 Oct)
        http://skawina.eu.org/mikolaj/vimlist
        CLEWN - http://clewn.sf.net
      • Bram Moolenaar
        ... The 2html script in Vim 7 can now preserve folding. It also works for diff mode with all the coloring. Vim 7 is still in early development. It works, but
        Message 3 of 11 , Nov 20, 2004
        • 0 Attachment
          Peoter Veliki wrote:

          > I'd like to use :TOhtml to generate and HTML file of my source code,
          > but I'd like to be able to set the fold levels in my code and and then
          > convert it to HTML without expanding the folds. For example, with the
          > folds set tot he maximum (zM) the file looks like an API with a list
          > of the functions and a description of each. I'd like to generate an
          > HTML file that preserves this view. Can this be done?
          >
          > If not, anyone figured out a good hack for doing this, other than say
          > doing a series of 'Print Screens'? (I tried that, it was a
          > nightmare.)
          >
          > What would be really cool is if when it generated the HTML file, it
          > created a whole set of HTML files that were all linked, where instead
          > of opening a fold, you'd click on a hyperlink that shows that opens
          > another HTML page with the contents of that fold, and so on and so
          > fourth. That would be extremely slick. Project!

          Peter Bismuti wrote:

          > I have to give a code presentation and wish to print out my code using
          > :TOhtml and have the current folding preserved to collapse comments,
          > sections that are irrelelvant (ugly) and reveal only the sections that
          > are important. Can this be done?

          The 2html script in Vim 7 can now preserve folding. It also works for
          diff mode with all the coloring.

          Vim 7 is still in early development. It works, but I can't say how
          stable it is. You need to get it from CVS, there are no binaries.

          --
          If your life is a hard drive,
          Christ can be your backup.

          /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
          /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
          \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
          \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
        • Hari Krishna Dara
          ... Does that mean Vim 7 has new functions to query HL groups directly, for those who don t have a linked syntax group? I have been looking for such functions
          Message 4 of 11 , Nov 22, 2004
          • 0 Attachment
            On Sat, 20 Nov 2004 at 3:46pm, Bram Moolenaar wrote:

            >
            > Peoter Veliki wrote:
            >
            > > I'd like to use :TOhtml to generate and HTML file of my source code,
            > > but I'd like to be able to set the fold levels in my code and and then
            > > convert it to HTML without expanding the folds. For example, with the
            > > folds set tot he maximum (zM) the file looks like an API with a list
            > > of the functions and a description of each. I'd like to generate an
            > > HTML file that preserves this view. Can this be done?
            > >
            > > If not, anyone figured out a good hack for doing this, other than say
            > > doing a series of 'Print Screens'? (I tried that, it was a
            > > nightmare.)
            > >
            > > What would be really cool is if when it generated the HTML file, it
            > > created a whole set of HTML files that were all linked, where instead
            > > of opening a fold, you'd click on a hyperlink that shows that opens
            > > another HTML page with the contents of that fold, and so on and so
            > > fourth. That would be extremely slick. Project!
            >
            > Peter Bismuti wrote:
            >
            > > I have to give a code presentation and wish to print out my code using
            > > :TOhtml and have the current folding preserved to collapse comments,
            > > sections that are irrelelvant (ugly) and reveal only the sections that
            > > are important. Can this be done?
            >
            > The 2html script in Vim 7 can now preserve folding. It also works for
            > diff mode with all the coloring.
            >
            > Vim 7 is still in early development. It works, but I can't say how
            > stable it is. You need to get it from CVS, there are no binaries.
            >
            >

            Does that mean Vim 7 has new functions to query HL groups directly, for
            those who don't have a linked syntax group? I have been looking for
            such functions for a long time, especially to limit searches to diff
            regions etc. Ability to create HTML with diff coloring should be very
            useful.

            --
            Thank a lot,
            Hari



            __________________________________
            Do you Yahoo!?
            Meet the all-new My Yahoo! - Try it today!
            http://my.yahoo.com
          • Bram Moolenaar
            ... There are new functions to find out about diff highlighting: diff_filler( {lnum}) Number diff filler lines about {lnum} diff_hlID( {lnum}, {col}) Number
            Message 5 of 11 , Nov 22, 2004
            • 0 Attachment
              Hari Krishna Dara wrote:

              > > The 2html script in Vim 7 can now preserve folding. It also works for
              > > diff mode with all the coloring.
              > >
              > > Vim 7 is still in early development. It works, but I can't say how
              > > stable it is. You need to get it from CVS, there are no binaries.
              >
              > Does that mean Vim 7 has new functions to query HL groups directly, for
              > those who don't have a linked syntax group? I have been looking for
              > such functions for a long time, especially to limit searches to diff
              > regions etc. Ability to create HTML with diff coloring should be very
              > useful.

              There are new functions to find out about diff highlighting:

              diff_filler( {lnum}) Number diff filler lines about {lnum}
              diff_hlID( {lnum}, {col}) Number diff highlighting at {lnum}/{col}


              Functions for syntax and highlight groups already existed.

              --
              Vi beats Emacs to death, and then again!
              http://linuxtoday.com/stories/5764.html

              /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
              /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
              \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
              \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
            • Hari Krishna Dara
              On Mon, 22 Nov 2004 at 10:52pm, Bram Moolenaar wrote: [snip] ... Sorry for not being clear, what I was talking about the highlighting shown by using :match
              Message 6 of 11 , Nov 22, 2004
              • 0 Attachment
                On Mon, 22 Nov 2004 at 10:52pm, Bram Moolenaar wrote:

                [snip]

                >
                >
                > Functions for syntax and highlight groups already existed.
                >

                Sorry for not being clear, what I was talking about the highlighting
                shown by using :match command. How do I know that a (line,col) is being
                shown with a specific highlighting group? Once I can determine this, I
                can make use of the functions synIDattr() and synIDtrans() to obtain
                display attributes.

                --
                Thanks,
                Hari



                __________________________________
                Do you Yahoo!?
                The all-new My Yahoo! - Get yours free!
                http://my.yahoo.com
              • David Fishburn
                ... Hmm, my plugin might already do what you want: SrchRplcHiGrp - Search and replace based on a syntax highlight group
                Message 7 of 11 , Nov 22, 2004
                • 0 Attachment
                  > >
                  > > Functions for syntax and highlight groups already existed.
                  > >
                  >
                  > Sorry for not being clear, what I was talking about the
                  > highlighting shown by using :match command. How do I know
                  > that a (line,col) is being shown with a specific highlighting
                  > group? Once I can determine this, I can make use of the
                  > functions synIDattr() and synIDtrans() to obtain display attributes.

                  Hmm, my plugin might already do what you want:
                  " SrchRplcHiGrp - Search and replace based on a syntax highlight group
                  " http://www.vim.org/script.php?script_id=848

                  When you place you cursor on a character (highlighted the correct colour)
                  run:
                  :SRChooseHiGrp[!]

                  One chooses the group, the other (with the !) chooses the base group.

                  Then you can perform a search and replace based on the highlight group name.

                  This might get you a bit closer anyway.

                  Dave

                  --
                  Do you use Vim to edit SQL?
                  <Plug>
                  Check the description of these plugins:
                  dbext.vim - Provides database access to 10 databases (Oracle, Sybase, SQL
                  Server, MySQL,...) (http://www.vim.org/scripts/script.php?script_id=356)
                  SQLUtilities - Formatting SQL, generate - columns lists, procedures for
                  databases (http://www.vim.org/scripts/script.php?script_id=492)
                  sql.vim - SQL indent file for Sybase ASA and Oracle
                  (http://www.vim.org/scripts/script.php?script_id=495)
                  Intellisense for Vim : SQL, C++, CSharp, Java, JSP, XML, HTML
                  (http://www.vim.org/scripts/script.php?script_id=747)
                  </Plug>
                • Hari Krishna Dara
                  ... Thanks, I will give it a try. I presume this doesn t work for searching under diff highlighting, because of the lack of Vim functions, but just checking.
                  Message 8 of 11 , Nov 22, 2004
                  • 0 Attachment
                    On Mon, 22 Nov 2004 at 7:15pm, David Fishburn wrote:

                    > > >
                    > > > Functions for syntax and highlight groups already existed.
                    > > >
                    > >
                    > > Sorry for not being clear, what I was talking about the
                    > > highlighting shown by using :match command. How do I know
                    > > that a (line,col) is being shown with a specific highlighting
                    > > group? Once I can determine this, I can make use of the
                    > > functions synIDattr() and synIDtrans() to obtain display attributes.
                    >
                    > Hmm, my plugin might already do what you want:
                    > " SrchRplcHiGrp - Search and replace based on a syntax highlight group
                    > " http://www.vim.org/script.php?script_id=848
                    >
                    > When you place you cursor on a character (highlighted the correct colour)
                    > run:
                    > :SRChooseHiGrp[!]
                    >
                    > One chooses the group, the other (with the !) chooses the base group.
                    >
                    > Then you can perform a search and replace based on the highlight group name.
                    >
                    > This might get you a bit closer anyway.
                    >
                    > Dave
                    >

                    Thanks, I will give it a try. I presume this doesn't work for searching
                    under diff highlighting, because of the lack of Vim functions, but just
                    checking.

                    --
                    Thanks,
                    Hari



                    __________________________________
                    Do you Yahoo!?
                    The all-new My Yahoo! - Get yours free!
                    http://my.yahoo.com
                  • Bram Moolenaar
                    ... To find out where the :match command finds a match you can search for that pattern yourself. That s what Vim does. The locations are not remembered in
                    Message 9 of 11 , Nov 23, 2004
                    • 0 Attachment
                      Hari Krishna Dara wrote:

                      > > Functions for syntax and highlight groups already existed.
                      >
                      > Sorry for not being clear, what I was talking about the highlighting
                      > shown by using :match command. How do I know that a (line,col) is being
                      > shown with a specific highlighting group? Once I can determine this, I
                      > can make use of the functions synIDattr() and synIDtrans() to obtain
                      > display attributes.

                      To find out where the ":match" command finds a match you can search for
                      that pattern yourself. That's what Vim does. The locations are not
                      remembered in any way.

                      --
                      TIM: Too late.
                      ARTHUR: What?
                      TIM: There he is!
                      [They all turn,, and see a large white RABBIT lollop a few yards out of the
                      cave. Accompanied by terrifying chord and jarring metallic monster noise.]
                      "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

                      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
                      /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
                      \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
                      \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
                    • David Fishburn
                      ... I just tried this in diff mode. You are right, no it does not work. In diff mode, I have a large section highlighted blue since it is missing from the
                      Message 10 of 11 , Nov 23, 2004
                      • 0 Attachment
                        > -----Original Message-----
                        > From: Hari Krishna Dara [mailto:hari_vim@...]
                        > Sent: Monday, November 22, 2004 8:25 PM
                        > To: David Fishburn
                        > Cc: 'Bram Moolenaar'; 'Peoter Veliki'; 'Vim@...'
                        > Subject: RE: preserving folding during :TOhtml?
                        >
                        >
                        > On Mon, 22 Nov 2004 at 7:15pm, David Fishburn wrote:
                        >
                        > > > >
                        > > > > Functions for syntax and highlight groups already existed.
                        > > > >
                        > > >
                        > > > Sorry for not being clear, what I was talking about the
                        > highlighting
                        > > > shown by using :match command. How do I know that a (line,col) is
                        > > > being shown with a specific highlighting group? Once I
                        > can determine
                        > > > this, I can make use of the functions synIDattr() and
                        > synIDtrans()
                        > > > to obtain display attributes.
                        > >
                        > > Hmm, my plugin might already do what you want:
                        > > " SrchRplcHiGrp - Search and replace based on a syntax
                        > highlight group
                        > > " http://www.vim.org/script.php?script_id=848
                        > >
                        > > When you place you cursor on a character (highlighted the correct
                        > > colour)
                        > > run:
                        > > :SRChooseHiGrp[!]
                        > >
                        > > One chooses the group, the other (with the !) chooses the
                        > base group.
                        > >
                        > > Then you can perform a search and replace based on the
                        > highlight group name.
                        > >
                        > > This might get you a bit closer anyway.
                        > >
                        > > Dave
                        > >
                        >
                        > Thanks, I will give it a try. I presume this doesn't work for
                        > searching under diff highlighting, because of the lack of Vim
                        > functions, but just checking.

                        I just tried this in diff mode.

                        You are right, no it does not work.

                        In diff mode, I have a large section highlighted "blue" since it is missing
                        from the other document.
                        The existing Vim syntax functions return the underlying syntax group names
                        for the filetype. They do not indicate that the section is even highlighted
                        "blue" due to diff mode.

                        Dave
                      Your message has been successfully submitted and would be delivered to recipients shortly.