Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-3634

Code macro fails to format last few lines

    XMLWordPrintable

    Details

    • Tests:
      Unit
    • Difficulty:
      Unknown
    • Similar issues:

      Description

      The code macro fails to format the last line in the following snippet:

      {{code language="sh"}}
      export X=foo
      bar
      {{/code}}
      

      I think the xdom.py script needs the following few lines at the end (took this from the Pygments docs):

          def format(self, tokensource, outfile):
              lastval = ''
              lasttype = None
              
              for ttype, value in tokensource:
                  if ttype == lasttype:
                      lastval += value
                  else:
                      if lastval:
                          self.listener.format(lasttype.__str__(), lastval, self.style.style_for_token(lasttype))
                      lasttype = ttype
                      lastval = value
      
              if lastval:
                  self.listener.format(lasttype.__str__(), lastval, self.style.style_for_token(lasttype))
      

      Appreciate it if you could fix this. Thanks in advance!

        Attachments

          Activity

            People

            Assignee:
            tmortagne Thomas Mortagne
            Reporter:
            orangerd Lewis Denizen
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Date of First Response: