Skip to content

Comments

Expose Ability to Get the Number Of a List Item#600

Open
bfoersterling wants to merge 1 commit intocommonmark:masterfrom
bfoersterling:list-item-number
Open

Expose Ability to Get the Number Of a List Item#600
bfoersterling wants to merge 1 commit intocommonmark:masterfrom
bfoersterling:list-item-number

Conversation

@bfoersterling
Copy link

rationale

The function cmark_node_get_item_number() improves the user friendliness
of the API as the library user does not have to implement a logic to derive
the number of a list item.

It is more efficient to store the item number once when parsing the markdown
content.
The function cmark_node_get_item_number only has to look at the previous
node. The library user might need to traverse until the start of the list
if he does not want to store the item numbers in a separate data type.

implementation

I added the new type cmark_item and made it a union member for the as
member in cmark_node.

The item number is calculated and stored in the function finalize().

- add cmark_node_get_item_number() function
- store item number in cmark_item member

Signed-off-by: Bjoern Foersterling <bjoern.foersterling@gmail.com>
@jgm
Copy link
Member

jgm commented Feb 22, 2026

@nwellnhof any objections to this?

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