/******************************************************************************/ /* */ /* SearchPath.cls - RexxPub's bin/ and css/ where the parser looks for them */ /* ========================================================================== */ /* */ /* This file is part of the Rexx Parser package */ /* [See https://rexx.epbcn.com/rexx-parser/] */ /* */ /* Copyright (c) 2024-2026 Josep Maria Blasco */ /* */ /* License: Apache License 2.0 (https://www.apache.org/licenses/LICENSE-2.0) */ /* */ /* Version history: */ /* */ /* Date Version Details */ /* -------- ------- --------------------------------------------------------- */ /* 20261122 0.7 First version: the parser is the one of the installed */ /* ooRexx, not a copy in bin/ */ /* 20261122 RexxPub's css/ in REXX_PARSER_STYLE_PATH: the parser */ /* finds there the styles that do not come with ooRexx */ /* (rgfdark, rgflight, test1) */ /* */ /******************************************************************************/ /* */ /* The parser comes with ooRexx (main/trunk/extensions/parser), and finds */ /* RexxPub's optional pieces (rexxpub/Spots.cls and rexxpub/GridTables.cls */ /* for FencedCode, rexxpub/Latex.Driver.cls for the Highlighter) in the */ /* search path, when its packages are loaded. RexxPub's bin/ is not always */ /* there: md2html called by its path, or the CGI under Apache. */ /* */ /* This package puts the directory of RexxPub's bin/ (the parent of the */ /* directory of this file) at the front of REXX_PATH, when it is loaded. A */ /* RexxPub program requires it BEFORE any file of the parser, so that the */ /* prologs of FencedCode.cls and Highlighter.cls already see it: */ /* */ /* ::Requires "rexxpub/SearchPath.cls" -- First: before the parser */ /* ::Requires "parser/FencedCode.cls" */ /* */ /* It also puts RexxPub's css/ (the sibling of bin/) at the end of */ /* REXX_PARSER_STYLE_PATH, where the parser looks for a style that is not in */ /* its own parser/css/: rgfdark, rgflight and test1 are only in RexxPub. The */ /* parser's directory comes first, so the copies of the shipped styles that */ /* css/ also holds (they are published at /rexx-parser/css/) do not hide the */ /* originals. */ /* */ /* The changes are in the environment of the process, so the programs it */ /* runs (Pandoc's Lua filters, say) inherit them. */ /* */ /******************************************************************************/ sl = .File~separator If sl == "\" Then pathSep = ";" Else pathSep = ":" -- The directory of this file is bin/rexxpub/: its parent is bin/ myPath = .context~package~name myDir = myPath~left( myPath~lastPos(sl) - 1 ) binDir = .File~new( myDir || sl".." )~absolutePath Call AddDirectory "REXX_PATH", binDir, "front" Call AddDirectory "REXX_PARSER_STYLE_PATH", - .File~new( binDir || sl".."sl"css" )~absolutePath, "end" Exit -- A directory at the front or at the end of a list of directories in the -- environment (separated as the PATH), if it is not there yet AddDirectory: Use Strict Arg var, dir, where list = Value(var, , "ENVIRONMENT") If (pathSep || list || pathSep)~pos( pathSep || dir || pathSep ) > 0 Then Return If list == "" Then list = dir Else If where == "end" Then list = list || pathSep || dir Else list = dir || pathSep || list Call Value var, list, "ENVIRONMENT" Return