Repository navigation
Conversation
|
✅ DCO Check Passed Thanks @r0h1tb, all your commits are properly signed off. 🎉 |
Merge Protections🟢 Merge protection satisfied — ready to merge. Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
|
@r0h1tb Can you fix the merge conflict? All the rest looks good to merge |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
e648805 to
2ae54ce
Compare
|
@dolfim-ibm partly, yes. #4400 landed the listing-block half first, so I rebased onto main and dropped mine. What's left is the comment handling ( |
ceberam
left a comment
There was a problem hiding this comment.
Thanks @r0h1tb for the contribution!
I agree that leaking // TODO ask legal and similar comment noise into converted output is a real bug, and the current behavior of silently dropping comment lines and blocks is the right default for most users.
However, silently dropping the content is an irreversible loss. AsciiDoc comments may also be used for editorial annotations, review notes, conditional-content explanations, and disabled-but-meaningful blocks, exactly the kind of content that is valuable for downstream AI workflows such as RAG pipelines and document summarization. Even for the use case that you described (the TODO ask legal notes), the comments may be useful for agents that would run tools to pull external (legal) information.
The Word, Excel, and PowerPoint backends all solve this with ContentLayer.NOTES. Comments are emitted into that layer, which is excluded from Markdown and HTML export by default. A user who wants the comment content can pass the NOTES layer to the serializer explicitly.
This is a zero-regression approach: the default output is identical to what this PR produces, but the content is not destroyed.
Suggested follow-up implementation
Add a small sentinel dataclass alongside the existing _LiteralBlock:
@dataclass(frozen=True)
class _CommentBlock:
text: str # raw comment text, delimiters strippedYield it from _iter_blocks instead of advancing past the comment lines silently. Then handle it in _parse:
elif isinstance(block, _CommentBlock):
doc.add_text(
text=block.text,
label=DocItemLabel.PARAGRAPH,
content_layer=ContentLayer.NOTES,
)My suggestion is:
- Merge this PR as-is
- Open a follow-up issue to re-capture AsciiDoc comments into
ContentLayer.NOTES, mirroring the Office backend pattern. - Optionally, add a
capture_comments: bool = Trueflag toAsciiDocBackendOptionsin that follow-up, so users can opt out of capturing comments entirely if they prefer.
|
Makes sense, the NOTES layer is a better home for them than dropping them. Opened #4593 for it, and I'm happy to pick it up once this one is in. The red |
Thanks @r0h1tb for taking this step forward, but let's check first if the other reviewers agree with the approach. FYI @PeterStaar-IBM @dolfim-ibm |
|
@r0h1tb this needs another rebase: #4431 landed comment skipping on main (
Could you rebase onto main, keep only those deltas on top of the existing On #4593: agreed with @ceberam, NOTES layer is the right home. |
…closed blocks Main already skips // lines and //// blocks. On top of that: - /// is not a line comment and stays as text. - Comment delimiters longer than four slashes open a block that only an identical line closes. - A comment delimiter with no matching closer breaks the paragraph instead of hiding the rest of the document, like a stray "--". Signed-off-by: Rohit Behera <126186063+r0h1tb@users.noreply.github.com>
2ae54ce to
bf9214b
Compare
|
Rebased onto main and narrowed to the three deltas on top of the existing comment logic: |
AI triage (advisory)Checked commit The PR changes the AsciiDoc backend so that Topic labels added: CI safety: no concern found. A maintainer must still approve CI. 3 related pull request(s) in the same code
The |
Problem
Main skips
//lines and////blocks (#4431), but:///is treated as a line comment and dropped, although AsciiDoc only treats exactly two slashes as one./////, ...) aren't recognised, so the block's content leaks into the output.////hides the rest of the document.Fix
On top of the existing
_LINE_COMMENT_RE/ comment-delimiter logic:_LINE_COMMENT_REmatches exactly two slashes.--handling from fix(asciidoc): turn listing blocks into code items #4400.Comments nested inside
====/****/____/--blocks are left for #4593.Tests
New cases for
///text, longer delimiters needing an identical closer, unclosed delimiters of each length, many unmatched delimiters without rescanning, and comment markers inside----/....staying code. 7 of them fail on main; the two literal-block controls pass both ways.tests/test_backend_asciidoc.py: 51 passed. Ruff format/check clean,tyreports the same 3 existing warnings as main, and the max-lines hook passes at its 1500 limit.Checklist: