A risk that the use of systems for structured authoring involves is that the targets for internal links are not included in all publications which include those links. You can avoid this if you condition these links with the same identifiers as their targets and if you make sure that their targets are always included in the same topic trees. This makes sure that they are always included in the same publications. Such details are easy to forget, though. When that happens, you must notice the empty links when you review those publications.
DoX CMS automatically adds the values for the targets of internal links inside them when it can find those targets. For example, when the same image is ‘image 1’ in one publication but ‘image 5’ in a different publication, the system includes the correct value inside these links in those publications. This only requires that you leave the text boxes for those links empty in the text editor.
If a publication does not include an element for the link to target, however, the link will simply be left empty. Such empty links are hard to notice when you review publications.
The solution to this is so obvious that I am ashamed for not having considered it before now. The implementation is similar to those that I proposed as part of a separate style for previews. However, all users of DoX CMS can add or adapt this solution as part of their default styles to make it easier to review publications.
Solution
Simply put, the solution is to add content to empty link elements with the help of your style sheets. There are only three situations in which link elements remain empty:
- the publication lacks an internal link’s target,
- no anchor text was written in an external link’s text box, or
- you have left the field for element title format empty.
The first two can be accommodated with warnings for them if you add this to your style sheets:
a:empty::after {content: "Warning: link target not found";}
a[href^="https://"]:empty::after {content: "Warning: add anchor text to link";}
a:empty::after {
color: red;
display: inline;
text-decoration: inherit;
text-transform: uppercase;
}
This adds the values for the content rule inside empty links in a very visible way. The provided specifications make these added parts red with uppercase letters. I wrote them in English but you can replace those phrases with warnings best suited for you. However, I recommend against translating them to match publications’ languages because they are designed to stand out when you review those publications.
The first part adds a warning about a missing link target to all empty links. The second part replaces this default warning, when the link value starts with ‘https://’. This leaves the first alternative to only be used by internal links which do not find their targets.
If you include external links that start with an identifier other than ‘https://’, you can also apply the same rule to them. To do so, you must separate copies of the original selector with commas and change the copies to use the alternative identifiers with which external links can start. Make sure to always include such identifiers at the starts of external links’ values, especially if you make these additions to your style sheets.
a[href^="https://"]:empty::after,
a[href^="www."]:empty::after
{content: "Warning: add anchor text to link";}
This solution does not designate links to which you wrote anchor texts in the text editor but which cannot find their targets.
The third situation would involve the same formulation as my proposed solution to the first situation but you should change the used phrase to reflect this difference. If you leave the element title format field empty, you thus cannot use this solution to find links which cannot find their targets inside a publication. I recommend almost without exception that you include a title format for elements, and this is not the only related reason.
Remember that you can use the option to find in content when you review publications, and use these phrases as your search terms. This lets you find the positions of all such warnings easily and quickly.