Skip to content

Conversation

@jstirnaman
Copy link
Contributor

Summary

Add support for extracting Hugo style attributes from HTML comments in plugin READMEs during the sync process.

Problem

Hugo style attributes like {.green} and {.orange} render as literal text on GitHub, making source READMEs look messy.

Solution

Use HTML comments to hide style attributes in source:

#### Recommended <!-- {.green} -->
#### Not recommended <!-- {.orange} -->

The sync script extracts these and applies them:

#### Recommended {.green}
#### Not recommended {.orange}

Supported Classes

  • {.green}, {.orange} - Color styling
  • {.recommended}, {.not-recommended} - Semantic styling
  • Any other {.classname} format

Test Plan

  • Verify regex extracts style attributes correctly
  • Test sync with downsampler plugin containing HTML comment styles

Add extractStyleAttributes() function to convert headings like:
  `#### Heading <!-- {.class} -->`
to:
  `#### Heading {.class}`

This allows source READMEs to render cleanly on GitHub while still
supporting Hugo style classes in docs-v2.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds functionality to extract Hugo style attributes from HTML comments in plugin READMEs during the sync process, allowing source files to render cleanly on GitHub while supporting Hugo styling in the documentation site.

Key changes:

  • Adds extractStyleAttributes() function that converts #### Heading <!-- {.class} --> to #### Heading {.class}
  • Integrates the transformation into the content processing pipeline between paragraph enhancement and code block formatting

@jstirnaman jstirnaman requested a review from sanderson January 5, 2026 17:03
@sanderson
Copy link
Collaborator

sanderson commented Jan 5, 2026

To clarify, these aren't just style attributes, these are custom html attributes as well (Goldmark Readme). For example:

## Heading 2 {.css-class #element-id attr="some value"}

I think it even now supports custom attributes on any block element, including paragraphs:

This is a markdown paragraph with custom attributes.
{#paragraph-id .custom-class attr="some value"}

But I may be wrong about block element support. I vaguely remember testing.

Does the regex account for this? Is the intent here to replace all of these attributes in the docs with HTML comments or just those in Telegraf READMEs?

@jstirnaman
Copy link
Contributor Author

To clarify, these aren't just style attributes, these are custom html attributes as well (Goldmark Readme). For example:

## Heading 2 {.css-class #element-id attr="some value"}

I think it even now supports custom attributes on any block element, including paragraphs:

This is a markdown paragraph with custom attributes.
{#paragraph-id .custom-class attr="some value"}

But I may be wrong about block element support. I vaguely remember testing.

Does the regex account for this? Is the intent here to replace all of these attributes in the docs with HTML comments or just those in Telegraf READMEs?

This script is currently only for the InfluxDB3 plugin READMEs, though I hope to extend it for client libs and other upstream docs soon. It won't be used for Telegraf--they have a separate workflow that they own.
Alternatively, we could match incoming headings and force styling onto them, but I chose the declarative path.
I kept the regex greedy to extract classes or attributes from comments. Last minute, I briefly considered using a data attribute instead, but class seemed just as appropriate for this.

@jstirnaman jstirnaman merged commit 36f9222 into master Jan 6, 2026
1 check passed
@jstirnaman jstirnaman deleted the jts-chore-extract-comment-style-attrs branch January 6, 2026 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants