Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions internal/forge/jira/adf.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,10 @@ func adfBlockContent(parent ast.Node, source []byte, depth int, restricted bool)
for c := parent.FirstChild(); c != nil; {
// In non-restricted context, attempt to convert <details>
// HTML blocks into ADF expand nodes. tryDetailsExpand
// handles both single-block (no blank lines inside the
// markup) and multi-block (blank lines split the <details>
// opening, body, and closing across several AST siblings)
// forms, since comments posted by pre-#9334 CLIs — which
// folded prior results into <details> blocks — produce the
// latter while hand-written Markdown typically produces the
// former.
// handles both single-block and multi-block <details>
// markup — the multi-block form is blank lines inside
// the markup splitting it across AST siblings (see its
// doc for the full layout description).
if !restricted {
if expand, next := tryDetailsExpand(c, source, depth); expand != nil {
content = append(content, expand)
Expand All @@ -146,12 +143,15 @@ var summaryInnerTagPattern = regexp.MustCompile(`<[^>]*>`)

// stickyHistorySentinelPattern matches sticky history sentinel comments
// on their own line, for stripping from <details> body content before
// re-parsing as Markdown. Pre-#9334 CLIs wrapped the history they folded
// into <details> blocks with these sentinels; comments those CLIs posted
// still sit unedited on old pull requests, and the sentinels must not
// become visible text inside the rendered ADF expansion. Kept as a
// read-side shim until such comments have aged out of the threads Jira
// quotes (#9517 removed the machinery that wrote them).
// re-parsing as Markdown. The sentinels are metadata, not content: the
Comment thread
tpouyer marked this conversation as resolved.
Resolved
// sticky history folding wrote them when it collapsed an older comment
// body into a new one, and #9517 removed that machinery. GitHub and
// GitLab comments keep that Markdown verbatim, and a Jira comment
// written before <details> blocks were mapped to expand nodes can hold
// a sentinel as literal text, so a body quoted from an older comment
// can still carry them. They must not become visible text inside the
// rendered ADF expansion, so the stripping stays as a read-side shim
// even now that nothing writes the sentinels any more.
var stickyHistorySentinelPattern = regexp.MustCompile(`(?m)^\s*<!--\s*sticky:history-(?:start|end)\s*-->\s*$`)

// tryDetailsExpand checks whether c is an HTML block opening a
Expand All @@ -164,11 +164,11 @@ var stickyHistorySentinelPattern = regexp.MustCompile(`(?m)^\s*<!--\s*sticky:his
// - Single-block: the entire <details>…</details> is one goldmark
// HTMLBlock (no blank lines inside), common in hand-written Markdown.
//
// - Multi-block: blank lines inside the markup (as produced by the
// pre-#9334 CLIs that folded prior results into <details> blocks)
// cause goldmark to split the opening tag, body, and closing tag
// across separate AST siblings. The function collects siblings
// until it finds the </details> closing block.
// - Multi-block: blank lines inside the markup cause goldmark to
// split the opening tag, body, and closing tag across separate AST
// siblings; any body whose markup contains blank lines takes this
// form, however it was written or copied. The function collects
// siblings until it finds the </details> closing block.
//
// Returns (expand, nextSibling) on success, or (nil, nil) if c is
// not a <details> opener — in which case adfBlockContent processes c
Expand Down
Loading