• Login
Community
  • Login

Functions list does not work for (X)HTML files

Scheduled Pinned Locked Moved General Discussion
5 Posts 2 Posters 459 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J
    jabcreations
    last edited by Feb 17, 2022, 12:55 AM

    The functions list is incredibly useful for me however it does not work in XHTML (and I presume HTML) files.

    I use XHTML files for quick standalone tests and for creating utilities that I need for internal development purposes.

    Here is a simple example of what the structure of the code looks like:

    **<?xml version=“1.0” encoding=“UTF-8”?>
    <!DOCTYPE html>
    <html xmlns=“http://www.w3.org/1999/xhtml ” xml:lang=“en”>
    <head>
    <title>Example Application</title>
    <script type=“application/javascript”>
    //<![CDATA[
    function hello_world() {alert(‘Hello World’);}
    //]]>
    </script>
    </head>

    <body>

    <main><p>Hello world.</p></main>

    </body>
    </html>**

    Everything else has been working fine and I haven’t encountered any instability in Notepad++ for probably a good two years now, maybe longer.

    M 1 Reply Last reply Feb 17, 2022, 2:12 AM Reply Quote 0
    • M
      Michael Vincent @jabcreations
      last edited by Feb 17, 2022, 2:12 AM

      @jabcreations said in Functions list does not work for (X)HTML files:

      The functions list is incredibly useful for me however it does not work in XHTML (and I presume HTML) files.

      You can write your own. Here’s mine:

      <?xml version="1.0" encoding="UTF-8" ?>
      <!-- ==========================================================================\
      |
      |   To learn how to make your own language parser, please check the following
      |   link:
      |       https://npp-user-manual.org/docs/function-list/
      |
      \=========================================================================== -->
      <NotepadPlus>
      	<functionList>
      		<!-- ======================================================== [ Parser goes here ] -->
      
      		<parser
      			displayName="HTML"
      			id         ="html_headers"
      			commentExpr="(?x)                                               # Utilize inline comments (see `RegEx - Pattern Modifiers`)
      							(?:\x3C!--(?:[^\-]|-(?!-\x3E))*--\x3E)          # Multi Line Comment
      						"
      		>
      			<function
      				mainExpr="(?x)                                              # Utilize inline comments (see `RegEx - Pattern Modifiers`)
      						\x3C                                                # begin of node
      						(?:
      							[hH][1-6]
      						)
      						(?:                                                 # match attributes
      							\s+                                             # at least one whitespace before attribute-name
      							\w+
      							\h*=\h*                                         # name-value separator can be surrounded by blanks
      							(?:                                             # quoted attribute value, embedded escaped quotes allowed...
      								\x22(?:[^\x22\x5C]|\x5C.)*?\x22             # ...double quoted...
      							|	\x27(?:[^\x27\x5C]|\x5C.)*?\x27             # ...single quoted
      							)
      						)*
      						(?:
      							\s*
      							\x3E
      						)
      						\w+(\s+\w+)*
      						(?:\x3C/[hH][1-6]\x3E)
      					"
      			>
      				<functionName>
      					<nameExpr expr="(?:\x3C(?:[hH][1-6])(?:\s+\w+\h*=\h*(?:\x22(?:[^\x22\x5C]|\x5C.)*?\x22|\x27(?:[^\x27\x5C]|\x5C.)*?\x27))*(?:\s*\x3E))\K.*" />
      				</functionName>
      			</function>
      		</parser>
      	</functionList>
      </NotepadPlus>
      

      Cheers.

      J 1 Reply Last reply Feb 17, 2022, 10:46 PM Reply Quote 3
      • J
        jabcreations @Michael Vincent
        last edited by Feb 17, 2022, 10:46 PM

        @michael-vincent Well, I’d thank you though I have no idea what to do with that. I just posted a bug report here:

        https://github.com/notepad-plus-plus/notepad-plus-plus/issues/11235

        M 1 Reply Last reply Feb 17, 2022, 11:34 PM Reply Quote 0
        • M
          Michael Vincent @jabcreations
          last edited by Michael Vincent Feb 17, 2022, 11:35 PM Feb 17, 2022, 11:34 PM

          @jabcreations said in Functions list does not work for (X)HTML files:

          I have no idea what to do with that.

          You put it in your Notepad++/functionList folder and restart Notepad++.

          It highlights all the header tags in HTML files. If you want something specific to functions and script tags, you can, as I said, write your own. It’s simple XML. Follow the instructions here https://npp-user-manual.org/docs/function-list/

          It certainly isn’t a bug.

          Cheers.

          J 1 Reply Last reply Feb 18, 2022, 11:36 PM Reply Quote 3
          • J
            jabcreations @Michael Vincent
            last edited by Feb 18, 2022, 11:36 PM

            @michael-vincent I have mountains on top of my mountains of work; I just don’t have it. I’ve got more than half a dozen dumbshit browser bugs that are extremely difficult to reproduce to report on top of my normal overflow of work. It’s just not happening at my end.

            1 Reply Last reply Reply Quote 0
            2 out of 5
            • First post
              2/5
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors