Unit test: highlight.001
This is a test for syntax highlighting.
Program listings are highlighted and numbered by default:
1 |#!/usr/bin/env python3
|
|"""This is yet another link checker. Was it better to write my own
|than find an existing cross-platform version? Maybe not, but it
5 |appeared to be easier."""
|
|import re
|import os
|import sys
10 |import json
|import glob
|import click
|try:
| import html5_parser
15 | import lxml.etree
| from saxonche import PySaxonProcessor
| importOk = True
|except ImportError:
| importOk = False
But numbering can be turned off:
#!/usr/bin/env python3
"""This is yet another link checker. Was it better to write my own
than find an existing cross-platform version? Maybe not, but it
appeared to be easier."""
import re
import os
import sys
import json
import glob
import click
try:
import html5_parser
import lxml.etree
from saxonche import PySaxonProcessor
importOk = True
except ImportError:
importOk = False
And so can highlighting. The most reliable way to disable highlighting
is to remove the language
attribute from the listing.
1 |#!/usr/bin/env python3
||
"""This is yet another link checker. Was it better to write my own
|than find an existing cross-platform version? Maybe not, but it
5 |appeared to be easier."""
||
import re
|import os
|import sys
10 |import json
|import glob
|import click
|try:
|import html5_parser
15 |import lxml.etree
|from saxonche import PySaxonProcessor
|importOk = True
|except ImportError:
|importOk = False
Screens are not highlighted or numbered by default:
❯ head -20 src/bin/linkcheck.py
#!/usr/bin/env python3
"""This is yet another link checker. Was it better to write my own
than find an existing cross-platform version? Maybe not, but it
appeared to be easier."""
import re
import os
import sys
import json
import glob
import click
try:
import html5_parser
import lxml.etree
from saxonche import PySaxonProcessor
importOk = True
except ImportError:
importOk = False
But can be turned on:
1 |❯ head -20 src/bin/linkcheck.py
|#!/usr/bin/env python3
|
|"""This is yet another link checker. Was it better to write my own
5 |than find an existing cross-platform version? Maybe not, but it
|appeared to be easier."""
|
|import re
|import os
10 |import sys
|import json
|import glob
|import click
|try:
15 | import html5_parser
| import lxml.etree
| from saxonche import PySaxonProcessor
| importOk = True
|except ImportError:
20 | importOk = False
Line numbering can begin at an arbitrary number:
601 |if __name__ == "__main__":
| # I'm perfectly happy with the name 'docbook'
| # pylint: disable=C0103
|
605 | try:
| docbook = JavaClassRunner(sys.argv[1:])
| docbook.compute_dependencies()
| sys.exit(docbook.run())
| except JavaClassRunnerException as err:
610 | print(str(err))
| sys.exit(1)