swiftlang / swift-book

The Swift Programming Language book
Apache License 2.0
1.76k stars 162 forks source link

Specify code listings are Swift #333

Open amartini51 opened 2 months ago

amartini51 commented 2 months ago

Because the Info.plist file specifies Swift as the default language via the CDDefaultCodeListingLanguage key, code listings with an unspecified language should still render correctly. However, it's still good to be explicit and makes the markdown files more usable by other toolchains.

Used the following script to find code listings that were missing an explicit language, and to verify that none remain after this change:

echo "Not specified as Swift"
cmark --to xml TSPL.docc/*/*.md |
xpath -q -n -e '//code_block[not(@info="swift")]'

echo "Languages used"
cmark --to xml TSPL.docc/*/*.md |
xpath -q -n -e '//code_block/@info' |
sort -u
amartini51 commented 2 months ago

Thank you to @liyanage for pointing one of these out, which prompted me to check the rest.