Community
    • Login

    ANSI X12/EDIFACT document viewing

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    edix12edifactsyntax highlightfolding
    12 Posts 8 Posters 15.5k 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.
    • innox80I
      innox80
      last edited by innox80

      Hello, I don’t know if can be useful for you, but I started to develop a plugin for Notepad++ that help in the analysis of the content of EDI files.
      At this moment is in early stage of development and it support only the EDIFACT format but soon I’ll develop also the part for the X12 format (stay tuned!)

      You can download the lates release version here: https://github.com/innox80/NppEdiAnalyzer/

      Jean-LucJ 1 Reply Last reply Reply Quote 3
      • Jean-LucJ
        Jean-Luc @innox80
        last edited by

        @innox80 :
        First of all, thank you & hello from France. I deal with EDI files since 20 years and that remains a useful tool therefore bravo for your initiative.

        I installed your beta NPP EDI Analyzer plugin, and here is my feedback :

        • format/unformat works fine for EDI FACT messages (even if I could do the same with some macro in NPP++) but didn’t test with ANSI X12 files

        • structure view works until double-click on an EDI data element ; from there, I have the following feature comment : this shows the element/component name but for EDI professionals, the best would be to have data element/component values (e.g DE3039 for NAD or C829.1082 for LIN, etc…)

        (actually, I notice the “Ref.Table Values” in the combo box below" but not sure what this refers to).

        In any case, well done. Keep going with this useful plugin.
        Thanks,

        innox80I 1 Reply Last reply Reply Quote 3
        • innox80I
          innox80 @Jean-Luc
          last edited by

          Hello @Jean-Luc thanks for your interest in NppEdiAnalizer and thanks so much for your suggestions.
          About your points:

          • the format/unformat is developed now only for the EDIFACT, I think to extend (in general all the features) to the X12 in the next release
          • I take note of your suggestion about the element/component values (e.g DE3039 for NAD or C829.1082 for LIN, etc…) for the next improvements, I’ll work on that
          • The meaning of the “Ref.Table Values” combobox is to show the available codified values/description for the selected field in the list on the right (here non many data is loaded for now, I have to add more values to have the full coverage)

          I’ll try to do a new release by the end of this month of February , so stay tuned!

          Snabel42S Daniel LD 2 Replies Last reply Reply Quote 3
          • Snabel42S
            Snabel42 @innox80
            last edited by

            @innox80 Any news on the new release, and would it include X12 support as well?

            1 Reply Last reply Reply Quote 0
            • Daniel LD
              Daniel L @innox80
              last edited by

              @innox80

              hello! i found this thread during a Google search for EDI support for notepad++. it looks like your Github project hasn’t been updated in a few years. did you ever get X12 working? would love to try it

              PeterJonesP 1 Reply Last reply Reply Quote 0
              • PeterJonesP
                PeterJones @Daniel L
                last edited by PeterJones

                @Daniel-L ,

                Unfortunately, @innox80 hasn’t been back since February 2021, so it’s doubtful you’ll get a direct response.

                However, you are in luck: according to the N++ Issue#6173 that was linked above, the EDIFACT and X12 lexers are in the lexer library (Lexilla) that Notepad++ uses for syntax highlighting. Which means, they are what I call “hidden lexers”, and I’ve previously made a script for the PythonScript plugin which can enable hidden lexers.

                You can download the most recent version of the script from my repo for pythonscripts from this link: HiddenLexers.py.

                The script doesn’t yet enable the X12 lexer, but as I have time over the next day or two, I’ll work on it; I’ll post an update (either updating this post, or replying) once I have it available.

                If you could tell me the common filename extensions for X12 and/or EDIFACT, I can include those as I’m customizing the script.

                Once the script is updated, you can follow the instructions in our How to install and run a script in PythonScript, which will explain how to install the plugin and install and run the script. If you want the HiddenLexers.py script to automatically run whenever you launch Notepad++, make sure you follow the STARTUP instructions at the end of the INSTALLATION section of the FAQ, and you would need to import HiddenLexers in your startup.py script, as described in that section of the FAQ.

                PeterJonesP 1 Reply Last reply Reply Quote 3
                • PeterJonesP
                  PeterJones @PeterJones
                  last edited by PeterJones

                  I assumed the X12 EDI extension is .x12. The HiddenLexers.py download has been updated to enable the X12 lexer for all files ending in .x12.

                  Since I know nothing about X12, I just found the example file used here (so I used the same .x12 file that Lexilla uses when testing their LexX12.cxx for the library that Notepad++ uses).

                  0e513404-9b4e-4a19-aaa5-104baeb3b806-image.png

                  I even was able to enable the folding (which is something I hadn’t tried in HiddenLexers to date).

                  You can now follow the FAQ instructions for installing the plugin and running the script.

                  If you don’t like the colors I chose (understandable), you can go to the line starting at editor.styleSetFore(self.SCE_X12_DEFAULT , and change the RGB triples for the foreground and/or the background. (If you change the colors: if you use the STARTUP version, you can exit notepad++ and rerun to get it to use the new colors; if you manually ran the script instead, you can just run the script twice more – the first will clear the old settings and the second will re-enable HiddenLexers using the new colors)

                  mkupperM 1 Reply Last reply Reply Quote 1
                  • mkupperM
                    mkupper @PeterJones
                    last edited by

                    @PeterJones said in ANSI X12/EDIFACT document viewing:

                    eb5aac25-b4bb-4727-9e59-b9074c043624-image.png

                    I got a 404 not found error when I tried to see the colors you picked. The link goes to https://community.notepad-plus-plus.org/assets/uploads/files/1732217676249-eb5aac25-b4bb-4727-9e59-b9074c043624-image.png which seems ok.

                    PeterJonesP 1 Reply Last reply Reply Quote 0
                    • PeterJonesP
                      PeterJones @mkupper
                      last edited by

                      @mkupper ,

                      The image has inexplicably disappeared off the server: I don’t know why. (And if you refresh your browser on the full URL, I think it will be 404 as well) I might have to try to regenerate it…

                      1 Reply Last reply Reply Quote 1
                      • Diego RaguindinD
                        Diego Raguindin
                        last edited by

                        I found this stack overflow post on the subject which mentioned creating a user-defined language.

                        I tried importing Chris K’s XML but got an error when importing it. Ran it through Claude and got the response that “[t]he issue is likely related to missing delimiter definitions in your XML file. Notepad++ requires that delimiters have proper open/close pairs defined, but your file only has numbered placeholders (00-23) without actual delimiter characters.”

                        Claude fixed it up for me:

                        <NotepadPlus>
                        <UserLang name="X12" ext="x12 edi" udlVersion="2.1">
                            <Settings>
                                <Global caseIgnored="no" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="0" />
                                <Prefix Keywords1="yes" Keywords2="yes" Keywords3="yes" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" />
                            </Settings>
                            <KeywordLists>
                                <Keywords name="Comments"></Keywords>
                                <Keywords name="Numbers, prefix1"></Keywords>
                                <Keywords name="Numbers, prefix2"></Keywords>
                                <Keywords name="Numbers, extras1"></Keywords>
                                <Keywords name="Numbers, extras2"></Keywords>
                                <Keywords name="Numbers, suffix1"></Keywords>
                                <Keywords name="Numbers, suffix2"></Keywords>
                                <Keywords name="Numbers, range"></Keywords>
                                <Keywords name="Operators1">*</Keywords>
                                <Keywords name="Operators2">~ :</Keywords>
                                <Keywords name="Folders in code1, open"></Keywords>
                                <Keywords name="Folders in code1, middle"></Keywords>
                                <Keywords name="Folders in code1, close"></Keywords>
                                <Keywords name="Folders in code2, open"></Keywords>
                                <Keywords name="Folders in code2, middle"></Keywords>
                                <Keywords name="Folders in code2, close"></Keywords>
                                <Keywords name="Folders in comment, open"></Keywords>
                                <Keywords name="Folders in comment, middle"></Keywords>
                                <Keywords name="Folders in comment, close"></Keywords>
                                <Keywords name="Keywords1">ISA IEA GS GE ST SE TA1</Keywords>
                                <Keywords name="Keywords2">AAA ACT ADX AK1 AK2 AK3 AK4 AK5 AK6 AK7 AK8 AK9 AMT AT1 AT2 AT3 AT4 AT5 AT6 AT7 AT8 AT9 B2 B2A BEG BGN BHT BPR BSN CAS CL1 CLM CLP CN1 COB CR1 CR2 CL3 CL4 CR5 CR6 CRC CTX CTT CUR DMG DN1 DN2 DSB DTM DTP EB EC ENT EQ FRM G61 G62 HCP HCR HD HI HL HLH HSD ICM IDC III IK3 IK4 IK5 INS IT1 K1 K2 K3 L3 L11 LIN LQ LUI LX MAN MEA MIA MOA MPI MSG N1 N2 N3 N4 NM1 NTE NX OI PAT PER PLA PLB PO1 PRF PRV PS1 PWK QTY RDM REF RMR S5 SAC SBR SLN SN1 STC SV1 SV2 SV3 SV4 SV5 SVC SVD TD5 TOO TRN TS2 TS3 UM</Keywords>
                                <Keywords name="Keywords3">LS LE</Keywords>
                                <Keywords name="Keywords4">00 000 0007 001 0010 0019 002 0022 003 004 00401 004010 004010X061 004010X061A1 004010X091 004010X091A1 004010X092 004010X092A1 004010X093 004010X093A1 004010X094 004010X094A1 004010X095 004010X095A1 004010X096 004010X096A1 004010X098 004010X098A1 005 00501 005010 005010X212 005010X217 005010X218 005010X220 005010X220A1 005010X221 005010X221A1 005010X222 005010X222A1 005010X223 005010X223A1 005010X223A2 005010X224 005010X224A1 005010X224A2 005010X230 005010X231 005010X279 005010X279A1 006 007 0078 008 009 01 010 011 012 013 014 015 016 017 018 019 02 020 021 022 023 024 025 026 027 028 029 03 030 031 032 035 036 04 05 050 06 07 08 09 090 091 096 097 0B 0F 0K 102 119 139 150 151 152 18 193 194 196 198 1A 1B 1C 1D 1E 1G 1H 1I 1J 1K 1L 1O 1P 1Q 1R 1S 1T 1U 1V 1W 1X 1Y 1Z 200 232 233 270 271 276 277 278 286 290 291 292 295 296 297 2A 2B 2C 2D 2E 2F 2I 2J 2K 2L 2P 2Q 2S 2U 2Z 30 300 301 303 304 307 31 314 318 330 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 356 357 36 360 361 374 382 383 385 386 388 393 394 3A 3C 3D 3E 3F 3G 3H 3I 3J 3K 3L 3M 3N 3O 3P 3Q 3R 3S 3T 3U 3V 3W 3X 3Y 3Z 40 405 41 417 431 434 435 438 439 441 442 444 446 45 452 453 454 455 456 458 46 461 463 471 472 473 474 480 481 484 492 4A 4B 4C 4D 4E 4F 4G 4H 4I 4J 4K 4L 4M 4N 4O 4P 4Q 4R 4S 4U 4V 4W 4X 4Y 4Z 539 540 543 573 580 581 582 598 5A 5B 5C 5D 5E 5F 5G 5H 5I 5J 5K 5L 5M 5N 5O 5P 5Q 5R 5S 5T 5U 5V 5W 5X 5Y 5Z 607 636 695 6A 6B 6C 6D 6E 6F 6G 6H 6I 6J 6K 6L 6M 6N 6O 6P 6Q 6R 6S 6U 6V 6W 6X 6Y 70 71 72 738 739 74 77 771 7C 82 820 831 834 835 837 85 850 856 866 87 8H 8U 8W 938 997 999 9A 9B 9C 9D 9E 9F 9H 9J 9K 9V 9X A0 A1 A172 A2 A3 A4 A5 A6 A7 A8 A9 AA AAE AAG AAH AAJ AB ABB ABC ABF ABJ ABK ABN AC ACH AD ADD ADM AE AF AG AH AI AJ AK AL ALC ALG ALS AM AN AO AP APC APR AQ AR AS AT AU AV AX AY AZ B1 B2 B3 B4 B6 B680 B7 B9 BA BB BBQ BBR BC BD BE BF BG BH BI BJ BK BL BLT BM BN BO BOP BP BPD BQ BR BS BT BTD BU BV BW BX BY BZ C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CAD CB CC CCP CD CE CER CF CG CH CHD CHK CI CJ CK CL CLI CLM01 CM CN CNJ CO CON CP CQ CR CS CT CV CW CX CY CZ D2 D3 D8 D9 D940 DA DB DCP DD DEN DEP DG DGN DH DI DJ DK DM DME DN DO DP DQ DR DS DT DX DY E1 E1D E2 E2D E3 E3D E5D E6D E7 E7D E8 E8D E9 E9D EA EAF EBA ECH ED EI EJ EL EM EMP EN ENT01 EO EP EPO ER ES ESP ET EV EW EX EXS EY F1 F2 F3 F4 F5 F6 F8 FA FAC FAM FB FC FD FE FF FGX FH FI FJ FK FL FM FO FS FT FWT FX FY G0 G1 G2 G3 G4 G5 G740 G8 G9 GB GD GF GH GI GJ GK GM GN GO GP GR GW GT GY H1 H6 HC HE HF HH HJ HLT HM HMO HN HO HP HPI HR HS HT I10 I11 I12 I13 I132 I3 I4 I5 I6 I7 I8 I9 IA IAT IC ID IE IF IG IH II IJ IK IL IN IND IP IR IS IV J1 J3 J6 JD JP KG KH KW L1 L2 L3 L4 L5 L6 LA LB LC LD LI LM LOI LR LT LU LTC LTD M1 M2 M3 M4 M5 M6 M7 M8 MA MB MC MD ME MED MH MI MJ ML MM MN MO MOD MP MR MRC MS MSC MT N5 N6 N7 N8 NA ND NE NF NH NI NM109 NL NN NON NQ NR NS NT NTR NU OA OB OC OD ODT OE OF OG OL ON OP OR OT OU OX OZ P0 P1 P2 P3 P4 P5 P6 P7 PA PB PC PD PDG PE PI PID PL PN PO POS PP PPO PQ PR PRA PRP PS PT PU PV PW PXC PY PZ Q4 QA QB QC QD QE QH QK QL QM QN QO QQ QR QS QV QY R1 R2 R3 R4 RA RB RC RD8 RE REC RET RF RGA RHB RLH RM RN RNH RP RR RT RU RW RX S1 S2 S3 S4 S5 S6 S7 S8 S9 SA SB SC SD SEP SET SFM SG SH SJ SK SL SP SPC SPO SPT SS STD SU SV SWT SX SY SZ T1 T10 T11 T12 T2 T3 T4 T5 T6 T7 T8 T9 TC TD TE TF TJ TL TM TN TNJ TO TPO TQ TR TRN02 TS TT TTP TU TV TWO TZ UC UH UI UK UN UP UPI UR UT V1 V5 VA VER VIS VN VO VS VV VY W1 WA WC WK WO WP WR WU WW X X12 X3 X4 X5 X9 XM XN XP XT XV XX XX1 XX2 XZ Y2 Y4 YR YT YY Z6 ZB ZH ZK ZL ZM ZN ZO ZV ZX ZZ D500</Keywords>
                                <Keywords name="Keywords5"></Keywords>
                                <Keywords name="Keywords6"></Keywords>
                                <Keywords name="Keywords7"></Keywords>
                                <Keywords name="Keywords8"></Keywords>
                                <Keywords name="Delimiters">00 00 01 01 02 02 03 03 04 04 05 05 06 06 07 07 08 08 09 09 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23</Keywords>
                            </KeywordLists>
                            <Styles>
                                <WordsStyle name="DEFAULT" fgColor="000000" bgColor="FFFFFF" colorStyle="1" fontStyle="0" nesting="0" />
                                <WordsStyle name="COMMENTS" fgColor="008000" bgColor="FFFFFF" colorStyle="1" fontStyle="0" nesting="0" />
                                <WordsStyle name="LINE COMMENTS" fgColor="008000" bgColor="FFFFFF" colorStyle="1" fontStyle="0" nesting="0" />
                                <WordsStyle name="NUMBERS" fgColor="FF8000" bgColor="FFFFFF" colorStyle="1" fontStyle="0" nesting="0" />
                                <WordsStyle name="KEYWORDS1" fgColor="0000FF" bgColor="FFFFFF" colorStyle="1" fontStyle="1" nesting="0" />
                                <WordsStyle name="KEYWORDS2" fgColor="8000FF" bgColor="FFFFFF" colorStyle="1" fontStyle="0" nesting="0" />
                                <WordsStyle name="KEYWORDS3" fgColor="00FF00" bgColor="FFFFFF" colorStyle="1" fontStyle="1" nesting="0" />
                                <WordsStyle name="KEYWORDS4" fgColor="808080" bgColor="FFFFFF" colorStyle="1" fontStyle="0" nesting="0" />
                                <WordsStyle name="KEYWORDS5" fgColor="000000" bgColor="FFFFFF" colorStyle="1" fontStyle="0" nesting="0" />
                                <WordsStyle name="KEYWORDS6" fgColor="000000" bgColor="FFFFFF" colorStyle="1" fontStyle="0" nesting="0" />
                                <WordsStyle name="KEYWORDS7" fgColor="000000" bgColor="FFFFFF" colorStyle="1" fontStyle="0" nesting="0" />
                                <WordsStyle name="KEYWORDS8" fgColor="000000" bgColor="FFFFFF" colorStyle="1" fontStyle="0" nesting="0" />
                                <WordsStyle name="OPERATORS" fgColor="FF0000" bgColor="FFFFFF" colorStyle="1" fontStyle="1" nesting="0" />
                                <WordsStyle name="FOLDER IN CODE1" fgColor="000000" bgColor="FFFFFF" colorStyle="1" fontStyle="0" nesting="0" />
                                <WordsStyle name="FOLDER IN CODE2" fgColor="000000" bgColor="FFFFFF" colorStyle="1" fontStyle="0" nesting="0" />
                                <WordsStyle name="FOLDER IN COMMENT" fgColor="000000" bgColor="FFFFFF" colorStyle="1" fontStyle="0" nesting="0" />
                                <WordsStyle name="DELIMITERS1" fgColor="000000" bgColor="FFFFFF" colorStyle="1" fontStyle="0" nesting="0" />
                                <WordsStyle name="DELIMITERS2" fgColor="000000" bgColor="FFFFFF" colorStyle="1" fontStyle="0" nesting="0" />
                                <WordsStyle name="DELIMITERS3" fgColor="000000" bgColor="FFFFFF" colorStyle="1" fontStyle="0" nesting="0" />
                                <WordsStyle name="DELIMITERS4" fgColor="000000" bgColor="FFFFFF" colorStyle="1" fontStyle="0" nesting="0" />
                                <WordsStyle name="DELIMITERS5" fgColor="000000" bgColor="FFFFFF" colorStyle="1" fontStyle="0" nesting="0" />
                                <WordsStyle name="DELIMITERS6" fgColor="000000" bgColor="FFFFFF" colorStyle="1" fontStyle="0" nesting="0" />
                                <WordsStyle name="DELIMITERS7" fgColor="000000" bgColor="FFFFFF" colorStyle="1" fontStyle="0" nesting="0" />
                                <WordsStyle name="DELIMITERS8" fgColor="000000" bgColor="FFFFFF" colorStyle="1" fontStyle="0" nesting="0" />
                            </Styles>
                        </UserLang>
                        </NotepadPlus>
                        

                        Saved it as an .xml and it imported successfully. But just formatting the text wasn’t enough for me – I wanted the ability to not just put each segment on its own line, but to be able to toggle it back and forth with a hotkey. So Claude had me install the “Python Script” plugin. Once installed, go to Plugins > Python Script > New Script, name the script <whatever>.py, paste the Python code below, then save it.

                        You can stop here if you don’t care about the hotkey and are fine running the script from the menu (Plugins > Python Script > Scripts > your script name). You can also add it to the toolbar at Plugins > Python Script > Configuration, selecting the script, and adding it to the “Toolbar” section.

                        Note: The script shows a confirmation message box each toggle (which detects whether the file is formatted or not, so the same hotkey does both operations automatically). You can remove these if you prefer silent operation (delete lines 19-21 and 38-40).

                        # EDI Format Toggle for Notepad++ PythonScript plugin
                        # This script toggles between formatted (segments on new lines) and unformatted (single line)
                        # Use the same hotkey to format and unformat!
                        
                        # Get the current document text
                        text = editor.getText()
                        
                        # Check if the file is currently formatted (has line breaks after ~)
                        if '~\n' in text or '~\r\n' in text:
                            # File is formatted - UNFORMAT IT (remove line breaks)
                            unformatted_text = text.replace('~\n', '~')
                            unformatted_text = unformatted_text.replace('~\r\n', '~')
                            
                            # Replace the entire document
                            editor.setText(unformatted_text)
                            
                            # Move cursor to the beginning
                            editor.gotoPos(0)
                            
                            # Show confirmation
                            notepad.messageBox("EDI file unformatted!\n\nAll segments are now on a single line.", "EDI Format Toggle")
                            
                        else:
                            # File is unformatted - FORMAT IT (add line breaks)
                            formatted_text = text.replace('~', '~\n')
                            
                            # Remove any double newlines
                            formatted_text = formatted_text.replace('\n\n', '\n')
                            
                            # Trim trailing whitespace
                            formatted_text = formatted_text.rstrip()
                            
                            # Replace the entire document
                            editor.setText(formatted_text)
                            
                            # Move cursor to the beginning
                            editor.gotoPos(0)
                            
                            # Show confirmation
                            notepad.messageBox("EDI file formatted!\n\nEach segment is now on its own line.", "EDI Format Toggle")
                        

                        Back to Plugins > Python Script > Configuration…, select the new script, add it to the “Menu” section, then OK.

                        To configure a hotkey for it I had to restart NPP as the script wasn’t coming up in the hotkey menu (Settings > Shortcut Mapper… > Plugin commands tab). Find the Python script, Modify button, set your hotkey, and enjoy!

                        Diego RaguindinD 1 Reply Last reply Reply Quote 0
                        • Diego RaguindinD
                          Diego Raguindin @Diego Raguindin
                          last edited by

                          Actually, I initially took Kedar’s XML, which I assume is based on Chris K’s

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