LibraryOpen-SourceBEMJavascript

Highlight.js grammar for EnergyPlus IDF

version license

I built an Highlight.JS language grammar for EnergyPlus IDF/IDD/Error: jmarrec/highlightjs-energyplus

It’s released on NPM, and also can be served from jsDelivr.

This page just has this ES6 module code on it

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/styles/atom-one-light.min.css">

<script type="module">
import hljs from 'https://cdn.jsdelivr.net/npm/@highlightjs/cdn-assets@11.11.1/es/core.min.js';
// Register the energyplus language grammar
import energyplus from 'https://cdn.jsdelivr.net/gh/jmarrec/highlightjs-energyplus@0.3.1/dist/energyplus.es.min.js';
import energyplusErr from 'https://cdn.jsdelivr.net/gh/jmarrec/highlightjs-energyplus@0.3.1/dist/energyplus-err.es.min.js';
import energyplusIdd from 'https://cdn.jsdelivr.net/gh/jmarrec/highlightjs-energyplus@0.3.1/dist/energyplus-idd.es.min.js';
hljs.registerLanguage('energyplus', energyplus);
hljs.registerLanguage('energyplus-err', energyplusErr);
hljs.registerLanguage('energyplus-idd', energyplusIdd);

hljs.highlightAll();
</script>

energyplus IDF

As you can see, it will highlight the Object classes, Choice values, Yes/No literals, etc.

! Environmental Emissions:        None
! Utility Tariffs:                None

  Version,26.1;

  Timestep,4;

  Building,
    Simple One Zone (Wireframe DXF),  !- Name
    0,                       !- North Axis {deg}
    Suburbs,                 !- Terrain
    0.04,                    !- Loads Convergence Tolerance Value {W}
    0.004,                   !- Temperature Convergence Tolerance Value {deltaC}
    MinimalShadowing,        !- Solar Distribution
    30,                      !- Maximum Number of Warmup Days
    6;                       !- Minimum Number of Warmup Day

  HeatBalanceAlgorithm,ConductionTransferFunction;

  SurfaceConvectionAlgorithm:Inside,TARP;

  SurfaceConvectionAlgorithm:Outside,DOE-2;

  SimulationControl,
    No,                      !- Do Zone Sizing Calculation
    No,                      !- Do System Sizing Calculation
    No,                      !- Do Plant Sizing Calculation
    Yes,                     !- Run Simulation for Sizing Periods
    Yes,                     !- Run Simulation for Weather File Run Periods
    No,                      !- Do HVAC Sizing Simulation for Sizing Periods
    1;                       !- Maximum Number of HVAC Sizing Simulation Passes

!-   ===========  ALL OBJECTS IN CLASS: OUTPUT:VARIABLE ===========

  Output:Variable,*,Site Total Sky Cover,hourly;

eplusout.err

I also created a grammar for energyplus-err:

Program Version,EnergyPlus, Version 25.2.0-6b7186059e, YMD=2026.02.12 16:08,
   ** Warning ** Version: in IDF="26.1" not the same as expected="25.2"
   **   ~~~   ** ..Location object=DENVER CENTENNIAL  GOLDEN   N_CO_USA DESIGN_CONDITIONS
   **   ~~~   ** ..due to location differences, Latitude difference=[2.24] degrees, Longitude difference=[17.26] degrees.
   ** Warning ** SetUpDesignDay: Entered DesignDay Barometric Pressure=81198 differs by more than 10% from Standard Barometric Pressure=98934.
   **   ~~~   ** ...occurs in DesignDay=DENVER CENTENNIAL  GOLDEN   N ANN HTG 99% CONDNS DB, Standard Pressure (based on elevation) will be used.
   ************* Testing Individual Branch Integrity
   ************* All Branches passed integrity testing
   ************* Beginning Simulation
   ** Warning ** Temperature out of range [-100. to 200.] (PsyPsatFnTemp)
   **   ~~~   **  Input Temperature=-3116.26
   **   ~~~   **  Input Humidity Ratio= 1.257224E-003
   **   ~~~   **  Resultant Temperature= -3.62E-003
   ** Severe  ** DetermineShadowingCombinations: There are 2 surfaces which are casting surfaces and are non-convex.
   **   ~~~   ** ...Shadowing values may be inaccurate. Check .shd report file for more surface shading details
   **  Fatal  ** Unable to determine fan air flow rate.
   ************* Simulation Error Summary *************
   *************
   *************  ** Warning ** Temperature out of range [-100. to 200.] (PsyPsatFnTemp)
   *************  **   ~~~   **   This error occurred 1 total times;
   *************  **   ~~~   **   Max=-3116.264404 C  Min=-3116.264404 C
   *************
   ************* EnergyPlus Completed Successfully-- 7 Warning; 0 Severe Errors; Elapsed Time=00hr 00min  0.61sec

   ************* EnergyPlus Terminated--Fatal Error Detected. 1 Warning; 1 Severe Errors; Elapsed Time=00hr 00min  0.03sec

energyplus IDD

And a grammar for IDD

!IDD_Version 25.2.0
!IDD_BUILD abc123def
! **************************************************************************
! This file is the Input Data Dictionary (IDD) for EnergyPlus.

\group Simulation Parameters

Version,
      \memo Specifies the EnergyPlus version of the IDF file.
      \unique-object
      \format singleLine
  A1 ; \field Version Identifier
      \default 25.2

SimulationControl,
      \unique-object
      \memo Note that the following 3 fields are related to the Sizing:Zone, Sizing:System,
      \memo and Sizing:Plant objects.
      \min-fields 7
  A1, \field Do Zone Sizing Calculation
      \note If Yes, Zone sizing is accomplished from corresponding Sizing:Zone objects.
      \type choice
      \key Yes
      \key No
      \default No
  N1; \field Maximum Number of HVAC Sizing Simulation Passes
      \type integer
      \minimum 1
      \default 1

\group Thermal Zones and Surfaces

Fictitious:HeatExchanger:Detailed,
      \memo A fictitious object exercising all IDD annotation varieties.
      \required-object
      \unique-object
      \extensible:3
      \obsolete New=>Fictitious:HeatExchanger:Detailed:V2
      \min-fields 12
  A1 , \field Name
       \required-field
       \retaincase
       \type alpha
       \reference HeatExchangerNames
       \reference-class-name AllHeatExchangers
  A2 , \field Zone Name
       \note Zone the heat exchanger is located in
       \type object-list
       \object-list ZoneNames
  A3 , \field Availability Schedule Name
       \type object-list
       \object-list ScheduleNames
       \external-list autoRDDvariable
  A4 , \field Heat Transfer Mode
       \type choice
       \key Convection
       \key Radiation
       \key Combined
       \default Convection
       \deprecated
  N1 , \field Design Capacity
       \note Total heat transfer capacity at design conditions
       \units W
       \ip-units Btu/h
       \type real
       \autosizable
       \minimum 0.0
       \default autosize
  N2 , \field Design Effectiveness
       \type real
       \minimum> 0.0
       \maximum< 1.0
       \default 0.75
  N3 , \field Inlet Temperature
       \units C
       \type real
       \minimum -100.0
       \maximum 200.0
  N4 , \field Flow Rate
       \note Volumetric flow rate through the exchanger
       \units m3/s
       \ip-units gal/min
       \type real
       \autocalculatable
       \minimum> 0
       \default autocalculate
  N5 , \field Pressure Drop
       \units Pa
       \unitsBasedOnField A4
       \type real
       \minimum 0
       \maximum 5.0E+05
  N6 , \field Convergence Tolerance
       \type real
       \minimum> 0.0
       \maximum 0.5
       \default 0.001
  A5 , \field End-Use Subcategory
       \type alpha
       \retaincase
       \default General
       \begin-extensible
  A6 , \field Inlet Node Name 1
       \required-field
       \type node
  A7 , \field Outlet Node Name 2
       \required-field
       \type node
  N7 ; \field Branch Flow Fraction
       \type real
       \minimum 0.0
       \maximum 1.0
       \default 1.0