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
On the standards website we use the USWDS usa-link--external class to render an icon to denote that the link in question leaves the .gov top level domain. This class is applied through a small amount of client-side JavaScript once the DOM content is loaded. This approach was originally used for developer speed but a better approach is to move this code into the markdown rendering process so that there's no client-side JS involved which will save a bit a few bytes on the wire.
The markdown parser in use is called markdown-it which implements the CommonMark spec and there are a few times during the rendering process that we need to supply code to make sure that we get all links checked and the class applied. These scenarios/areas are:
The link_open rendering step which happens when the renderer encounters the beginning an anchor element in the token stream. This code alone gets most links but there's a couple of cases it doesn't handle. [18F site example code]
The next scenario happens when the renderer encounters an HTML block inside of a markdown document. The renderer rule for this is named html_block. [18F site example code]
The final scenario happens when the renderer encounters some inline HTML which is a rule named html_inline.[18F site example code]
The text was updated successfully, but these errors were encountered:
On the standards website we use the USWDS
usa-link--external
class to render an icon to denote that the link in question leaves the .gov top level domain. This class is applied through a small amount of client-side JavaScript once the DOM content is loaded. This approach was originally used for developer speed but a better approach is to move this code into the markdown rendering process so that there's no client-side JS involved which will save a bit a few bytes on the wire.The markdown parser in use is called markdown-it which implements the CommonMark spec and there are a few times during the rendering process that we need to supply code to make sure that we get all links checked and the class applied. These scenarios/areas are:
link_open
rendering step which happens when the renderer encounters the beginning an anchor element in the token stream. This code alone gets most links but there's a couple of cases it doesn't handle. [18F site example code]html_block
. [18F site example code]html_inline
.[18F site example code]The text was updated successfully, but these errors were encountered: