Skip to content

Add Node#fence for code block metadata - #20

Merged
ioquatix merged 1 commit into
socketry:mainfrom
kristoph:add-node-fenced
Aug 20, 2026
Merged

Add Node#fence for code block metadata#20
ioquatix merged 1 commit into
socketry:mainfrom
kristoph:add-node-fenced

Conversation

@kristoph

@kristoph kristoph commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

Adds Markly::Node#fence to expose the parsed marker metadata for fenced code blocks.

The method returns a Markly::Node::Fence structure containing:

  • character — the backtick or tilde marker.
  • length — the number of marker characters.
  • indent — the indentation before the opening fence.

It returns nil for indented code blocks and non-code nodes. The code info string remains available separately through Node#code_info.

block = Markly.parse("  ~~~~ ruby\n  Object.new\n  ~~~~").first_child

block.fence
# => #<struct Markly::Node::Fence character="~", length=4, indent=2>

The structure is defined and instantiated directly by the native extension. This change also adds coverage for backtick and tilde fences, non-default fence lengths and indentation, indented code blocks, and non-code nodes.

@ioquatix

ioquatix commented Apr 9, 2026

Copy link
Copy Markdown
Member

I'm not sure about the name fenced. I also wonder if we should use a Hash for this. Is there any precedent in other parts of the code? Maybe it's better to use a Data or Struct? 🤷

However, in principle, I am okay with this change.

@ioquatix

Copy link
Copy Markdown
Member

After thinking about this, what about adding fence_character or fence_marker etc.

@samuel-williams-shopify samuel-williams-shopify changed the title Add Node#fenced method for code block fence metadata Add Node#fence for code block metadata Aug 20, 2026
Expose the parsed fence character, length, and indentation as a Node::Fence structure for fenced code blocks.
@ioquatix
ioquatix merged commit 8693083 into socketry:main Aug 20, 2026
11 of 14 checks passed
@ioquatix ioquatix added this to the v0.17.0 milestone Aug 20, 2026
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