diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..765207f
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,6 @@
+# Customise GitHub Linguist
+
+# Highlight Inno Setup's .ps files as Pascal
+*.ps linguist-language=Pascal
+# Include Markdown files in stats
+*.md linguist-detectable
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bdd9af9..6d271b4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,43 @@ This change log begins with the first ever pre-release version of what was then
From release 2.0.0 the version numbering has attempted to adhere to the principles of [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## Release 2.3.0 - 2022-10-22
+
+This release includes _PasHi_ v2.3.0 and _PasHiGUI_ v1.3.0
+
+### PasHi 2.3.0 [build 15]
+
+* Added new `--inhibit-styling` command to prevent `` tags from being emitted for specified highlighter elements. [Issue 30]
+* Modified operation of `--trim` command to add facility to trim trailing spaces from source code lines. Added new parameters to specify whether lines, trailing spaces or nothing are to be trimmed. Maintained backward compatibility with older parameters, but deprecated them. [Issue 29]
+* Added new `-v` command as an alias for `--verbosity`. [Issue 38]
+* Added `frag` parameter as an alias for `fragment` in `--doc-type` command. [Issue 47]
+* Enabled `-` to be used as a parameter.
+* Added support for parsing set type parameters in form `{elem1,elem2,...}`.
+* Updated text of help screen re the new & modified commands.
+* Some minor refactoring.
+
+### PasHiGUI 1.3.0 [build 9]
+
+* Updated options pane to provide support for the new `--inhibit-styling` and modified `--trim` commands.
+
+### General
+
+* Update `UserGuide.html`:
+ * Add information about new & modified commands.
+ * Tweaked some content.
+ * Restyled tales for impreved readability.
+* Bumped config files version from 5 to 6. [Issue 55]
+* Updated `config-template`:
+ * Added comments detailing new `inhibit-styling` and modified `trim` commands.
+ * Added information about `line-number-satrt` command omitted from previous release. [Issue 53]
+ * Standardised formatting of comments.
+ * Added content explaining how to get help on the purpose of the config file commands.
+
+### Repository changes
+
+* Added link to user guide in `README.md`. [Issue 50]
+* Corrected formatting of Inno Setup files on GitHub. [Issue 36]
+
## Release 2.2.1 - 2022-08-29
This release includes _PasHi_ v2.2.1 and _PasHiGUI_ v1.2.1. Changes are as follows:
@@ -56,9 +93,8 @@ This release includes _PasHi_ v2.2.0 and _PasHiGUI_ v1.2.0. Changes are as follo
* Fixed CSS errors
* Made minor changes to read-me file that is included in distributions.
* Updated various web addresses in documentation.
-* Updated `config-template` comments:
- * noted fact that the `version` command can't be used in the `config` file
- * added details of new `line-number-start` command & its parameters
+* Updated `config-template` comments to note that the `version` command can't be used in the `config` file
+* Bumped config files version from 4 to 5.
## Release 2.1.0 - 2021-09-22
@@ -96,6 +132,7 @@ This release includes _PasHi_ v2.1.0 and _PasHiGUI_ v1.1.0. Changes are as follo
* noted fact that the `help` command can no longer be used in the `config` file
* added details of new `viewport` and `edge-compatibility` commands
* noted new command parameters
+* Bumped config files version from 3 to 4.
* Commented all v1 CSS classes as deprecated in `.css` files.
## Release 2.0.0 - 2016-09-22
diff --git a/Config/config-template b/Config/config-template
index 6f7e61e..8b1d8dd 100644
--- a/Config/config-template
+++ b/Config/config-template
@@ -65,6 +65,10 @@
#
# A complete list of valid commands follows. Commands and parameters that are
# slated for removal in the next major release are flagged as deprecated.
+#
+# For an explanation of what these commands do see the documentation of the
+# related command line command in the user guide or in PasHi's help screen,
+# accessed by typing "PasHi --help".
# --- Input source commands ---
@@ -78,9 +82,12 @@
# --- Input source trimming ---
# Command:
# trim
-# where ie either "yes" or "no"
+# where is one of "-", "lines", "spaces", "all", "yes" or "no"
+# ** the "yes" and "no" parameters are DEPRECATED
+# use "lines" instead of "yes" and "-" instead of "no"
# Default:
-# trim yes
+# trim lines
+# ** the default is DEPRECATED: may change to "all" in next release
# --- Multiple input file separation ---
@@ -145,7 +152,7 @@
# title-default
-# -- Output document encoding ---
+# --- Output document encoding ---
# Command:
# encoding
# where is one of "utf-8", "utf-16", "windows-1252" or "iso-8859-1"
@@ -188,7 +195,28 @@
# legacy-css no
-# -- Line numbering
+# --- Code generation ---
+# Command:
+# inhibit-styling
+# where is either:
+# a set of zero or more of the values, "space", "comment", "kwd", "ident",
+# "sym", "str", "num", "float", "hex", "preproc", "asm" or "err",
+# separated by commas, with no spaces, and enclosed in curly brackets,
+# or:
+# a single one of the above values,
+# or:
+# a minus sign, "-", as an alias for the empty set "{}".
+# Examples:
+# inhibit-styling {space}
+# inhibit-styling space
+# inhibit-styling {num,float,hex}
+# inhibit-styling {}
+# inhibit-styling -
+# Default:
+# inhibit-styling {}
+
+
+# --- Line numbering ---
# Commands:
# line-numbering
# where is either "on" or "off"
@@ -196,13 +224,16 @@
# where is a number in range 1..6
# line-number-padding
# where is one of "space", "zero", "dot" or "dash"
+# line-number-start
+# where is a number in range 1...9999
# Defaults:
# line-numbering off
# line-number-width 3
# line-number-padding space
+# line-number-start 1
-# -- Line styling
+# --- Line styling ---
# Command:
# striping
# where is either "on" or "off"
@@ -210,16 +241,16 @@
# striping off
-# -- Meta tags
+# --- Meta tags ---
# Commands:
# viewport
# where is one of "phone" or "none"
# edge-compatibility
# where is either "on" or "off"
-# Defaults:
-# viewport none
-# ** the viewport default is DEPRECATED: may change in next major release
-# edge-compatibility off
+# Defaults:
+# viewport none
+# ** the viewport default is DEPRECATED: may change in next major release
+# edge-compatibility off
# --- Output verbosity ---
diff --git a/Config/version b/Config/version
index 7813681..62f9457 100644
--- a/Config/version
+++ b/Config/version
@@ -1 +1 @@
-5
\ No newline at end of file
+6
\ No newline at end of file
diff --git a/Docs/UserGuide.html b/Docs/UserGuide.html
index 70aa6fb..3e32cd2 100644
--- a/Docs/UserGuide.html
+++ b/Docs/UserGuide.html
@@ -96,6 +96,9 @@
margin: 0.5em 0 0 0;
padding: 0;
}
+ td p:first-child {
+ margin-top: 0;
+ }
pre,
code,
.file,
@@ -288,10 +291,10 @@
--input-stdin |
|
- Reads source code from standard input. Since standard input is the default
- input source, this command is provided mainly to restore the default
- behaviour if it has been overridden in the config file.
- This command should not be combined with --input-clipboard or
- used if file names are specified on the command line.
+ Reads source code from standard input. Since standard input is the
+ default input source, this command is provided mainly to restore the
+ default behaviour if it has been overridden in the config file.
+ This command should not be combined with --input-clipboard
+ or used if file names are specified on the command line.
|
--input-clipboard |
-r |
- Reads source code from the clipboard.
- This command should not be combined with --input-stdin or
- used if file names are specified on the command line.
+ Reads source code from the clipboard.
+ This command should not be combined with --input-stdin or
+ used if file names are specified on the command line.
|
--output-stdout |
|
- Writes highlighted code to standard output. Since standard output is the
- default output destination, this command is provided mainly to restore the
- default behaviour if it has been overridden in the config file.
- This command should not be combined with either --output-file
- or --output-clipboard .
+ Writes highlighted code to standard output. Since standard output is
+ the default output destination, this command is provided mainly to restore
+ the default behaviour if it has been overridden in the config file.
+ This command should not be combined with either
+ --output-file or --output-clipboard .
|
--output-file |
-o |
- Writes highlighted code to the file specified by the following parameter.
- Using this command has exactly the same effect as redirecting standard
- output to a file.
- This command should not be combined with either
- --output-stdout or --output-clipboard .
+ Writes highlighted code to the file specified by the following
+ parameter. Using this command has exactly the same effect as redirecting
+ standard output to a file.
+ This command should not be combined with either
+ --output-stdout or --output-clipboard .
|
--output-clipboard |
-w |
- Writes highlighted code to the clipboard. All output is stored as Unicode
- text. Character set information is excluded from complete HTML documents.
-
- Do not combine this command with either --output-stdout
- or --output-file .
+ Writes highlighted code to the clipboard. All output is stored as
+ Unicode text. Character set information is excluded from complete HTML
+ documents.
+ Do not combine this command with either --output-stdout
+ or --output-file .
|
--doc-type |
-d |
- Determines the type of document to be output. All but one of the document
- types are complete HTML documents. The required document type is specified
- in the following parameter which must be one of:
-
+ Determines the type of document to be output. All but one of the
+ document types are complete HTML documents. The required document type is
+ specified in the following parameter which must be one of:
+
-
xhtml : Complete XHTML document (the default):
Default deprecated – to change to
@@ -480,9 +483,9 @@
html5 : Complete HTML 5 document.
-
-
fragment : An HTML code fragment containing only the
- highlighted code wrapped in <div> ...
- </div> tags.
+ fragment or frag : An HTML code fragment
+ containing only the highlighted code wrapped in
+ <div> ... </div> tags.
Various commands that relate only to complete HTML documents are
ignored when this option is used.
@@ -492,12 +495,13 @@
--branding |
-b |
- Switches on or off the inclusion of "branding" information in
+ Switches on or off the inclusion of "branding" information in
output documents. Branding means that the document contains code
- indicating that the document was generated by PasHi.
- In the case of --branding , the following parameter determines
- whether branding is switched on or off. The parameter must be one of:
-
+ indicating that the document was generated by PasHi.
+ In the case of --branding , the following parameter
+ determines whether branding is switched on or off. The parameter must be
+ one of:
+
-
True , 1 , Y , yes or
on :
@@ -509,103 +513,102 @@
Exclude branding.
- The short form of the command, -b , acts as a switch:
+ The short form of the command, -b , acts as a switch:
-b+ and -b1 include branding while
- -b- and -b0 exclude it.
+ -b- and -b0 exclude it.
|
|
--language |
-l |
- Specifies the language used in the output document. A language code
+ Specifies the language used in the output document. A language code
recognised by HTML must be provided in the parameter that immediately
follows this command. The code is not checked. If this command is not
- supplied then no language information is included in the output file.
-
- This command has no effect if the --doc-type fragment
- command is used.
+ supplied then no language information is included in the output file.
+ This command has no effect if the --doc-type fragment
+ command is used.
|
--language-neutral |
|
- Indicates that no language information is to be included in output
+ Indicates that no language information is to be included in output
documents. Since this is the default behaviour this command is provided
mainly to restore that behaviour if it has been overridden in the config
- file.
+ file.
|
--title |
-t |
- Sets the title of the output document. The title text must be supplied in
- the parameter immediately following the command. Titles containing spaces
- must be enclosed in double quotes.
- This command has no effect if the --doc-type fragment
- command is also used.
+ Sets the title of the output document. The title text must be supplied
+ in the parameter immediately following the command. Titles containing
+ spaces must be enclosed in double quotes.
+ This command has no effect if the --doc-type fragment
+ command is also used.
|
--title-default |
|
- Indicates that the default title is to be used in the output document.
+ Indicates that the default title is to be used in the output document.
Since this is the default behaviour this command is provided mainly to
- restore that behaviour if it has been overridden in the config file.
- This command has no effect if the
- --doc-type fragment command is also used.
+ restore that behaviour if it has been overridden in the config file.
+ This command has no effect if the
+ --doc-type fragment command is also used.
|
--embed-css |
-s |
- Creates an embedded CSS style sheet in the output document. The CSS is
+ Creates an embedded CSS style sheet in the output document. The CSS is
read from the file whose name is specified by the parameter immediately
following the command. The CSS must define the styles described
- below.
- If the file name includes no path information, e.g.
+ below.
+ If the file name includes no path information, e.g.
delphi2006.css , then the file will be expected to be found in
the %AppData%\DelphiDabbler\PasHi directory. To
read a file from the working directory, prepend .\ to it,
- e.g. .\delphi2006.css .
- Do not combine this command with --link-css or
+ e.g. .\delphi2006.css .
+ Do not combine this command with --link-css or
--default-css because the commands are mutually exclusive and
the result will be unpredictable. --embed-css is ignored if
- the --doc-type fragment command is also used.
+ the --doc-type fragment command is also used.
|
--link-css |
-k |
- Specifies the URL of an external CSS file to be linked from the generated
- HTML file. The URL must be given in the parameter immediately following
- this command. The URL can be relative or absolute. The linked CSS file
- must define the styles described below.
- Since no CSS is embedded in the output file the
+ Specifies the URL of an external CSS file to be linked from the
+ generated HTML file. The URL must be given in the parameter immediately
+ following this command. The URL can be relative or absolute. The linked
+ CSS file must define the styles described below.
+ Since no CSS is embedded in the output file the
--hide-css command does nothing if used with this command.
Do not combine --link-css with --embed-css or
--default-css because the commands are mutually exclusive and
the result will be unpredicatble. --link-css is ignored if
- --doc-type fragment is also used.
+ --doc-type fragment is also used.
|
--default-css |
|
- Inidicates that the default style sheet is to be embedded in the output
+ Inidicates that the default style sheet is to be embedded in the output
document. Since this is the default behaviour, this command is provided
mainly to restore that behaviour if it has been overridden in the config
- file.
- This command negates both the --embed-css and
+ file.
+ This command negates both the --embed-css and
--link-css commands and should not be combined with them
because the result will be unpredictable. --default-css is
- ignored if the --doc-type fragment command is also used.
+ ignored if the --doc-type fragment command is also used.
|
@@ -613,14 +616,14 @@
[deprecated]
-c |
- Determines wheher embedded CSS code is wrapped in HTML comment tags
+ Determines wheher embedded CSS code is wrapped in HTML comment tags
(<!-- ... --> ). This command is provided
because some old browsers will render the CSS as text unless it is
- enclosed in comment tags.
- In the case of --hide-css the parameter following the command
- determines whether the CSS is hidden in comments or not. This parameter
- must be one of the following:
-
+ enclosed in comment tags.
+ In the case of --hide-css the parameter following the
+ command determines whether the CSS is hidden in comments or not. This
+ parameter must be one of the following:
+
-
True , 1 , Y , yes or
on :
@@ -632,12 +635,12 @@
Do not use comments (the default).
- The short form of the command, -c , acts as a switch.
+ The short form of the command, -c , acts as a switch.
-c+ and -c1 hide the CSS in comments while
- -c- and -c0 do not.
- --hide-css is ignored when either the
+ -c- and -c0 do not.
+ --hide-css is ignored when either the
--doc-type fragment or --link-css commands
- are used.
+ are used.
|
@@ -646,11 +649,11 @@
|
- Determines whether CSS classes in generated HTML documents revert to those
- used in PasHi v1 (legacy) or whether the new class names
+ Determines whether CSS classes in generated HTML documents revert to
+ those used in PasHi v1 (legacy) or whether the new class names
introduced in PasHi v2 are used. The next parameter must have one
- of the following values:
-
+ of the following values:
+
-
True , 1 , Y , yes or
on :
@@ -662,24 +665,60 @@
Use new CSS class names (the default).
- This command is provided for when you have to maintain code that uses the
- old CSS style names. New code should use the new class names.
- When using the --embed-css or --link-css
+ This command is provided for when you have to maintain code that uses
+ the old CSS style names. New code should use the new class names.
+ When using the --embed-css or --link-css
commands you should be careful to ensure that the CSS file you are
embedding or linking defines the correct class names. The CSS files that
are optionally installed with PasHi define both legacy and new
CSS classes. See below for information about the
- required CSS class names.
+ required CSS class names.
+ |
+
+
+ --inhibit-styling |
+ |
+
+ Enables styling for specified syntactic elements to be omitted from the
+ HTML output. This is useful in reducing the size of HTML documents if you
+ have elements that are not styled in any way.
+ This command must be followed by a parameter which is either
+ the name of a syntactic element for which styling is to be prevented
+ or a set of zero or more syntactic elements. A set is a comma
+ delimited list of element names, enclosed in { and
+ } characters. The list must not contain spaces. Valid element
+ names are:
+
+ space : white space
+ comment : comments
+ kwd : keywords
+ ident : identifiers
+ sym : symbols
+ str : string literals
+ num : integers
+ float : floating point numbers
+ hex : hexadecimal numbers
+ preproc : pre-processor instructions
+ asm : assembler code
+ err : syntax errors
+
+ Use {} (an empty set) or - (a minus sign) to
+ enable all elements to be highlighted (the default).
+ Examples: To suppress generation of styling for white space only, use
+ --inhibit-styling space or --inhibit-styling
+ {space} . To suppress both white space and syntax errors use
+ --inhibit-styling {space,err} .
|
--encoding |
-e |
- Sets the character encoding used for output to that specified in the
+ Sets the character encoding used for output to that specified in the
next parameter. HTML documents are marked with the chosen format and the
- resulting file may include byte order marks. Valid encoding parameters are:
-
+ resulting file may include byte order marks. Valid encoding parameters
+ are:
+
-
utf-8 or utf8 : Encodes in Unicode using
UTF-8 format with byte order mark (the default).
@@ -699,56 +738,94 @@
latin1 : Encodes in ISO-8859-1 format.
- This command is ignored if the --output-clipboard command is
- specified, because data is always written to the clipboard in Unicode.
+ This command is ignored if the --output-clipboard command
+ is specified, because data is always written to the clipboard in
+ Unicode.
|
--trim |
- -m |
+ -m
+ [deprecated] |
- Determines if source code is trimmed of leading and trailing blank lines
+ Determines if or how source code is trimmed of blank lines and spaces
before highlighting. Multiple source files are trimmed individually before
- concatenation.
- In the case of --trim the following parameter is used to
- turn trimming on or off:
-
+ concatenation.
+ In the case of --trim the following parameter is used to
+ specify the type of trimming to be performed:
+
+ -
+
- , none or nothing :
+ do not trim anything.
+
+ -
+
lines :
+ trim leading and trailing blank lines (the default)
+ Default deprecated – to change to
+ all ..
+
+ -
+
spaces :
+ trim trailing spaces from lines.
+
+ -
+
all or everything :
+ trim leading and trailing blank lines and trim trailing spaces from
+ lines.
+
+
+ --trim also supports the following Boolean values that
+ were used with --trim in PasHi v2.2.1 and
+ earlier.
+
-
True , 1 , Y , yes or
- on :
- Source code is trimmed (the default).
+ on all deprecated:
+ Aliases for --trim lines .
-
False , 0 , N , no or
- off :
- Source code is not trimmed.
+ off all deprecated:
+ Aliases for --trim none .
+
+
+ The short form of the command, -m , acted as a switch in
+ PasHi v2.2.1 and earlier. The command is now interpreted as
+ follows:
+
+ -
+
-m+ and -m1 both
+ deprecated:
+ Aliases for --trim lines .
+
+ -
+
-m- and -m0 both
+ deprecated:
+ Aliases for --trim none .
- The short form of the command, -m , acts as a switch:
- -m+ and -m1 switch trimming on while
- -m- and -m0 switch it off.
|
--separator-lines |
|
- Specifies the number of blank lines to insert between the contents of each
- source file. The required number of lines is given in the following
- parameter and must be in the range 0..16. The default value is 1.
- This command is ignored unless more than one file is specified on the
- command line.
+ Specifies the number of blank lines to insert between the contents of
+ each source file. The required number of lines is given in the following
+ parameter and must be in the range 0..16. The default value is 1.
+ This command is ignored unless more than one file is specified on the
+ command line.
|
--line-numbering |
-n |
- Determines whether line numbers are prepended to each line of source code
- in the output document.
- In the case of --line-numbering the following parameter is
- used to switch line numbering on or off:
-
+ Determines whether line numbers are prepended to each line of source
+ code in the output document.
+ In the case of --line-numbering the following parameter is
+ used to switch line numbering on or off:
+
-
True , 1 , Y , yes or
on :
@@ -760,31 +837,32 @@
Line numbers are disabled (the default).
- The short form of the command, -n , acts as a switch:
+ The short form of the command, -n , acts as a switch:
-n+ and -n1 enable line numbering on while
- -n- and -n0 disable it.
+ -n- and -n0 disable it.
|
--line-number-width |
-i |
- Determines the minimum width, in characters, occupied by line numbers.
+ Determines the minimum width, in characters, occupied by line numbers.
Line numbers are padded to this width if necessary, but longer line
numbers are not truncated. The required width is given in the following
- parameter and must be in the range 1..6. The default value is 3.
- This command is ignored if line numbering is not enabled: see the
- --line-numbering command.
+ parameter and must be in the range 1..6. The default value is 3.
+ This command is ignored if line numbering is not enabled: see the
+ --line-numbering command.
|
--line-number-padding |
-p |
- Determines the padding character to be used when the number of characters
- in a line number is less than the available width. The required character
- is specified in the following parameter, which must be one of:
-
+ Determines the padding character to be used when the number of
+ characters in a line number is less than the available width. The required
+ character is specified in the following parameter, which must be one
+ of:
+
-
space : Pads with space characters (the default).
@@ -798,28 +876,28 @@
dot : Pads with dots (.).
- This command is ignored if line numbering is not enabled: see the
- --line-numbering command.
+ This command is ignored if line numbering is not enabled: see the
+ --line-numbering command.
|
--line-number-start |
-z |
- Determines the number of the first line in the listing, in the range
- 1..9999. The default value is 1.
- This command is ignored if line numbering is not enabled: see the
- --line-numbering command.
+ Determines the number of the first line in the listing, in the range
+ 1..9999. The default value is 1.
+ This command is ignored if line numbering is not enabled: see the
+ --line-numbering command.
|
--striping |
|
- Determines whether alternate lines of source code in the output document
- are styled differently or appear the same. The next parameter must be one
- of the following values:
-
+ Determines whether alternate lines of source code in the output
+ document are styled differently or appear the same. The next parameter
+ must be one of the following values:
+
-
True , 1 , Y , yes or
on :
@@ -831,24 +909,24 @@
All lines have the same appearance (the default).
- Each line of output is enclosed in its own <pre> tag.
- When striping is disabled each <pre> tag has class
+ Each line of output is enclosed in its own <pre>
+ tag. When striping is disabled each <pre> tag has class
line which can optionally be defined in CSS to style the
line. When striping is enabled the line class is replaced by
odd-line and even-line on alternate lines.
These classes must be defined differently in CSS otherwise no difference
between alternate lines will be visible. See below for
- more information about the necessary CSS classes.
+ more information about the necessary CSS classes.
|
--viewport |
|
- Determines the type, if any, of viewport meta-data that is written to a
+ Determines the type, if any, of viewport meta-data that is written to a
HTML document head section. The type of meta-data depends on the value
- the next parameter, which must be one of:
- |
--edge-compatibility |
|
- Determines whether a Microsoft Edge IE compatibility meta tag is written
- to an HTML document head. The next parameter must be one of the following
- values:
-
+ Determines whether a Microsoft Edge IE compatibility meta tag is
+ written to an HTML document head. The next parameter must be one of the
+ following values:
+
-
True , 1 , Y , yes or
on :
@@ -884,18 +962,18 @@
Do not write the meta data (the default).
- This command has no effect if the --doc-type fragment
- command is also used.
+ This command has no effect if the --doc-type fragment
+ command is also used.
|
--verbosity |
|
- Determines the amount of output PasHi writes to standard error while
+ Determines the amount of output PasHi writes to standard error while
executing. The amount of output depends on the value of the next
- parameter, which must be one of:
-
+ parameter, which must be one of:
+
-
normal : Normal screen output (the default). This causes
the program to display sign-on information and to display a message
@@ -926,22 +1004,24 @@
--quiet |
-q |
- Alias for the --verbosity quiet command.
+ Alias for the --verbosity quiet command.
|
|
--help |
-h |
- Displays a help screen. The remainder of the command line is ignored.
+ Displays a help screen. The remainder of the command line is
+ ignored.
|
--version |
- |
+ -v |
- Displays the program's version number. The remainder of the command line
- is ignored, except for --help , which takes precendence.
+ Displays the program's version number. The remainder of the command
+ line is ignored, except for --help , which takes
+ precendence.
|
@@ -973,32 +1053,32 @@
-rc
[deprecated] |
- Alias for the --input-clipboard command.
+ Alias for the --input-clipboard command.
|
-wc
[deprecated] |
- Alias for the --output-clipboard command.
+ Alias for the --output-clipboard command.
|
-frag
[deprecated] |
- Alias for the --doc-type fragment command.
+ Alias for the --doc-type fragment command.
|
-hidecss
[deprecated] |
- Alias for -c+ or the --hide-css yes
- command.
- Note: the --hide-css and
+ Alias for -c+ or the --hide-css yes
+ command.
+ Note: the --hide-css and
-c commands are also
- [deprecated].
+ [deprecated].
|
@@ -1179,7 +1259,7 @@
scripts are:
-
+
-
config-template
@@ -1302,7 +1382,7 @@
There are further CSS classes that can be associated with each line. They are:
-
+
-
.line
@@ -1346,7 +1426,7 @@
class should be provided. These classes are:
-
+
-
.comment
@@ -1610,7 +1690,7 @@
PasHi is first run after installation. The files are:
-
+
-
delphi4.css
diff --git a/README.md b/README.md
index 6dc62bf..ae471d9 100644
--- a/README.md
+++ b/README.md
@@ -14,7 +14,7 @@ For users who prefer to use a GUI, PasHi's installer provides the option to inst
For full details of how to install PasHi etc. see the file `ReadMe.txt` that is included in the program download.
-A comprehensive user guide, `UserGuide.html` is installed alongside PasHi. PasHiGUI provides a menu option to display the file.
+A comprehensive user guide, [`UserGuide.html`](https://htmlpreview.github.io/?https://github.com/delphidabbler/pashi/blob/master/Docs/UserGuide.html) is installed alongside PasHi. PasHiGUI provides a menu option to display the file.
> **Note:** Both `ReadMe.txt` and `UserGuide.html` can also be found in the `Docs` directory in PasHi's [GitHub repository](https://github.com/delphidabbler/pashi).
diff --git a/Src/Assets/Help.txt b/Src/Assets/Help.txt
index 54168e9..595e82e 100644
--- a/Src/Assets/Help.txt
+++ b/Src/Assets/Help.txt
@@ -63,6 +63,29 @@ PasHi supports the following commands:
no - do not enclose CSS [default]
Alternatively use -c+ to enclose CSS in comments or
-c- not to do so.
+--inhibit-styling Enables styling for specified syntactic elements to
+ be omitted from the HTML output. The following
+ parameter must be in set format: a comma delimited
+ list of the names of syntactic elements for which
+ styling is to be prevented. The list must be
+ enclosed in { and } characters, for e.g.
+ {space,kwd}. Valid element names are:
+ space - white space
+ comment - comments
+ kwd - keywords
+ ident - identifiers
+ sym - symbols
+ str - string literals
+ num - integers
+ float - floating point numbers
+ hex - hexadecimal numbers
+ preproc - pre-processor instructions
+ asm - assembler code
+ err - syntax errors
+ Use the empty set, {}, to style all elements
+ [default].
+ Where there is just one syntactic element being
+ specified, the curly brackets can be omitted.
--input-clipboard -r Read source code from the clipboard instead of
stdin or file(s).
--input-stdin Read source code from stdin [default].
@@ -123,14 +146,21 @@ PasHi supports the following commands:
include spaces surround the text in double quotes.
--title-default Uses the program's default title for the output
document [default].
---trim -m Determines whether input documents are trimmed of
- leading and trailing blank lines. --trim requires
+--trim -m Determines whether and how input documents are
+ trimmed of blank lines and spaces. --trim requires
the next parameter to supply one of the following
values:
- yes - trim [default]
- no - do not trim
- Alternatively use -m+ to trim or -m- to prevent
- trimming.
+ - - do not trim anything.
+ lines - trim leading and trailing blank lines.
+ [default] (*default deprecated: lines option
+ will remain*)
+ spaces - trim trailing spaces from lines
+ all - trim leading and trailing blank lines and
+ trim trailing spaces from lines
+ yes - alias for "lines" parameter (*deprecated*)
+ no - alias for "-" parameter (*deprecated*)
+ -m+ (*deprecated*) is an alias for "--trim lines"
+ and -m- (*deprecated*) is an alias for "trim -".
--verbosity Specifies the amount of output from the program.
The next parameter must be one of:
normal - sign-on, error, warning and completion
@@ -139,7 +169,7 @@ PasHi supports the following commands:
no-warn - no warnings: sign-on, error and
completion messages only.
quiet - error messages only.
---version Displays program version. Do not use with other
+--version -v Displays program version. Do not use with other
commands.
--viewport Determines the type, if any, of viewport meta-data
written to a HTML document head section. The next
diff --git a/Src/GUI/FmMain.dfm b/Src/GUI/FmMain.dfm
index 2ff88a7..dc44049 100644
--- a/Src/GUI/FmMain.dfm
+++ b/Src/GUI/FmMain.dfm
@@ -249,13 +249,13 @@ object MainForm: TMainForm
ParentColor = True
TabOrder = 2
object cpnlMisc: TCategoryPanel
- Top = 190
+ Top = 317
Height = 30
Caption = 'Miscellaneous'
Color = clWindow
Collapsed = True
TabOrder = 0
- ExpandedHeight = 262
+ ExpandedHeight = 284
inline frmMisc: TMiscOptionsFrame
Left = 0
Top = 0
@@ -268,7 +268,7 @@ object MainForm: TMainForm
end
end
object cpnlLines: TCategoryPanel
- Top = 160
+ Top = 287
Height = 30
Caption = 'Line Numbering && Striping'
Color = clWindow
@@ -287,7 +287,7 @@ object MainForm: TMainForm
end
end
object cpnlCSS: TCategoryPanel
- Top = 130
+ Top = 257
Height = 30
Caption = 'Style Sheets'
Color = clWindow
@@ -307,19 +307,23 @@ object MainForm: TMainForm
end
object cpnlDocType: TCategoryPanel
Top = 0
- Height = 130
- Caption = 'Document Type'
+ Height = 257
+ Caption = 'Document Generation'
Color = clWindow
TabOrder = 3
inline frmDocType: TDocTypeOptionsFrame
Left = 0
Top = 0
Width = 219
- Height = 104
+ Height = 231
Align = alClient
TabOrder = 0
ExplicitWidth = 219
- ExplicitHeight = 104
+ ExplicitHeight = 231
+ inherited clbInhibitStyling: TCheckListBox
+ BevelEdges = []
+ BevelInner = bvLowered
+ end
end
end
end
@@ -461,7 +465,7 @@ object MainForm: TMainForm
Left = 336
Top = 152
Bitmap = {
- 494C010105000900200010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
+ 494C010105000900280010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000400000002000000001002000000000000020
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
diff --git a/Src/GUI/FrOptions.UDocType.dfm b/Src/GUI/FrOptions.UDocType.dfm
index e300df7..d081789 100644
--- a/Src/GUI/FrOptions.UDocType.dfm
+++ b/Src/GUI/FrOptions.UDocType.dfm
@@ -6,6 +6,14 @@ inherited DocTypeOptionsFrame: TDocTypeOptionsFrame
Height = 13
Caption = 'Document type:'
end
+ object lblInhibitStyling: TLabel
+ Left = 8
+ Top = 106
+ Width = 69
+ Height = 13
+ Caption = 'Inhibit Styling:'
+ FocusControl = clbInhibitStyling
+ end
object rbDocTypeFragment: TRadioButton
Left = 8
Top = 8
@@ -34,4 +42,12 @@ inherited DocTypeOptionsFrame: TDocTypeOptionsFrame
Style = csDropDownList
TabOrder = 2
end
+ object clbInhibitStyling: TCheckListBox
+ Left = 8
+ Top = 124
+ Width = 188
+ Height = 97
+ ItemHeight = 13
+ TabOrder = 3
+ end
end
diff --git a/Src/GUI/FrOptions.UDocType.pas b/Src/GUI/FrOptions.UDocType.pas
index 660425a..8682acd 100644
--- a/Src/GUI/FrOptions.UDocType.pas
+++ b/Src/GUI/FrOptions.UDocType.pas
@@ -16,7 +16,7 @@ interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls,
+ Dialogs, StdCtrls, CheckLst,
FrOptions.UHelper, FrOptions.UBase, UOptions;
type
@@ -25,10 +25,13 @@ TDocTypeOptionsFrame = class(TBaseOptionsFrame)
rbDocTypeComplete: TRadioButton;
cbCompleteDocType: TComboBox;
lblCompleteDocType: TLabel;
+ clbInhibitStyling: TCheckListBox;
+ lblInhibitStyling: TLabel;
procedure rbDocTypeFragmentClick(Sender: TObject);
procedure rbDocTypeCompleteClick(Sender: TObject);
private
fDocTypeMap: TValueMap;
+ fInhibitStylesMap: TValueMap;
procedure UpdateControls;
public
constructor Create(AOwner: TComponent); override;
@@ -40,6 +43,10 @@ TDocTypeOptionsFrame = class(TBaseOptionsFrame)
implementation
+uses
+ StrUtils,
+ Types;
+
{$R *.dfm}
{ TDocTypeOptionsFrame }
@@ -56,11 +63,29 @@ constructor TDocTypeOptionsFrame.Create(AOwner: TComponent);
end;
fDocTypeMap.GetDescriptions(cbCompleteDocType.Items);
cbCompleteDocType.ItemIndex := fDocTypeMap.IndexOfValue('html5');
+
+ fInhibitStylesMap := TValueMap.Create;
+ fInhibitStylesMap.Add('White space', 'space');
+ fInhibitStylesMap.Add('Comments', 'comment');
+ fInhibitStylesMap.Add('Keywords', 'kwd');
+ fInhibitStylesMap.Add('Identifiers', 'ident');
+ fInhibitStylesMap.Add('Symbols', 'sym');
+ fInhibitStylesMap.Add('String literals', 'str');
+ fInhibitStylesMap.Add('Integers', 'num');
+ fInhibitStylesMap.Add('Floating Point Numbers', 'float');
+ fInhibitStylesMap.Add('Hexadecimal numbers', 'hex');
+ fInhibitStylesMap.Add('Pre-processor instructions', 'preproc');
+ fInhibitStylesMap.Add('Inline assembler', 'asm');
+ fInhibitStylesMap.Add('Syntax Errors', 'err');
+ fInhibitStylesMap.GetDescriptions(clbInhibitStyling.Items);
+ clbInhibitStyling.ItemIndex := fInhibitStylesMap.IndexOfValue('space');
+
UpdateControls;
end;
destructor TDocTypeOptionsFrame.Destroy;
begin
+ fInhibitStylesMap.Free;
fDocTypeMap.Free;
inherited;
end;
@@ -68,6 +93,10 @@ destructor TDocTypeOptionsFrame.Destroy;
procedure TDocTypeOptionsFrame.Initialise(const Options: TOptions);
var
DocType: string;
+ Styles: TStringDynArray;
+ StylesStr: string;
+ Style: string;
+ Idx: Integer;
begin
DocType := Options.GetParamAsStr('doc-type');
if DocType = 'fragment' then
@@ -81,6 +110,20 @@ procedure TDocTypeOptionsFrame.Initialise(const Options: TOptions);
rbDocTypeComplete.Checked := True;
cbCompleteDocType.ItemIndex := fDocTypeMap.IndexOfValue(DocType);
end;
+
+ StylesStr := Options.GetParamAsStr('inhibit-styling');
+ if Length(StylesStr) >= 2 then
+ begin
+ StylesStr := Copy(StylesStr, 2, Length(StylesStr) - 2);
+ Styles := SplitString(StylesStr, ',');
+ for Style in Styles do
+ begin
+ Idx := fInhibitStylesMap.IndexOfValue(Style);
+ if Idx >= 0 then
+ clbInhibitStyling.Checked[Idx] := True;
+ end;
+ end;
+
UpdateControls;
end;
@@ -95,6 +138,9 @@ procedure TDocTypeOptionsFrame.rbDocTypeFragmentClick(Sender: TObject);
end;
procedure TDocTypeOptionsFrame.UpdateOptions(const Options: TOptions);
+var
+ Idx: Integer;
+ Value: string;
begin
if rbDocTypeFragment.Checked then
Options.Store('doc-type', 'fragment')
@@ -102,6 +148,19 @@ procedure TDocTypeOptionsFrame.UpdateOptions(const Options: TOptions);
Options.Store(
'doc-type', fDocTypeMap.ValueByIndex(cbCompleteDocType.ItemIndex)
);
+
+ Value := '';
+ for Idx := 0 to Pred(clbInhibitStyling.Count) do
+ begin
+ if clbInhibitStyling.Checked[Idx] then
+ begin
+ if Value = '' then
+ Value := fInhibitStylesMap.ValueByIndex(Idx)
+ else
+ Value := Value + ',' + fInhibitStylesMap.ValueByIndex(Idx);
+ end;
+ end;
+ Options.Store('inhibit-styling', '{' + Value + '}');
end;
procedure TDocTypeOptionsFrame.UpdateControls;
diff --git a/Src/GUI/FrOptions.UMisc.dfm b/Src/GUI/FrOptions.UMisc.dfm
index 0ca388e..a467dfb 100644
--- a/Src/GUI/FrOptions.UMisc.dfm
+++ b/Src/GUI/FrOptions.UMisc.dfm
@@ -1,33 +1,35 @@
inherited MiscOptionsFrame: TMiscOptionsFrame
+ Height = 283
+ ExplicitHeight = 283
object lblSeparatorLines: TLabel
Left = 8
- Top = 36
+ Top = 60
Width = 111
Height = 13
Caption = 'Separate input files by '
end
object lblSeparatorLinesEnd: TLabel
Left = 162
- Top = 36
+ Top = 60
Width = 29
Height = 13
Caption = 'line(s)'
end
object lblLanguage: TLabel
Left = 8
- Top = 64
+ Top = 88
Width = 123
Height = 26
Caption = 'HTML document language'#13#10'(leave blank for default)'
end
object lblTitle: TLabel
Left = 8
- Top = 104
+ Top = 128
Width = 116
Height = 26
Caption = 'Title of HTML document'#13#10'(leave blank for default)'
end
- object chkTrim: TCheckBox
+ object chkTrimLines: TCheckBox
Left = 8
Top = 8
Width = 217
@@ -37,7 +39,7 @@ inherited MiscOptionsFrame: TMiscOptionsFrame
end
object seSeparatorLines: TSpinEdit
Left = 117
- Top = 33
+ Top = 57
Width = 40
Height = 22
EditorEnabled = False
@@ -49,7 +51,7 @@ inherited MiscOptionsFrame: TMiscOptionsFrame
end
object edLanguage: TEdit
Left = 145
- Top = 69
+ Top = 93
Width = 49
Height = 21
MaxLength = 5
@@ -57,14 +59,14 @@ inherited MiscOptionsFrame: TMiscOptionsFrame
end
object edTitle: TEdit
Left = 8
- Top = 136
+ Top = 160
Width = 186
Height = 21
TabOrder = 3
end
object chkBranding: TCheckBox
Left = 8
- Top = 166
+ Top = 190
Width = 217
Height = 17
Caption = 'Include "branding" in documents'
@@ -72,7 +74,7 @@ inherited MiscOptionsFrame: TMiscOptionsFrame
end
object chkViewport: TCheckBox
Left = 8
- Top = 189
+ Top = 213
Width = 217
Height = 17
Caption = 'Set viewport to make mobile friendly'
@@ -80,10 +82,18 @@ inherited MiscOptionsFrame: TMiscOptionsFrame
end
object chkEdgeCompatibility: TCheckBox
Left = 8
- Top = 212
+ Top = 236
Width = 217
Height = 17
Caption = 'Include MS Edge compatibility info'
TabOrder = 6
end
+ object chkTrimSpaces: TCheckBox
+ Left = 8
+ Top = 29
+ Width = 217
+ Height = 17
+ Caption = 'Trim spaces from line ends'
+ TabOrder = 7
+ end
end
diff --git a/Src/GUI/FrOptions.UMisc.pas b/Src/GUI/FrOptions.UMisc.pas
index fdf3c54..c9c99a0 100644
--- a/Src/GUI/FrOptions.UMisc.pas
+++ b/Src/GUI/FrOptions.UMisc.pas
@@ -20,7 +20,7 @@ interface
type
TMiscOptionsFrame = class(TBaseOptionsFrame)
- chkTrim: TCheckBox;
+ chkTrimLines: TCheckBox;
lblSeparatorLines: TLabel;
seSeparatorLines: TSpinEdit;
lblSeparatorLinesEnd: TLabel;
@@ -31,6 +31,7 @@ TMiscOptionsFrame = class(TBaseOptionsFrame)
chkBranding: TCheckBox;
chkViewport: TCheckBox;
chkEdgeCompatibility: TCheckBox;
+ chkTrimSpaces: TCheckBox;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
@@ -40,6 +41,9 @@ TMiscOptionsFrame = class(TBaseOptionsFrame)
implementation
+uses
+ UUtils;
+
{$R *.dfm}
{ TMultiFileOptionsFrame }
@@ -56,8 +60,22 @@ destructor TMiscOptionsFrame.Destroy;
end;
procedure TMiscOptionsFrame.Initialise(const Options: TOptions);
+var
+ StrVal: string;
begin
- chkTrim.Checked := Options.GetParamAsBool('trim');
+ StrVal := Options.GetParamAsStr('trim');
+ // Filter out deprecated values for --trim command
+ if IsStrInList(StrVal, ['true', '1', 'y', 'yes', 'on'], False) then
+ StrVal := 'lines'
+ else if IsStrInList(StrVal, ['false', '0', 'n', 'no', 'off'], False) then
+ StrVal := '-'
+ // Choose one item from aliases for --trim parameter names
+ else if IsStrInList(StrVal, ['none', 'nothing'], False) then
+ StrVal := '-'
+ else if IsStrInList(StrVal, ['everything'], False) then
+ StrVal := 'all';
+ chkTrimLines.Checked := IsStrInList(StrVal, ['all', 'lines'], False);
+ chkTrimSpaces.Checked := IsStrInList(StrVal, ['all', 'spaces'], False);
seSeparatorLines.Value := Options.GetParamAsInt('separator-lines');
@@ -82,7 +100,20 @@ procedure TMiscOptionsFrame.Initialise(const Options: TOptions);
procedure TMiscOptionsFrame.UpdateOptions(const Options: TOptions);
begin
- Options.Store('trim', chkTrim.Checked);
+ if chkTrimLines.Checked then
+ begin
+ if chkTrimSpaces.Checked then
+ Options.Store('trim', 'all')
+ else
+ Options.Store('trim', 'lines');
+ end
+ else
+ begin
+ if chkTrimSpaces.Checked then
+ Options.Store('trim', 'spaces')
+ else
+ Options.Store('trim', '-');
+ end;
Options.Store('separator-lines', seSeparatorLines.Value);
diff --git a/Src/GUI/UOptions.pas b/Src/GUI/UOptions.pas
index 8fab43f..d35f7bc 100644
--- a/Src/GUI/UOptions.pas
+++ b/Src/GUI/UOptions.pas
@@ -252,6 +252,8 @@ procedure TOptions.SetDefaults;
Store('viewport', 'none');
if not IsSet('edge-compatibility') then
Store('edge-compatibility', False);
+ if not IsSet('inhibit-styling') then
+ Store('inhibit-styling', '{}');
end;
procedure TOptions.Store(const Option, Value: string);
diff --git a/Src/GUI/UUtils.pas b/Src/GUI/UUtils.pas
index 07ec6d0..2f06bf2 100644
--- a/Src/GUI/UUtils.pas
+++ b/Src/GUI/UUtils.pas
@@ -3,7 +3,7 @@
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/
*
- * Copyright (C) 2006-2016, Peter Johnson (www.delphidabbler.com).
+ * Copyright (C) 2006-2022, Peter Johnson (www.delphidabbler.com).
*
* Various utility routines.
}
@@ -28,10 +28,16 @@ function StringFromStream(const Stm: TStream): string;
function ListFiles(const Dir, Wildcard: string; const List: TStrings): Boolean;
+function IsStrInList(const Str: string; const List: array of string;
+ CaseSensitive: Boolean): Boolean;
+
+
implementation
uses
+ // Project
+ UConsts,
// Delphi
SysUtils, ActiveX;
@@ -116,5 +122,21 @@ function ListFiles(const Dir, Wildcard: string; const List: TStrings): Boolean;
end;
end;
+function IsStrInList(const Str: string; const List: array of string;
+ CaseSensitive: Boolean): Boolean;
+var
+ TestFn: function(const A, B: string): Boolean;
+ Elem: string;
+begin
+ if CaseSensitive then
+ TestFn := SameStr
+ else
+ TestFn := SameText;
+ Result := False;
+ for Elem in List do
+ if TestFn(Elem, Str) then
+ Exit(True);
+end;
+
end.
diff --git a/Src/Hiliter.UGlobals.pas b/Src/Hiliter.UGlobals.pas
index d3e6e27..162e8fc 100644
--- a/Src/Hiliter.UGlobals.pas
+++ b/Src/Hiliter.UGlobals.pas
@@ -41,6 +41,9 @@ interface
heError // an unrecognised piece of code (shouldn't happen)
);
+ /// Set of hiliter elements.
+ THiliteElements = set of THiliteElement;
+
/// Records options used to customise syntax highlighting.
///
THiliteOptions = record
@@ -50,14 +53,17 @@ THiliteOptions = record
fPadding: Char;
fStartNumber: Word;
fAlternateLines: Boolean;
+ fExcludedElements: THiliteElements;
public
property UseLineNumbering: Boolean read fUseLineNumbering;
property Width: Byte read fWidth;
property Padding: Char read fPadding;
property StartNumber: Word read fStartNumber;
property AlternateLines: Boolean read fAlternateLines;
+ property ExcludedElements: THiliteElements read fExcludedElements;
constructor Create(AUseLineNumbering: Boolean; AWidth: Byte;
- APadding: Char; AAlternateLines: Boolean; AStartNumber: Word);
+ APadding: Char; AAlternateLines: Boolean; AStartNumber: Word;
+ AExcludedElements: THiliteElements);
end;
/// Interface implemented by all highlighter classes.
@@ -83,7 +89,8 @@ implementation
{ THiliteOptions }
constructor THiliteOptions.Create(AUseLineNumbering: Boolean;
- AWidth: Byte; APadding: Char; AAlternateLines: Boolean; AStartNumber: Word);
+ AWidth: Byte; APadding: Char; AAlternateLines: Boolean; AStartNumber: Word;
+ AExcludedElements: THiliteElements);
begin
fUseLineNumbering := AUseLineNumbering;
if fUseLineNumbering then
@@ -99,6 +106,7 @@ constructor THiliteOptions.Create(AUseLineNumbering: Boolean;
fStartNumber := 0;
end;
fAlternateLines := AAlternateLines;
+ fExcludedElements := AExcludedElements;
end;
end.
diff --git a/Src/Hiliter.UHiliters.pas b/Src/Hiliter.UHiliters.pas
index 62c36c0..b350f1d 100644
--- a/Src/Hiliter.UHiliters.pas
+++ b/Src/Hiliter.UHiliters.pas
@@ -67,6 +67,7 @@ TLegacyCSSNames = class(TInterfacedObject, ICSSClassNames)
/// Supplies names of CSS classes used in highlighting.
TCSSNames = class(TInterfacedObject, ICSSClassNames)
+ public
function MainClass: string;
function ElementClass(const Elem: THiliteElement): string;
end;
@@ -77,6 +78,7 @@ THTMLHiliter = class sealed(TParsedSyntaxHiliter, ISyntaxHiliter)
strict private
fCSSClases: ICSSClassNames; // provides name of CSS classes
fIsEmptyLine: Boolean; // flags if a line has no content
+ function IsElemRequired(const Elem: THiliteElement): Boolean;
strict protected
procedure BeginDoc; override;
procedure EndDoc; override;
@@ -194,15 +196,17 @@ function TParsedSyntaxHiliter.LineNumberStr: string;
procedure THTMLHiliter.AfterElem(Elem: THiliteElement);
begin
- // Close the element's span
- Writer.Append('');
+ if IsElemRequired(Elem) then
+ // Close the element's span
+ Writer.Append('');
end;
procedure THTMLHiliter.BeforeElem(Elem: THiliteElement);
begin
inherited;
- // Open a span for required class
- Writer.AppendFormat('', [fCSSClases.ElementClass(Elem)]);
+ if IsElemRequired(Elem) then
+ // Open a span for required class
+ Writer.AppendFormat('', [fCSSClases.ElementClass(Elem)]);
end;
procedure THTMLHiliter.BeginDoc;
@@ -248,6 +252,16 @@ procedure THTMLHiliter.EndLine;
Writer.AppendLine('');
end;
+function THTMLHiliter.IsElemRequired(const Elem: THiliteElement): Boolean;
+var
+ E: THiliteElement;
+begin
+ for E in Options.ExcludedElements do
+ if E = Elem then
+ Exit(False);
+ Result := True;
+end;
+
procedure THTMLHiliter.WriteElem(const ElemText: string);
begin
// Write element text with illegal characters converted to entities
diff --git a/Src/Renderers.UFactory.pas b/Src/Renderers.UFactory.pas
index 638648a..e868dd2 100644
--- a/Src/Renderers.UFactory.pas
+++ b/Src/Renderers.UFactory.pas
@@ -51,7 +51,8 @@ class function TRendererFactory.CreateRenderer(const SourceCode: string;
Config.LineNumberWidth,
Config.LineNumberPadding,
Config.Striping,
- Config.LineNumberStart
+ Config.LineNumberStart,
+ Config.ExcludedSpans
)
);
case Config.DocType of
diff --git a/Src/UConfig.pas b/Src/UConfig.pas
index 805b7ef..1e6403a 100644
--- a/Src/UConfig.pas
+++ b/Src/UConfig.pas
@@ -15,7 +15,8 @@
interface
uses
- SysUtils, Classes;
+ SysUtils, Classes,
+ Hiliter.UGlobals;
type
@@ -72,6 +73,15 @@ interface
vpPhone
);
+ /// Enumerates different trim operations applied to source code.
+ /// prior to processing.
+ TTrimOperation = (
+ tsNone, // don't trim anything
+ tsLines, // trim blank lines from beginning and end of a source file
+ tsSpaces, // trim trailing spaces from source code lines
+ tsBoth // trim blank lines and spaces
+ );
+
/// Valid range of separator lines between files.
TSeparatorLines = 0..16;
@@ -99,7 +109,7 @@ TConfig = class(TObject)
fCSSSource: TCSSSource;
fCSSLocation: string;
fOutputEncodingId: TOutputEncodingId;
- fTrimSource: Boolean;
+ fTrimSource: TTrimOperation;
fInFiles: TStringList;
fSeparatorLines: TSeparatorLines;
fLegacyCSSNames: Boolean;
@@ -110,6 +120,7 @@ TConfig = class(TObject)
fStriping: Boolean;
fViewport: TViewport;
fEdgeCompatibility: Boolean;
+ fExcludedSpans: THiliteElements;
function GetInputFiles: TArray;
public
constructor Create;
@@ -138,8 +149,8 @@ TConfig = class(TObject)
property InputFiles: TArray read GetInputFiles;
property BrandingPermitted: Boolean
read fBrandingPermitted write fBrandingPermitted default True;
- property TrimSource: Boolean
- read fTrimSource write fTrimSource default True;
+ property TrimSource: TTrimOperation
+ read fTrimSource write fTrimSource default tsLines;
property SeparatorLines: TSeparatorLines
read fSeparatorLines write fSeparatorLines default 1;
property LegacyCSSNames: Boolean
@@ -156,6 +167,8 @@ TConfig = class(TObject)
property Viewport: TViewport read fViewport write fViewport default vpNone;
property EdgeCompatibility: Boolean
read fEdgeCompatibility write fEdgeCompatibility default False;
+ property ExcludedSpans: THiliteElements
+ read fExcludedSpans write fExcludedSpans default [];
procedure AddInputFile(const FN: string);
function OutputEncoding: TEncoding;
function OutputEncodingName: string;
@@ -189,7 +202,7 @@ constructor TConfig.Create;
fBrandingPermitted := True;
fLanguage := '';
fVerbosity := vbNormal;
- fTrimSource := True;
+ fTrimSource := tsLines;
fSeparatorLines := 1;
fLegacyCSSNames := False;
fUseLineNumbering := False;
@@ -199,6 +212,7 @@ constructor TConfig.Create;
fStriping := False;
fViewport := vpNone;
fEdgeCompatibility := False;
+ fExcludedSpans := [];
end;
destructor TConfig.Destroy;
diff --git a/Src/UParams.pas b/Src/UParams.pas
index 2357191..c336d3a 100644
--- a/Src/UParams.pas
+++ b/Src/UParams.pas
@@ -18,8 +18,10 @@ interface
uses
// Delphi
SysUtils,
+ Types,
Generics.Collections,
// Project
+ Hiliter.UGlobals,
UConfig;
type
@@ -47,6 +49,7 @@ interface
siHelp, // display help
siVerbosity, // determines amount of messages output by program
siTrim, // determines if source code is trimmed
+ siTrim2, // determines if & how source code is trimmed
siSeparatorLines, // specifies number of lines that separate source files
siLineNumbering, // determines if output file is to be line numbered
siLineNumberWidth, // specifies width of line numbers in characters
@@ -56,7 +59,8 @@ interface
siViewport, // which viewport meta-data to output, if any
siEdgeCompatibility,// whether edge compatibility info meta-data is output
siLineNumberStart, // specifies starting line number
- siVersion // display program's version
+ siVersion, // display program's version
+ siInhibitStyling // inhibits styling of some highlight elements
);
type
@@ -100,6 +104,9 @@ TCommand = record
/// commands provided.
TParams = class(TObject)
strict private
+ const
+ SetParamOpener = '{';
+ SetParamCloser = '}';
var
fParamQueue: TQueue; // Queue of parameters to be processed
fCmdLookup: TDictionary;
@@ -112,6 +119,9 @@ TParams = class(TObject)
fVerbosityLookup: TDictionary;
fPaddingLookup: TDictionary;
fViewportLookup: TDictionary;
+ fHiliteSpanClsLookup: TDictionary;
+ fHiliteAliasLookup: TDictionary;
+ fTrimLookup: TDictionary;
fConfig: TConfig; // Reference to program's configuration object
fWarnings: TList;
fFirstCommandFound: Boolean; // detects filenames after 1st command
@@ -119,6 +129,8 @@ TParams = class(TObject)
procedure GetCmdLineParams;
procedure ParseCommand(const IsConfigCmd: Boolean);
procedure ParseFileName;
+ function TryParseSetParam(const Param: string; out Elems: TStringDynArray):
+ Boolean;
function GetStringParameter(const Cmd: TCommand): string;
function GetBooleanParameter(const Cmd: TCommand): Boolean;
function GetEncodingParameter(const Cmd: TCommand): TOutputEncodingId;
@@ -128,6 +140,7 @@ TParams = class(TObject)
UInt16;
function GetPaddingParameter(const Cmd: TCommand): Char;
function GetViewportParameter(const Cmd: TCommand): TViewport;
+ function GetExcludedSpansParameter(const Cmd: TCommand): THiliteElements;
function GetWarnings: TArray;
function AdjustCommandName(const Name: string; IsCfgCmd: Boolean): string;
function IsV1Command(const Name: string): Boolean;
@@ -171,6 +184,7 @@ implementation
// Delphi
StrUtils, Classes, Character,
// Project
+ Hiliter.UHiliters,
UComparers, UConfigFiles;
@@ -191,6 +205,9 @@ function TParams.AdjustCommandName(const Name: string;
end;
constructor TParams.Create(const Config: TConfig);
+var
+ HiliteElem: THiliteElement;
+ CSSNames: TCSSNames;
begin
Assert(Assigned(Config), 'TParams.Create: Config is nil');
inherited Create;
@@ -219,6 +236,7 @@ constructor TParams.Create(const Config: TConfig);
Add('-r', siInputClipboard);
Add('-s', siEmbedCSS);
Add('-t', siTitle);
+ Add('-v', siVersion);
Add('-w', siOutputClipboard);
Add('-z', siLineNumberStart);
// long forms
@@ -252,6 +270,7 @@ constructor TParams.Create(const Config: TConfig);
Add('--viewport', siViewport);
Add('--edge-compatibility', siEdgeCompatibility);
Add('--version', siVersion);
+ Add('--inhibit-styling', siInhibitStyling);
// commands kept for backwards compatibility with v1.x
Add('-frag', siFragment);
Add('-hidecss', siForceHideCSS);
@@ -313,6 +332,7 @@ constructor TParams.Create(const Config: TConfig);
Add('html4', dtHTML4);
Add('html5', dtHTML5);
Add('fragment', dtFragment);
+ Add('frag', dtFragment);
end;
// lookup table for any command with boolean parameters
fBooleanLookup := TDictionary.Create(
@@ -362,10 +382,44 @@ constructor TParams.Create(const Config: TConfig);
Add('tablet', vpPhone);
end;
fWarnings := TList.Create(TTextComparer.Create);
+
+ fTrimLookup := TDictionary.Create(
+ TTextEqualityComparer.Create
+ );
+ fTrimLookup.Add('-', tsNone);
+ fTrimLookup.Add('none', tsNone);
+ fTrimLookup.Add('nothing', tsNone);
+ fTrimLookup.Add('lines', tsLines);
+ fTrimLookup.Add('spaces', tsSpaces);
+ fTrimLookup.Add('all', tsBoth);
+ fTrimLookup.Add('everything', tsBoth);
+ // Additionally old Boolean params are supported, but deprecated.
+ // False => 'none' and True => 'lines'
+
+ fHiliteSpanClsLookup := TDictionary.Create(
+ TTextEqualityComparer.Create
+ );
+ fHiliteAliasLookup := TDictionary.Create(
+ TTextEqualityComparer.Create
+ );
+ CSSNames := TCSSNames.Create;
+ try
+ for HiliteElem := Low(THiliteElement) to High(THiliteElement) do
+ begin
+ fHiliteSpanClsLookup.Add(CSSNames.ElementClass(HiliteElem), HiliteElem);
+ // add element name as alias for {element-name}
+ fHiliteAliasLookup.Add(CSSNames.ElementClass(HiliteElem), [HiliteElem]);
+ end;
+ finally
+ CSSNames.Free;
+ end;
+ fHiliteAliasLookup.Add('-', []); // alias for empty set {}
end;
destructor TParams.Destroy;
begin
+ fHiliteAliasLookup.Free;
+ fHiliteSpanClsLookup.Free;
fWarnings.Free;
fViewportLookup.Free;
fPaddingLookup.Free;
@@ -444,6 +498,43 @@ function TParams.GetEncodingParameter(const Cmd: TCommand): TOutputEncodingId;
Result := fEncodingLookup[Param];
end;
+function TParams.GetExcludedSpansParameter(const Cmd: TCommand):
+ THiliteElements;
+var
+ Param: string;
+ Spans: TStringDynArray;
+ Span: string;
+resourcestring
+ sBadSpanCls = 'Invalid span class name for "%s": ';
+ sBadParam = 'Invalid parameter for "%s": ';
+begin
+ // Parameter is EITHER a set or an alias for a set
+ // Set is enclosed in {}, alias is not.
+ Param := GetStringParameter(Cmd);
+ if TryParseSetParam(Param, Spans) then
+ begin
+ // Parameter is a valid set of zero or more elements
+ Result := [];
+ for Span in Spans do
+ begin
+ if not fHiliteSpanClsLookup.ContainsKey(Span) then
+ raise ECommandError.Create(
+ Cmd.Name, sBadSpanCls + Format('"%s', [Span])
+ );
+ Include(Result, fHiliteSpanClsLookup[Span]);
+ end;
+ end
+ else
+ begin
+ // Not a set parameter - test for a valid alias
+ if not fHiliteAliasLookup.ContainsKey(Param) then
+ raise ECommandError.Create(
+ Cmd.Name, sBadParam + Format('"%s"', [Param])
+ );
+ Result := fHiliteAliasLookup[Param];
+ end;
+end;
+
function TParams.GetNumericParameter(const Cmd: TCommand; const Lo,
Hi: UInt16): UInt16;
var
@@ -483,8 +574,9 @@ function TParams.GetStringParameter(const Cmd: TCommand): string;
Result := ''
else
Result := fParamQueue.Peek;
- if (Result = '') or AnsiStartsStr('-', Result) then
- raise ECommandError.Create(Cmd.Name, sNoParam);
+ if (Result = '')
+ or (AnsiStartsStr('-', Result) and (Result <> '-')) then
+ raise ECommandError.Create(Cmd.Name, sNoParam);
end;
function TParams.GetVerbosityParameter(const Cmd: TCommand): TVerbosity;
@@ -575,15 +667,19 @@ procedure TParams.ParseCommand(const IsConfigCmd: Boolean);
resourcestring
// Error messages
sBadCommand = 'Unrecognised command "%s"';
+ sBadParam = 'Unrecognised parameter "%0:s" for command "%1:s"';
sCantBeSwitch = '%s cannot be a switch command';
sMustBeSwitch = '%s must be a switch command: append "+" or "-"';
- sBlacklisted = 'The "%s" command is not permitted.';
+ sBlacklisted = 'The "%s" command is not permitted';
// Warnings
sDeprecatedCmd = 'The "%s" command is deprecated';
+ sDeprecatedParam = 'The "%0:s" parameter of the "%1:s" command is deprecated';
+ sDeprecatedSwitch = 'The "%s" switch is deprecated';
sDepDocType = 'The "html4" parameter of the "%s" command is deprecated';
var
Command: TCommand;
CommandId: TCommandId;
+ Param: string;
begin
Command := fParamQueue.Dequeue;
if not fCmdLookup.ContainsKey(Command.Name) then
@@ -713,10 +809,39 @@ procedure TParams.ParseCommand(const IsConfigCmd: Boolean);
siTrim:
begin
if Command.IsSwitch then
- fConfig.TrimSource := Command.SwitchValue
+ begin
+ if Command.SwitchValue = True then
+ fConfig.TrimSource := tsLines
+ else
+ fConfig.TrimSource := tsNone;
+ fWarnings.Add(
+ Format(
+ sDeprecatedSwitch, [AdjustCommandName(Command.Name, IsConfigCmd)]
+ )
+ );
+ end
else
begin
- fConfig.TrimSource := GetBooleanParameter(Command);
+ Param := GetStringParameter(Command);
+ if fTrimLookup.ContainsKey(Param) then
+ fConfig.TrimSource := fTrimLookup[Param]
+ else if fBooleanLookup.ContainsKey(Param) then
+ begin
+ if fBooleanLookup[Param] = True then
+ fConfig.TrimSource := tsLines
+ else
+ fConfig.TrimSource := tsNone;
+ fWarnings.Add(
+ Format(
+ sDeprecatedParam,
+ [Param, AdjustCommandName(Command.Name, IsConfigCmd)]
+ )
+ );
+ end
+ else
+ raise Exception.CreateFmt(
+ sBadParam, [Param, AdjustCommandName(Command.Name, IsConfigCmd)]
+ );
fParamQueue.Dequeue;
end;
end;
@@ -782,6 +907,11 @@ procedure TParams.ParseCommand(const IsConfigCmd: Boolean);
fConfig.EdgeCompatibility := GetBooleanParameter(Command);
fParamQueue.Dequeue;
end;
+ siInhibitStyling:
+ begin
+ fConfig.ExcludedSpans := GetExcludedSpansParameter(Command);
+ fParamQueue.Dequeue;
+ end;
end;
end;
@@ -799,6 +929,31 @@ procedure TParams.ParseFileName;
fParamQueue.Dequeue;
end;
+function TParams.TryParseSetParam(const Param: string;
+ out Elems: TStringDynArray): Boolean;
+var
+ ParamContent: string;
+begin
+ // A set parameter has the form (in sort of BNF):
+ // "{" [ { "," } ] "}"
+ // where elem is simple text
+ // E.gs:
+ // {} - empty set
+ // {elem} - one item set
+ // {elem1,elem2,elem3} - three item set
+ // Note - there can be no spaces anywhere in the parameter
+ SetLength(Elems, 0);
+ if Length(Param) < 2 then
+ Exit(False);
+ if Param[1] <> SetParamOpener then
+ Exit(False);
+ if Param[Length(Param)] <> SetParamCloser then
+ Exit(False);
+ ParamContent := Copy(Param, 2, Length(Param) - 2);
+ Elems := SplitString(ParamContent, ',');
+ Result := True;
+end;
+
{ TCommand }
constructor TCommand.Create(const Cmd: string);
diff --git a/Src/USourceProcessor.pas b/Src/USourceProcessor.pas
index 6c34125..ff35001 100644
--- a/Src/USourceProcessor.pas
+++ b/Src/USourceProcessor.pas
@@ -23,7 +23,8 @@ TSourceProcessor = class(TObject)
strict private
var
fConfig: TConfig;
- class function TrimSource(const SourceCode: string): string;
+ class function TrimSourceLines(const SourceCode: string): string;
+ class function TrimSourceTrailingSpaces(const SourceCode: string): string;
function Separator: string;
public
constructor Create(const Config: TConfig);
@@ -33,6 +34,7 @@ TSourceProcessor = class(TObject)
implementation
uses
+ StrUtils,
Classes,
IO.Readers.UFactory, UConsts;
@@ -64,8 +66,10 @@ function TSourceProcessor.Process(const Sources: TArray): string;
for SourceCode in Sources do
begin
ProcessedSource := SourceCode;
- if fConfig.TrimSource then
- ProcessedSource := TrimSource(ProcessedSource);
+ if fConfig.TrimSource in [tsLines, tsBoth] then
+ ProcessedSource := TrimSourceLines(ProcessedSource);
+ if fConfig.TrimSource in [tsSpaces, tsBoth] then
+ ProcessedSource := TrimSourceTrailingSpaces(ProcessedSource);
AddToOutput(ProcessedSource);
end;
Result := SB.ToString;
@@ -83,7 +87,8 @@ function TSourceProcessor.Separator: string;
Result := Result + CRLF;
end;
-class function TSourceProcessor.TrimSource(const SourceCode: string): string;
+class function TSourceProcessor.TrimSourceLines(const SourceCode: string):
+ string;
var
Lines: TStringList;
begin
@@ -98,4 +103,25 @@ class function TSourceProcessor.TrimSource(const SourceCode: string): string;
end;
end;
+class function TSourceProcessor.TrimSourceTrailingSpaces(
+ const SourceCode: string): string;
+var
+ Lines: TStringList;
+ Idx: Integer;
+begin
+ Lines := TStringList.Create;
+ try
+ Lines.Text := SourceCode;
+ Result := '';
+ if Lines.Count = 0 then
+ Exit;
+ Result := TrimRight(Lines[0]);
+ for Idx := 1 to Pred(Lines.Count) do
+ Result := Result + EOL + TrimRight(Lines[Idx]);
+ finally
+ Lines.Free;
+ end;
+end;
+
end.
+
diff --git a/VERSION b/VERSION
index bc1c12a..17434b1 100644
--- a/VERSION
+++ b/VERSION
@@ -1,7 +1,7 @@
# PasHi & PasHiGUI file & product version numbers
-cmdlinefilever=2.2.1
-cmdlinebuild=14
-guifilever=1.2.1
-guibuild=8
-productver=2.2.1
+cmdlinefilever=2.3.0
+cmdlinebuild=15
+guifilever=1.3.0
+guibuild=9
+productver=2.3.0