You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Many, many updates to the public header files.
- tidyenum.h was reorganized substantially in order to better generate
documentation with Doxygen.
- This was also a good time to clean up all of the various enums for languages
and strings. Everything is simple and in a single enum now, other than a
couple of cases (TidyOptionId, for example, doesn't need to be redefined).
- A full and complete audit of the strings meant some opportunities to delete
useless strings.
- Reorganized the order of the strings in language_en.h in order to better
find things when programmers want to make changes. There are a lot fewer
internal "sections" now, and everything has been painstakingly sorted within
the remaining sections.
- Consequently rebased all of the PO's, POT, and other language files.
- Updated several of the READMEs with the newest information.
- Made the READMEs easier to copy into the Doxygen project by changing some of
the code format for compatibility, mainly the use of tildes instead of
backslashes for code blocks.
- Added tidyGetMessageCode() to message API. Despite the huge diff, this is the
only externally-visible change, other than removing some enums (but not their
values!).
- Passing `next` tests on Mac, Linux, Win10.
Copy file name to clipboardExpand all lines: README/API_AND_NAMESPACE.md
+2-3
Original file line number
Diff line number
Diff line change
@@ -66,7 +66,7 @@ All of the information above is useful for anyone who wants to browse Tidy's sou
66
66
67
67
## Behind the scenes
68
68
69
-
The first thing we need to do is have the internal version of the function that we want to add. Tidy has module that handles localization: `language.h/c`. In the header is where we define the interface to LibTidy, which should be namespaced according to the discussion above. We can declare:
69
+
The first thing we need to do is have the internal version of the function that we want to add. Tidy has a module that handles localization: `language.h/c`. In the header is where we define the interface to LibTidy, which should be namespaced according to the discussion above. We can declare:
@@ -78,7 +78,7 @@ Now you have a decision to make: if you plan to use this function internally, yo
78
78
79
79
## The API
80
80
81
-
Once implemented, we want a pretty, public-facing name for our `tidyLocalizedString()` function, which appropriate is `tidyLocalizedString()`. Add the declaration to `tidy.h`:
81
+
Once implemented, we want a pretty, public-facing name for our `tidyLocalizedString()` function, which appropriately is `tidyLocalizedString()`. Add the declaration to `tidy.h`:
Copy file name to clipboardExpand all lines: README/ATTRIBUTES.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -11,13 +11,13 @@ Tidy’s large number of attributes are supported via number of files:
11
11
12
12
So, to add a new `attribute=value`, on one or more existing tags, consists of the following simple steps -
13
13
14
-
1.`tidyenum.h` - Give the attribute an internal name, like `TidyAttr_XXXX`, and thus a value. While there were some initial steps to keep this `TidyAttrId`enumeration alphabetic, now just add the new `TidyAttr_XXXX` just before the last entry `N_TIDY_ATTRIBS`.
14
+
1.`tidyenum.h` - Give the attribute an internal name, like `TidyAttr_XXXX`, and thus a value. Please try to keep this enumeration in alphabetical order.
15
15
16
16
2.`attrs.c` - Assign the string value of the attribute. Of course this must be unique. And then assign a `function` to verify the attribute value. There are already a considerable number of defined functions to verify specific attribute values, but maybe this new attribute requires a new function, so that should be written, and defined.
17
17
18
18
3.`attrdict.c` - If this attribute only relates to specific tags, then it should be added to their list. There are some general attributes that are allowed on every, or most tags, so this new attribute and value should be added accordingly.
19
19
20
-
4.`tags.c` - Now the new attribute will be verified for each tag it is associate with in the `tag_defs[]` table. Like for example the `<button ...>`, `{ TidyTag_BUTTON, ...` has `&TY_(W3CAttrsFor_BUTTON)[0]` assigned.
20
+
4.`tags.c` - Now the new attribute will be verified for each tag it is associated with in the `tag_defs[]` table. Like for example the `<button ...>`, `{ TidyTag_BUTTON, ...` has `&TY_(W3CAttrsFor_BUTTON)[0]` assigned.
21
21
22
22
So, normally, just changing 3 files, `tidyenum.h`, `attrs.c`, and `attrdict.c`, will already adjust `tags.c` to accept a new `attribute=value` for any tag, or all tags. Simple...
Copy file name to clipboardExpand all lines: README/MESSAGES.md
+11-6
Original file line number
Diff line number
Diff line change
@@ -4,18 +4,23 @@ Tidy has quite complex warning/error messaging system. This is all about adding
4
4
5
5
First assign the message a key value. This is done in `tidyenum.h`, in one of the two enumerations that are listed there.
6
6
7
-
1.`tidyMessageCodes` - starts with the value `tidyMessageCodes_first = 500`, and it must be first. These are messages that appear in Tidy's report list, the list that's emitted telling you what Tidy did to your code. **However** don't modify this enum directly. You'll modify a preprocessor macro instead.
7
+
1.`tidyStrings` - starts with the value `TIDYSTRINGS_FIRST = 500`, and it must be first. This is the list of all strings available in Tidy with the exception of strings provided by other enumerations. **However** don't modify this enum directly. You'll modify a preprocessor macro instead.
8
8
9
-
2.`tidyMessagesMisc` - starts with the value `tidyMessagesMisc_first = tidyMessageCodes_last`. These are messages that are emitted that tell you general information, such as further advice.
9
+
2.`TidyOptionId` - You probably won't need this unless you're adding new options, and there's another readme for that.
10
+
11
+
3.`TidyConfigCategory` - You probably won't need this, either, unless you're adding a whole new category for options.
12
+
13
+
4.`TidyReportLevel` - And you probably won't need this, either.
14
+
10
15
11
-
All enum values are only ever used by name within **libTidy** (and incidentally, should only ever be used by name in your client applications; never trust the value!), so feel free to enter new strings wherever they make the most sense. There are already existing categories (marked by comments), or feel free to create a new category if that's best.
16
+
All enum values are only ever used by name within **libTidy** (and incidentally, should only ever be used by name in your client applications; never trust the value!), so feel free to enter new strings wherever they make the most sense.
12
17
13
-
As mentioned above, `tidyMessageCodes` messaged must be defined in one of the existing macros named like `FOREACH_...(FN)`, such as `FOREACH_MSG_ENTITIES(FN)`. These macros ensure that another data structure used for localization and key lookup is updated automatically any time strings are added or removed, thus limiting the possibility of developer error.
18
+
As mentioned above, `tidyStrings` messages must be defined in one of the existing macros named like `FOREACH_...(FN)`, such as `FOREACH_DIALOG_MSG(FN)`. These macros ensure that another data structure used for localization and key lookup is updated automatically any time strings are added or removed, thus limiting the possibility of developer error.
14
19
15
20
16
21
## Step 1
17
22
18
-
So in this case I want to add 3 warning messages: `BAD_SURROGATE_PAIR`, `BAD_SURROGATE_TAIL`, and `BAD_SURROGATE_LEAD`. Because these are error messages, they belong in the `tidyErrorCodes` enum, and they fit into nicely into the macro beginning `FOREACH_MSG_ENCODING(FN)`.
23
+
So in this case I want to add 3 warning messages: `BAD_SURROGATE_PAIR`, `BAD_SURROGATE_TAIL`, and `BAD_SURROGATE_LEAD`. Because these are error messages, they belong in the `tidyStrings` enum, and they fit into nicely into the macro beginning `FOREACH_DIALOG_MSG(FN)`. Please look at the comments for the category which indicates which output routine is used to generate the error, and keep this list in order!
19
24
20
25
21
26
## Step 2
@@ -24,7 +29,7 @@ The next step is adding a `format` string to `language_en.h`. This string may la
24
29
25
30
Where to add this seems a bit of a mess, but in general things are grouped by where they're used in `libTidy`, and often in alphabetical order within those groups. Here I've added them relative to where they were placed in the other enums and structs.
26
31
27
-
Depending on which of the output routines you use (consult `message.c`) you may be able to use parameters such as `%u` and `%s` in your format strings. The available data is currently limited to the available message output routines, but perhaps generalizing this in order to make more data available will be a nice focus of Tidy 5.5. Please don't use `printf` for message output within **libTidy**.
32
+
Depending on which of the output routines you use (consult `message.c`) you may be able to use parameters such as `%u` and `%s` in your format strings. The available data is currently limited to the available message output routines. Please don't use `printf` for message output within **libTidy**.
Copy file name to clipboardExpand all lines: README/OPTIONS.md
+33-32
Original file line number
Diff line number
Diff line change
@@ -4,32 +4,32 @@ Tidy supports a quite large number of configuration options. The full list can b
4
4
5
5
The options can also be listed in xml format. `-xml-help` will output each option plus a description. `-xml-config` will not only output the option and a desciption, but will include the type, default and examples. These xml outputs are used, with the aid of `xsltproc` and `doxygen`, to generate the [API Documentation](http://api.html-tidy.org/).
6
6
7
-
These options can also be used by application linking with **`libtidy`**. For each option there is a `TidyOptionId` enumeration in the `tidyenum.h` file, and get/set functions for each option type.
7
+
These options can also be used by application linking with `libtidy`. For each option there is a `TidyOptionId` enumeration in the `tidyenum.h` file, and get/set functions for each option type.
8
8
9
9
This file indicates how to add a new option to tidy, here adding an option `TidyEscapeScripts`. In essence it consists of 4 steps:
10
10
11
-
1. Add the option **`ID`** to `tidyenum.h`.
12
-
2. Add to the **`table`**`TidyOptionImpl option_defs[]` in `config.c`
13
-
3. Add the id, with a **`description`** to `language_en.h`
11
+
1. Add the option `ID` to `tidyenum.h`.
12
+
2. Add to the `table``TidyOptionImpl option_defs[]` in `config.c`
13
+
3. Add the id, with a `description` to `language_en.h`
14
14
4. Use the option in the code.
15
15
16
16
#### 1. Option ID
17
17
18
-
In `tidyenum.h` the `TidyOptionId` can be in any order, but normally a new option would be added just before the last`N_TIDY_OPTIONS`, which must remain the last. Choosing the id name can be any string, but by convention it will commence with `Tidy` followed by brief descriptive text.
18
+
In `tidyenum.h` the `TidyOptionId` can be in any order, but please try to keep things alphabetical, and keep in mind that`N_TIDY_OPTIONS` must remain the last. Choosing the id name can be any string, but by convention it will commence with `Tidy` followed by brief descriptive text.
19
19
20
20
Naturally it can not be the same as any exisitng option. That is, it must be unique. And it will be followed by a brief descriptive special doxygen formatted comment. So for this new option I have chosen -
21
21
22
-
```
22
+
~~~
23
23
TidyEscapeScripts, /**< Escape items that look like closing tags */
24
-
```
24
+
~~~
25
25
26
26
#### 2. Table Definition
27
27
28
28
In `config.c`, added in `TidyOptionImpl option_defs[]`. Again it can be in any order, but normally a new option would be added just before the last `N_TIDY_OPTIONS`, which must remain the last.
29
29
30
30
The structure definition of the table entries is simple -
31
31
32
-
```
32
+
~~~
33
33
struct _tidy_option
34
34
{
35
35
TidyOptionId id;
@@ -41,93 +41,94 @@ struct _tidy_option
41
41
const ctmbstr* pickList; /* pick list */
42
42
ctmbstr pdflt; /* default for TidyString */
43
43
};
44
-
```
44
+
~~~
45
45
46
-
Naturally it will commence with the above chosen unique **`id`**.
46
+
Naturally it will commence with the above chosen unique `id`.
47
47
48
-
The **`category`** will be one of this enumeration -
TidyMiscellaneous /**< File handling, message format, etc. */
57
+
TidyMiscellaneous, /**< File handling, message format, etc. */
58
+
TidyInternalCategory /**< Option is internal only. */
58
59
} TidyConfigCategory;
59
-
```
60
+
~~~
60
61
61
62
Care, each of these enumeration strings have been equated to 2 uppercase letters. If you feel there should be another `category` or group then this can be discussed, and added.
62
63
63
-
The **`name`** can be anything, but should try to be somewhat descriptive of the option. Again this string must be unique. It should be lowercase alphanumeric characters, and can contain a `-` separator. Remember this is the name places on the command line, or in a configuration file to set the option.
64
+
The `name` can be anything, but should try to be somewhat descriptive of the option. Again this string must be unique. It should be lowercase alphanumeric characters, and can contain a `-` separator. Remember this is the name places on the command line, or in a configuration file to set the option.
64
65
65
-
The **`type`** is one of the following enumeration items -
66
+
The `type` is one of the following enumeration items -
66
67
67
-
```
68
+
~~~
68
69
typedef enum
69
70
{
70
71
TidyString, /**< String */
71
72
TidyInteger, /**< Integer or enumeration */
72
73
TidyBoolean /**< Boolean flag */
73
74
} TidyOptionType;
74
-
```
75
+
~~~
75
76
76
77
Care, each of these enumeration strings have been equated to two uppercase letters. If you feel there should be another `type` then this can be discussed, but would require other additional things. And also note the `TidyTriState` is the same as a `TidyInteger` except uses its own parser.
77
78
78
-
The next item is the **`default`** value for a boolean, tristate or integer. Note tidy set `no=0` and `yes=1` as its own `Bool` enumeration.
79
+
The next item is the `default` value for a boolean, tristate or integer. Note tidy set `no=0` and `yes=1` as its own `Bool` enumeration.
79
80
80
-
There are a number of **`parser`** for the options. Likewise a number of **`pickList`**. Find another option similar to your new option and use the same values.
81
+
There are a number of `parser` for the options. Likewise a number of `pickList`. Find another option similar to your new option and use the same values.
81
82
82
-
Presently no options have the final **`default`** string, and it is left out of the table. The compiler will add a NULL.
83
+
Presently no options have the final `default` string, and it is left out of the table. The compiler will add a NULL.
83
84
84
85
The final table entry added. Note in here the spacing has been compressed, but in the actual code the current column settings should be maintained if possible -
In `language_en.h`, in the section labelled **Options Documentation**. It can be anywhere, but usually a new option would be added just before the next section labelled **Console Application**.
93
+
In `language_en.h`, in the section labelled **Options Documentation**. Please try to keep this in alphabetical order.
93
94
94
95
Each entry is a structure with 3 members -
95
-
```
96
+
~~~
96
97
typedef struct languageDictionaryEntry {
97
98
uint key;
98
99
uint pluralForm;
99
100
ctmbstr value;
100
101
} languageDictionaryEntry;
101
-
```
102
+
~~~
102
103
103
-
The **`key`** is the option **`ID`**; The **`pluralForm`** is not used for options, and should be `0`; The **`value`** is the description string.
104
+
The `key` is the option `ID`; The `pluralForm` is not used for options, and should be `0`; The `value` is the description string.
104
105
105
106
Some care has to be taken with the description string. The only html allowed here is `<code>...</code>`, `<var>...</var>`, `<em>...</em>`, `<strong>...</strong>`, and `<br/>`. Entities, tags, attributes, etc., should be enclosed in `<code>...</code>`. Option values should be enclosed in `<var>...</var>`. It's very important that `<br/>` be self-closing! This string is processed to build the API documentation.
106
107
107
108
This is the desription added for this new option.
108
109
109
-
```
110
+
~~~
110
111
{
111
112
TidyEscapeScripts, 0,
112
113
"This option causes items that look like closing tags, like <code></g</code> to be "
113
114
"escaped to <code><\\/g</code>. Set this option to 'no' if you do not want this."
114
115
},
115
-
```
116
+
~~~
116
117
117
118
#### 4. Use in Code
118
119
119
120
This can be added anywhere in the code to change the current code action. While the testing of the option depends on the option type, the most common is `cfgBool( doc, id )`. Here is an example of where this new option is used -
120
121
121
-
```
122
+
~~~
122
123
/*\ if javascript insert backslash before /
123
124
* Issue #348 - Add option, escape-scripts, to skip
124
125
\*/
125
126
if ((TY_(IsJavaScript)(container)) && cfgBool(doc, TidyEscapeScripts))
126
127
{
127
-
```
128
+
~~~
128
129
129
130
#### Summary
130
131
131
-
That's about it. Just 4 places. Obviously the best idea it to search for an existing option **`ID`**, and follow where it is all defined and used, and copy that. It is not difficult.
132
+
That's about it. Just 4 places. Obviously the best idea it to search for an existing option `ID`, and follow where it is all defined and used, and copy that. It is not difficult.
Copy file name to clipboardExpand all lines: README/TAGS.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ Note, there are a group of configuration options to add **tags** not yet approve
8
8
9
9
So, adding a new HTML **tag** consists of the following simple steps:
10
10
11
-
1.`tidyenum.h` - Give the element an internal name, like `TidyTag_XXXX`, and thus a value. While there were some initial steps to keep this `TidyTagId` enumeration alphabetic, now just add the new `TidyTag_XXXX` just before the last entry `N_TIDY_TAGS`.
11
+
1.`tidyenum.h` - Give the element an internal name, like `TidyTag_XXXX`, and thus a value. Please keep this list in alphabetical order.
12
12
13
13
2.`tags.c` - Add a line to the `tag_defs[]` table. This assigns the unique string value of the element. Then the html versions that support the element, a pointer to the attributes supported by that elelment, and a bit field of the elements characteristics, inline, block, etc.
Copy file name to clipboardExpand all lines: README/VERSION.md
+10-10
Original file line number
Diff line number
Diff line change
@@ -58,41 +58,41 @@ The **libTidy** version is controlled by the contents of `version.txt` in the ro
58
58
59
59
This file consists of two lines of dot (.) separated items. The first being the **major**, **minor**, and **patch** version values, and the second string is a date. Example:
60
60
61
-
```
61
+
~~~
62
62
5.3.15
63
63
2017.01.29
64
-
```
64
+
~~~
65
65
66
66
When **CMake** is run, this file is read and two macros are added to the compile flags:
0 commit comments