{{ message }}
Repository navigation
Conversation
AsciiDoc documents had no lexer at all. The new lexer marks the document title and the section titles, the document header (author line, revision line and attribute entries), delimited blocks, list items, labelled list items, admonitions, links, images, comments and the common inline formatting.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What
Fixes #1752 — adds a lexer for AsciiDoc, which Pygments had no support for at all (there is no AsciiDoc entry in the lexer mapping).
The lexer was written against the official AsciiDoc syntax quick reference and covers the parts that show up in ordinary documents:
=,==,===, ...):name: value)----(listing),====(example),****(sidebar),____(quote),....(literal) and++++(passthrough) — together with the block attribute line in front of them ([source,python],[NOTE])*,.,-, nested levels) and checkbox items (* [x])term:: description)NOTE:,TIP:,IMPORTANT:,WARNING:,CAUTION:)link:target[text],https://example.org[text]) and images (image::target[Alt])//and the////block form) and attribute references ({name})*bold*,_italic*,`monospace`and#mark#The token types follow the other markup lexers in Pygments:
Generic.Headingfor the document title,Generic.Subheadingfor section titles,String.Backtickfor monospace,Generic.Strong/Generic.Emph/Generic.EmphStrongfor the inline marks,Name.Attributefor attribute entries,Name.Tagfor link and image targets,Keywordfor admonition labels, list markers and block attributes.The inline marks follow the AsciiDoc rule that they have to sit on a word boundary, so
some_var_nameandtext*not bold*textare left alone.Scope
Tables (
|===), the CSV table block and the more exotic inline macros are deliberately left out of this first version so that it stays reviewable; they can follow once the core is accepted.Tests
tests/examplefiles/asciidoc/sample.adoc(+ generated golden) covers a document header with author, revision and attribute entries, section titles, all the inline marks, links, images, attribute references, labelled list items, nested and checkbox list items, an admonition block, a one-line admonition, a source block, a sidebar, an example, a quote, a literal block and both comment forms.Verified locally:
pytest -q --ignore=tests/contrast— 5335 passed, 16 skippedpytest tests/examplefiles -k asciidoc— 1 passedruff check --ignore UP031 .,scripts/check_crlf.py,scripts/detect_missing_analyse_text.py --skip-no-aliases,scripts/check_sources.py,scripts/count_token_references.py— all cleanErrortokens, also for CRLF files, an empty file, a document without a title, an unterminated block, a table block and a file with only punctuation@pbx — I saw your 2021 comment about starting a fork for this. If that work is still alive, please say so and I will step aside; otherwise, feel free to review this one.
AI usage disclosure: the lexer and its tests were prepared with AI assistance; all test results above were produced locally and reviewed.