Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support acronyms within example and address blocks #350

Merged
merged 4 commits into from
Oct 4, 2024
Merged

Conversation

brucebolt
Copy link
Member

@brucebolt brucebolt commented Oct 3, 2024

Fixes an issue where acronyms are not correctly marked up when within example or address blocks.

Trello card

lib/govspeak.rb Dismissed Show resolved Hide resolved
@brucebolt brucebolt marked this pull request as ready for review October 3, 2024 15:56
Copy link
Member

@yndajas yndajas left a comment

Choose a reason for hiding this comment

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

Like George, I'm not super familiar with the syntax here, but the tests and their similarity to other acronym tests give me sufficient confidence this does the job


The labels/first lines of each of the comments here are following the Conventional Comments format, which I'm trying out after watching a useful DevOpsDays London talk

extension("example", surrounded_by("$E")) do |body|
<<~BODY
<div class="example" markdown="1">
#{body.strip.gsub(/\A^\|/, "\n|").gsub(/\|$\Z/, "|\n")}
Copy link
Member

Choose a reason for hiding this comment

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

suggestion (if-minor): documentation

Is this some kind of default? I can see that it's the same as what's done with CTAs, but it's different to how the address blocks code looks. Is there code or other documentation that could be linked to in this and maybe the next commit message to explain why:

  1. moving from wrap_with_div ... Govspeak::Document to this RegEx is suitable here?
  2. markdown="1" seems to be the key change for the abbreviation substitution to kick in (based on the next commit)

Copy link
Member Author

@brucebolt brucebolt Oct 4, 2024

Choose a reason for hiding this comment

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

I'd just copied this from CTAs, but it turns out .gsub(/\A^\|/, "\n|").gsub(/\|$\Z/, "|\n") allows support for tables within the block.

I think that's useful and can't see anything in the documentation to suggest that shouldn't be allowed, so I've added it as a separate commit with an explanation.

I'll also add some detail to the commits about the markdown="1" being the key to getting these to include acronyms.

@@ -1247,6 +1247,20 @@ class GovspeakTest < Minitest::Test
)
end

test_given_govspeak "
Copy link
Member

Choose a reason for hiding this comment

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

thought: documentation

Would be nice if this method took some kind of human-readable description argument, but now's probably not the time to go adding that to this massive spec!

Copy link
Member Author

Choose a reason for hiding this comment

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

It would be nice to break this huge file down into some smaller ones, or even just wrap some context blocks around things. I'll add a card to the backlog so it's not forgotten, as I don't think it'll be a trivial task to understand what exactly is being tested in each example.

These were not previously supported, so updating them to work in the
same way as call to action blocks.

Adding `markdown="1"` to the surrounding block tells Kramdown that the
content needs further markdown parsing, otherwise it just ignores any
markdown within HTML.
This matches their behaviour with call to action, which is a similar
block.
These were not previously supported, so updating them to work in the
same way as call to action blocks.

Adding `markdown="1"` to the surrounding block tells Kramdown that the
content needs further markdown parsing, otherwise it just ignores any
markdown within HTML.
@brucebolt brucebolt merged commit 64b73f5 into main Oct 4, 2024
9 checks passed
@brucebolt brucebolt deleted the abbr-callout branch October 4, 2024 10:00
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.

2 participants